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