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