summary refs log tree commit diff
path: root/Makefile
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-05-20 21:40:11 -0400
committerJune McEnroe <june@causal.agency>2020-05-20 21:40:11 -0400
commit245b0cbb43e4f7745db1ef6a9082692be6a89053 (patch)
tree07e0ee90be17569f58bd95737ee457b00c6fca88 /Makefile
parentUpdate email addresses (diff)
downloadlitterbox-245b0cbb43e4f7745db1ef6a9082692be6a89053.tar.gz
litterbox-245b0cbb43e4f7745db1ef6a9082692be6a89053.zip
Rewrite build and install like pounce 1.3
man pages are no longer compressed!
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile44
1 files changed, 28 insertions, 16 deletions
diff --git a/Makefile b/Makefile
index 96bd125..85eadc2 100644
--- a/Makefile
+++ b/Makefile
@@ -1,14 +1,18 @@
-PREFIX = /usr/local
-MANDIR = ${PREFIX}/share/man
-ETCDIR = ${PREFIX}/etc
+PREFIX ?= /usr/local
+MANDIR ?= ${PREFIX}/share/man
+ETCDIR ?= ${PREFIX}/etc
+
+CFLAGS += -I${PREFIX}/include
+LDFLAGS += -L${PREFIX}/lib
 
 CFLAGS += -std=c11 -Wall -Wextra -Wpedantic
 LDLIBS = -lsqlite3
-LDLIBS.litterbox = -ltls
+LDLIBS.litterbox = -lsqlite3 -ltls
 
 BINS = litterbox scoop unscoop
 MANS = ${BINS:=.1}
-RCS  =
+RCS  = rc.d/litterbox
+INSTALLS = install-rcs
 
 -include config.mk
 
@@ -20,10 +24,10 @@ dev: tags all test
 all: ${BINS}
 
 litterbox: ${OBJS.litterbox}
-	${CC} ${LDFLAGS} ${OBJS.$@} ${LDLIBS} ${LDLIBS.$@} -o $@
+	${CC} ${LDFLAGS} ${OBJS.$@} ${LDLIBS.$@} -o $@
 
 .o:
-	${CC} ${LDFLAGS} $< ${LDLIBS} ${LDLIBS.$@} -o $@
+	${CC} ${LDFLAGS} $< ${LDLIBS} -o $@
 
 ${BINS:=.o}: database.h
 
@@ -33,19 +37,27 @@ test: .test
 	set -e; for format in ${FORMATS}; do ./unscoop -n -f $$format; done
 	touch .test
 
+.SUFFIXES: .in
+
+.in:
+	sed -e 's|%%PREFIX%%|${PREFIX}|g' $< > $@
+
 tags: *.c *.h
 	ctags -w *.c *.h
 
 clean:
-	rm -f .test tags ${BINS} ${OBJS.litterbox} ${BINS:=.o}
+	rm -f .test tags ${BINS} ${RCS} ${OBJS.litterbox} ${BINS:=.o}
+
+install: ${BINS} ${MANS} ${INSTALLS}
+	install -d ${DESTDIR}${PREFIX}/bin ${DESTDIR}${MANDIR}/man1
+	install ${BINS} ${DESTDIR}${PREFIX}/bin
+	install -m 644 ${MANS} ${DESTDIR}${MANDIR}/man1
 
-install: ${BINS} ${MANS}
-	install -d ${PREFIX}/bin ${MANDIR}/man1
-	install ${BINS} ${PREFIX}/bin
-	for man in ${MANS}; do gzip -c $$man > ${MANDIR}/man1/$$man.gz; done
-	if [ -n '${RCS}' ]; then install -d ${ETCDIR}/rc.d; fi
-	if [ -n '${RCS}' ]; then install ${RCS} ${ETCDIR}/rc.d; fi
+install-rcs: ${RCS}
+	install -d ${DESTDIR}${ETCDIR}/rc.d
+	install ${RCS} ${DESTDIR}${ETCDIR}/rc.d
 
 uninstall:
-	rm -f ${BINS:%=${PREFIX}/bin/%} ${MANS:%=${MANDIR}/man1/%.gz}
-	if [ -n '${RCS}' ]; then rm -f ${RCS:%=${ETCDIR}/%}; fi
+	rm -f ${BINS:%=${DESTDIR}${PREFIX}/bin/%}
+	rm -f ${MANS:%=${DESTDIR}${MANDIR}/man1/%}
+	rm -f ${RCS:%=${DESTDIR}${ETCDIR}/%}