diff options
author | Dmitrij D. Czarkoff <czarkoff@gmail.com> | 2016-11-22 15:48:04 +0100 |
---|---|---|
committer | Dmitrij D. Czarkoff <czarkoff@gmail.com> | 2016-11-22 15:48:04 +0100 |
commit | 9aea3f0ddad87cc97f246161075d249177aeae46 (patch) | |
tree | c38f53c163fb43505ccb0a541295777dcea186b5 | |
parent | 34840c1148e2a46f1000bc538c58f0ef0634acec (diff) | |
download | imv-9aea3f0ddad87cc97f246161075d249177aeae46.tar.gz |
Separate preprocessor flags from compiler flags, libs from linker flags
PR #98 hints that we were venturing into downstream's territory: compiler and
linker flags may be OS-specific, while preprocessor flags and libraries are our
responsibility. Provide clean separation between these categories.
Downstreams may still need to provide "--std=c99" in CFLAGS though.
-rw-r--r-- | Makefile | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -10,8 +10,9 @@ MUTE := @ endif CFLAGS ?= -W -Wall -pedantic -Wmissing-prototypes -CFLAGS += -std=c99 $(shell sdl2-config --cflags) -D_XOPEN_SOURCE=700 -LDFLAGS += $(shell sdl2-config --libs) -lfreeimage -lSDL2_ttf -lfontconfig -lpthread +CFLAGS += -std=c99 +CPPFLAGS += $(shell sdl2-config --cflags) -D_XOPEN_SOURCE=700 +LIBS := $(shell sdl2-config --libs) -lfreeimage -lSDL2_ttf -lfontconfig -lpthread BUILDDIR ?= build TARGET := $(BUILDDIR)/imv @@ -19,7 +20,8 @@ TARGET := $(BUILDDIR)/imv SOURCES := $(wildcard src/*.c) OBJECTS := $(patsubst src/%.c,$(BUILDDIR)/%.o,$(SOURCES)) TESTS := $(patsubst test/%.c,$(BUILDDIR)/test_%,$(wildcard test/*.c)) -TFLAGS ?= -g ${CFLAGS} +TFLAGS ?= -g $(CFLAGS) $(CPPFLAGS) $(shell pkg-config --cflags cmocka) +TLIBS := $(LIBS) $(shell pkg-config --libs cmocka) VERSION := $(shell git describe --abbrev=8 --dirty --always --tags 2> /dev/null) ifeq ($(VERSION),) @@ -32,7 +34,7 @@ imv: $(TARGET) $(TARGET): $(OBJECTS) @echo "LINKING $@" - $(MUTE)$(CC) -o $@ $^ $(LDLIBS) $(LDFLAGS) + $(MUTE)$(CC) -o $@ $^ $(LIBS) $(LDFLAGS) debug: CFLAGS += -DDEBUG -g -pg debug: $(TARGET) @@ -44,11 +46,11 @@ $(BUILDDIR): $(BUILDDIR)/%.o: src/%.c @echo "COMPILING $@" - $(MUTE)$(CC) -c $(CFLAGS) -o $@ $< + $(MUTE)$(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $< $(BUILDDIR)/test_%: test/%.c src/%.c @echo "BUILDING $@" - $(MUTE)$(CC) -o $@ -Isrc $(TFLAGS) $^ $(LDFLAGS) -lcmocka + $(MUTE)$(CC) -o $@ -Isrc $(TFLAGS) $^ $(LDFLAGS) $(TLIBS) check: $(BUILDDIR) $(TESTS) @echo "RUNNING TESTS" |