Makefile: improvements
- Rewrite the Makefile. - Remove config.mk - Be verbose. - Separate CFLAGS, CPPFLAGS and LDFLAGS and respect system compiler flags. - Remove default POSIX flags such as ${CC}. - make dist: add missing files. - make dist: pipe directly to stdin instead of making a tar file. - Generalize the name and use ${NAME},${BIN} and ${MAN1} variables. Signed-off-by: Christoph Lohmann <20h@r-36.net>
This commit is contained in:
parent
1c4c6d33a7
commit
a6db1af027
70
Makefile
70
Makefile
@ -1,15 +1,32 @@
|
|||||||
# catpoint - simple presentation software
|
# catpoint - simple presentation software
|
||||||
# See LICENSE file for copyright and license details.
|
# See LICENSE file for copyright and license details.
|
||||||
|
|
||||||
include config.mk
|
.POSIX:
|
||||||
|
|
||||||
SRC = catpoint.c
|
NAME = catpoint
|
||||||
|
VERSION = 1.0
|
||||||
|
|
||||||
|
# paths
|
||||||
|
PREFIX = /usr/local
|
||||||
|
MANPREFIX = ${PREFIX}/share/man
|
||||||
|
|
||||||
|
# use system flags.
|
||||||
|
CATPOINT_CFLAGS = ${CFLAGS}
|
||||||
|
CATPOINT_CPPFLAGS = ${CPPFLAGS}
|
||||||
|
CATPOINT_LDFLAGS = ${LDFLAGS} -lncursesw
|
||||||
|
|
||||||
|
# Gentoo
|
||||||
|
#CATPOINT_LDFLAGS = ${LDFLAGS} -lncursesw -ltinfow
|
||||||
|
|
||||||
|
SRC = ${NAME}.c
|
||||||
|
MAN1 = ${NAME}.1
|
||||||
|
BIN = ${NAME}
|
||||||
OBJ = ${SRC:.c=.o}
|
OBJ = ${SRC:.c=.o}
|
||||||
|
|
||||||
all: options catpoint
|
all: catpoint
|
||||||
|
|
||||||
options:
|
options:
|
||||||
@echo catpoint build options:
|
@echo ${NAME} build options:
|
||||||
@echo "CFLAGS = ${CFLAGS}"
|
@echo "CFLAGS = ${CFLAGS}"
|
||||||
@echo "LDFLAGS = ${LDFLAGS}"
|
@echo "LDFLAGS = ${LDFLAGS}"
|
||||||
@echo "CC = ${CC}"
|
@echo "CC = ${CC}"
|
||||||
@ -18,42 +35,35 @@ config.h:
|
|||||||
cp config.def.h config.h
|
cp config.def.h config.h
|
||||||
|
|
||||||
.c.o:
|
.c.o:
|
||||||
@echo CC $<
|
${CC} -c ${CATPOINT_CFLAGS} ${CATPOINT_CPPFLAGS} $<
|
||||||
@${CC} -c ${CFLAGS} $<
|
|
||||||
|
|
||||||
${OBJ}: config.mk
|
${OBJ}:
|
||||||
|
|
||||||
catpoint: ${OBJ}
|
catpoint: ${OBJ}
|
||||||
@echo CC -o $@
|
${CC} -o $@ ${OBJ} ${CATPOINT_LDFLAGS}
|
||||||
@${CC} -o $@ ${OBJ} ${LDFLAGS}
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@echo cleaning
|
rm -f ${BIN} ${OBJ} ${NAME}-${VERSION}.tar.gz
|
||||||
@rm -f catpoint ${OBJ} catpoint-${VERSION}.tar.gz
|
|
||||||
|
|
||||||
dist: clean
|
dist:
|
||||||
@echo creating dist tarball
|
mkdir -p ${NAME}-${VERSION}
|
||||||
@mkdir -p catpoint-${VERSION}
|
cp -R LICENSE Makefile README.md TOOLS ${SRC} \
|
||||||
@cp -R LICENSE Makefile README.md config.mk ${SRC} catpoint-${VERSION}
|
${MAN1} showoff ${NAME}-${VERSION}
|
||||||
@tar -cf catpoint-${VERSION}.tar catpoint-${VERSION}
|
tar -cf - "${NAME}-${VERSION}" | \
|
||||||
@gzip catpoint-${VERSION}.tar
|
gzip -c > ${NAME}-${VERSION}.tar.gz
|
||||||
@rm -rf catpoint-${VERSION}
|
rm -rf ${NAME}-${VERSION}
|
||||||
|
|
||||||
install: all
|
install: all
|
||||||
@echo installing executable file to ${DESTDIR}${PREFIX}/bin
|
mkdir -p ${DESTDIR}${PREFIX}/bin
|
||||||
@mkdir -p ${DESTDIR}${PREFIX}/bin
|
cp -f ${BIN} ${DESTDIR}${PREFIX}/bin
|
||||||
@cp -f catpoint ${DESTDIR}${PREFIX}/bin
|
chmod 755 ${DESTDIR}${PREFIX}/bin/${BIN}
|
||||||
@chmod 755 ${DESTDIR}${PREFIX}/bin/catpoint
|
mkdir -p ${DESTDIR}${MANPREFIX}/man1
|
||||||
@#echo installing manual page to ${DESTDIR}${MANPREFIX}/man1
|
cp -f ${MAN1} ${DESTDIR}${MANPREFIX}/man1/${MAN1}
|
||||||
@#mkdir -p ${DESTDIR}${MANPREFIX}/man1
|
chmod 644 ${DESTDIR}${MANPREFIX}/man1/${MAN1}
|
||||||
@#sed "s/VERSION/${VERSION}/g" < catpoint.1 > ${DESTDIR}${MANPREFIX}/man1/catpoint.1
|
|
||||||
@#chmod 644 ${DESTDIR}${MANPREFIX}/man1/catpoint.1
|
|
||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
@echo removing executable file from ${DESTDIR}${PREFIX}/bin
|
rm -f ${DESTDIR}${PREFIX}/bin/${BIN}
|
||||||
@rm -f ${DESTDIR}${PREFIX}/bin/catpoint
|
rm -f ${DESTDIR}${MANPREFIX}/man1/${MAN1}
|
||||||
#@echo removing manual page from ${DESTDIR}${MANPREFIX}/man1
|
|
||||||
#@rm -f ${DESTDIR}${MANPREFIX}/man1/catpoint.1
|
|
||||||
|
|
||||||
.PHONY: all options clean dist install uninstall
|
.PHONY: all options clean dist install uninstall
|
||||||
|
|
||||||
|
21
config.mk
21
config.mk
@ -1,21 +0,0 @@
|
|||||||
# catpoint
|
|
||||||
VERSION = 1.0
|
|
||||||
|
|
||||||
# Customize below to fit your system
|
|
||||||
|
|
||||||
# paths
|
|
||||||
PREFIX = /usr/local
|
|
||||||
MANPREFIX = ${PREFIX}/share/man
|
|
||||||
|
|
||||||
# libs
|
|
||||||
LIBS = -lncursesw
|
|
||||||
# Gentoo
|
|
||||||
#LIBS = -lncursesw -ltinfow
|
|
||||||
|
|
||||||
# flags
|
|
||||||
CFLAGS = -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os
|
|
||||||
LDFLAGS = -s ${LIBS}
|
|
||||||
|
|
||||||
# compiler and linker
|
|
||||||
CC = cc
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user