resize-gd

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 diff
     1.1 --- a/Makefile	Sat Jun 14 10:47:45 2008 +0200
     1.2 +++ b/Makefile	Sat Jun 14 12:00:23 2008 +0200
     1.3 @@ -1,2 +1,104 @@
     1.4 -resize-gd: resize-gd.c
     1.5 -	gcc -o resize-gd -lgd -lpng -lz -ljpeg  -lm resize-gd.c
     1.6 +# by meillo@marmaro.de
     1.7 +
     1.8 +NAME=resize-gd
     1.9 +
    1.10 +# extracts VERSION from the sources
    1.11 +VERSION=$(shell cat *.c | sed -n '/define[ \t]*VERSION/ s/.*"\([^"]*\)".*/\1/p'  )
    1.12 +NV=${NAME}-${VERSION}
    1.13 +
    1.14 +DOCS = 
    1.15 +
    1.16 +# paths
    1.17 +PREFIX = /usr/local
    1.18 +BINDIR = ${PREFIX}/bin
    1.19 +MANDIR = ${PREFIX}/share/man
    1.20 +
    1.21 +# compile env
    1.22 +CC = gcc
    1.23 +LD = ${CC}
    1.24 +DEBUG = -g
    1.25 +LIBS = -lgd
    1.26 +CFLAGS = -Wall -pedantic -c ${DEBUG}
    1.27 +LDFLAGS = -Wall -pedantic ${DEBUG} $(LIBS)
    1.28 +
    1.29 +# files
    1.30 +SRC=resize-gd.c
    1.31 +OBJ=$(SRC:.c=.o)
    1.32 +DEP = 
    1.33 +
    1.34 +
    1.35 +
    1.36 +.PHONY: all
    1.37 +all: options build
    1.38 +
    1.39 +
    1.40 +.PHONY: options
    1.41 +options:
    1.42 +	@echo build options:
    1.43 +	@echo "CC     = ${CC}"
    1.44 +	@echo "LD     = ${LD}"
    1.45 +	@echo "CFLAGS = ${CFLAGS}"
    1.46 +	@echo "LDFLAGS = ${LDFLAGS}"
    1.47 +	@echo
    1.48 +
    1.49 +
    1.50 +.PHONY: build
    1.51 +build: options ${NAME}
    1.52 +
    1.53 +
    1.54 +${NAME}: $(OBJ)
    1.55 +	$(CC) $(LDFLAGS) $(OBJ) -o $@
    1.56 +
    1.57 +
    1.58 +${OBJ}: ${DEP}
    1.59 +
    1.60 +
    1.61 +.PHONY: strip
    1.62 +strip: ${NAME}
    1.63 +	@echo stripping ${NAME}
    1.64 +	@strip ${NAME}
    1.65 +
    1.66 +
    1.67 +.PHONY: dist
    1.68 +dist: build changelog
    1.69 +	@echo "generating tarball"
    1.70 +	@mkdir -p ${NV}
    1.71 +	@cp -rf ${SRC} ${DEP} ${NAME}.1 Makefile ${DOCS} ${NV}
    1.72 +	@tar -czf ${NV}.tar.gz ${NV}
    1.73 +	@rm -rf ${NV}
    1.74 +
    1.75 +
    1.76 +.PHONY: changelog
    1.77 +changelog:
    1.78 +	@echo generating changelog from mercurial log
    1.79 +	@hg log -v --style changelog > ChangeLog
    1.80 +
    1.81 +
    1.82 +.PHONY: install
    1.83 +install: build strip
    1.84 +	@echo installing executable file to ${DESTDIR}${BINDIR}
    1.85 +	@mkdir -p ${DESTDIR}${BINDIR}
    1.86 +	@cp ${NAME} ${DESTDIR}${BINDIR}
    1.87 +	@chmod 755 ${DESTDIR}${BINDIR}/${NAME}
    1.88 +	@echo installing manual page to ${DESTDIR}${MANDIR}/man1
    1.89 +	@mkdir -p ${DESTDIR}${MANDIR}/man1
    1.90 +	@cp ${NAME}.1 ${DESTDIR}${MANDIR}/man1/${NAME}.1
    1.91 +	@chmod 644 ${DESTDIR}${MANDIR}/man1/${NAME}.1
    1.92 +
    1.93 +
    1.94 +.PHONY: uninstall
    1.95 +uninstall:
    1.96 +	@echo removing executable file from ${DESTDIR}${BINDIR}
    1.97 +	@rm -f ${DESTDIR}${BINDIR}/${NAME}
    1.98 +	@echo removing manual page from ${DESTDIR}${MANDIR}/man1
    1.99 +	@rm -f ${DESTDIR}${MANDIR}/man1/${NAME}.1
   1.100 +
   1.101 +
   1.102 +.PHONY: clean
   1.103 +clean:
   1.104 +	rm -f *.o
   1.105 +
   1.106 +
   1.107 +.PHONY: realclean
   1.108 +realclean: clean
   1.109 +	rm -f ${NAME} ChangeLog