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 | |
8 | # the Free Software Foundation; either version d 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 | # | |
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 | |
a0898ee0 | 23 | VERSION:=0.4.0~beta2 |
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 \ |
e4cfe537 | 65 | md5.o sha512.o tun.o slip.o sha1.o ipaddr.o log.o \ |
3b83c932 SE |
66 | process.o @LIBOBJS@ \ |
67 | hackypar.o | |
e4cfe537 | 68 | # version.o is handled specially below and in the link rule for secnet. |
9d3a4132 | 69 | |
9018e07a IJ |
70 | TEST_OBJECTS:=eax-aes-test.o eax-serpent-test.o eax-serpentbe-test.o \ |
71 | eax-test.o aes.o | |
72 | ||
e4cfe537 IJ |
73 | ifeq (version.o,$(MAKECMDGOALS)) |
74 | OBJECTS:=version.o | |
75 | TEST_OBJECTS:= | |
76 | endif | |
77 | ||
e250348a IJ |
78 | STALE_PYTHON_FILES= $(foreach e, py pyc, \ |
79 | $(foreach p, /usr /usr/local, \ | |
80 | $(foreach l, ipaddr, \ | |
af720152 | 81 | $(DESTDIR)$p/share/secnet/$l.$e \ |
e250348a IJ |
82 | ))) |
83 | ||
2fe58dfd SE |
84 | %.c: %.y |
85 | ||
86 | %.yy.c: %.fl | |
27f5042b | 87 | flex --header=$*.yy.h -o$@ $< |
2fe58dfd | 88 | |
76eca292 | 89 | %.tab.c %.tab.h: %.y |
8689b3a9 | 90 | bison -d -o $@ $< |
2fe58dfd | 91 | |
c26f37f0 | 92 | %.o: %.c conffile.yy.h |
fe5e9cc4 | 93 | $(CC) $(CPPFLAGS) $(ALL_CFLAGS) -c $< -o $@ |
2fe58dfd | 94 | |
9018e07a | 95 | all: $(TARGETS) check |
2fe58dfd | 96 | |
8689b3a9 SE |
97 | # Automatic remaking of configuration files, from autoconf documentation |
98 | ${srcdir}/configure: configure.in | |
99 | cd ${srcdir} && autoconf | |
100 | ||
101 | # autoheader might not change config.h.in, so touch a stamp file. | |
102 | ${srcdir}/config.h.in: stamp-h.in | |
f74f5f43 | 103 | ${srcdir}/stamp-h.in: configure.in |
8689b3a9 SE |
104 | cd ${srcdir} && autoheader |
105 | echo timestamp > ${srcdir}/stamp-h.in | |
106 | ||
107 | config.h: stamp-h | |
108 | stamp-h: config.h.in config.status | |
109 | ./config.status | |
110 | ||
974d0468 | 111 | Makefile: Makefile.in config.status |
8689b3a9 | 112 | ./config.status |
974d0468 SE |
113 | |
114 | config.status: configure | |
8689b3a9 SE |
115 | ./config.status --recheck |
116 | # End of config file remaking rules | |
59635212 | 117 | |
d3fe100d | 118 | # C and header file dependency rules |
9018e07a IJ |
119 | SOURCES:=$(OBJECTS:.o=.c) $(TEST_OBJECTS:.o=.c) |
120 | DEPENDS:=$(OBJECTS:.o=.d) $(TEST_OBJECTS:.o=.d) | |
d3fe100d | 121 | |
76f7ef9c | 122 | -include *.d |
d3fe100d SE |
123 | |
124 | # Manual dependencies section | |
8689b3a9 | 125 | conffile.yy.c: conffile.fl conffile.tab.c |
27f5042b | 126 | conffile.yy.h: conffile.yy.c |
8689b3a9 SE |
127 | conffile.tab.c: conffile.y |
128 | # End of manual dependencies section | |
974d0468 | 129 | |
2fe58dfd | 130 | secnet: $(OBJECTS) |
e4cfe537 IJ |
131 | $(MAKE) version.o # *.o $(filter-out %.o, $^) |
132 | $(CC) $(LDFLAGS) $(ALL_CFLAGS) -o $@ $(OBJECTS) version.o $(LDLIBS) | |
133 | # We (always) regenerate the version, but only if we regenerate the | |
134 | # binary. (This is necessary as the version string is can depend on | |
135 | # any of the source files, eg to see whether "+" is needed.) | |
136 | ||
137 | ifneq (,$(wildcard .git/HEAD)) | |
138 | # If we have (eg) committed, relink and thus regenerate the version | |
139 | # with the new info from git describe. | |
140 | secnet: Makefile .git/HEAD $(shell sed -n 's#^ref: #.git/#p' .git/HEAD) | |
141 | secnet: $(wildcard .git/packed-refs) | |
142 | endif | |
2fe58dfd | 143 | |
9018e07a | 144 | check: eax-aes-test.confirm eax-serpent-test.confirm \ |
6437945a | 145 | eax-serpentbe-test.confirm check-ipaddrset |
9018e07a | 146 | |
974d0468 | 147 | version.c: Makefile |
fcbc5905 | 148 | echo "#include \"secnet.h\"" >$@.new |
e4cfe537 IJ |
149 | @set -ex; if test -e .git; 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 | |
fcbc5905 | 156 | mv -f $@.new $@ |
974d0468 | 157 | |
9018e07a IJ |
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 | ||
6437945a IJ |
165 | check-ipaddrset: ipaddrset-test.py ipaddrset.py ipaddrset-test.expected |
166 | $(srcdir)/ipaddrset-test.py >ipaddrset-test.new | |
167 | diff -u ipaddrset-test.expected ipaddrset-test.new | |
168 | ||
9018e07a IJ |
169 | .PRECIOUS: eax-%-test |
170 | ||
60fe3102 | 171 | installdirs: |
d3fe100d | 172 | $(INSTALL) -d $(prefix)/share/secnet $(sbindir) |
3ca86f6d | 173 | $(INSTALL) -d $(mandir)/man8 |
e61a41a4 | 174 | $(INSTALL) -d $(datarootdir)/secnet |
60fe3102 RK |
175 | |
176 | install: installdirs | |
e250348a IJ |
177 | set -e; ok=true; for f in $(STALE_PYTHON_FILES); do \ |
178 | if test -e $$f; then \ | |
179 | echo >&2 "ERROR: $$f still exists "\ | |
180 | "- try \`make install-force'"; \ | |
181 | ok=false; \ | |
182 | fi; \ | |
183 | done; \ | |
184 | $$ok | |
d3fe100d SE |
185 | $(INSTALL_PROGRAM) secnet $(sbindir)/`echo secnet|sed '$(transform)'` |
186 | $(INSTALL_PROGRAM) ${srcdir}/make-secnet-sites $(sbindir)/`echo make-secnet-sites|sed '$(transform)'` | |
9c7a0b4e | 187 | $(INSTALL_DATA) ${srcdir}/ipaddrset.py $(prefix)/share/secnet/ipaddrset.py |
e61a41a4 IJ |
188 | $(INSTALL_SCRIPT) ${srcdir}/polypath-interface-monitor-linux \ |
189 | $(datarootdir)/secnet/. | |
9c7a0b4e | 190 | $(INSTALL_DATA) secnet.8 $(mandir)/man8/secnet.8 |
974d0468 | 191 | |
e250348a IJ |
192 | install-force: |
193 | rm -f $(STALE_PYTHON_FILES) | |
194 | $(MAKE) install | |
195 | ||
2fe58dfd | 196 | clean: |
c26f37f0 | 197 | $(RM) -f *.o *.yy.[ch] *.tab.[ch] $(TARGETS) core version.c |
4b478582 | 198 | $(RM) -f *.d *.pyc *~ eax-*-test.confirm eax-*-test |
2fe58dfd SE |
199 | |
200 | realclean: clean | |
d3fe100d | 201 | $(RM) -f *~ Makefile config.h *.d \ |
8689b3a9 SE |
202 | config.log config.status config.cache \ |
203 | stamp-h Makefile.bak | |
2fe58dfd | 204 | |
469fd1d9 SE |
205 | distclean: realclean |
206 | ||
974d0468 | 207 | pfname:=$(PACKAGE)-$(VERSION) |
2562e34b | 208 | tarfname:=../$(pfname).tar |
974d0468 | 209 | dist: |
2562e34b IJ |
210 | $(RM) -rf $(tarfname) $(tarfname).gz |
211 | git archive --format=tar --prefix=$(pfname)/ HEAD -o $(tarfname) | |
212 | gzip -9f $(tarfname) | |
213 | ||
214 | # Release checklist: | |
215 | # 1. Check that the tree has what you want | |
216 | # | |
66ee7152 IJ |
217 | # 2. Update VERSION (above) and debian/changelog |
218 | # but DO NOT COMMIT | |
2562e34b IJ |
219 | # |
220 | # 3. Run | |
221 | # ./configure | |
222 | # make dist | |
223 | # and check that the resulting tarball looks OK. | |
224 | # Eg, untar it and build it, or have it reviewed. | |
225 | # | |
66ee7152 | 226 | # 3. Commit the updates to VERSION (above) and debian/changelog |
2562e34b | 227 | # |
71bdd1d9 | 228 | # 4. git-tag -m "secnet $VERSION" -s v${VERSION//\~/_} |
2562e34b | 229 | # |
71bdd1d9 | 230 | # 5. git-push origin v${VERSION//\~/_} v${VERSION//\~/_}~0:master |
2562e34b | 231 | # |
fd44936f IJ |
232 | # 6. Run, again, |
233 | # make dist | |
234 | # | |
53dea2fb | 235 | # 7. gpg --detach-sign ../secnet-$VERSION.tar.gz |
b57cc2eb | 236 | # |
fd44936f | 237 | # 8. rsync -v ../secnet-$VERSION.tar.gz* \ |
2562e34b IJ |
238 | # chiark:/home/ianmdlvl/public-html/secnet/download/ |
239 | # | |
ca535922 IJ |
240 | # 9. In zealot's squeeze chroot: |
241 | # rm -rf ../d; mkdir ../d; cd ../d | |
242 | # tar zxf ../secnet-$VERSION.tar.gz | |
243 | # cd secnet-$VERSION | |
244 | # dpkg-buildpackage -a -uc -us -rfakeroot | |
245 | # rsync -vP ../secnet_${VERSION}_i386.deb ianmdlvl@chiark:public-html/secnet/download/ | |
246 | # | |
247 | # 9a. On chiark as ianmdlvl: | |
248 | # cd ~ianmdlvl/secnet-build/ | |
53dea2fb IJ |
249 | # tar zxf ~ianmdlvl/public-html/secnet/download/secnet-$VERSION.tar.gz |
250 | # cd secnet-$VERSION | |
ca535922 IJ |
251 | # dpkg-buildpackage -a -uc -us -rfakeroot |
252 | # mv ../secnet_${VERSION}_i386.deb ~ianmdlvl/public-html/secnet/download/backport/ | |
66ee7152 | 253 | # |
fd44936f | 254 | # 10. On chiark as user secnet: |
9c8b8146 IJ |
255 | # cd ~secnet/public-html/release/ |
256 | # mkdir $VERSION | |
257 | # cd $VERSION | |
258 | # ln -s /home/ianmdlvl/public-html/secnet/download/secnet?$VERSION* . | |
71bdd1d9 IJ |
259 | # mkdir polypath-backport |
260 | # ln -s /home/ianmdlvl/public-html/secnet/download/backport/secnet?$VERSION* polypath-backport/. | |
261 | # ln -s /home/ianmdlvl/public-html/secnet/download/backport/*adns* polypath-backport/. | |
66ee7152 | 262 | # |
fd44936f | 263 | # 11. write and post a release announcement |
71bdd1d9 | 264 | # find -type l | sort | xargs sha256sum |