mk

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

c_lib.mk (1236B)


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