From: Mike Lowis Date: Wed, 30 Dec 2015 12:44:42 +0000 (+0000) Subject: Added distribution tarball tasks to the makefile X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=17a724947043865309d981e43c3f8835b87447cf;p=projs%2Fatf.git Added distribution tarball tasks to the makefile --- diff --git a/Makefile b/Makefile index a90128a..a30c21e 100644 --- a/Makefile +++ b/Makefile @@ -3,17 +3,20 @@ #------------------------------------------------------------------------------ # Update these variables according to your requirements. +# version +VERSION = 0.0.1 + # tools CC = c99 LD = ${CC} AR = ar # flags -INCS = -Isource/ -Itests/ -CPPFLAGS = -D_XOPEN_SOURCE=700 -CFLAGS += ${INCS} ${CPPFLAGS} -LDFLAGS += ${LIBS} -ARFLAGS = rcs +INCS = -Isource/ -Itests/ +CPPFLAGS = -D_XOPEN_SOURCE=700 +CFLAGS = ${INCS} ${CPPFLAGS} +LDFLAGS = ${LIBS} +ARFLAGS = rcs # commands COMPILE = @echo CC $@; ${CC} ${CFLAGS} -c -o $@ $< @@ -22,21 +25,33 @@ ARCHIVE = @echo AR $@; ${AR} ${ARFLAGS} $@ $^ CLEAN = @rm -f #------------------------------------------------------------------------------ -# Build Targets and Rules +# Build-Specific Macros #------------------------------------------------------------------------------ +# Library macros LIBNAME = atf -LIB = lib${LIBNAME}.a - -DEPS = ${OBJS:.o=.d} -OBJS = source/atf.o +LIB = lib${LIBNAME}.a +DEPS = ${OBJS:.o=.d} +OBJS = source/atf.o +# Test binary macros TEST_BIN = test${LIBNAME} TEST_DEPS = ${TEST_OBJS:.o=.d} TEST_OBJS = tests/main.o tests/test_signals.o +# Distribution dir and tarball settings +DISTDIR = ${LIBNAME}-${VERSION} +DISTTAR = ${DISTDIR}.tar +DISTGZ = ${DISTTAR}.gz +DISTFILES = config.mk LICENSE.md Makefile README.md source tests + # load user-specific settings -include config.mk +#------------------------------------------------------------------------------ +# Phony Targets +#------------------------------------------------------------------------------ +.PHONY: all options tests + all: options ${LIB} tests options: @@ -49,27 +64,37 @@ options: @echo " ARFLAGS = ${ARFLAGS}" tests: ${TEST_BIN} - -${LIB}: ${OBJS} - ${ARCHIVE} - -${TEST_BIN}: ${TEST_OBJS} ${LIB} - ${LINK} - -./$@ + -./${TEST_BIN} @echo "Note: It is expected that exactly 2 of the tests will fail." -.c.o: - ${COMPILE} +dist: clean + @echo DIST ${DISTGZ} + @mkdir -p ${DISTDIR} + @cp -R ${DISTFILES} ${DISTDIR} + @tar -cf ${DISTTAR} ${DISTDIR} + @gzip ${DISTTAR} + @rm -rf ${DISTDIR} clean: ${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} + ${CLEAN} ${DISTTAR} ${DISTGZ} + +#------------------------------------------------------------------------------ +# Target-Specific Rules +#------------------------------------------------------------------------------ +.c.o: + ${COMPILE} + +${LIB}: ${OBJS} + ${ARCHIVE} + +${TEST_BIN}: ${TEST_OBJS} ${LIB} + ${LINK} # load dependency files -include ${DEPS} -include ${TEST_DEPS} -.PHONY: all options tests -