Makefile: be verbose and remove options

Some things to improve at some point:

* Respect system/packaging CFLAGS/LDFLAGS (don't hardcode -Os -Wall -pedantic,
  -s, etc).
This commit is contained in:
Hiltjo Posthuma 2023-10-06 11:39:40 +02:00
parent aecfb3f680
commit 5678764412
1 changed files with 20 additions and 35 deletions

View File

@ -6,56 +6,41 @@ include config.mk
SRC = slock.c ${COMPATSRC} SRC = slock.c ${COMPATSRC}
OBJ = ${SRC:.c=.o} OBJ = ${SRC:.c=.o}
all: options slock all: slock
options:
@echo slock build options:
@echo "CFLAGS = ${CFLAGS}"
@echo "LDFLAGS = ${LDFLAGS}"
@echo "CC = ${CC}"
.c.o: .c.o:
@echo CC $< ${CC} -c ${CFLAGS} $<
@${CC} -c ${CFLAGS} $<
${OBJ}: config.h config.mk arg.h util.h ${OBJ}: config.h config.mk arg.h util.h
config.h: config.h:
@echo creating $@ from config.def.h cp config.def.h $@
@cp config.def.h $@
slock: ${OBJ} slock: ${OBJ}
@echo CC -o $@ ${CC} -o $@ ${OBJ} ${LDFLAGS}
@${CC} -o $@ ${OBJ} ${LDFLAGS}
clean: clean:
@echo cleaning rm -f slock ${OBJ} slock-${VERSION}.tar.gz
@rm -f slock ${OBJ} slock-${VERSION}.tar.gz
dist: clean dist: clean
@echo creating dist tarball mkdir -p slock-${VERSION}
@mkdir -p slock-${VERSION} cp -R LICENSE Makefile README slock.1 config.mk \
@cp -R LICENSE Makefile README slock.1 config.mk \
${SRC} config.def.h arg.h util.h slock-${VERSION} ${SRC} config.def.h arg.h util.h slock-${VERSION}
@tar -cf slock-${VERSION}.tar slock-${VERSION} tar -cf slock-${VERSION}.tar slock-${VERSION}
@gzip slock-${VERSION}.tar gzip slock-${VERSION}.tar
@rm -rf slock-${VERSION} rm -rf slock-${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 slock ${DESTDIR}${PREFIX}/bin
@cp -f slock ${DESTDIR}${PREFIX}/bin chmod 755 ${DESTDIR}${PREFIX}/bin/slock
@chmod 755 ${DESTDIR}${PREFIX}/bin/slock chmod u+s ${DESTDIR}${PREFIX}/bin/slock
@chmod u+s ${DESTDIR}${PREFIX}/bin/slock mkdir -p ${DESTDIR}${MANPREFIX}/man1
@echo installing manual page to ${DESTDIR}${MANPREFIX}/man1 sed "s/VERSION/${VERSION}/g" <slock.1 >${DESTDIR}${MANPREFIX}/man1/slock.1
@mkdir -p ${DESTDIR}${MANPREFIX}/man1 chmod 644 ${DESTDIR}${MANPREFIX}/man1/slock.1
@sed "s/VERSION/${VERSION}/g" <slock.1 >${DESTDIR}${MANPREFIX}/man1/slock.1
@chmod 644 ${DESTDIR}${MANPREFIX}/man1/slock.1
uninstall: uninstall:
@echo removing executable file from ${DESTDIR}${PREFIX}/bin rm -f ${DESTDIR}${PREFIX}/bin/slock
@rm -f ${DESTDIR}${PREFIX}/bin/slock rm -f ${DESTDIR}${MANPREFIX}/man1/slock.1
@echo removing manual page from ${DESTDIR}${MANPREFIX}/man1
@rm -f ${DESTDIR}${MANPREFIX}/man1/slock.1
.PHONY: all options clean dist install uninstall .PHONY: all clean dist install uninstall