chiark / gitweb /
0addd4df8621b432df405cb8d33a61ef2b29bd54
[userv-utils.git] / ipif / Makefile
1 # Makefile for ipif/udptunnel stuff
2
3 # This file is part of ipif, part of userv-util
4 #
5 # Copyright 1996-2013 Ian Jackson <ijackson@chiark.greenend.org.uk>
6 # Copyright 1998 David Damerell <damerell@chiark.greenend.org.uk>
7 # Copyright 1999,2003
8 #    Chancellor Masters and Scholars of the University of Cambridge
9 # Copyright 2010 Tony Finch <fanf@dotat.at>
10 #
11 # This is free software; you can redistribute it and/or modify it
12 # under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 3 of the License, or
14 # (at your option) any later version.
15 #
16 # This program is distributed in the hope that it will be useful, but
17 # WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19 # General Public License for more details.
20 #
21 # You should have received a copy of the GNU General Public License
22 # along with userv-utils; if not, see http://www.gnu.org/licenses/.
23
24 include ../settings.make
25
26 varlibvpn=      $(varlibuserv)/vpn
27 etcvpn=         $(etcdir)/userv/vpn
28
29 PROGRAM_TARGETS+=
30 PROGRAM_TARGETS$(depr)+= udptunnel-forwarder udptunnel-reconf
31
32 TARGETS+=               service
33 TARGETS$(depr)+=        blowfishtest
34 TARGETS+=               $(PROGRAM_TARGETS)
35
36 PROGRAMS$(depr)+=       udptunnel
37 PROGRAMS+=              $(PROGRAM_TARGETS)
38
39 DIRS+=                  $(libuserv)
40 DIRS$(depr)+=           $(bindir) $(services) $(varlibvpn) $(shareuserv)
41
42 SHAREFILES$(depr)+=     udptunnel-vpn-config.m4 udptunnel-vpn-defaults
43
44 MECHFILES=      null pkcs5 timestamp sequence blowfish
45 MECHOBJS=       $(foreach m, $(MECHFILES), mech-$m.o)
46
47 OBJS_FORWARD=   forwarder.o $(MECHOBJS) blowfish.o automech.c utils.c
48 OBJS_BFTEST=    blowfishtest.o blowfish.o hex.o
49
50 all:            $(TARGETS)
51
52 install:        installdirs all
53                 mkdir -p $(DIRS)
54                 cp -b service $(libuserv)/ipif
55                 set -e; for f in $(PROGRAMS); do cp -b $$f $(bindir)/.; done
56                 cp ipif $(services)/ipif:new
57                 set -e; cd $(services); test -f ipif || mv ipif:new ipif
58                 set -e; for f in $(SHAREFILES); do cp $$f $(shareuserv)/.; done
59
60 install-docs:
61
62 install-examples:
63                 set -e; if [ "x$depr" = x ]; then \
64                         mkdir -p $(etcvpn); \
65                         cp *.example $(etcvpn)/.; \
66                 fi
67
68 udptunnel-reconf:       udptunnel-reconf.pl Makefile
69                 perl -p                                                   \
70         -e '    print "                                                 ' \
71         -e '\$$shareuserv= \"$(shareuserv)\";\n                         ' \
72         -e '\$$etcvpn= \"$(etcvpn)\";\n                                 ' \
73         -e '\$$varlibvpn= \"$(varlibvpn)\";\n" if m#^\# \@\@\@\-#;      ' \
74         -e '    $$_="" if m/^\# \@\@\@\-/ .. m/^\# \-\@\@\@/;           ' \
75                         <$< >$@.new
76                 chmod +x $@.new
77                 mv -f $@.new $@
78
79
80 udptunnel-forwarder:    $(OBJS_FORWARD)
81                 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS_FORWARD)
82
83 blowfishtest:           $(OBJS_BFTEST)
84                 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS_BFTEST)
85
86 automech.h:             automechgen.sh Makefile
87                 ./$< $(MECHFILES)
88
89 automech.c:             automech.h
90
91 clean:
92                 rm -f *.o core automech.[ch] *~ ./#*#
93
94 realclean distclean:    clean
95                 rm -f $(TARGETS)
96
97 forwarder.o $(MECHOBJS) automech.o utils.o:     forwarder.h automech.h
98 blowfish.o mech-blowfish.o blowfishtest.o:      blowfish.h
99 blowfishtest.o hex.o:                           hex.h