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