Build and test the new crypto toys
[secnet] / Makefile.in
... / ...
CommitLineData
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
22PACKAGE:=secnet
23VERSION=0.4.5
24
25@SET_MAKE@
26
27srcdir:=@srcdir@
28VPATH:=@srcdir@
29
30SHELL:=/bin/sh
31RM:=@RM@
32CC:=@CC@
33INSTALL:=@INSTALL@
34INSTALL_PROGRAM:=@INSTALL_PROGRAM@
35INSTALL_SCRIPT:=@INSTALL_SCRIPT@
36INSTALL_DATA:=@INSTALL_DATA@
37
38prefix:=$(DESTDIR)@prefix@
39exec_prefix:=@exec_prefix@
40sbindir:=@sbindir@
41sysconfdir:=$(DESTDIR)@sysconfdir@
42datarootdir:=@datarootdir@
43transform:=@program_transform_name@
44mandir:=@mandir@
45
46CFLAGS:=-Wall @WRITESTRINGS@ @CFLAGS@ -Werror \
47 -W -Wno-unused -Wno-unused-parameter \
48 -Wno-pointer-sign -Wstrict-prototypes -Wmissing-prototypes \
49 -Wmissing-declarations -Wnested-externs -Wredundant-decls \
50 -Wpointer-arith -Wformat=2 -Winit-self \
51 -Wswitch-enum -Wunused-variable -Wunused-function -Wbad-function-cast \
52 -Wno-strict-aliasing -fno-strict-aliasing \
53 -MMD
54ALL_CFLAGS:=@DEFS@ -I$(srcdir) -I. $(CFLAGS) $(EXTRA_CFLAGS)
55CPPFLAGS:=@CPPFLAGS@ -DDATAROOTDIR='"$(datarootdir)"' $(EXTRA_CPPFLAGS)
56LDFLAGS:=@LDFLAGS@ $(EXTRA_LDFLAGS)
57LDLIBS:=@LIBS@ $(EXTRA_LDLIBS)
58
59TARGETS:=secnet
60
61OBJECTS:=secnet.o util.o conffile.yy.o conffile.tab.o conffile.o modules.o \
62 resolver.o random.o udp.o site.o transform-cbcmac.o transform-eax.o \
63 comm-common.o polypath.o \
64 netlink.o rsa.o dh.o serpent.o serpentbe.o \
65 md5.o sha512.o tun.o slip.o sha1.o ipaddr.o log.o \
66 process.o @LIBOBJS@ \
67 hackypar.o
68# version.o is handled specially below and in the link rule for secnet.
69
70CRYPTO_TESTS = keccak1600 sha3 f25519 x25519 ed25519 fgoldi x448 ed448
71
72TEST_OBJECTS:=eax-aes-test.o eax-serpent-test.o eax-serpentbe-test.o \
73 eax-test.o aes.o \
74 $(addsuffix -test.o,$(CRYPTO_TESTS))
75
76ifeq (version.o,$(MAKECMDGOALS))
77OBJECTS:=version.o
78TEST_OBJECTS:=
79endif
80
81STALE_PYTHON_FILES= $(foreach e, py pyc, \
82 $(foreach p, /usr /usr/local, \
83 $(foreach l, ipaddr, \
84 $(DESTDIR)$p/share/secnet/$l.$e \
85 )))
86
87%.c: %.y
88
89%.yy.c: %.fl
90 flex --header=$*.yy.h -o$@ $<
91
92%.tab.c %.tab.h: %.y
93 bison -d -o $@ $<
94
95%.o: %.c conffile.yy.h
96 $(CC) $(CPPFLAGS) $(ALL_CFLAGS) -c $< -o $@
97
98all: $(TARGETS) check
99
100# Automatic remaking of configuration files, from autoconf documentation
101${srcdir}/configure: configure.in
102 cd ${srcdir} && autoconf
103
104# autoheader might not change config.h.in, so touch a stamp file.
105${srcdir}/config.h.in: stamp-h.in
106${srcdir}/stamp-h.in: configure.in
107 cd ${srcdir} && autoheader
108 echo timestamp > ${srcdir}/stamp-h.in
109
110config.h: stamp-h
111stamp-h: config.h.in config.status
112 ./config.status
113
114Makefile: Makefile.in config.status
115 ./config.status
116
117config.status: configure
118 ./config.status --recheck
119# End of config file remaking rules
120
121# C and header file dependency rules
122SOURCES:=$(OBJECTS:.o=.c) $(TEST_OBJECTS:.o=.c)
123DEPENDS:=$(OBJECTS:.o=.d) $(TEST_OBJECTS:.o=.d)
124
125-include *.d
126
127# Manual dependencies section
128conffile.yy.c: conffile.fl conffile.tab.c
129conffile.yy.h: conffile.yy.c
130conffile.tab.c: conffile.y
131# End of manual dependencies section
132
133conffile.yy.o: ALL_CFLAGS += -Wno-sign-compare
134
135secnet: $(OBJECTS)
136 $(MAKE) version.o # *.o $(filter-out %.o, $^)
137 $(CC) $(LDFLAGS) $(ALL_CFLAGS) -o $@ $(OBJECTS) version.o $(LDLIBS)
138# We (always) regenerate the version, but only if we regenerate the
139# binary. (This is necessary as the version string is can depend on
140# any of the source files, eg to see whether "+" is needed.)
141
142ifneq (,$(wildcard .git/HEAD))
143# If we have (eg) committed, relink and thus regenerate the version
144# with the new info from git describe.
145secnet: Makefile .git/HEAD $(shell sed -n 's#^ref: #.git/#p' .git/HEAD)
146secnet: $(wildcard .git/packed-refs)
147endif
148
149check: eax-aes-test.confirm eax-serpent-test.confirm \
150 eax-serpentbe-test.confirm check-ipaddrset \
151 msgcode-test.confirm \
152 $(foreach c,$(CRYPTO_TESTS),$c-test.confirm)
153
154version.c: Makefile
155 echo "#include \"secnet.h\"" >$@.new
156 @set -ex; if test -e .git && type -p git >/dev/null; then \
157 v=$$(git describe --match 'v*'); v=$${v#v}; \
158 if ! git diff --quiet HEAD; then v="$$v+"; fi; \
159 else \
160 v="$(VERSION)"; \
161 fi; \
162 echo "char version[]=\"secnet $$v\";" >>$@.new
163 mv -f $@.new $@
164
165eax-%-test: eax-%-test.o eax-test.o %.o
166 $(CC) $(LDFLAGS) $(ALL_CFLAGS) -o $@ $^
167
168eax-%-test.confirm: eax-%-test eax-%-test.vectors
169 ./$< <$(srcdir)/eax-$*-test.vectors >$@.new
170 mv -f $@.new $@
171
172msgcode-test: msgcode-test.o
173 $(CC) $(LDFLAGS) $(ALL_CFLAGS) -o $@ $^
174
175msgcode-test.confirm: msgcode-test
176 ./msgcode-test
177 touch $@
178
179$(foreach c,$(CRYPTO_TESTS),$c-test): %-test: %-test.o crypto-test.o
180 $(CC) $(LDFLAGS) $(ALL_CFLAGS) -o $@ $^
181
182$(foreach c,$(CRYPTO_TESTS),$c-test.confirm): \
183 %-test.confirm: %-test %-tests.in
184 ./$*-test <$(srcdir)/$*-tests.in
185 touch $@
186
187keccak1600-test: keccak1600.o
188sha3-test: sha3.o keccak1600.o
189f25519-test: f25519.o
190x25519-test: x25519.o f25519.o
191ed25519-test: sha512.o f25519.o scaf.o ed25519.o
192fgoldi-test: fgoldi.o
193x448-test: x448.o fgoldi.o
194ed448-test: keccak1600.o sha3.o fgoldi.o scaf.o ed448.o
195
196f25519-test.o: ec-field-test.c
197 $(CC) $(CPPFLAGS) $(ALL_CFLAGS) -c -DFIELD=f25519 $< -o $@
198fgoldi-test.o: ec-field-test.c
199 $(CC) $(CPPFLAGS) $(ALL_CFLAGS) -c -DFIELD=fgoldi $< -o $@
200x25519-test.o: xdh-test.c
201 $(CC) $(CPPFLAGS) $(ALL_CFLAGS) -c -DXDH=x25519 -DFIELD=f25519 $< -o $@
202x448-test.o: xdh-test.c
203 $(CC) $(CPPFLAGS) $(ALL_CFLAGS) -c -DXDH=x448 -DFIELD=fgoldi $< -o $@
204
205check-ipaddrset: ipaddrset-test.py ipaddrset.py ipaddrset-test.expected
206 $(srcdir)/ipaddrset-test.py >ipaddrset-test.new
207 diff -u $(srcdir)/ipaddrset-test.expected ipaddrset-test.new
208
209.PRECIOUS: eax-%-test
210
211installdirs:
212 $(INSTALL) -d $(prefix)/share/secnet $(sbindir)
213 $(INSTALL) -d $(mandir)/man8
214 $(INSTALL) -d $(datarootdir)/secnet
215
216install: installdirs
217 set -e; ok=true; for f in $(STALE_PYTHON_FILES); do \
218 if test -e $$f; then \
219 echo >&2 "ERROR: $$f still exists "\
220 "- try \`make install-force'"; \
221 ok=false; \
222 fi; \
223 done; \
224 $$ok
225 $(INSTALL_PROGRAM) secnet $(sbindir)/`echo secnet|sed '$(transform)'`
226 $(INSTALL_PROGRAM) ${srcdir}/make-secnet-sites $(sbindir)/`echo make-secnet-sites|sed '$(transform)'`
227 $(INSTALL_DATA) ${srcdir}/ipaddrset.py $(prefix)/share/secnet/ipaddrset.py
228 $(INSTALL_SCRIPT) ${srcdir}/polypath-interface-monitor-linux \
229 $(datarootdir)/secnet/.
230 $(INSTALL_DATA) ${srcdir}/secnet.8 $(mandir)/man8/secnet.8
231
232install-force:
233 rm -f $(STALE_PYTHON_FILES)
234 $(MAKE) install
235
236clean:
237 $(RM) -f *.o *.yy.[ch] *.tab.[ch] $(TARGETS) core version.c
238 $(RM) -f *.d *.pyc *~ eax-*-test.confirm eax-*-test
239 $(RM) -f msgcode-test.confirm msgcode-test
240 $(RM) -f $(addsuffix -test, $(CRYPTO_TESTS))
241 $(RM) -f $(addsuffix -test.confirm, $(CRYPTO_TESTS))
242
243realclean: clean
244 $(RM) -f *~ Makefile config.h *.d \
245 config.log config.status config.cache \
246 stamp-h Makefile.bak
247
248distclean: realclean
249
250# Release checklist:
251#
252# 0. Use this checklist from Makefile.in
253#
254# 1. Check that the tree has what you want
255#
256# 2. Update changelog:
257# gbp dch --since=<PREVIOUS VERSION>
258# and then edit debian/changelog.
259#
260# 3. Update VERSION (in this file, above) and
261# finalise debian/changelog (removing ~ from version) and commit.
262#
263# 4. Build source and binaries:
264# dgit -wgf sbuild -A -c stretch
265#
266# 5. dpkg -i on zealot just to check
267# dpkg -i ~ian/things/Fvpn/bpd/secnet_${VERSION}_amd64.deb
268#
269# 6. run it on chiark
270# check we can still ping davenant and chiark
271#
272# 7. Make git tag and source tarball signature:
273# git-tag -u general -m "secnet $VERSION" -s v${VERSION//\~/_}
274# gpg -u general --detach-sign ../bpd/secnet_$VERSION.tar.gz
275#
276# 8. Publish the branch and distriubtion files:
277# git-push origin v${VERSION//\~/_} v${VERSION//\~/_}~0:master
278# dcmd rsync -v ../bpd/secnet_${VERSION}_multi.changes chiark:/home/ianmdlvl/public-html/secnet/download/
279#
280# 9. Sort out html. On chiark as user secnet:
281# cd ~secnet/public-html/release/
282# mkdir $VERSION
283# cd $VERSION
284# ln -s /home/ianmdlvl/public-html/secnet/download/secnet?$VERSION* .
285# ln -sfn $VERSION ../current
286#
287# 10. write and post a release announcement
288# cd ../bpd
289# dcmd sha256sum secnet_${VERSION}_multi.changes
290# ...
291# gpg --clearsign ../release-announcement
292# rsync -vP ../release-announcement.asc c:mail/d/
293#
294# 11. bump changelog version in master, to new version with ~