From: Michael D. Lowis Date: Wed, 30 Dec 2015 04:02:44 +0000 (-0500) Subject: Added config.mk file to allow user-specific overrides X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=2a719a4239bb25de8b9a7a3ca32bbee78c6b6a53;p=projs%2Fonward.git Added config.mk file to allow user-specific overrides --- diff --git a/.gitignore b/.gitignore index 73b1829..5cabc30 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,8 @@ *.o +*.d +*.gcno +*.gcda *.a *.exe .rsconscache +config.mk diff --git a/Makefile b/Makefile index be310a0..6adb396 100644 --- a/Makefile +++ b/Makefile @@ -15,18 +15,25 @@ CFLAGS += ${INCS} ${CPPFLAGS} LDFLAGS += ${LIBS} ARFLAGS = rcs +# commands +COMPILE = @echo CC $@; ${CC} ${CFLAGS} -c -o $@ $< +LINK = @echo LD $@; ${LD} -o $@ $^ ${LDFLAGS} +ARCHIVE = @echo AR $@; ${AR} ${ARFLAGS} $@ $^ +CLEAN = @rm -f + #------------------------------------------------------------------------------ # Build Targets and Rules #------------------------------------------------------------------------------ -SRCS = source/onward.c source/main.c -OBJS = ${SRCS:.c=.o} -LIB = libonward.a -BIN = onward -TEST_SRCS = tests/atf.c tests/main.c tests/test_interpreter.c tests/test_vars.c -TEST_OBJS = ${TEST_SRCS:.c=.o} -TEST_BIN = testonward +LIBNAME = onward +LIB = lib${LIBNAME}.a +BIN = ${LIBNAME} +DEPS = ${OBJS:.o=.d} +OBJS = source/onward.o source/main.o + +# load user-specific settings +-include config.mk -all: options ${BIN} ${TEST_BIN} +all: options ${LIB} ${BIN} options: @echo "Toolchain Configuration:" @@ -38,25 +45,20 @@ options: @echo " ARFLAGS = ${ARFLAGS}" ${LIB}: ${OBJS} - @echo AR $@ - @${AR} ${ARFLAGS} $@ ${OBJS} + ${ARCHIVE} ${BIN}: ${LIB} - @echo LD $@ - @${LD} -o $@ ${LIB} ${LDFLAGS} - - -${TEST_BIN}: ${TEST_OBJS} ${LIB} - @echo LD $@ - @${LD} -o $@ ${TEST_OBJS} ${LIB} ${LDFLAGS} - -./$@ + ${LINK} .c.o: - @echo CC $< - @${CC} ${CFLAGS} -c -o $@ $< + ${COMPILE} clean: - @rm -f ${LIB} ${BIN} ${TEST_BIN} ${OBJS} ${TEST_OBJS} + ${CLEAN} ${LIB} ${BIN} ${OBJS} ${DEPS} + ${CLEAN} ${OBJS:.o=.gcno} ${OBJS:.o=.gcda} + +# load dependency files +-include ${DEPS} .PHONY: all options diff --git a/config.mk b/config.mk new file mode 100644 index 0000000..7d6c9bd --- /dev/null +++ b/config.mk @@ -0,0 +1,17 @@ +#------------------------------------------------------------------------------ +# User and Platform Specific Configuration Options +#------------------------------------------------------------------------------ +# Override the tools used with platform specific ones +#CC = cc +#LD = ${CC} +#AR = ar + +# GCC dependency generation +#COMPILE += && ${CC} --std=c11 ${INCS} -MM -MT $@ -MF ${@:.o=.d} ${<:.o=.c} + +# Enable output of debug symbols +#CFLAGS += -g + +# Enable output of coverage information +#CFLAGS += --coverage +#LDFLAGS += --coverage