chiark / gitweb /
6560746926d314eff26534fb6ff67d12724d54db
[secnet.git] / Makefile.in
1 # Makefile for secnet
2 #
3 # This file is part of secnet.
4 # See README for full list of copyright holders.
5 #
6 # secnet is free software; you can redistribute it and/or modify it
7 # under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
10
11 # secnet is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 # General Public License for more details.
15
16 # You should have received a copy of the GNU General Public License
17 # version 3 along with secnet; if not, see
18 # https://www.gnu.org/licenses/gpl.html.
19
20 .PHONY: all clean realclean distclean dist install
21
22 PACKAGE:=secnet
23 VERSION=0.4.5
24
25 VPATH:=@srcdir@
26 srcdir:=@srcdir@
27 include common.make
28
29 INSTALL:=@INSTALL@
30 INSTALL_PROGRAM:=@INSTALL_PROGRAM@
31 INSTALL_SCRIPT:=@INSTALL_SCRIPT@
32 INSTALL_DATA:=@INSTALL_DATA@
33
34 prefix:=$(DESTDIR)@prefix@
35 exec_prefix:=@exec_prefix@
36 sbindir:=@sbindir@
37 sysconfdir:=$(DESTDIR)@sysconfdir@
38 datarootdir:=@datarootdir@
39 transform:=@program_transform_name@
40 mandir:=@mandir@
41
42 ALL_CFLAGS:=@DEFS@ -I$(srcdir) -I. $(CFLAGS) $(EXTRA_CFLAGS)
43 CPPFLAGS:=@CPPFLAGS@ -DDATAROOTDIR='"$(datarootdir)"' $(EXTRA_CPPFLAGS)
44 LDFLAGS:=@LDFLAGS@ $(EXTRA_LDFLAGS)
45 LDLIBS:=@LIBS@ $(EXTRA_LDLIBS)
46
47 TARGETS:=secnet
48
49 OBJECTS:=secnet.o util.o conffile.yy.o conffile.tab.o conffile.o modules.o \
50         resolver.o random.o udp.o site.o transform-cbcmac.o transform-eax.o \
51         comm-common.o polypath.o \
52         netlink.o rsa.o dh.o serpent.o serpentbe.o \
53         md5.o sha512.o tun.o slip.o sha1.o ipaddr.o log.o \
54         process.o @LIBOBJS@ \
55         hackypar.o
56 # version.o is handled specially below and in the link rule for secnet.
57
58 TEST_OBJECTS:=eax-aes-test.o eax-serpent-test.o eax-serpentbe-test.o \
59                 eax-test.o aes.o
60
61 ifeq (version.o,$(MAKECMDGOALS))
62 OBJECTS:=version.o
63 TEST_OBJECTS:=
64 endif
65
66 STALE_PYTHON_FILES=     $(foreach e, py pyc, \
67                         $(foreach p, /usr /usr/local, \
68                         $(foreach l, ipaddr, \
69                         $(DESTDIR)$p/share/secnet/$l.$e \
70                         )))
71
72 %.c:    %.y
73
74 %.yy.c: %.fl
75         flex --header=$*.yy.h -o$@ $<
76
77 %.tab.c %.tab.h:        %.y
78         bison -d -o $@ $<
79
80 %.o: %.c conffile.yy.h
81         $(CC) $(CPPFLAGS) $(ALL_CFLAGS) -c $< -o $@
82
83 all:    $(TARGETS) check
84
85 # Automatic remaking of configuration files, from autoconf documentation
86 ${srcdir}/configure: configure.in
87         cd ${srcdir} && autoconf
88
89 # autoheader might not change config.h.in, so touch a stamp file.
90 ${srcdir}/config.h.in: config.stamp.in
91 ${srcdir}/config.stamp.in: configure.in
92         cd ${srcdir} && autoheader
93         echo timestamp > ${srcdir}/config.stamp.in
94
95 config.h: config.stamp
96 config.stamp: config.h.in config.status
97         ./config.status
98
99 Makefile: Makefile.in config.status
100         ./config.status
101
102 config.status: configure
103         ./config.status --recheck
104 # End of config file remaking rules
105
106 # C and header file dependency rules
107 SOURCES:=$(OBJECTS:.o=.c) $(TEST_OBJECTS:.o=.c)
108 DEPENDS:=$(OBJECTS:.o=.d) $(TEST_OBJECTS:.o=.d)
109
110 -include *.d
111
112 # Manual dependencies section
113 conffile.yy.c:  conffile.fl conffile.tab.c
114 conffile.yy.h:  conffile.yy.c
115 conffile.tab.c: conffile.y
116 # End of manual dependencies section
117
118 conffile.yy.o: ALL_CFLAGS += -Wno-sign-compare
119
120 secnet: $(OBJECTS)
121         $(MAKE) version.o # *.o $(filter-out %.o, $^)
122         $(CC) $(LDFLAGS) $(ALL_CFLAGS) -o $@ $(OBJECTS) version.o $(LDLIBS)
123 # We (always) regenerate the version, but only if we regenerate the
124 # binary.  (This is necessary as the version string is can depend on
125 # any of the source files, eg to see whether "+" is needed.)
126
127 ifneq (,$(wildcard .git/HEAD))
128 # If we have (eg) committed, relink and thus regenerate the version
129 # with the new info from git describe.
130 secnet: Makefile .git/HEAD $(shell sed -n 's#^ref: #.git/#p' .git/HEAD)
131 secnet: $(wildcard .git/packed-refs)
132 endif
133
134 TESTDIRS=stest mtest
135
136 check: eax-aes-test.confirm eax-serpent-test.confirm \
137         eax-serpentbe-test.confirm check-ipaddrset \
138         msgcode-test.confirm $(addprefix check-,$(TESTDIRS))
139
140 version.c: Makefile
141         echo "#include \"secnet.h\"" >$@.new
142         @set -ex; if test -e .git && type -p git >/dev/null; then \
143                 v=$$(git describe --match 'v*'); v=$${v#v}; \
144                 if ! git diff --quiet HEAD; then v="$$v+"; fi; \
145         else \
146                 v="$(VERSION)"; \
147         fi; \
148         echo "char version[]=\"secnet $$v\";" >>$@.new
149         mv -f $@.new $@
150
151 eax-%-test: eax-%-test.o eax-test.o %.o
152         $(CC) $(LDFLAGS) $(ALL_CFLAGS) -o $@ $^
153
154 eax-%-test.confirm: eax-%-test eax-%-test.vectors
155         ./$< <$(srcdir)/eax-$*-test.vectors >$@.new
156         mv -f $@.new $@
157
158 msgcode-test: msgcode-test.o
159         $(CC) $(LDFLAGS) $(ALL_CFLAGS) -o $@ $^
160
161 msgcode-test.confirm: msgcode-test
162         ./msgcode-test
163         touch $@
164
165 check-ipaddrset: ipaddrset-test.py ipaddrset.py ipaddrset-test.expected
166         $(srcdir)/ipaddrset-test.py >ipaddrset-test.new
167         diff -u $(srcdir)/ipaddrset-test.expected ipaddrset-test.new
168
169 check-stest: secnet test-example/sites.conf
170         $(MAKE) -C stest check
171
172 check-mtest: make-secnet-sites ipaddrset.py
173         $(MAKE) -C mtest check
174
175 test-example/sites.conf:
176         $(MAKE) -C test-example
177
178 .PRECIOUS: eax-%-test
179
180 installdirs:
181         $(INSTALL) -d $(prefix)/share/secnet $(sbindir)
182         $(INSTALL) -d $(mandir)/man8
183         $(INSTALL) -d $(datarootdir)/secnet
184
185 install: installdirs
186         set -e; ok=true; for f in $(STALE_PYTHON_FILES); do \
187                 if test -e $$f; then \
188                         echo >&2 "ERROR: $$f still exists "\
189                                 "- try \`make install-force'"; \
190                         ok=false; \
191                 fi; \
192         done; \
193         $$ok
194         $(INSTALL_PROGRAM) secnet $(sbindir)/`echo secnet|sed '$(transform)'`
195         $(INSTALL_PROGRAM) ${srcdir}/make-secnet-sites $(sbindir)/`echo make-secnet-sites|sed '$(transform)'`
196         $(INSTALL_DATA) ${srcdir}/ipaddrset.py $(prefix)/share/secnet/ipaddrset.py
197         $(INSTALL_SCRIPT) ${srcdir}/polypath-interface-monitor-linux \
198                 $(datarootdir)/secnet/.
199         $(INSTALL_DATA) ${srcdir}/secnet.8 $(mandir)/man8/secnet.8
200
201 install-force:
202         rm -f $(STALE_PYTHON_FILES)
203         $(MAKE) install
204
205 clean: $(addprefix clean-,$(TESTDIRS))
206         $(RM) -f *.o *.yy.[ch] *.tab.[ch] $(TARGETS) core version.c
207         $(RM) -f *.d *.pyc *~ eax-*-test.confirm eax-*-test
208         $(RM) -f msgcode-test.confirm msgcode-test
209
210 $(addprefix clean-,$(TESTDIRS)): clean-%:
211         $(MAKE) -C $* clean
212
213 realclean:      clean
214         $(RM) -f *~ Makefile config.h  *.d \
215         config.log config.status config.cache \
216         config.stamp Makefile.bak
217
218 distclean:      realclean
219
220 # Release checklist:
221 #
222 #  0. Use this checklist from Makefile.in
223 #
224 #  1. Check that the tree has what you want
225 #
226 #  2. Update changelog:
227 #         gbp dch --since=<PREVIOUS VERSION>
228 #     and then edit debian/changelog.
229 #
230 #  3. Update VERSION (in this file, above) and
231 #     finalise debian/changelog (removing ~ from version) and commit.
232 #
233 #  4. Build source and binaries:
234 #       dgit -wgf sbuild -A -c stretch
235 #
236 #  5. dpkg -i on zealot just to check
237 #       dpkg -i ~ian/things/Fvpn/bpd/secnet_${VERSION}_amd64.deb
238 #
239 #  6. run it on chiark
240 #     check we can still ping davenant and chiark
241 #
242 #  7. Make git tag and source tarball signature:
243 #       git-tag -u general -m "secnet $VERSION" -s v${VERSION//\~/_}
244 #       gpg -u general --detach-sign ../bpd/secnet_$VERSION.tar.gz
245 #
246 #  8. Publish the branch and distriubtion files:
247 #       git-push origin v${VERSION//\~/_} v${VERSION//\~/_}~0:master
248 #       dcmd rsync -v ../bpd/secnet_${VERSION}_multi.changes chiark:/home/ianmdlvl/public-html/secnet/download/
249 #
250 #  9. Sort out html.  On chiark as user secnet:
251 #       cd ~secnet/public-html/release/
252 #       mkdir $VERSION
253 #       cd $VERSION
254 #       ln -s /home/ianmdlvl/public-html/secnet/download/secnet?$VERSION* .
255 #       ln -sfn $VERSION ../current
256 #
257 # 10. write and post a release announcement
258 #       cd ../bpd
259 #       dcmd sha256sum secnet_${VERSION}_multi.changes
260 #       ...
261 #       gpg --clearsign ../release-announcement
262 #       rsync -vP ../release-announcement.asc c:mail/d/
263 #
264 # 11. bump changelog version in master, to new version with ~