changeset 4:aa24986b8969

replaces simple Makefile with a good one
author meillo@marmaro.de
date Sat, 14 Jun 2008 12:00:23 +0200
parents 35a50e57b6f5
children 8e2804fe30bc
files Makefile
diffstat 1 files changed, 104 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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