fe6ec6efefcc00ae68dd3cce890ced5d510136f9
[userv-utils] / 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 etcuserv= $(etcdir)/userv
28 etcvpn= $(etcuserv)/vpn
29
30 PROGRAM_TARGETS+=
31 PROGRAM_TARGETS$(depr)+= udptunnel-forwarder udptunnel-reconf
32
33 TARGETS+= service
34 TARGETS$(depr)+= blowfishtest
35 TARGETS+= $(PROGRAM_TARGETS)
36
37 PROGRAMS$(depr)+= udptunnel
38 PROGRAMS+= $(PROGRAM_TARGETS)
39
40 DIRS+= $(libuserv) $(etcuserv) $(services)
41 DIRS+= $(docdir)/userv-ipif
42 DIRS$(depr)+= $(bindir) $(varlibvpn) $(shareuserv)
43
44 SHAREFILES$(depr)+= udptunnel-vpn-config.m4 udptunnel-vpn-defaults
45
46 MECHFILES= null pkcs5 timestamp sequence blowfish
47 MECHOBJS= $(foreach m, $(MECHFILES), mech-$m.o)
48
49 OBJS_FORWARD= forwarder.o $(MECHOBJS) blowfish.o automech.c utils.c
50 OBJS_BFTEST= blowfishtest.o blowfish.o hex.o
51
52 all: $(TARGETS)
53
54 install: all
55 mkdir -p $(DIRS)
56 cp -b service $(libuserv)/ipif
57 set -e; for f in $(PROGRAMS); do cp -b $$f $(bindir)/.; done
58 cp ipif $(services)/ipif:new
59 set -e; cd $(services); test -f ipif || mv ipif:new ipif
60 set -e; for f in $(SHAREFILES); do cp $$f $(shareuserv)/.; done
61
62 install-docs:
63 sed -n '1,/^$$/p' service.c >$(docdir)/userv-ipif/service.c.txt
64
65 install-examples:
66 set -e; if [ "x$depr" = x ]; then \
67 mkdir -p $(etcvpn); \
68 cp *.example $(etcvpn)/.; \
69 fi
70
71 udptunnel-reconf: udptunnel-reconf.pl Makefile
72 perl -p \
73 -e ' print " ' \
74 -e '\$$shareuserv= \"$(shareuserv)\";\n ' \
75 -e '\$$etcvpn= \"$(etcvpn)\";\n ' \
76 -e '\$$varlibvpn= \"$(varlibvpn)\";\n" if m#^\# \@\@\@\-#; ' \
77 -e ' $$_="" if m/^\# \@\@\@\-/ .. m/^\# \-\@\@\@/; ' \
78 <$< >$@.new
79 chmod +x $@.new
80 mv -f $@.new $@
81
82
83 udptunnel-forwarder: $(OBJS_FORWARD)
84 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS_FORWARD)
85
86 blowfishtest: $(OBJS_BFTEST)
87 $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS_BFTEST)
88
89 automech.h: automechgen.sh Makefile
90 ./$< $(MECHFILES)
91
92 automech.c: automech.h
93
94 clean:
95 rm -f *.o core automech.[ch] *~ ./#*#
96
97 realclean distclean: clean
98 rm -f $(TARGETS)
99
100 forwarder.o $(MECHOBJS) automech.o utils.o: forwarder.h automech.h
101 blowfish.o mech-blowfish.o blowfishtest.o: blowfish.h
102 blowfishtest.o hex.o: hex.h