chiark / gitweb /
Add 'base91-python/' from commit '749aa78cf12496cca4b9bf3eafe045809fc0da10'
[secnet.git] / Dir.sd.mk
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.5.1
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 &:local+global OBJECTS TARGETS
48
49 TARGETS:=secnet
50
51 OBJECTS:=secnet.o util.o conffile.yy.o conffile.tab.o conffile.o modules.o \
52         resolver.o random.o udp.o site.o transform-cbcmac.o transform-eax.o \
53         comm-common.o polypath.o privcache.o \
54         netlink.o rsa.o dh.o serpent.o serpentbe.o \
55         md5.o sha512.o tun.o slip.o sha1.o ipaddr.o log.o \
56         process.o @LIBOBJS@ \
57         hackypar.o base91s/base91.o
58 # version.o is handled specially below and in the link rule for secnet.
59
60 PYMODULES := ipaddrset.py argparseactionnoyes.py
61
62 TEST_OBJECTS:=eax-aes-test.o eax-serpent-test.o eax-serpentbe-test.o \
63                 eax-test.o aes.o
64
65 ifeq (version.o,$(MAKECMDGOALS))
66 OBJECTS:=
67 TEST_OBJECTS:=
68 endif
69
70 &OBJECTS += $(OBJECTS) $(TEST_OBJECTS)
71
72 STALE_PYTHON_FILES=     $(foreach e, py pyc, \
73                         $(foreach p, /usr /usr/local, \
74                         $(foreach l, ipaddr, \
75                         $(DESTDIR)$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 conffile.yy.h
87         $(CC) $(CPPFLAGS) $(ALL_CFLAGS) $(CDEPS_CFLAGS) -c $< -o $@
88
89 all::   $(TARGETS)
90
91 ${srcdir}/config.h.in: configure.ac
92         cd ${srcdir} && autoheader
93         touch $@
94
95 MAKEFILE_TEMPLATES += config.h.in
96 CONFIG_STATUS_OUTPUTS += config.h
97
98 # Manual dependencies section
99 conffile.yy.c:  conffile.fl conffile.tab.c
100 conffile.yy.h:  conffile.yy.c
101 conffile.tab.c: conffile.y
102 # End of manual dependencies section
103
104 conffile.yy.o: ALL_CFLAGS += -Wno-sign-compare
105
106 secnet: $(OBJECTS)
107         $(MAKE) -f main.mk version.o # *.o $(filter-out %.o, $^)
108         $(CC) $(LDFLAGS) $(ALL_CFLAGS) -o $@ $(OBJECTS) version.o $(LDLIBS)
109 # We (always) regenerate the version, but only if we regenerate the
110 # binary.  (This is necessary as the version string is can depend on
111 # any of the source files, eg to see whether "+" is needed.)
112
113 ifneq (,$(wildcard .git/HEAD))
114 # If we have (eg) committed, relink and thus regenerate the version
115 # with the new info from git describe.
116 secnet: Makefile .git/HEAD $(wildcard $(shell sed -n 's#^ref: #.git/#p' .git/HEAD))
117 secnet: $(wildcard .git/packed-refs)
118 endif
119
120 TESTDIRS=stest mtest
121
122 &TARGETS_check = eax-aes-test.confirm eax-serpent-test.confirm \
123         eax-serpentbe-test.confirm ipaddrset.confirm
124
125 &TARGETS_fullcheck += $(&TARGETS_check)
126 &TARGETS_fullcheck += msgcode-test.confirm
127
128 recheck:
129         rm -f $(&TARGETS_check)
130         rm -rf $(addsuffix /d-*, $(TESTDIRS))
131         $(MAKE) -f main.mk check
132
133 .PHONY: FORCE
134 version.c: FORCE
135         echo "#include \"secnet.h\"" >$@.new
136         @set -ex; if test -e .git && type -p git >/dev/null; then \
137                 v=$$(git describe --match 'v*'); v=$${v#v}; \
138                 if ! git diff --quiet HEAD; then v="$$v+"; fi; \
139         else \
140                 v="$(VERSION)"; \
141         fi; \
142         echo "char version[]=\"secnet $$v\";" >>$@.new
143         mv -f $@.new $@
144
145 eax-%-test: eax-%-test.o eax-test.o %.o
146         $(CC) $(LDFLAGS) $(ALL_CFLAGS) -o $@ $^
147
148 eax-%-test.confirm: eax-%-test eax-%-test.vectors
149         ./$< <$(srcdir)/eax-$*-test.vectors >$@.new
150         mv -f $@.new $@
151
152 &CDEPS_OBJECTS += msgcode-test.o
153
154 msgcode-test: msgcode-test.o
155         $(CC) $(LDFLAGS) $(ALL_CFLAGS) -o $@ $^
156
157 msgcode-test.confirm: msgcode-test
158         ./msgcode-test
159         touch $@
160
161 ipaddrset.confirm: ipaddrset-test.py ipaddrset.py ipaddrset-test.expected
162         $(srcdir)/ipaddrset-test.py >ipaddrset-test.new
163         diff -u $(srcdir)/ipaddrset-test.expected ipaddrset-test.new
164         touch $@
165
166 .PRECIOUS: eax-%-test
167
168 installdirs:
169         $(INSTALL) -d $(prefix)/share/secnet $(sbindir)
170         $(INSTALL) -d $(mandir)/man8
171         $(INSTALL) -d $(datarootdir)/secnet
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         set -e; for m in $(PYMODULES); do \
185                 $(INSTALL_DATA) ${srcdir}/$$m $(prefix)/share/secnet/$$m; \
186                 done
187         $(INSTALL_SCRIPT) ${srcdir}/polypath-interface-monitor-linux \
188                 $(datarootdir)/secnet/.
189         $(INSTALL_DATA) ${srcdir}/secnet.8 $(mandir)/man8/secnet.8
190
191 install-force:
192         rm -f $(STALE_PYTHON_FILES)
193         $(MAKE) -f main.mk install
194
195 &CLEAN += .version.d
196 &CLEAN += $(TARGETS) $(&TARGETS_check) $(&TARGETS_fullcheck)
197
198 clean::
199         $(RM) -f *.o *.yy.[ch] *.tab.[ch] core version.c
200         $(RM) -f *.pyc *~ eax-*-test.confirm eax-*-test
201         $(RM) -rf __pycache__
202         $(RM) -f msgcode-test.confirm msgcode-test
203
204 realclean::     clean
205         $(RM) -f *~ Makefile config.h \
206         config.log config.status config.cache \
207         config.stamp Makefile.bak
208
209 distclean::     realclean
210
211 include subdirmk/regen.mk
212
213 &:warn !single-char-var
214 # Release checklist:
215 #
216 #  0. Use this checklist from Dir.sd.mk
217 #
218 #  1. Check that the tree has what you want
219 #
220 #  2. Update changelog:
221 #         gbp dch --since=<PREVIOUS VERSION>
222 #     and then edit debian/changelog.
223 #
224 #  3. Update VERSION (in this file, above) and
225 #     finalise debian/changelog (removing ~ from version) and commit.
226 #
227 #  4. Build source and binaries:
228 #       dgit -wgf sbuild -A -c stretch -j8
229 #
230 #  5. dpkg -i on zealot just to check
231 #       dpkg -i ~ian/things/Fvpn/bpd/secnet_${VERSION}_amd64.deb
232 #
233 #  6. run it on chiark
234 #     check we can still ping davenant and chiark
235 #
236 #  7. Make git tag and source tarball signature:
237 #       git-tag -u general -m "secnet $VERSION" -s v${VERSION//\~/_}
238 #       gpg -u general --detach-sign ../bpd/secnet_$VERSION.tar.gz
239 #
240 #  8. Publish the branch and distriubtion files:
241 #       git-push origin v${VERSION//\~/_} v${VERSION//\~/_}~0:master
242 #       dcmd rsync -v ../bpd/secnet_${VERSION}_multi.changes chiark:/home/ianmdlvl/public-html/secnet/download/
243 #
244 #  9. Sort out html.  On chiark as user secnet:
245 #       cd ~secnet/public-html/release/
246 #       mkdir $VERSION
247 #       cd $VERSION
248 #       ln -s /home/ianmdlvl/public-html/secnet/download/secnet?$VERSION* .
249 #       ln -sfn $VERSION ../current
250 #
251 # 10. write and post a release announcement
252 #       cd ../bpd
253 #       dcmd sha256sum secnet_${VERSION}_multi.changes
254 #       ...
255 #       gpg --clearsign ../release-announcement
256 #       rsync -vP ../release-announcement.asc c:mail/d/
257 #
258 # 11. bump changelog version in master, to new version with ~