Build system: Install ipaddrset.py and secnet.8 with correct perms
[secnet] / 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.4.0~beta1
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 INSTALL_SCRIPT:=@INSTALL_SCRIPT@
34 INSTALL_DATA:=@INSTALL_DATA@
35
36 prefix:=$(DESTDIR)@prefix@
37 exec_prefix:=@exec_prefix@
38 sbindir:=@sbindir@
39 sysconfdir:=$(DESTDIR)@sysconfdir@
40 datarootdir:=@datarootdir@
41 transform:=@program_transform_name@
42 mandir:=@mandir@
43
44 CFLAGS:=-Wall @WRITESTRINGS@ @CFLAGS@ -Werror \
45 -W -Wno-unused -Wno-unused-parameter \
46 -Wno-pointer-sign -Wstrict-prototypes -Wmissing-prototypes \
47 -Wmissing-declarations -Wnested-externs -Wredundant-decls \
48 -Wpointer-arith -Wformat=2 -Winit-self \
49 -Wswitch-enum -Wunused-variable -Wunused-function -Wbad-function-cast \
50 -Wno-strict-aliasing -fno-strict-aliasing \
51 -MMD
52 ALL_CFLAGS:=@DEFS@ -I$(srcdir) -I. $(CFLAGS) $(EXTRA_CFLAGS)
53 CPPFLAGS:=@CPPFLAGS@ -DDATAROOTDIR='"$(datarootdir)"' $(EXTRA_CPPFLAGS)
54 LDFLAGS:=@LDFLAGS@ $(EXTRA_LDFLAGS)
55 LDLIBS:=@LIBS@ $(EXTRA_LDLIBS)
56
57 TARGETS:=secnet
58
59 OBJECTS:=secnet.o util.o conffile.yy.o conffile.tab.o conffile.o modules.o \
60 resolver.o random.o udp.o site.o transform-cbcmac.o transform-eax.o \
61 comm-common.o polypath.o \
62 netlink.o rsa.o dh.o serpent.o serpentbe.o \
63 md5.o sha512.o tun.o slip.o sha1.o ipaddr.o log.o \
64 process.o @LIBOBJS@ \
65 hackypar.o
66 # version.o is handled specially below and in the link rule for secnet.
67
68 TEST_OBJECTS:=eax-aes-test.o eax-serpent-test.o eax-serpentbe-test.o \
69 eax-test.o aes.o
70
71 ifeq (version.o,$(MAKECMDGOALS))
72 OBJECTS:=version.o
73 TEST_OBJECTS:=
74 endif
75
76 STALE_PYTHON_FILES= $(foreach e, py pyc, \
77 $(foreach p, /usr /usr/local, \
78 $(foreach l, ipaddr, \
79 $(DESTDIR)$p/share/secnet/$l.$e \
80 )))
81
82 %.c: %.y
83
84 %.yy.c: %.fl
85 flex --header=$*.yy.h -o$@ $<
86
87 %.tab.c %.tab.h: %.y
88 bison -d -o $@ $<
89
90 %.o: %.c conffile.yy.h
91 $(CC) $(CPPFLAGS) $(ALL_CFLAGS) -c $< -o $@
92
93 all: $(TARGETS) check
94
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
101 ${srcdir}/stamp-h.in: configure.in
102 cd ${srcdir} && autoheader
103 echo timestamp > ${srcdir}/stamp-h.in
104
105 config.h: stamp-h
106 stamp-h: config.h.in config.status
107 ./config.status
108
109 Makefile: Makefile.in config.status
110 ./config.status
111
112 config.status: configure
113 ./config.status --recheck
114 # End of config file remaking rules
115
116 # C and header file dependency rules
117 SOURCES:=$(OBJECTS:.o=.c) $(TEST_OBJECTS:.o=.c)
118 DEPENDS:=$(OBJECTS:.o=.d) $(TEST_OBJECTS:.o=.d)
119
120 -include *.d
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 -u 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 $(INSTALL) -d $(datarootdir)/secnet
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_DATA) ${srcdir}/ipaddrset.py $(prefix)/share/secnet/ipaddrset.py
186 $(INSTALL_SCRIPT) ${srcdir}/polypath-interface-monitor-linux \
187 $(datarootdir)/secnet/.
188 $(INSTALL_DATA) secnet.8 $(mandir)/man8/secnet.8
189
190 install-force:
191 rm -f $(STALE_PYTHON_FILES)
192 $(MAKE) install
193
194 clean:
195 $(RM) -f *.o *.yy.[ch] *.tab.[ch] $(TARGETS) core version.c
196 $(RM) -f *.d *.pyc *~ eax-*-test.confirm eax-*-test
197
198 realclean: clean
199 $(RM) -f *~ Makefile config.h *.d \
200 config.log config.status config.cache \
201 stamp-h Makefile.bak
202
203 distclean: realclean
204
205 pfname:=$(PACKAGE)-$(VERSION)
206 tarfname:=../$(pfname).tar
207 dist:
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 #
215 # 2. Update VERSION (above) and debian/changelog
216 # but DO NOT COMMIT
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 #
224 # 3. Commit the updates to VERSION (above) and debian/changelog
225 #
226 # 4. git-tag -m "secnet $VERSION" -s v$VERSION
227 #
228 # 5. git-push origin v$VERSION v${VERSION}~0:master
229 #
230 # 6. Run, again,
231 # make dist
232 #
233 # 7. gpg --detach-sign ../secnet-$VERSION.tar.gz
234 #
235 # 8. rsync -v ../secnet-$VERSION.tar.gz* \
236 # chiark:/home/ianmdlvl/public-html/secnet/download/
237 #
238 # 9. On chiark:
239 # tar zxf ~ianmdlvl/public-html/secnet/download/secnet-$VERSION.tar.gz
240 # cd secnet-$VERSION
241 # debian/rules build
242 # fakeroot debian/rules binary
243 # mv ../secnet_${VERSION}_i386.deb ~ianmdlvl/public-html/secnet/download/
244 #
245 # 10. On chiark as user secnet:
246 # cd ~secnet/public-html/release/
247 # mkdir $VERSION
248 # cd $VERSION
249 # ln -s /home/ianmdlvl/public-html/secnet/download/secnet?$VERSION* .
250 #
251 # 11. write and post a release announcement