3 # This file is part of secnet.
4 # See README for full list of copyright holders.
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.
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.
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.
20 .PHONY: all clean realclean distclean dist install
30 INSTALL_PROGRAM:=@INSTALL_PROGRAM@
31 INSTALL_SCRIPT:=@INSTALL_SCRIPT@
32 INSTALL_DATA:=@INSTALL_DATA@
34 prefix:=$(DESTDIR)@prefix@
35 exec_prefix:=@exec_prefix@
37 sysconfdir:=$(DESTDIR)@sysconfdir@
38 datarootdir:=@datarootdir@
39 transform:=@program_transform_name@
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)
49 OBJECTS:=secnet.o util.o conffile.yy.o conffile.tab.o conffile.o modules.o \
50 resolver.o random.o udp.o site.o transform-cbcmac.o transform-eax.o \
51 comm-common.o polypath.o \
52 netlink.o rsa.o dh.o serpent.o serpentbe.o \
53 md5.o sha512.o tun.o slip.o sha1.o ipaddr.o log.o \
56 # version.o is handled specially below and in the link rule for secnet.
58 PYMODULES := ipaddrset.py argparseactionnoyes.py
60 TEST_OBJECTS:=eax-aes-test.o eax-serpent-test.o eax-serpentbe-test.o \
63 ifeq (version.o,$(MAKECMDGOALS))
68 STALE_PYTHON_FILES= $(foreach e, py pyc, \
69 $(foreach p, /usr /usr/local, \
70 $(foreach l, ipaddr, \
71 $(DESTDIR)$p/share/secnet/$l.$e \
77 flex --header=$*.yy.h -o$@ $<
82 %.o: %.c conffile.yy.h
83 $(CC) $(CPPFLAGS) $(ALL_CFLAGS) -c $< -o $@
85 all:: $(TARGETS) check
87 include subdirmk/regen.mk
89 # autoheader might not change config.h.in, so touch a stamp file.
90 ${srcdir}/config.h.in: config.stamp.in
91 ${srcdir}/config.stamp.in: configure.ac
92 cd ${srcdir} && autoheader
93 echo timestamp > ${srcdir}/config.stamp.in
95 MAKEFILE_TEMPLATES += config.h.in
97 # C and header file dependency rules
98 SOURCES:=$(OBJECTS:.o=.c) $(TEST_OBJECTS:.o=.c)
99 DEPENDS:=$(OBJECTS:.o=.d) $(TEST_OBJECTS:.o=.d)
103 # Manual dependencies section
104 conffile.yy.c: conffile.fl conffile.tab.c
105 conffile.yy.h: conffile.yy.c
106 conffile.tab.c: conffile.y
107 # End of manual dependencies section
109 conffile.yy.o: ALL_CFLAGS += -Wno-sign-compare
112 $(MAKE) version.o # *.o $(filter-out %.o, $^)
113 $(CC) $(LDFLAGS) $(ALL_CFLAGS) -o $@ $(OBJECTS) version.o $(LDLIBS)
114 # We (always) regenerate the version, but only if we regenerate the
115 # binary. (This is necessary as the version string is can depend on
116 # any of the source files, eg to see whether "+" is needed.)
118 ifneq (,$(wildcard .git/HEAD))
119 # If we have (eg) committed, relink and thus regenerate the version
120 # with the new info from git describe.
121 secnet: Makefile .git/HEAD $(shell sed -n 's#^ref: #.git/#p' .git/HEAD)
122 secnet: $(wildcard .git/packed-refs)
127 FAST_CHECKS= eax-aes-test.confirm eax-serpent-test.confirm \
128 eax-serpentbe-test.confirm check-ipaddrset \
129 $(addprefix check-,$(TESTDIRS))
131 CHECKS += $(FAST_CHECKS)
132 CHECKS += msgcode-test.confirm
138 rm -rf $(addsuffix /d-*, $(TESTDIRS))
142 echo "#include \"secnet.h\"" >$@.new
143 @set -ex; if test -e .git && type -p git >/dev/null; then \
144 v=$$(git describe --match 'v*'); v=$${v#v}; \
145 if ! git diff --quiet HEAD; then v="$$v+"; fi; \
149 echo "char version[]=\"secnet $$v\";" >>$@.new
152 eax-%-test: eax-%-test.o eax-test.o %.o
153 $(CC) $(LDFLAGS) $(ALL_CFLAGS) -o $@ $^
155 eax-%-test.confirm: eax-%-test eax-%-test.vectors
156 ./$< <$(srcdir)/eax-$*-test.vectors >$@.new
159 msgcode-test: msgcode-test.o
160 $(CC) $(LDFLAGS) $(ALL_CFLAGS) -o $@ $^
162 msgcode-test.confirm: msgcode-test
166 check-ipaddrset: ipaddrset-test.py ipaddrset.py ipaddrset-test.expected
167 $(srcdir)/ipaddrset-test.py >ipaddrset-test.new
168 diff -u $(srcdir)/ipaddrset-test.expected ipaddrset-test.new
170 check-stest: secnet test-example/sites.conf
171 $(MAKE) -C stest check
173 check-mtest: make-secnet-sites $(PYMODULES)
174 $(MAKE) -C mtest check
176 test-example/sites.conf:
177 $(MAKE) -C test-example
179 .PRECIOUS: eax-%-test
182 $(INSTALL) -d $(prefix)/share/secnet $(sbindir)
183 $(INSTALL) -d $(mandir)/man8
184 $(INSTALL) -d $(datarootdir)/secnet
187 set -e; ok=true; for f in $(STALE_PYTHON_FILES); do \
188 if test -e $$f; then \
189 echo >\&2 "ERROR: $$f still exists "\
190 "- try \`make install-force'"; \
195 $(INSTALL_PROGRAM) secnet $(sbindir)/`echo secnet|sed '$(transform)'`
196 $(INSTALL_PROGRAM) ${srcdir}/make-secnet-sites $(sbindir)/`echo make-secnet-sites|sed '$(transform)'`
197 set -e; for m in $(PYMODULES); do \
198 $(INSTALL_DATA) ${srcdir}/$$m $(prefix)/share/secnet/$$m; \
200 $(INSTALL_SCRIPT) ${srcdir}/polypath-interface-monitor-linux \
201 $(datarootdir)/secnet/.
202 $(INSTALL_DATA) ${srcdir}/secnet.8 $(mandir)/man8/secnet.8
205 rm -f $(STALE_PYTHON_FILES)
208 clean:: $(addprefix clean-,$(TESTDIRS))
209 $(RM) -f *.o *.yy.[ch] *.tab.[ch] $(TARGETS) core version.c
210 $(RM) -f *.d *.pyc *~ eax-*-test.confirm eax-*-test
211 $(RM) -rf __pycache__
212 $(RM) -f msgcode-test.confirm msgcode-test
214 $(addprefix clean-,$(TESTDIRS)): clean-%:
218 $(RM) -f *~ Makefile config.h *.d \
219 config.log config.status config.cache \
220 config.stamp Makefile.bak
222 distclean:: realclean
226 # 0. Use this checklist from Makefile.in
228 # 1. Check that the tree has what you want
230 # 2. Update changelog:
231 # gbp dch --since=<PREVIOUS VERSION>
232 # and then edit debian/changelog.
234 # 3. Update VERSION (in this file, above) and
235 # finalise debian/changelog (removing ~ from version) and commit.
237 # 4. Build source and binaries:
238 # dgit -wgf sbuild -A -c stretch -j8
240 # 5. dpkg -i on zealot just to check
241 # dpkg -i ~ian/things/Fvpn/bpd/secnet_${VERSION}_amd64.deb
243 # 6. run it on chiark
244 # check we can still ping davenant and chiark
246 # 7. Make git tag and source tarball signature:
247 # git-tag -u general -m "secnet $VERSION" -s v${VERSION//\~/_}
248 # gpg -u general --detach-sign ../bpd/secnet_$VERSION.tar.gz
250 # 8. Publish the branch and distriubtion files:
251 # git-push origin v${VERSION//\~/_} v${VERSION//\~/_}~0:master
252 # dcmd rsync -v ../bpd/secnet_${VERSION}_multi.changes chiark:/home/ianmdlvl/public-html/secnet/download/
254 # 9. Sort out html. On chiark as user secnet:
255 # cd ~secnet/public-html/release/
258 # ln -s /home/ianmdlvl/public-html/secnet/download/secnet?$VERSION* .
259 # ln -sfn $VERSION ../current
261 # 10. write and post a release announcement
263 # dcmd sha256sum secnet_${VERSION}_multi.changes
265 # gpg --clearsign ../release-announcement
266 # rsync -vP ../release-announcement.asc c:mail/d/
268 # 11. bump changelog version in master, to new version with ~