Makefile: be more conformant: at link-time use LDFLAGS, not CFLAGS, also use CPPFLAGS prepended to CFLAGS at compile-commands, append optional LIBS at link-time after everything else

This commit is contained in:
Wolfgang Bumiller 2013-04-23 16:49:43 +02:00
parent d6f6241872
commit 3d9a06591a

View file

@ -9,8 +9,12 @@ UNAME ?= $(shell uname)
CYGWIN = $(findstring CYGWIN, $(UNAME))
MINGW = $(findstring MINGW32, $(UNAME))
CC ?= clang
CFLAGS += -Wall -Wextra -Werror -I. -fno-strict-aliasing -fsigned-char $(OPTIONAL)
CC ?= clang
# linker flags and optional additional libraries if required
LDFLAGS :=
LIBS :=
CFLAGS += -Wall -Wextra -Werror -I. -fno-strict-aliasing -fsigned-char $(OPTIONAL)
ifneq ($(shell git describe --always 2>/dev/null),)
CFLAGS += -DGMQCC_GITINFO="\"$(shell git describe --always)\""
endif
@ -169,22 +173,22 @@ SPLINTFLAGS = \
#standard rules
default: all
%.o: %.c
$(CC) -c $< -o $@ $(CFLAGS)
$(CC) -c $< -o $@ $(CPPFLAGS) $(CFLAGS)
exec-standalone.o: exec.c
$(CC) -c $< -o $@ $(CFLAGS) -DQCVM_EXECUTOR=1
$(CC) -c $< -o $@ $(CPPFLAGS) $(CFLAGS) -DQCVM_EXECUTOR=1
$(QCVM): $(OBJ_X)
$(CC) -o $@ $^ $(CFLAGS) -lm
$(CC) -o $@ $^ $(LDFLAGS) -lm $(LIBS)
$(GMQCC): $(OBJ_C) $(OBJ_D)
$(CC) -o $@ $^ $(CFLAGS) -lm
$(CC) -o $@ $^ $(LDFLAGS) -lm $(LIBS)
$(TESTSUITE): $(OBJ_T)
$(CC) -o $@ $^ $(CFLAGS) -lm
$(CC) -o $@ $^ $(LDFLAGS) -lm $(LIBS)
$(PAK): $(OBJ_P)
$(CC) -o $@ $^ $(CFLAGS)
$(CC) -o $@ $^ $(LDFLAGS)
all: $(GMQCC) $(QCVM) $(TESTSUITE) $(PAK)