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