mk

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

Makefile_C_CPP_FULL.mk (1173B)


      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_DIR = <++>
     12 OBJ_DIR = <++>
     13 BIN_DIR = <++>
     14 
     15 SRC = <++>
     16 OBJ = ${SRC:${SRC_DIR}.<++>=${OBJ_DIR}.o}
     17 
     18 all: options ${BIN}
     19 
     20 options:
     21 	@echo ${BIN} build options:
     22 	@echo "CFLAGS   = ${CFLAGS}"
     23 	@echo "LDFLAGS  = ${LDFLAGS}"
     24 	@echo "CC       = ${CC}"
     25 
     26 ${BIN}: ${OBJ}
     27 	${MKDIR} ${BIN_DIR}
     28 	${CC} ${LDFLAGS} ${OBJ} -o $@
     29 	${MV} ${BIN} ${BIN_DIR}
     30 
     31 .<++>.o:
     32 	${MKDIR} ${OBJ_DIR}
     33 	${CC} -c ${CFLAGS} $<
     34 
     35 dist: clean
     36 	${MKDIR} ${DIST}
     37 	${CP} -R <++> ${DIST}
     38 	${TAR} ${DIST}.tar ${DIST}
     39 	${GZIP} ${DIST}.tar
     40 	${RM_DIR} ${DIST}
     41 
     42 run:
     43 	./${BIN_DIR}/${BIN}
     44 
     45 install: all
     46 	${MKDIR} ${DESTDIR}${BIN_DIR} ${DESTDIR}${MAN_DIR}
     47 	${CP} ${BIN_DIR}/${BIN} ${BIN_DIR}
     48 	${CP} ${MAN1} ${DESTDIR}${MAN_DIR}
     49 	sed "s/VERSION/${VERSION}/g" < ${MAN1} > ${DESTDIR}${MAN_DIR}/${MAN1}
     50 	chmod 755 ${DESTDIR}${BIN_DIR}/${BIN}
     51 	chmod 644 ${DESTDIR}${MAN_DIR}/${MAN1}
     52 
     53 uninstall:
     54 	${RM} ${DESTDIR}${BIN_DIR}/${BIN}
     55 	${RM} ${DESTDIR}${MAN_DIR}/${MAN1}
     56 	
     57 clean:
     58 	${RM_DIR} ${BIN_DIR} ${OBJ_DIR}
     59 	${RM} ${DIST}.tar.gz
     60 
     61 .PHONY: all options clean dist install uninstall run