mk

Makefile templates
git clone git://git.christosmarg.xyz
Log | Files | Refs | README | LICENSE

Makefile_C_CPP_SIMPLE.mk (998B)


      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} ${DIST}
     30 	${CP} -R <++> ${DIST}
     31 	${TAR} ${DIST}.tar ${DIST}
     32 	${GZIP} ${DIST}.tar
     33 	${RM_DIR} ${DIST}
     34 
     35 run:
     36 	./${BIN}
     37 
     38 install: all
     39 	${MKDIR} ${DESTDIR}${BIN_DIR} ${DESTDIR}${MAN_DIR}
     40 	${CP} ${BIN} ${BIN_DIR}
     41 	${CP} ${MAN1} ${DESTDIR}${MAN_DIR}
     42 	sed "s/VERSION/${VERSION}/g" < ${MAN1} > ${DESTDIR}${MAN_DIR}/${MAN1}
     43 	chmod 755 ${DESTDIR}${BIN_DIR}/${BIN}
     44 	chmod 644 ${DESTDIR}${MAN_DIR}/${MAN1}
     45 
     46 uninstall:
     47 	${RM} ${DESTDIR}${BIN_DIR}/${BIN}
     48 	${RM} ${DESTDIR}${MAN_DIR}/${MAN1}
     49 
     50 clean:
     51 	${RM} ${BIN} ${OBJ} ${DIST}.tar.gz
     52 
     53 .PHONY: all options clean dist install uninstall run