Debian Codegraph @

GNUmakefile

raw symbols SCIP
1
2 MAKEFLAGS += --warn-undefined-variables
3
4 cleanfiles := *.o rewrite-time
5
6 variants := lockfile-check lockfile-create lockfile-remove lockfile-touch
7 variants += mail-lock mail-touchlock mail-unlock
8
9 generated := $(addprefix bin/,$(variants))
10 generated += $(patsubst %,man/%.1,$(variants))
11 cleanfiles += $(generated)
12
13 CFLAGS := -g -Wall -Wformat-security -Werror -O2 -fwrapv -fno-strict-aliasing $(CFLAGS)
14 CPPFLAGS ?=
15 LDFLAGS ?=
16
17 .SUFFIXES:
18
19 %.o: %.c
20 $(CC) $(CPPFLAGS) $(CFLAGS) -c $<
21 %: %.o
22 $(CC) -o $@ $(LDFLAGS) $^ $(LOADLIBES) $(LDLIBS)
23
24 all: $(generated)
25 .PHONY: all
26
27 config.h: debian/changelog rewrite-time
28 set -ex; \
29 date="$$(./changelog-date)"; \
30 ver="$$(./changelog-version)"; \
31 echo '#pragma once' > [email protected]; \
32 echo "#define LOCKFILE_PROGS_DATE \"$$date\"" >> [email protected]; \
33 echo "#define LOCKFILE_PROGS_VERSION \"$$ver\"" >> [email protected]; \
34 mv config.h.tmp config.h
35 cleanfiles += config.h config.h.tmp
36
37 lockfile-progs.o: config.h
38
39 # Two independent binaries because mail-lock may need sgid, etc.
40 bin/lockfile-create: LOADLIBES += -llockfile
41 bin/lockfile-create: lockfile-progs.o
42 mkdir -p bin
43 $(CC) -o $@ $(LDFLAGS) $< $(LOADLIBES)
44 bin/mail-lock: bin/lockfile-create
45 cp -p $^ $@
46 bin/lockfile-%: bin/lockfile-create
47 ln $^ $@
48 bin/mail-%: bin/mail-lock
49 ln $^ $@
50 cleandirs += bin
51
52 man/lockfile-progs.1: lockfile-progs.1.in debian/changelog rewrite-time
53 mkdir -p man
54 set -ex; \
55 date="$$(./changelog-date)"; \
56 ver="$$(./changelog-version)"; \
57 sed -E -e "s/@DATE@/$$date/" -e "s/@VERSION@/$$ver/;" $< > [email protected]; \
58 mv [email protected] $@
59 cleanfiles += man/lockfile-progs.1 man/lockfile-progs.1.tmp
60 cleandirs += man
61
62 man/%.1: man/lockfile-progs.1
63 echo .so lockfile-progs.1 > $@
64
65 # These tests are quite insufficient, but perhaps better than nothing for now.
66 check: all
67 rm -rf check
68 mkdir check
69
70 bin/lockfile-create check/file
71 bin/lockfile-touch --oneshot check/file
72 bin/lockfile-check check/file
73 bin/lockfile-remove check/file
74 ! test -e check/file.lock
75
76 bin/lockfile-create --lock-name check/file.lock
77 bin/lockfile-touch --oneshot --lock-name check/file.lock
78 bin/lockfile-check --lock-name check/file.lock
79 bin/lockfile-remove --lock-name check/file.lock
80 ! test -e check/file.lock
81
82 bin/lockfile-create --use-pid --lock-name check/file.lock
83 bin/lockfile-touch --oneshot --lock-name check/file.lock
84 # PID shouldn't be the same, so this should fail.
85 bin/lockfile-check --use-pid --lock-name check/file.lock
86 bin/lockfile-remove --lock-name check/file.lock
87 ! test -e check/file.lock
88
89 bin/lockfile-create --use-pid --lock-name check/lockfile.no-pid
90 .PHONY: check
91 cleandirs += check
92
93 clean:
94 rm -f $(cleanfiles)
95 rm -rf $(cleandirs)
96 .PHONY: clean