mk

Makefile templates
git clone git://git.margiolis.net/mk.git
Log | Files | Refs | README | LICENSE

c.mk (1042B)


      1 # See LICENSE file for copyright and license details.
      2 # <++>
      3 .POSIX:
      4 
      5 include config.mk
      6 
      7 BIN = <++>
      8 DIST = ${BIN}-${VERSION}
      9 MAN1 = ${BIN}.1
     10 
     11 SRC = <++>
     12 OBJ = ${SRC:.<++>=.o}
     13 
     14 all: options ${BIN}
     15 
     16 options:
     17 	@echo ${BIN} build options:
     18 	@echo "CFLAGS	= ${CFLAGS}"
     19 	@echo "LDFLAGS	= ${LDFLAGS}"
     20 	@echo "CC	= ${CC}"
     21 
     22 ${BIN}: ${OBJ}
     23 	${CC} ${LDFLAGS} ${OBJ} -o $@
     24 
     25 .<++>.o:
     26 	${CC} -c ${CFLAGS} $<
     27 
     28 dist: clean
     29 	mkdir -p ${DIST}
     30 	cp -R <++> ${DIST}
     31 	tar -cf ${DIST}.tar ${DIST}
     32 	gzip ${DIST}.tar
     33 	rm -rf ${DIST}
     34 
     35 run:
     36 	./${BIN}
     37 
     38 install: all
     39 	mkdir -p ${DESTDIR}${PREFIX}/bin ${DESTDIR}${MANPREFIX}/man1
     40 	cp -f ${BIN} ${DESTDIR}${PREFIX}/bin
     41 	cp -f ${MAN1} ${DESTDIR}${MANPREFIX}/man1
     42 	sed "s/VERSION/${VERSION}/g" < ${MAN1} > ${DESTDIR}${MANPREFIX}/man1/${MAN1}
     43 	chmod 755 ${DESTDIR}${PREFIX}/bin/${BIN}
     44 	chmod 644 ${DESTDIR}${MANPREFIX}/man1/${MAN1}
     45 
     46 uninstall:
     47 	rm -f ${DESTDIR}${PREFIX}/bin/${BIN} \
     48 		${DESTDIR}${MANPREFIX}/man1/${MAN1}
     49 
     50 clean:
     51 	rm -f ${BIN} ${OBJ} ${DIST}.tar.gz *.core
     52 
     53 .PHONY: all options clean dist install uninstall run