Build system: Break out SECNET_C_GETFUNC macro
[secnet] / Makefile.in
... / ...
CommitLineData
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 d 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
22PACKAGE:=secnet
23VERSION:=0.4.0~beta1
24
25@SET_MAKE@
26
27srcdir:=@srcdir@
28VPATH:=@srcdir@
29
30SHELL:=/bin/sh
31RM:=@RM@
32CC:=@CC@
33INSTALL:=@INSTALL@
34INSTALL_PROGRAM:=@INSTALL_PROGRAM@
35INSTALL_SCRIPT:=@INSTALL_SCRIPT@
36INSTALL_DATA:=@INSTALL_DATA@
37
38prefix:=$(DESTDIR)@prefix@
39exec_prefix:=@exec_prefix@
40sbindir:=@sbindir@
41sysconfdir:=$(DESTDIR)@sysconfdir@
42datarootdir:=@datarootdir@
43transform:=@program_transform_name@
44mandir:=@mandir@
45
46CFLAGS:=-Wall @WRITESTRINGS@ @CFLAGS@ -Werror \
47 -W -Wno-unused -Wno-unused-parameter \
48 -Wno-pointer-sign -Wstrict-prototypes -Wmissing-prototypes \
49 -Wmissing-declarations -Wnested-externs -Wredundant-decls \
50 -Wpointer-arith -Wformat=2 -Winit-self \
51 -Wswitch-enum -Wunused-variable -Wunused-function -Wbad-function-cast \
52 -Wno-strict-aliasing -fno-strict-aliasing \
53 -MMD
54ALL_CFLAGS:=@DEFS@ -I$(srcdir) -I. $(CFLAGS) $(EXTRA_CFLAGS)
55CPPFLAGS:=@CPPFLAGS@ -DDATAROOTDIR='"$(datarootdir)"' $(EXTRA_CPPFLAGS)
56LDFLAGS:=@LDFLAGS@ $(EXTRA_LDFLAGS)
57LDLIBS:=@LIBS@ $(EXTRA_LDLIBS)
58
59TARGETS:=secnet
60
61OBJECTS:=secnet.o util.o conffile.yy.o conffile.tab.o conffile.o modules.o \
62 resolver.o random.o udp.o site.o transform-cbcmac.o transform-eax.o \
63 comm-common.o polypath.o \
64 netlink.o rsa.o dh.o serpent.o serpentbe.o \
65 md5.o sha512.o tun.o slip.o sha1.o ipaddr.o log.o \
66 process.o @LIBOBJS@ \
67 hackypar.o
68# version.o is handled specially below and in the link rule for secnet.
69
70TEST_OBJECTS:=eax-aes-test.o eax-serpent-test.o eax-serpentbe-test.o \
71 eax-test.o aes.o
72
73ifeq (version.o,$(MAKECMDGOALS))
74OBJECTS:=version.o
75TEST_OBJECTS:=
76endif
77
78STALE_PYTHON_FILES= $(foreach e, py pyc, \
79 $(foreach p, /usr /usr/local, \
80 $(foreach l, ipaddr, \
81 $(DESTDIR)$p/share/secnet/$l.$e \
82 )))
83
84%.c: %.y
85
86%.yy.c: %.fl
87 flex --header=$*.yy.h -o$@ $<
88
89%.tab.c %.tab.h: %.y
90 bison -d -o $@ $<
91
92%.o: %.c conffile.yy.h
93 $(CC) $(CPPFLAGS) $(ALL_CFLAGS) -c $< -o $@
94
95all: $(TARGETS) check
96
97# Automatic remaking of configuration files, from autoconf documentation
98${srcdir}/configure: configure.in
99 cd ${srcdir} && autoconf
100
101# autoheader might not change config.h.in, so touch a stamp file.
102${srcdir}/config.h.in: stamp-h.in
103${srcdir}/stamp-h.in: configure.in
104 cd ${srcdir} && autoheader
105 echo timestamp > ${srcdir}/stamp-h.in
106
107config.h: stamp-h
108stamp-h: config.h.in config.status
109 ./config.status
110
111Makefile: Makefile.in config.status
112 ./config.status
113
114config.status: configure
115 ./config.status --recheck
116# End of config file remaking rules
117
118# C and header file dependency rules
119SOURCES:=$(OBJECTS:.o=.c) $(TEST_OBJECTS:.o=.c)
120DEPENDS:=$(OBJECTS:.o=.d) $(TEST_OBJECTS:.o=.d)
121
122-include *.d
123
124# Manual dependencies section
125conffile.yy.c: conffile.fl conffile.tab.c
126conffile.yy.h: conffile.yy.c
127conffile.tab.c: conffile.y
128# End of manual dependencies section
129
130secnet: $(OBJECTS)
131 $(MAKE) version.o # *.o $(filter-out %.o, $^)
132 $(CC) $(LDFLAGS) $(ALL_CFLAGS) -o $@ $(OBJECTS) version.o $(LDLIBS)
133# We (always) regenerate the version, but only if we regenerate the
134# binary. (This is necessary as the version string is can depend on
135# any of the source files, eg to see whether "+" is needed.)
136
137ifneq (,$(wildcard .git/HEAD))
138# If we have (eg) committed, relink and thus regenerate the version
139# with the new info from git describe.
140secnet: Makefile .git/HEAD $(shell sed -n 's#^ref: #.git/#p' .git/HEAD)
141secnet: $(wildcard .git/packed-refs)
142endif
143
144check: eax-aes-test.confirm eax-serpent-test.confirm \
145 eax-serpentbe-test.confirm check-ipaddrset
146
147version.c: Makefile
148 echo "#include \"secnet.h\"" >$@.new
149 @set -ex; if test -e .git; then \
150 v=$$(git describe --match 'v*'); v=$${v#v}; \
151 if ! git diff --quiet HEAD; then v="$$v+"; fi; \
152 else \
153 v="$(VERSION)"; \
154 fi; \
155 echo "char version[]=\"secnet $$v\";" >>$@.new
156 mv -f $@.new $@
157
158eax-%-test: eax-%-test.o eax-test.o %.o
159 $(CC) $(LDFLAGS) $(ALL_CFLAGS) -o $@ $^
160
161eax-%-test.confirm: eax-%-test eax-%-test.vectors
162 ./$< <$(srcdir)/eax-$*-test.vectors >$@.new
163 mv -f $@.new $@
164
165check-ipaddrset: ipaddrset-test.py ipaddrset.py ipaddrset-test.expected
166 $(srcdir)/ipaddrset-test.py >ipaddrset-test.new
167 diff -u ipaddrset-test.expected ipaddrset-test.new
168
169.PRECIOUS: eax-%-test
170
171installdirs:
172 $(INSTALL) -d $(prefix)/share/secnet $(sbindir)
173 $(INSTALL) -d $(mandir)/man8
174 $(INSTALL) -d $(datarootdir)/secnet
175
176install: installdirs
177 set -e; ok=true; for f in $(STALE_PYTHON_FILES); do \
178 if test -e $$f; then \
179 echo >&2 "ERROR: $$f still exists "\
180 "- try \`make install-force'"; \
181 ok=false; \
182 fi; \
183 done; \
184 $$ok
185 $(INSTALL_PROGRAM) secnet $(sbindir)/`echo secnet|sed '$(transform)'`
186 $(INSTALL_PROGRAM) ${srcdir}/make-secnet-sites $(sbindir)/`echo make-secnet-sites|sed '$(transform)'`
187 $(INSTALL_DATA) ${srcdir}/ipaddrset.py $(prefix)/share/secnet/ipaddrset.py
188 $(INSTALL_SCRIPT) ${srcdir}/polypath-interface-monitor-linux \
189 $(datarootdir)/secnet/.
190 $(INSTALL_DATA) secnet.8 $(mandir)/man8/secnet.8
191
192install-force:
193 rm -f $(STALE_PYTHON_FILES)
194 $(MAKE) install
195
196clean:
197 $(RM) -f *.o *.yy.[ch] *.tab.[ch] $(TARGETS) core version.c
198 $(RM) -f *.d *.pyc *~ eax-*-test.confirm eax-*-test
199
200realclean: clean
201 $(RM) -f *~ Makefile config.h *.d \
202 config.log config.status config.cache \
203 stamp-h Makefile.bak
204
205distclean: realclean
206
207pfname:=$(PACKAGE)-$(VERSION)
208tarfname:=../$(pfname).tar
209dist:
210 $(RM) -rf $(tarfname) $(tarfname).gz
211 git archive --format=tar --prefix=$(pfname)/ HEAD -o $(tarfname)
212 gzip -9f $(tarfname)
213
214# Release checklist:
215# 1. Check that the tree has what you want
216#
217# 2. Update VERSION (above) and debian/changelog
218# but DO NOT COMMIT
219#
220# 3. Run
221# ./configure
222# make dist
223# and check that the resulting tarball looks OK.
224# Eg, untar it and build it, or have it reviewed.
225#
226# 3. Commit the updates to VERSION (above) and debian/changelog
227#
228# 4. git-tag -m "secnet $VERSION" -s v$VERSION
229#
230# 5. git-push origin v$VERSION v${VERSION}~0:master
231#
232# 6. Run, again,
233# make dist
234#
235# 7. gpg --detach-sign ../secnet-$VERSION.tar.gz
236#
237# 8. rsync -v ../secnet-$VERSION.tar.gz* \
238# chiark:/home/ianmdlvl/public-html/secnet/download/
239#
240# 9. On chiark:
241# tar zxf ~ianmdlvl/public-html/secnet/download/secnet-$VERSION.tar.gz
242# cd secnet-$VERSION
243# debian/rules build
244# fakeroot debian/rules binary
245# mv ../secnet_${VERSION}_i386.deb ~ianmdlvl/public-html/secnet/download/
246#
247# 10. On chiark as user secnet:
248# cd ~secnet/public-html/release/
249# mkdir $VERSION
250# cd $VERSION
251# ln -s /home/ianmdlvl/public-html/secnet/download/secnet?$VERSION* .
252#
253# 11. write and post a release announcement