aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2021-09-16 18:33:26 +0200
committerMattias Andrée <maandree@kth.se>2021-09-16 18:33:26 +0200
commitb1be4de9c4bf7fdfa40f6afdd6864818c0a93859 (patch)
tree132e675588894f1072e456f21d1757bddae34435
parentBump year (diff)
downloadorphan-reaper-4080f7571dc3a13205c0a87b1bbe4afe47943a6d.tar.gz
orphan-reaper-4080f7571dc3a13205c0a87b1bbe4afe47943a6d.tar.bz2
orphan-reaper-4080f7571dc3a13205c0a87b1bbe4afe47943a6d.tar.xz
Improve makefile + m whitespace fix2.3.3
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--Makefile55
-rw-r--r--config.mk9
-rw-r--r--orphan-reaper.c1
3 files changed, 30 insertions, 35 deletions
diff --git a/Makefile b/Makefile
index 8e8681f..5135a29 100644
--- a/Makefile
+++ b/Makefile
@@ -5,60 +5,53 @@ include $(CONFIGFILE)
DEFS = -D'LIBEXECDIR="$(LIBEXECDIR)"'
+BIN =\
+ orphan-reaper\
+ reapd
-all: orphan-reaper reapd orphan-reaper.test reapd.test test
+TEST_BIN =\
+ orphan-reaper.test\
+ reapd.test\
+ test
-orphan-reaper.o: orphan-reaper.c arg.h
- $(CC) -c -o $@ orphan-reaper.c $(CFLAGS) $(CPPFLAGS) $(DEFS)
+OBJ =\
+ $(BIN:=.o)\
+ $(TEST_BIN:=.o)
-orphan-reaper: orphan-reaper.o
- $(CC) -o $@ orphan-reaper.o $(LDFLAGS)
-orphan-reaper.test.o: orphan-reaper.c arg.h
- $(CC) -c -o $@ orphan-reaper.c $(CFLAGS) $(CPPFLAGS) -DTEST
+all: $(BIN) $(TEST_BIN)
+$(OBJ): arg.h
-orphan-reaper.test: orphan-reaper.test.o
- $(CC) -o $@ orphan-reaper.test.o $(LDFLAGS)
+.o:
+ $(CC) -o $@ $< $(LDFLAGS)
-reapd.o: reapd.c
- $(CC) -c -o $@ reapd.c $(CFLAGS) $(CPPFLAGS) $(DEFS)
+.c.o:
+ $(CC) -c -o $@ $< $(CFLAGS) $(CPPFLAGS) $(DEFS)
-reapd: reapd.o
- $(CC) -o $@ reapd.o $(LDFLAGS)
+.c.test.o:
+ $(CC) -c -o $@ $< $(CFLAGS) $(CPPFLAGS) -DTEST
-reapd.test.o: reapd.c
- $(CC) -c -o $@ reapd.c $(CFLAGS) $(CPPFLAGS) -DTEST
-
-reapd.test: reapd.test.o
- $(CC) -o $@ reapd.test.o $(LDFLAGS)
-
-test.o: test.c
- $(CC) -c -o $@ test.c $(CFLAGS) $(CPPFLAGS)
-
-test: test.o
- $(CC) -o $@ test.o $(LDFLAGS)
-
-check: orphan-reaper.test reapd.test test
+check: $(TEST_BIN)
test $$(./orphan-reaper.test ./test | wc -l) = 4
-install: orphan-reaper reapd
+install: $(BIN)
mkdir -p -- "$(DESTDIR)$(PREFIX)/bin"
mkdir -p -- "$(DESTDIR)$(LIBEXECDIR)"
- mkdir -p -- "$(DESTDIR)$(PREFIX)/share/licenses/orphan-reaper"
mkdir -p -- "$(DESTDIR)$(MANPREFIX)/man1"
cp -- orphan-reaper "$(DESTDIR)$(PREFIX)/bin/"
cp -- reapd "$(DESTDIR)$(LIBEXECDIR)/"
- cp -- LICENSE "$(DESTDIR)$(PREFIX)/share/licenses/orphan-reaper/"
cp -- orphan-reaper.1 "$(DESTDIR)$(MANPREFIX)/man1/orphan-reaper.1"
uninstall:
-rm -f -- "$(DESTDIR)$(PREFIX)/bin/orphan-reaper"
-rm -f -- "$(DESTDIR)$(LIBEXECDIR)/reapd"
-rmdir -- "$(DESTDIR)$(LIBEXECDIR)"
- -rm -rf -- "$(DESTDIR)$(PREFIX)/share/licenses/orphan-reaper"
-rm -f -- "$(DESTDIR)$(MANPREFIX)/man1/orphan-reaper.1"
clean:
- -rm -rf -- *.o orphan-reaper reapd orphan-reaper.test reapd.test test
+ -rm -rf -- *.o *.su $(BIN) $(TEST_BIN)
+
+.SUFFIXES:
+.SUFFIXES: .test.o .o .c
.PHONY: all check install uninstall clean
diff --git a/config.mk b/config.mk
index 016beb1..bad3f79 100644
--- a/config.mk
+++ b/config.mk
@@ -1,8 +1,9 @@
-PREFIX = /usr/local
-MANPREFIX = $(PREFIX)/share/man
+PREFIX = /usr
+MANPREFIX = $(PREFIX)/share/man
+LIBEXECDIR = $(PREFIX)/libexec/orphan-reaper
-LIBEXECDIR = $(PREFIX)/lib/orphan-reaper
+CC = cc
-CFLAGS = -std=c99 -Wall -Wextra -O2
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700
+CFLAGS = -std=c99 -Wall -O2
LDFLAGS = -s
diff --git a/orphan-reaper.c b/orphan-reaper.c
index 07304ba..bfc5a80 100644
--- a/orphan-reaper.c
+++ b/orphan-reaper.c
@@ -17,6 +17,7 @@
# endif
#endif
+
char *argv0;
static