]> git.mdlowis.com Git - projs/atf.git/commitdiff
Added config.mk for user-specific configuration
authorMichael D. Lowis <mike@mdlowis.com>
Wed, 30 Dec 2015 03:36:40 +0000 (22:36 -0500)
committerMichael D. Lowis <mike@mdlowis.com>
Wed, 30 Dec 2015 03:36:40 +0000 (22:36 -0500)
.gitignore
Makefile
config.mk [new file with mode: 0644]

index 4d40434d64211e92aee925553d1e87d57b0ed08d..3672b54ef5f801d23b56487b372295c9465035cc 100644 (file)
@@ -3,6 +3,9 @@
 *.ko
 *.obj
 *.elf
+*.d
+*.gcno
+*.gcda
 
 # Libraries
 *.lib
@@ -21,3 +24,4 @@
 *.i*86
 *.x86_64
 *.hex
+config.mk
index f6282803c719d0c12e32b5d7a86515e535bc5e72..a90128a870b0189f151b70b7c259c870ab619c48 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -15,15 +15,29 @@ 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/atf.c
-OBJS = ${SRCS:.c=.o}
-TEST_SRCS = tests/main.c tests/test_signals.c
-TEST_OBJS = ${TEST_SRCS:.c=.o}
+LIBNAME = atf
+LIB  = lib${LIBNAME}.a
+
+DEPS = ${OBJS:.o=.d}
+OBJS = source/atf.o
+
+TEST_BIN  = test${LIBNAME}
+TEST_DEPS = ${TEST_OBJS:.o=.d}
+TEST_OBJS = tests/main.o tests/test_signals.o
 
-all: options libatf.a testatf
+# load user-specific settings
+-include config.mk
+
+all: options ${LIB} tests
 
 options:
        @echo "Toolchain Configuration:"
@@ -34,22 +48,28 @@ options:
        @echo "  AR       = ${AR}"
        @echo "  ARFLAGS  = ${ARFLAGS}"
 
-libatf.a: ${OBJS}
-       @echo AR $@
-       @${AR} ${ARFLAGS} $@ ${OBJS}
+tests: ${TEST_BIN}
+
+${LIB}: ${OBJS}
+       ${ARCHIVE}
 
-testatf: ${TEST_OBJS} libatf.a
-       @echo LD $@
-       @${LD} -o $@ ${TEST_OBJS} libatf.a ${LDFLAGS}
+${TEST_BIN}: ${TEST_OBJS} ${LIB}
+       ${LINK}
        -./$@
        @echo "Note: It is expected that exactly 2 of the tests will fail."
 
 .c.o:
-       @echo CC $<
-       @${CC} ${CFLAGS} -c -o $@ $<
+       ${COMPILE}
 
 clean:
-       @rm -f libatf.a testatf ${OBJS} ${TEST_OBJS}
+       ${CLEAN} ${LIB} ${TEST_BIN} ${OBJS} ${TEST_OBJS}
+       ${CLEAN} ${OBJS:.o=.gcno} ${OBJS:.o=.gcda}
+       ${CLEAN} ${TEST_OBJS:.o=.gcno} ${TEST_OBJS:.o=.gcda}
+       ${CLEAN} ${DEPS} ${TEST_DEPS}
+
+# load dependency files
+-include ${DEPS}
+-include ${TEST_DEPS}
 
-.PHONY: all options
+.PHONY: all options tests
 
diff --git a/config.mk b/config.mk
new file mode 100644 (file)
index 0000000..b4b59ae
--- /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} ${INCS} -MM -MT $@ -MF ${@:.o=.d} ${<:.o=.c}
+
+# Enable output of debug symbols
+#CFLAGS += -g
+
+# Enable output of coverage information
+#CFLAGS  += --coverage
+#LDFLAGS += --coverage