[hackers] [farbfeld] Makefile improvements || Hiltjo Posthuma
commit c494437937ee01c6d3eb5b630a15e207aae76c25
Author: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
AuthorDate: Tue May 17 23:02:25 2016 +0200
Commit: FRIGN <dev_AT_frign.de>
CommitDate: Wed May 18 10:34:05 2016 +0200
Makefile improvements
- fix: rebuild on source change.
- allow to override dependency flag per tool (the ones that have deps).
- rebuild on config.mk or headers change.
diff --git a/Makefile b/Makefile
index 21b82d9..2177d25 100644
--- a/Makefile
+++ b/Makefile
_AT_@ -11,17 +11,20 @@ MAN5 = farbfeld.5
all: ${BIN}
-png2ff ff2png:
- ${CC} -o $_AT_ ${CFLAGS} ${CPPFLAGS} -L${PNGLIB} -lpng -I${PNGINC} ${LDFLAGS} $@.c
+${BIN}: ${_AT_:=.o}
-jpg2ff ff2jpg:
- ${CC} -o $_AT_ ${CFLAGS} ${CPPFLAGS} -L${JPGLIB} -ljpeg -I${JPGINC} ${LDFLAGS} $@.c
+OBJ = ${SRC:.c=.o}
-.c:
- ${CC} -o $_AT_ ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} $<
+${OBJ}: config.mk ${HDR}
+
+.o:
+ ${CC} ${CFLAGS} ${$*-LDFLAGS} -o $_AT_ $<
+
+.c.o:
+ ${CC} ${CFLAGS} ${$*-CFLAGS} ${CPPFLAGS} -c $<
clean:
- rm -f ${BIN}
+ rm -f ${BIN} ${OBJ}
dist:
rm -rf "farbfeld-${VERSION}"
diff --git a/config.mk b/config.mk
index 4ecba54..5fde97e 100644
--- a/config.mk
+++ b/config.mk
_AT_@ -23,3 +23,17 @@ LDFLAGS = -s ${LIBS}
# compiler and linker
CC = cc
+
+# flags per tool.
+
+png2ff-CFLAGS := -I${PNGINC}
+png2ff-LDFLAGS := -L${PNGLIB} -lpng
+
+ff2png-CFLAGS := -I${PNGINC}
+ff2png-LDFLAGS := -L${PNGLIB} -lpng
+
+jpg2ff-CFLAGS := -I${JPGINC}
+jpg2ff-LDFLAGS := -L${JPGLIB} -ljpeg
+
+ff2jpg-CFLAGS := -I${JPGINC}
+ff2jpg-LDFLAGS := -L${JPGLIB} -ljpeg
Received on Wed May 18 2016 - 10:34:24 CEST
This archive was generated by hypermail 2.3.0
: Wed May 18 2016 - 10:36:16 CEST