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