Commit | Line | Data |
---|---|---|
974d0468 SE |
1 | # Makefile for secnet |
2 | # Copyright (C) 1995-2001 Stephen Early <steve@greenend.org.uk> | |
3 | ||
4 | # This program is free software; you can redistribute it and/or modify | |
5 | # it under the terms of the GNU General Public License as published by | |
6 | # the Free Software Foundation; either version 2, or (at your option) | |
7 | # any later version. | |
8 | ||
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. | |
13 | ||
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
17 | ||
d3fe100d | 18 | .PHONY: all clean realclean distclean dist install |
2fe58dfd SE |
19 | |
20 | PACKAGE:=secnet | |
537ff1ad | 21 | VERSION:=0.4.0~beta1 |
2fe58dfd SE |
22 | |
23 | @SET_MAKE@ | |
24 | ||
25 | srcdir:=@srcdir@ | |
26 | VPATH:=@srcdir@ | |
27 | ||
974d0468 SE |
28 | SHELL:=/bin/sh |
29 | RM:=@RM@ | |
30 | CC:=@CC@ | |
31 | INSTALL:=@INSTALL@ | |
32 | INSTALL_PROGRAM:=@INSTALL_PROGRAM@ | |
e61a41a4 | 33 | INSTALL_SCRIPT:=@INSTALL_SCRIPT@ |
2fe58dfd | 34 | |
328ae477 IJ |
35 | prefix:=@prefix@ |
36 | exec_prefix:=@exec_prefix@ | |
37 | sbindir:=@sbindir@ | |
38 | sysconfdir:=@sysconfdir@ | |
e61a41a4 | 39 | datarootdir:=@datarootdir@ |
328ae477 IJ |
40 | transform:=@program_transform_name@ |
41 | mandir:=@mandir@ | |
42 | ||
0ade8ecc | 43 | CFLAGS:=-Wall @WRITESTRINGS@ @CFLAGS@ -Werror \ |
b24a72ef | 44 | -W -Wno-unused -Wno-unused-parameter \ |
18ca0b44 IJ |
45 | -Wno-pointer-sign -Wstrict-prototypes -Wmissing-prototypes \ |
46 | -Wmissing-declarations -Wnested-externs -Wredundant-decls \ | |
47 | -Wpointer-arith -Wformat=2 -Winit-self \ | |
07575765 | 48 | -Wswitch-enum -Wunused-variable -Wunused-function -Wbad-function-cast \ |
76f7ef9c IJ |
49 | -Wno-strict-aliasing -fno-strict-aliasing \ |
50 | -MMD | |
68438849 | 51 | ALL_CFLAGS:=@DEFS@ -I$(srcdir) -I. $(CFLAGS) $(EXTRA_CFLAGS) |
e61a41a4 | 52 | CPPFLAGS:=@CPPFLAGS@ -DDATAROOTDIR='"$(datarootdir)"' $(EXTRA_CPPFLAGS) |
68438849 IJ |
53 | LDFLAGS:=@LDFLAGS@ $(EXTRA_LDFLAGS) |
54 | LDLIBS:=@LIBS@ $(EXTRA_LDLIBS) | |
2fe58dfd SE |
55 | |
56 | TARGETS:=secnet | |
57 | ||
58 | OBJECTS:=secnet.o util.o conffile.yy.o conffile.tab.o conffile.o modules.o \ | |
b02b720a | 59 | resolver.o random.o udp.o site.o transform-cbcmac.o transform-eax.o \ |
ce5c098f | 60 | comm-common.o polypath.o \ |
b02b720a | 61 | netlink.o rsa.o dh.o serpent.o serpentbe.o \ |
e4cfe537 | 62 | md5.o sha512.o tun.o slip.o sha1.o ipaddr.o log.o \ |
3b83c932 SE |
63 | process.o @LIBOBJS@ \ |
64 | hackypar.o | |
e4cfe537 | 65 | # version.o is handled specially below and in the link rule for secnet. |
9d3a4132 | 66 | |
9018e07a IJ |
67 | TEST_OBJECTS:=eax-aes-test.o eax-serpent-test.o eax-serpentbe-test.o \ |
68 | eax-test.o aes.o | |
69 | ||
e4cfe537 IJ |
70 | ifeq (version.o,$(MAKECMDGOALS)) |
71 | OBJECTS:=version.o | |
72 | TEST_OBJECTS:= | |
73 | endif | |
74 | ||
e250348a IJ |
75 | STALE_PYTHON_FILES= $(foreach e, py pyc, \ |
76 | $(foreach p, /usr /usr/local, \ | |
77 | $(foreach l, ipaddr, \ | |
78 | $p/share/secnet/$l.$e \ | |
79 | ))) | |
80 | ||
2fe58dfd SE |
81 | %.c: %.y |
82 | ||
83 | %.yy.c: %.fl | |
27f5042b | 84 | flex --header=$*.yy.h -o$@ $< |
2fe58dfd | 85 | |
76eca292 | 86 | %.tab.c %.tab.h: %.y |
8689b3a9 | 87 | bison -d -o $@ $< |
2fe58dfd | 88 | |
c26f37f0 | 89 | %.o: %.c conffile.yy.h |
fe5e9cc4 | 90 | $(CC) $(CPPFLAGS) $(ALL_CFLAGS) -c $< -o $@ |
2fe58dfd | 91 | |
9018e07a | 92 | all: $(TARGETS) check |
2fe58dfd | 93 | |
8689b3a9 SE |
94 | # Automatic remaking of configuration files, from autoconf documentation |
95 | ${srcdir}/configure: configure.in | |
96 | cd ${srcdir} && autoconf | |
97 | ||
98 | # autoheader might not change config.h.in, so touch a stamp file. | |
99 | ${srcdir}/config.h.in: stamp-h.in | |
f74f5f43 | 100 | ${srcdir}/stamp-h.in: configure.in |
8689b3a9 SE |
101 | cd ${srcdir} && autoheader |
102 | echo timestamp > ${srcdir}/stamp-h.in | |
103 | ||
104 | config.h: stamp-h | |
105 | stamp-h: config.h.in config.status | |
106 | ./config.status | |
107 | ||
974d0468 | 108 | Makefile: Makefile.in config.status |
8689b3a9 | 109 | ./config.status |
974d0468 SE |
110 | |
111 | config.status: configure | |
8689b3a9 SE |
112 | ./config.status --recheck |
113 | # End of config file remaking rules | |
59635212 | 114 | |
d3fe100d | 115 | # C and header file dependency rules |
9018e07a IJ |
116 | SOURCES:=$(OBJECTS:.o=.c) $(TEST_OBJECTS:.o=.c) |
117 | DEPENDS:=$(OBJECTS:.o=.d) $(TEST_OBJECTS:.o=.d) | |
d3fe100d | 118 | |
76f7ef9c | 119 | -include *.d |
d3fe100d SE |
120 | |
121 | # Manual dependencies section | |
8689b3a9 | 122 | conffile.yy.c: conffile.fl conffile.tab.c |
27f5042b | 123 | conffile.yy.h: conffile.yy.c |
8689b3a9 SE |
124 | conffile.tab.c: conffile.y |
125 | # End of manual dependencies section | |
974d0468 | 126 | |
2fe58dfd | 127 | secnet: $(OBJECTS) |
e4cfe537 IJ |
128 | $(MAKE) version.o # *.o $(filter-out %.o, $^) |
129 | $(CC) $(LDFLAGS) $(ALL_CFLAGS) -o $@ $(OBJECTS) version.o $(LDLIBS) | |
130 | # We (always) regenerate the version, but only if we regenerate the | |
131 | # binary. (This is necessary as the version string is can depend on | |
132 | # any of the source files, eg to see whether "+" is needed.) | |
133 | ||
134 | ifneq (,$(wildcard .git/HEAD)) | |
135 | # If we have (eg) committed, relink and thus regenerate the version | |
136 | # with the new info from git describe. | |
137 | secnet: Makefile .git/HEAD $(shell sed -n 's#^ref: #.git/#p' .git/HEAD) | |
138 | secnet: $(wildcard .git/packed-refs) | |
139 | endif | |
2fe58dfd | 140 | |
9018e07a | 141 | check: eax-aes-test.confirm eax-serpent-test.confirm \ |
6437945a | 142 | eax-serpentbe-test.confirm check-ipaddrset |
9018e07a | 143 | |
974d0468 | 144 | version.c: Makefile |
fcbc5905 | 145 | echo "#include \"secnet.h\"" >$@.new |
e4cfe537 IJ |
146 | @set -ex; if test -e .git; then \ |
147 | v=$$(git describe --match 'v*'); v=$${v#v}; \ | |
148 | if ! git diff --quiet HEAD; then v="$$v+"; fi; \ | |
149 | else \ | |
150 | v="$(VERSION)"; \ | |
151 | fi; \ | |
152 | echo "char version[]=\"secnet $$v\";" >>$@.new | |
fcbc5905 | 153 | mv -f $@.new $@ |
974d0468 | 154 | |
9018e07a IJ |
155 | eax-%-test: eax-%-test.o eax-test.o %.o |
156 | $(CC) $(LDFLAGS) $(ALL_CFLAGS) -o $@ $^ | |
157 | ||
158 | eax-%-test.confirm: eax-%-test eax-%-test.vectors | |
159 | ./$< <$(srcdir)/eax-$*-test.vectors >$@.new | |
160 | mv -f $@.new $@ | |
161 | ||
6437945a IJ |
162 | check-ipaddrset: ipaddrset-test.py ipaddrset.py ipaddrset-test.expected |
163 | $(srcdir)/ipaddrset-test.py >ipaddrset-test.new | |
164 | diff -u ipaddrset-test.expected ipaddrset-test.new | |
165 | ||
9018e07a IJ |
166 | .PRECIOUS: eax-%-test |
167 | ||
60fe3102 | 168 | installdirs: |
d3fe100d | 169 | $(INSTALL) -d $(prefix)/share/secnet $(sbindir) |
3ca86f6d | 170 | $(INSTALL) -d $(mandir)/man8 |
e61a41a4 | 171 | $(INSTALL) -d $(datarootdir)/secnet |
60fe3102 RK |
172 | |
173 | install: installdirs | |
e250348a IJ |
174 | set -e; ok=true; for f in $(STALE_PYTHON_FILES); do \ |
175 | if test -e $$f; then \ | |
176 | echo >&2 "ERROR: $$f still exists "\ | |
177 | "- try \`make install-force'"; \ | |
178 | ok=false; \ | |
179 | fi; \ | |
180 | done; \ | |
181 | $$ok | |
d3fe100d SE |
182 | $(INSTALL_PROGRAM) secnet $(sbindir)/`echo secnet|sed '$(transform)'` |
183 | $(INSTALL_PROGRAM) ${srcdir}/make-secnet-sites $(sbindir)/`echo make-secnet-sites|sed '$(transform)'` | |
6437945a | 184 | $(INSTALL) ${srcdir}/ipaddrset.py $(prefix)/share/secnet/ipaddrset.py |
e61a41a4 IJ |
185 | $(INSTALL_SCRIPT) ${srcdir}/polypath-interface-monitor-linux \ |
186 | $(datarootdir)/secnet/. | |
3ca86f6d | 187 | $(INSTALL) secnet.8 $(mandir)/man8/secnet.8 |
974d0468 | 188 | |
e250348a IJ |
189 | install-force: |
190 | rm -f $(STALE_PYTHON_FILES) | |
191 | $(MAKE) install | |
192 | ||
2fe58dfd | 193 | clean: |
c26f37f0 | 194 | $(RM) -f *.o *.yy.[ch] *.tab.[ch] $(TARGETS) core version.c |
4b478582 | 195 | $(RM) -f *.d *.pyc *~ eax-*-test.confirm eax-*-test |
2fe58dfd SE |
196 | |
197 | realclean: clean | |
d3fe100d | 198 | $(RM) -f *~ Makefile config.h *.d \ |
8689b3a9 SE |
199 | config.log config.status config.cache \ |
200 | stamp-h Makefile.bak | |
2fe58dfd | 201 | |
469fd1d9 SE |
202 | distclean: realclean |
203 | ||
974d0468 | 204 | pfname:=$(PACKAGE)-$(VERSION) |
2562e34b | 205 | tarfname:=../$(pfname).tar |
974d0468 | 206 | dist: |
2562e34b IJ |
207 | $(RM) -rf $(tarfname) $(tarfname).gz |
208 | git archive --format=tar --prefix=$(pfname)/ HEAD -o $(tarfname) | |
209 | gzip -9f $(tarfname) | |
210 | ||
211 | # Release checklist: | |
212 | # 1. Check that the tree has what you want | |
213 | # | |
66ee7152 IJ |
214 | # 2. Update VERSION (above) and debian/changelog |
215 | # but DO NOT COMMIT | |
2562e34b IJ |
216 | # |
217 | # 3. Run | |
218 | # ./configure | |
219 | # make dist | |
220 | # and check that the resulting tarball looks OK. | |
221 | # Eg, untar it and build it, or have it reviewed. | |
222 | # | |
66ee7152 | 223 | # 3. Commit the updates to VERSION (above) and debian/changelog |
2562e34b | 224 | # |
1ca0593d | 225 | # 4. git-tag -m "secnet $VERSION" -s v$VERSION |
2562e34b | 226 | # |
64a0c442 | 227 | # 5. git-push origin v$VERSION v${VERSION}~0:master |
2562e34b | 228 | # |
fd44936f IJ |
229 | # 6. Run, again, |
230 | # make dist | |
231 | # | |
53dea2fb | 232 | # 7. gpg --detach-sign ../secnet-$VERSION.tar.gz |
b57cc2eb | 233 | # |
fd44936f | 234 | # 8. rsync -v ../secnet-$VERSION.tar.gz* \ |
2562e34b IJ |
235 | # chiark:/home/ianmdlvl/public-html/secnet/download/ |
236 | # | |
fd44936f | 237 | # 9. On chiark: |
53dea2fb IJ |
238 | # tar zxf ~ianmdlvl/public-html/secnet/download/secnet-$VERSION.tar.gz |
239 | # cd secnet-$VERSION | |
66ee7152 IJ |
240 | # debian/rules build |
241 | # fakeroot debian/rules binary | |
1ca0593d | 242 | # mv ../secnet_${VERSION}_i386.deb ~ianmdlvl/public-html/secnet/download/ |
66ee7152 | 243 | # |
fd44936f | 244 | # 10. On chiark as user secnet: |
9c8b8146 IJ |
245 | # cd ~secnet/public-html/release/ |
246 | # mkdir $VERSION | |
247 | # cd $VERSION | |
248 | # ln -s /home/ianmdlvl/public-html/secnet/download/secnet?$VERSION* . | |
66ee7152 | 249 | # |
fd44936f | 250 | # 11. write and post a release announcement |