chiark / gitweb /
changelog: work on documentation of changes since ea31544cc33a
[secnet.git] / Dir.sd.mk
1 # Makefile for secnet
2 #
3 # This file is part of secnet.
4 # See README for full list of copyright holders.
5 #
6 # secnet is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
10
11 # secnet is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 # General Public License for more details.
15
16 # You should have received a copy of the GNU General Public License
17 # version 3 along with secnet; if not, see
18 # https://www.gnu.org/licenses/gpl.html.
19
20 .PHONY: all clean realclean distclean dist install
21
22 PACKAGE:=secnet
23 VERSION=0.5.1
24
25 VPATH:=@srcdir@
26 srcdir:=@srcdir@
27 include common.make
28
29 INSTALL:=@INSTALL@
30 INSTALL_PROGRAM:=@INSTALL_PROGRAM@
31 INSTALL_SCRIPT:=@INSTALL_SCRIPT@
32 INSTALL_DATA:=@INSTALL_DATA@
33
34 prefix:=$(DESTDIR)@prefix@
35 exec_prefix:=@exec_prefix@
36 sbindir:=@sbindir@
37 sysconfdir:=$(DESTDIR)@sysconfdir@
38 datarootdir:=@datarootdir@
39 transform:=@program_transform_name@
40 mandir:=@mandir@
41
42 ALL_CFLAGS:=@DEFS@ -I$(srcdir) -I. $(CFLAGS) $(EXTRA_CFLAGS)
43 CPPFLAGS:=@CPPFLAGS@ -DDATAROOTDIR='"$(datarootdir)"' $(EXTRA_CPPFLAGS)
44 LDFLAGS:=@LDFLAGS@ $(EXTRA_LDFLAGS)
45 LDLIBS:=@LIBS@ $(EXTRA_LDLIBS)
46
47 &:local+global OBJECTS TARGETS
48
49 TARGETS:=secnet
50
51 OBJECTS:=secnet.o util.o conffile.yy.o conffile.tab.o conffile.o modules.o \
52         resolver.o random.o udp.o site.o transform-cbcmac.o transform-eax.o \
53         comm-common.o polypath.o privcache.o pubkeys.o pubkeys.yy.o \
54         netlink.o rsa.o dh.o serpent.o serpentbe.o \
55         md5.o sha512.o tun.o slip.o sha1.o ipaddr.o log.o \
56         process.o osdep.o @LIBOBJS@ \
57         hackypar.o base91s/base91.o
58 # version.o is handled specially below and in the link rule for secnet.
59
60 PYMODULES := ipaddrset.py argparseactionnoyes.py base91.py
61
62 TEST_OBJECTS:=eax-aes-test.o eax-serpent-test.o eax-serpentbe-test.o \
63                 eax-test.o aes.o
64
65 ifeq (version.o,$(MAKECMDGOALS))
66 OBJECTS:=
67 TEST_OBJECTS:=
68 endif
69
70 &OBJECTS += $(OBJECTS) $(TEST_OBJECTS)
71
72 STALE_PYTHON_FILES=     $(foreach e, py pyc, \
73                         $(foreach p, /usr /usr/local, \
74                         $(foreach l, ipaddr, \
75                         $(DESTDIR)$p/share/secnet/$l.$e \
76                         )))
77
78 %.yy.c %.yy.h:  %.fl
79         flex --header=$*.yy.h -o$*.yy.c $<
80
81 %.tab.c %.tab.h:        %.y
82         bison -d -o $@ $<
83
84 %.o: %.c
85         $(CC) $(CPPFLAGS) $(ALL_CFLAGS) $(CDEPS_CFLAGS) -c $< -o $@
86
87 $(OBJECTS): conffile.yy.h pubkeys.yy.h base91s/base91.h
88 # ^ we can't write this as a dependency on the %.o %.c rule
89 #   because (say) conffile.yy.c isn't mentioned so doesn't "ought
90 #   to exist" in make's mind.  But specifying it explicitly like this
91 #   works.
92
93 all::   $(TARGETS)
94
95 ${srcdir}/config.h.in: configure.ac
96         cd ${srcdir} && autoheader
97         touch $@
98
99 MAKEFILE_TEMPLATES += config.h.in
100 CONFIG_STATUS_OUTPUTS += config.h
101
102 # Manual dependencies section
103 conffile.yy.c: conffile.tab.c
104 %.tab.c: %.y
105 # End of manual dependencies section
106
107 %.yy.o: ALL_CFLAGS += -Wno-sign-compare -Wno-unused-function
108
109 secnet: $(OBJECTS)
110         $(MAKE) -f main.mk version.o # *.o $(filter-out %.o, $^)
111         $(CC) $(LDFLAGS) $(ALL_CFLAGS) -o $@ $(OBJECTS) version.o $(LDLIBS)
112 # We (always) regenerate the version, but only if we regenerate the
113 # binary.  (This is necessary as the version string is can depend on
114 # any of the source files, eg to see whether "+" is needed.)
115
116 ifneq (,$(wildcard .git/HEAD))
117 # If we have (eg) committed, relink and thus regenerate the version
118 # with the new info from git describe.
119 secnet: Makefile .git/HEAD $(wildcard $(shell sed -n 's#^ref: #.git/#p' .git/HEAD))
120 secnet: $(wildcard .git/packed-refs)
121 endif
122
123 TESTDIRS=stest mtest
124
125 &TARGETS_check = eax-aes-test.confirm eax-serpent-test.confirm \
126         eax-serpentbe-test.confirm ipaddrset.confirm
127
128 &TARGETS_fullcheck += $(&TARGETS_check)
129 &TARGETS_fullcheck += msgcode-test.confirm
130
131 RECHECK_RM += $(&TARGETS_check)
132 RECHECK_RM += $(addsuffix /d-*, $(TESTDIRS));
133 # Really the eval below should come very late, so that subdirs can add
134 # their stuff to RECHECK_RM, but we do not have a way to do that with
135 # subdirmk yet.  So we embed ad-hoc knowledge about TESTDIRS.
136
137 # This contrives to delete things before make starts, if the user
138 # said "recheck".  The alternative is having recheck be a target
139 # which contains the rm's and then runs $(MAKE) again but then
140 # we recursively re-enter make in parallel, which is Bad.
141 $(eval $(if $(filter recheck,$(MAKECMDGOALS)), \
142         $(shell set -x; rm -rf $(RECHECK_RM) )))
143
144 recheck: check
145
146 .PHONY: FORCE
147 version.c: FORCE
148         echo "#include \"secnet.h\"" >$@.new
149         @set -ex; if test -e .git && type -p git >/dev/null; then \
150                 v=$$(git describe --match 'v*'); v=$${v#v}; \
151                 if ! git diff --quiet HEAD; then v="$$v+"; fi; \
152         else \
153                 v="$(VERSION)"; \
154         fi; \
155         echo "char version[]=\"secnet $$v\";" >>$@.new
156         mv -f $@.new $@
157
158 eax-%-test: eax-%-test.o eax-test.o %.o
159         $(CC) $(LDFLAGS) $(ALL_CFLAGS) -o $@ $^
160
161 eax-%-test.confirm: eax-%-test eax-%-test.vectors
162         ./$< <$(srcdir)/eax-$*-test.vectors >$@.new
163         mv -f $@.new $@
164
165 &CDEPS_OBJECTS += msgcode-test.o
166
167 msgcode-test: msgcode-test.o
168         $(CC) $(LDFLAGS) $(ALL_CFLAGS) -o $@ $^
169
170 msgcode-test.confirm: msgcode-test
171         ./msgcode-test
172         touch $@
173
174 ipaddrset.confirm: ipaddrset-test.py ipaddrset.py ipaddrset-test.expected
175         $(srcdir)/ipaddrset-test.py >ipaddrset-test.new
176         diff -u $(srcdir)/ipaddrset-test.expected ipaddrset-test.new
177         touch $@
178
179 &CLEAN += & pubkeys.fl
180
181 pubkeys.fl: ${srcdir}/pubkeys.fl.pl
182         ${srcdir}/pubkeys.fl.pl >$@.tmp && mv -f $@.tmp $@
183
184 .PRECIOUS: eax-%-test
185
186 installdirs:
187         $(INSTALL) -d $(prefix)/share/secnet $(sbindir)
188         $(INSTALL) -d $(mandir)/man8
189         $(INSTALL) -d $(datarootdir)/secnet
190
191 install: installdirs
192         set -e; ok=true; for f in $(STALE_PYTHON_FILES); do \
193                 if test -e $$f; then \
194                         echo >&\&2 "ERROR: $$f still exists "\
195                                 "- try \`make install-force'"; \
196                         ok=false; \
197                 fi; \
198         done; \
199         $$ok
200         $(INSTALL_PROGRAM) secnet $(sbindir)/`echo secnet|sed '$(transform)'`
201         $(INSTALL_PROGRAM) ${srcdir}/make-secnet-sites $(sbindir)/`echo make-secnet-sites|sed '$(transform)'`
202         set -e; for m in $(PYMODULES); do \
203                 $(INSTALL_DATA) ${srcdir}/$$m $(prefix)/share/secnet/$$m; \
204                 done
205         $(INSTALL_SCRIPT) ${srcdir}/polypath-interface-monitor-linux \
206                 $(datarootdir)/secnet/.
207         $(INSTALL_DATA) ${srcdir}/secnet.8 $(mandir)/man8/secnet.8
208
209 install-force:
210         rm -f $(STALE_PYTHON_FILES)
211         $(MAKE) -f main.mk install
212
213 &CLEAN += .version.d
214 &CLEAN += $(TARGETS) $(&TARGETS_check) $(&TARGETS_fullcheck)
215
216 clean::
217         $(RM) -f *.o *.yy.[ch] *.tab.[ch] core version.c
218         $(RM) -f *.pyc *~ eax-*-test.confirm eax-*-test
219         $(RM) -rf __pycache__
220         $(RM) -f msgcode-test.confirm msgcode-test
221
222 realclean::     clean
223         $(RM) -f *~ Makefile config.h \
224         config.log config.status config.cache \
225         config.stamp Makefile.bak
226
227 distclean::     realclean
228
229 include subdirmk/regen.mk
230
231 &:warn !single-char-var
232 # Release checklist:
233 #
234 #  0. Use this checklist from Dir.sd.mk
235 #
236 #  1. Check that the tree has what you want
237 #
238 #  2. Update changelog:
239 #         gbp dch --since=<PREVIOUS VERSION>
240 #     and then edit debian/changelog.
241 #
242 #  3. Update VERSION (in this file, above) and
243 #     finalise debian/changelog (removing ~ from version) and commit.
244 #
245 #  4. Build source and binaries:
246 #       dgit -wgf sbuild -A -c stretch -j8
247 #
248 #  5. dpkg -i on zealot just to check
249 #       dpkg -i ~ian/things/Fvpn/bpd/secnet_${VERSION}_amd64.deb
250 #
251 #  6. run it on chiark
252 #     check we can still ping davenant and chiark
253 #
254 #  7. Make git tag and source tarball signature:
255 #       git-tag -u general -m "secnet $VERSION" -s v${VERSION//\~/_}
256 #       gpg -u general --detach-sign ../bpd/secnet_$VERSION.tar.gz
257 #
258 #  8. Publish the branch and distriubtion files:
259 #       git-push origin v${VERSION//\~/_} v${VERSION//\~/_}~0:master
260 #       dcmd rsync -v ../bpd/secnet_${VERSION}_multi.changes chiark:/home/ianmdlvl/public-html/secnet/download/
261 #
262 #  9. Sort out html.  On chiark as user secnet:
263 #       cd ~secnet/public-html/release/
264 #       mkdir $VERSION
265 #       cd $VERSION
266 #       ln -s /home/ianmdlvl/public-html/secnet/download/secnet?$VERSION* .
267 #       ln -sfn $VERSION ../current
268 #
269 # 10. write and post a release announcement
270 #       cd ../bpd
271 #       dcmd sha256sum secnet_${VERSION}_multi.changes
272 #       ...
273 #       gpg --clearsign ../release-announcement
274 #       rsync -vP ../release-announcement.asc c:mail/d/
275 #
276 # 11. bump changelog version in master, to new version with ~