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