]> git.mdlowis.com Git - proto/libbk.git/commitdiff
Switched to posix compliant makefile master
authorMichael D. Lowis <mike@mdlowis.com>
Mon, 30 Nov 2015 01:49:07 +0000 (20:49 -0500)
committerMichael D. Lowis <mike@mdlowis.com>
Mon, 30 Nov 2015 01:49:07 +0000 (20:49 -0500)
LICENSE.md [moved from LICENSE with 100% similarity]
Makefile [new file with mode: 0644]
build.ninja [deleted file]

similarity index 100%
rename from LICENSE
rename to LICENSE.md
diff --git a/Makefile b/Makefile
new file mode 100644 (file)
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 (file)
index 0c6cf85..0000000
+++ /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
-