chiark / gitweb /
e2121d50c2eb8b38bce3c8ca92e1422efb50adf1
[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         netlink.o rsa.o dh.o serpent.o serpentbe.o \
58         md5.o sha512.o tun.o slip.o sha1.o ipaddr.o log.o \
59         process.o @LIBOBJS@ \
60         hackypar.o
61 # version.o is handled specially below and in the link rule for secnet.
62
63 TEST_OBJECTS:=eax-aes-test.o eax-serpent-test.o eax-serpentbe-test.o \
64                 eax-test.o aes.o
65
66 ifeq (version.o,$(MAKECMDGOALS))
67 OBJECTS:=version.o
68 TEST_OBJECTS:=
69 endif
70
71 STALE_PYTHON_FILES=     $(foreach e, py pyc, \
72                         $(foreach p, /usr /usr/local, \
73                         $(foreach l, ipaddr, \
74                         $p/share/secnet/$l.$e \
75                         )))
76
77 %.c:    %.y
78
79 %.yy.c: %.fl
80         flex --header=$*.yy.h -o$@ $<
81
82 %.tab.c %.tab.h:        %.y
83         bison -d -o $@ $<
84
85 %.o: %.c
86         $(CC) $(CPPFLAGS) $(ALL_CFLAGS) -c $< -o $@
87
88 all:    $(TARGETS) check
89
90 # Automatic remaking of configuration files, from autoconf documentation
91 ${srcdir}/configure: configure.in
92         cd ${srcdir} && autoconf
93
94 # autoheader might not change config.h.in, so touch a stamp file.
95 ${srcdir}/config.h.in: stamp-h.in
96 ${srcdir}/stamp-h.in: configure.in
97         cd ${srcdir} && autoheader
98         echo timestamp > ${srcdir}/stamp-h.in
99
100 config.h: stamp-h
101 stamp-h: config.h.in config.status
102         ./config.status
103
104 Makefile: Makefile.in config.status
105         ./config.status
106
107 config.status: configure
108         ./config.status --recheck
109 # End of config file remaking rules
110
111 # C and header file dependency rules
112 SOURCES:=$(OBJECTS:.o=.c) $(TEST_OBJECTS:.o=.c)
113 DEPENDS:=$(OBJECTS:.o=.d) $(TEST_OBJECTS:.o=.d)
114
115 $(DEPENDS): ${srcdir}/depend.sh
116
117 %.d: %.c
118         ${srcdir}/depend.sh $(srcdir) $(CPPFLAGS) $(ALL_CFLAGS) $< > $@
119
120 -include $(DEPENDS)
121
122 # Manual dependencies section
123 conffile.yy.c:  conffile.fl conffile.tab.c
124 conffile.yy.h:  conffile.yy.c
125 conffile.tab.c: conffile.y
126 # End of manual dependencies section
127
128 secnet: $(OBJECTS)
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
135 ifneq (,$(wildcard .git/HEAD))
136 # If we have (eg) committed, relink and thus regenerate the version
137 # with the new info from git describe.
138 secnet: Makefile .git/HEAD $(shell sed -n 's#^ref: #.git/#p' .git/HEAD)
139 secnet: $(wildcard .git/packed-refs)
140 endif
141
142 check: eax-aes-test.confirm eax-serpent-test.confirm \
143         eax-serpentbe-test.confirm check-ipaddrset
144
145 version.c: Makefile
146         echo "#include \"secnet.h\"" >$@.new
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
154         mv -f $@.new $@
155
156 eax-%-test: eax-%-test.o eax-test.o %.o
157         $(CC) $(LDFLAGS) $(ALL_CFLAGS) -o $@ $^
158
159 eax-%-test.confirm: eax-%-test eax-%-test.vectors
160         ./$< <$(srcdir)/eax-$*-test.vectors >$@.new
161         mv -f $@.new $@
162
163 check-ipaddrset: ipaddrset-test.py ipaddrset.py ipaddrset-test.expected
164         $(srcdir)/ipaddrset-test.py >ipaddrset-test.new
165         diff ipaddrset-test.expected ipaddrset-test.new
166
167 .PRECIOUS: eax-%-test
168
169 installdirs:
170         $(INSTALL) -d $(prefix)/share/secnet $(sbindir)
171         $(INSTALL) -d $(mandir)/man8
172
173 install: installdirs
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
182         $(INSTALL_PROGRAM) secnet $(sbindir)/`echo secnet|sed '$(transform)'`
183         $(INSTALL_PROGRAM) ${srcdir}/make-secnet-sites $(sbindir)/`echo make-secnet-sites|sed '$(transform)'`
184         $(INSTALL) ${srcdir}/ipaddrset.py $(prefix)/share/secnet/ipaddrset.py
185         $(INSTALL) secnet.8 $(mandir)/man8/secnet.8
186
187 install-force:
188         rm -f $(STALE_PYTHON_FILES)
189         $(MAKE) install
190
191 clean:
192         $(RM) -f *.o *.yy.c *.tab.[ch] $(TARGETS) core version.c
193         $(RM) -f *.d *~ eax-*-test.confirm eax-*-test
194
195 realclean:      clean
196         $(RM) -f *~ Makefile config.h  *.d \
197         config.log config.status config.cache \
198         stamp-h Makefile.bak
199
200 distclean:      realclean
201
202 pfname:=$(PACKAGE)-$(VERSION)
203 tarfname:=../$(pfname).tar
204 dist:
205         $(RM) -rf $(tarfname) $(tarfname).gz
206         git archive --format=tar --prefix=$(pfname)/ HEAD -o $(tarfname)
207         gzip -9f $(tarfname)
208
209 # Release checklist:
210 #  1. Check that the tree has what you want
211 #
212 #  2. Update VERSION (above) and debian/changelog
213 #     but DO NOT COMMIT
214 #
215 #  3. Run
216 #       ./configure
217 #       make dist
218 #     and check that the resulting tarball looks OK.
219 #     Eg, untar it and build it, or have it reviewed.
220 #
221 #  3. Commit the updates to VERSION (above) and debian/changelog
222 #
223 #  4. git-tag -m "secnet $VERSION" -s v$VERSION
224 #
225 #  5. git-push origin v$VERSION v${VERSION}~0:master
226 #
227 #  6. Run, again,
228 #       make dist
229 #
230 #  7. gpg --detach-sign ../secnet-$VERSION.tar.gz
231 #
232 #  8. rsync -v ../secnet-$VERSION.tar.gz* \
233 #        chiark:/home/ianmdlvl/public-html/secnet/download/
234 #
235 #  9. On chiark:
236 #       tar zxf ~ianmdlvl/public-html/secnet/download/secnet-$VERSION.tar.gz
237 #       cd secnet-$VERSION
238 #       debian/rules build
239 #       fakeroot debian/rules binary
240 #       mv ../secnet_${VERSION}_i386.deb ~ianmdlvl/public-html/secnet/download/
241 #
242 #  10. On chiark as user secnet:
243 #       cd ~secnet/public-html/release/
244 #       mkdir $VERSION
245 #       cd $VERSION
246 #       ln -s /home/ianmdlvl/public-html/secnet/download/secnet?$VERSION* .
247 #
248 #  11. write and post a release announcement