# HG changeset patch # User meillo@marmaro.de # Date 1213437623 -7200 # Node ID aa24986b89698bf2f5c96b48acbc910bea2c9b04 # Parent 35a50e57b6f5e1bdc309d5182f5cae91068b6b61 replaces simple Makefile with a good one diff -r 35a50e57b6f5 -r aa24986b8969 Makefile --- a/Makefile Sat Jun 14 10:47:45 2008 +0200 +++ b/Makefile Sat Jun 14 12:00:23 2008 +0200 @@ -1,2 +1,104 @@ -resize-gd: resize-gd.c - gcc -o resize-gd -lgd -lpng -lz -ljpeg -lm resize-gd.c +# by meillo@marmaro.de + +NAME=resize-gd + +# extracts VERSION from the sources +VERSION=$(shell cat *.c | sed -n '/define[ \t]*VERSION/ s/.*"\([^"]*\)".*/\1/p' ) +NV=${NAME}-${VERSION} + +DOCS = + +# paths +PREFIX = /usr/local +BINDIR = ${PREFIX}/bin +MANDIR = ${PREFIX}/share/man + +# compile env +CC = gcc +LD = ${CC} +DEBUG = -g +LIBS = -lgd +CFLAGS = -Wall -pedantic -c ${DEBUG} +LDFLAGS = -Wall -pedantic ${DEBUG} $(LIBS) + +# files +SRC=resize-gd.c +OBJ=$(SRC:.c=.o) +DEP = + + + +.PHONY: all +all: options build + + +.PHONY: options +options: + @echo build options: + @echo "CC = ${CC}" + @echo "LD = ${LD}" + @echo "CFLAGS = ${CFLAGS}" + @echo "LDFLAGS = ${LDFLAGS}" + @echo + + +.PHONY: build +build: options ${NAME} + + +${NAME}: $(OBJ) + $(CC) $(LDFLAGS) $(OBJ) -o $@ + + +${OBJ}: ${DEP} + + +.PHONY: strip +strip: ${NAME} + @echo stripping ${NAME} + @strip ${NAME} + + +.PHONY: dist +dist: build changelog + @echo "generating tarball" + @mkdir -p ${NV} + @cp -rf ${SRC} ${DEP} ${NAME}.1 Makefile ${DOCS} ${NV} + @tar -czf ${NV}.tar.gz ${NV} + @rm -rf ${NV} + + +.PHONY: changelog +changelog: + @echo generating changelog from mercurial log + @hg log -v --style changelog > ChangeLog + + +.PHONY: install +install: build strip + @echo installing executable file to ${DESTDIR}${BINDIR} + @mkdir -p ${DESTDIR}${BINDIR} + @cp ${NAME} ${DESTDIR}${BINDIR} + @chmod 755 ${DESTDIR}${BINDIR}/${NAME} + @echo installing manual page to ${DESTDIR}${MANDIR}/man1 + @mkdir -p ${DESTDIR}${MANDIR}/man1 + @cp ${NAME}.1 ${DESTDIR}${MANDIR}/man1/${NAME}.1 + @chmod 644 ${DESTDIR}${MANDIR}/man1/${NAME}.1 + + +.PHONY: uninstall +uninstall: + @echo removing executable file from ${DESTDIR}${BINDIR} + @rm -f ${DESTDIR}${BINDIR}/${NAME} + @echo removing manual page from ${DESTDIR}${MANDIR}/man1 + @rm -f ${DESTDIR}${MANDIR}/man1/${NAME}.1 + + +.PHONY: clean +clean: + rm -f *.o + + +.PHONY: realclean +realclean: clean + rm -f ${NAME} ChangeLog