chiark / gitweb /
0328c1cc7af320e440991f4fceb9296135858351
[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
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 check: eax-aes-test.confirm eax-serpent-test.confirm \
135         eax-serpentbe-test.confirm check-ipaddrset \
136         msgcode-test.confirm check-test
137
138 version.c: Makefile
139         echo "#include \"secnet.h\"" >$@.new
140         @set -ex; if test -e .git && type -p git >/dev/null; then \
141                 v=$$(git describe --match 'v*'); v=$${v#v}; \
142                 if ! git diff --quiet HEAD; then v="$$v+"; fi; \
143         else \
144                 v="$(VERSION)"; \
145         fi; \
146         echo "char version[]=\"secnet $$v\";" >>$@.new
147         mv -f $@.new $@
148
149 eax-%-test: eax-%-test.o eax-test.o %.o
150         $(CC) $(LDFLAGS) $(ALL_CFLAGS) -o $@ $^
151
152 eax-%-test.confirm: eax-%-test eax-%-test.vectors
153         ./$< <$(srcdir)/eax-$*-test.vectors >$@.new
154         mv -f $@.new $@
155
156 msgcode-test: msgcode-test.o
157         $(CC) $(LDFLAGS) $(ALL_CFLAGS) -o $@ $^
158
159 msgcode-test.confirm: msgcode-test
160         ./msgcode-test
161         touch $@
162
163 check-ipaddrset: ipaddrset-test.py ipaddrset.py ipaddrset-test.expected
164         $(srcdir)/ipaddrset-test.py >ipaddrset-test.new
165         diff -u $(srcdir)/ipaddrset-test.expected ipaddrset-test.new
166
167 check-test: secnet test-example/sites.conf
168         $(MAKE) -C test check
169
170 test-example/sites.conf:
171         $(MAKE) -C test-example
172
173 .PRECIOUS: eax-%-test
174
175 installdirs:
176         $(INSTALL) -d $(prefix)/share/secnet $(sbindir)
177         $(INSTALL) -d $(mandir)/man8
178         $(INSTALL) -d $(datarootdir)/secnet
179
180 install: installdirs
181         set -e; ok=true; for f in $(STALE_PYTHON_FILES); do \
182                 if test -e $$f; then \
183                         echo >&2 "ERROR: $$f still exists "\
184                                 "- try \`make install-force'"; \
185                         ok=false; \
186                 fi; \
187         done; \
188         $$ok
189         $(INSTALL_PROGRAM) secnet $(sbindir)/`echo secnet|sed '$(transform)'`
190         $(INSTALL_PROGRAM) ${srcdir}/make-secnet-sites $(sbindir)/`echo make-secnet-sites|sed '$(transform)'`
191         $(INSTALL_DATA) ${srcdir}/ipaddrset.py $(prefix)/share/secnet/ipaddrset.py
192         $(INSTALL_SCRIPT) ${srcdir}/polypath-interface-monitor-linux \
193                 $(datarootdir)/secnet/.
194         $(INSTALL_DATA) ${srcdir}/secnet.8 $(mandir)/man8/secnet.8
195
196 install-force:
197         rm -f $(STALE_PYTHON_FILES)
198         $(MAKE) install
199
200 clean:
201         $(RM) -f *.o *.yy.[ch] *.tab.[ch] $(TARGETS) core version.c
202         $(RM) -f *.d *.pyc *~ eax-*-test.confirm eax-*-test
203         $(RM) -f msgcode-test.confirm msgcode-test
204
205 realclean:      clean
206         $(RM) -f *~ Makefile config.h  *.d \
207         config.log config.status config.cache \
208         config.stamp Makefile.bak
209
210 distclean:      realclean
211
212 # Release checklist:
213 #
214 #  0. Use this checklist from Makefile.in
215 #
216 #  1. Check that the tree has what you want
217 #
218 #  2. Update changelog:
219 #         gbp dch --since=<PREVIOUS VERSION>
220 #     and then edit debian/changelog.
221 #
222 #  3. Update VERSION (in this file, above) and
223 #     finalise debian/changelog (removing ~ from version) and commit.
224 #
225 #  4. Build source and binaries:
226 #       dgit -wgf sbuild -A -c stretch
227 #
228 #  5. dpkg -i on zealot just to check
229 #       dpkg -i ~ian/things/Fvpn/bpd/secnet_${VERSION}_amd64.deb
230 #
231 #  6. run it on chiark
232 #     check we can still ping davenant and chiark
233 #
234 #  7. Make git tag and source tarball signature:
235 #       git-tag -u general -m "secnet $VERSION" -s v${VERSION//\~/_}
236 #       gpg -u general --detach-sign ../bpd/secnet_$VERSION.tar.gz
237 #
238 #  8. Publish the branch and distriubtion files:
239 #       git-push origin v${VERSION//\~/_} v${VERSION//\~/_}~0:master
240 #       dcmd rsync -v ../bpd/secnet_${VERSION}_multi.changes chiark:/home/ianmdlvl/public-html/secnet/download/
241 #
242 #  9. Sort out html.  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 #       ln -sfn $VERSION ../current
248 #
249 # 10. write and post a release announcement
250 #       cd ../bpd
251 #       dcmd sha256sum secnet_${VERSION}_multi.changes
252 #       ...
253 #       gpg --clearsign ../release-announcement
254 #       rsync -vP ../release-announcement.asc c:mail/d/
255 #
256 # 11. bump changelog version in master, to new version with ~