2 # Copyright (C) 1995-2001 Stephen Early <steve@greenend.org.uk>
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)
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.
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.
18 .PHONY: all clean realclean distclean dist install
32 INSTALL_PROGRAM:=@INSTALL_PROGRAM@
34 CFLAGS:=-Wall @WRITESTRINGS@ @CFLAGS@ -Werror \
35 -W -Wno-unused -Wno-unused-parameter \
36 -Wno-pointer-sign -Wstrict-prototypes -Wmissing-prototypes \
37 -Wmissing-declarations -Wnested-externs -Wredundant-decls \
38 -Wpointer-arith -Wformat=2 -Winit-self \
39 -Wswitch-enum -Wunused-variable -Wunused-function -Wbad-function-cast \
40 -Wno-strict-aliasing -fno-strict-aliasing
41 ALL_CFLAGS:=@DEFS@ -I$(srcdir) -I. $(CFLAGS) $(EXTRA_CFLAGS)
42 CPPFLAGS:=@CPPFLAGS@ $(EXTRA_CPPFLAGS)
43 LDFLAGS:=@LDFLAGS@ $(EXTRA_LDFLAGS)
44 LDLIBS:=@LIBS@ $(EXTRA_LDLIBS)
47 exec_prefix:=@exec_prefix@
49 sysconfdir:=@sysconfdir@
50 transform:=@program_transform_name@
55 OBJECTS:=secnet.o util.o conffile.yy.o conffile.tab.o conffile.o modules.o \
56 resolver.o random.o udp.o site.o transform-cbcmac.o transform-eax.o \
57 netlink.o rsa.o dh.o serpent.o serpentbe.o \
58 md5.o sha512.o tun.o slip.o sha1.o ipaddr.o log.o \
61 # version.o is handled specially below and in the link rule for secnet.
63 TEST_OBJECTS:=eax-aes-test.o eax-serpent-test.o eax-serpentbe-test.o \
66 ifeq (version.o,$(MAKECMDGOALS))
74 flex --header=$*.yy.h -o$@ $<
80 $(CC) $(CPPFLAGS) $(ALL_CFLAGS) -c $< -o $@
84 # Automatic remaking of configuration files, from autoconf documentation
85 ${srcdir}/configure: configure.in
86 cd ${srcdir} && autoconf
88 # autoheader might not change config.h.in, so touch a stamp file.
89 ${srcdir}/config.h.in: stamp-h.in
90 ${srcdir}/stamp-h.in: configure.in
91 cd ${srcdir} && autoheader
92 echo timestamp > ${srcdir}/stamp-h.in
95 stamp-h: config.h.in config.status
98 Makefile: Makefile.in config.status
101 config.status: configure
102 ./config.status --recheck
103 # End of config file remaking rules
105 # C and header file dependency rules
106 SOURCES:=$(OBJECTS:.o=.c) $(TEST_OBJECTS:.o=.c)
107 DEPENDS:=$(OBJECTS:.o=.d) $(TEST_OBJECTS:.o=.d)
109 $(DEPENDS): ${srcdir}/depend.sh
112 ${srcdir}/depend.sh $(srcdir) $(CPPFLAGS) $(ALL_CFLAGS) $< > $@
116 # Manual dependencies section
117 conffile.yy.c: conffile.fl conffile.tab.c
118 conffile.yy.h: conffile.yy.c
119 conffile.tab.c: conffile.y
120 # End of manual dependencies section
123 $(MAKE) version.o # *.o $(filter-out %.o, $^)
124 $(CC) $(LDFLAGS) $(ALL_CFLAGS) -o $@ $(OBJECTS) version.o $(LDLIBS)
125 # We (always) regenerate the version, but only if we regenerate the
126 # binary. (This is necessary as the version string is can depend on
127 # any of the source files, eg to see whether "+" is needed.)
129 ifneq (,$(wildcard .git/HEAD))
130 # If we have (eg) committed, relink and thus regenerate the version
131 # with the new info from git describe.
132 secnet: Makefile .git/HEAD $(shell sed -n 's#^ref: #.git/#p' .git/HEAD)
133 secnet: $(wildcard .git/packed-refs)
136 check: eax-aes-test.confirm eax-serpent-test.confirm \
137 eax-serpentbe-test.confirm
140 echo "#include \"secnet.h\"" >$@.new
141 @set -ex; if test -e .git; then \
142 v=$$(git describe --match 'v*'); v=$${v#v}; \
143 if ! git diff --quiet HEAD; then v="$$v+"; fi; \
147 echo "char version[]=\"secnet $$v\";" >>$@.new
150 eax-%-test: eax-%-test.o eax-test.o %.o
151 $(CC) $(LDFLAGS) $(ALL_CFLAGS) -o $@ $^
153 eax-%-test.confirm: eax-%-test eax-%-test.vectors
154 ./$< <$(srcdir)/eax-$*-test.vectors >$@.new
157 .PRECIOUS: eax-%-test
160 $(INSTALL) -d $(prefix)/share/secnet $(sbindir)
161 $(INSTALL) -d $(mandir)/man8
164 $(INSTALL_PROGRAM) secnet $(sbindir)/`echo secnet|sed '$(transform)'`
165 $(INSTALL_PROGRAM) ${srcdir}/make-secnet-sites $(sbindir)/`echo make-secnet-sites|sed '$(transform)'`
166 $(INSTALL) ${srcdir}/ipaddr.py $(prefix)/share/secnet/ipaddr.py
167 $(INSTALL) secnet.8 $(mandir)/man8/secnet.8
170 $(RM) -f *.o *.yy.c *.tab.[ch] $(TARGETS) core version.c
171 $(RM) -f *.d *~ eax-*-test.confirm eax-*-test
174 $(RM) -f *~ Makefile config.h *.d \
175 config.log config.status config.cache \
180 pfname:=$(PACKAGE)-$(VERSION)
181 tarfname:=../$(pfname).tar
183 $(RM) -rf $(tarfname) $(tarfname).gz
184 git archive --format=tar --prefix=$(pfname)/ HEAD -o $(tarfname)
188 # 1. Check that the tree has what you want
190 # 2. Update VERSION (above) and debian/changelog
196 # and check that the resulting tarball looks OK.
197 # Eg, untar it and build it, or have it reviewed.
199 # 3. Commit the updates to VERSION (above) and debian/changelog
201 # 4. git-tag -m "secnet $VERSION" -s v$VERSION
203 # 5. git-push origin v$VERSION v${VERSION}~0:master
208 # 7. gpg --detach-sign ../secnet-$VERSION.tar.gz
210 # 8. rsync -v ../secnet-$VERSION.tar.gz* \
211 # chiark:/home/ianmdlvl/public-html/secnet/download/
214 # tar zxf ~ianmdlvl/public-html/secnet/download/secnet-$VERSION.tar.gz
217 # fakeroot debian/rules binary
218 # mv ../secnet_${VERSION}_i386.deb ~ianmdlvl/public-html/secnet/download/
220 # 10. On chiark as user secnet:
221 # cd ~secnet/public-html/release/
224 # ln -s /home/ianmdlvl/public-html/secnet/download/secnet?$VERSION* .
226 # 11. write and post a release announcement