From: Michael D. Lowis Date: Mon, 30 Nov 2015 01:49:07 +0000 (-0500) Subject: Switched to posix compliant makefile X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=3ae1f8274b08d011ac748b0534aa1f0baa2c7a70;p=proto%2Flibbk.git Switched to posix compliant makefile --- diff --git a/LICENSE b/LICENSE.md similarity index 100% rename from LICENSE rename to LICENSE.md diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..79dca33 --- /dev/null +++ b/Makefile @@ -0,0 +1,56 @@ +#------------------------------------------------------------------------------ +# Build Configuration +#------------------------------------------------------------------------------ +# Update these variables according to your requirements. + +# tools +CC = c99 +LD = ${CC} +AR = ar + +# flags +INCS = -Isource/ -Itests/ +CPPFLAGS = -D_XOPEN_SOURCE=700 -DBK_DEBUG_TRACE +CFLAGS += ${INCS} ${CPPFLAGS} +LDFLAGS += ${LIBS} +ARFLAGS = rcs + +#------------------------------------------------------------------------------ +# Build Targets and Rules +#------------------------------------------------------------------------------ +SRCS = source/alg.c source/drc.c source/main.c +OBJS = ${SRCS:.c=.o} +LIB = libbk.a +TEST_SRCS = tests/main.c +TEST_OBJS = ${TEST_SRCS:.c=.o} +TEST_BIN = testbk + +all: options ${LIB} ${TEST_BIN} + +options: + @echo "Toolchain Configuration:" + @echo " CC = ${CC}" + @echo " CFLAGS = ${CFLAGS}" + @echo " LD = ${LD}" + @echo " LDFLAGS = ${LDFLAGS}" + @echo " AR = ${AR}" + @echo " ARFLAGS = ${ARFLAGS}" + +${LIB}: ${OBJS} + @echo AR $@ + @${AR} ${ARFLAGS} $@ ${OBJS} + +${TEST_BIN}: ${TEST_OBJS} ${LIB} + @echo LD $@ + @${LD} -o $@ ${TEST_OBJS} ${LIB} ${LDFLAGS} + -./$@ + +.c.o: + @echo CC $< + @${CC} ${CFLAGS} -c -o $@ $< + +clean: + @rm -f ${LIB} ${TEST_BIN} ${OBJS} ${TEST_OBJS} + +.PHONY: all options + diff --git a/build.ninja b/build.ninja deleted file mode 100644 index 0c6cf85..0000000 --- a/build.ninja +++ /dev/null @@ -1,43 +0,0 @@ -############################################################################### -# Build Variables -############################################################################### -CC = gcc -DEPSUFFIX = .d -CPPFLAGS = -Isource/ -CFLAGS = -pg -g -O3 -Wall -Wextra --std=c99 --pedantic -DBK_DEBUG_TRACE -LD = gcc -LDFLAGS = -pg -AR = ar -ARFLAGS = rcs - -############################################################################### -# Build Rule Definitions -############################################################################### -rule cc - command = $CC -MMD -MF $out$DEPSUFFIX $CPPFLAGS $CFLAGS -c -o $out $in - depfile = $out$DEPSUFFIX - -rule ld - command = $LD $LDFLAGS -o $out $in - -rule ar - command = $AR $ARFLAGS $out $in - depfile = $out$DEPSUFFIX - -rule run - command = ./$in - -############################################################################### -# Build Targets -############################################################################### -# LibBK Static Library -build source/main.o: cc source/main.c -build source/alg.o: cc source/alg.c -build source/drc.o: cc source/drc.c -build libbk.a: ar source/main.o source/alg.o source/drc.o - -# Garbage Collection Test Application -build tests/main.o: cc tests/main.c -build tests/tests: ld tests/main.o libbk.a -build gctrace.out: run tests/tests -