farbfeld

suckless image format with conversion tools
git clone git://git.suckless.org/farbfeld
Log | Files | Refs | README | LICENSE

commit c494437937ee01c6d3eb5b630a15e207aae76c25
parent 3d0f4c70385c8ad1dbaad1bb266e644c7109aa6a
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Tue, 17 May 2016 23:02:25 +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.

Diffstat:
MMakefile | 17++++++++++-------
Mconfig.mk | 14++++++++++++++
2 files changed, 24 insertions(+), 7 deletions(-)

diff --git a/Makefile b/Makefile @@ -11,17 +11,20 @@ MAN5 = farbfeld.5 all: ${BIN} -png2ff ff2png: - ${CC} -o $@ ${CFLAGS} ${CPPFLAGS} -L${PNGLIB} -lpng -I${PNGINC} ${LDFLAGS} $@.c +${BIN}: ${@:=.o} -jpg2ff ff2jpg: - ${CC} -o $@ ${CFLAGS} ${CPPFLAGS} -L${JPGLIB} -ljpeg -I${JPGINC} ${LDFLAGS} $@.c +OBJ = ${SRC:.c=.o} -.c: - ${CC} -o $@ ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} $< +${OBJ}: config.mk ${HDR} + +.o: + ${CC} ${CFLAGS} ${$*-LDFLAGS} -o $@ $< + +.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 @@ -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