OSDN Git Service

2013.10.24
[uclinux-h8/uClinux-dist.git] / freeswan / utils / Makefile
1 # utilities build and install
2 # Copyright (C) 1998-2001  Henry Spencer.
3
4 # This program is free software; you can redistribute it and/or modify it
5 # under the terms of the GNU General Public License as published by the
6 # Free Software Foundation; either version 2 of the License, or (at your
7 # option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
8
9 # This program is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 # or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12 # for more details.
13 #
14 # RCSID $Id: Makefile,v 1.106 2002/04/01 20:05:27 mcr Exp $
15
16
17
18 include ../Makefile.inc
19 include ../Makefile.ver
20
21
22
23 PUBS=ipsec
24 BINS=_copyright ranbits rsasigkey
25 SCRIPTS=auto barf look manual newhostkey showdefaults showhostkey send-pr
26 INTERNALS=_include _confread _keycensor _secretcensor _updown _updown.dhcp \
27         _realsetup _startklips _plutorun _plutoload
28 PRIVS=$(PUBS) $(SCRIPTS) $(INTERNALS) $(BINS)
29 LIBFILES=ipsec_pr.template
30 GENDFILES=secrets.eg conf.eg
31 GENDSCRIPTS=ipsec send-pr 
32 LOCALS=
33 PLAIN_MANS=ipsec.8
34 IPSEC_CMANS=auto.8 barf.8 manual.8 newhostkey.8 ranbits.8 rsasigkey.8 setup.8 \
35         showdefaults.8 showhostkey.8 send-pr.8
36 MANS=$(PLAIN_MANS) $(IPSEC_CMANS)
37 CFLAGS=-I../lib $(USERCOMPILE)
38 LIB=../lib/libfreeswan.a
39 PUB=--mode=644
40 PRIV=--mode=600
41 RSAKEYBITS=2192
42 FMANDIR=$(MANTREE)/man5
43 CMANDIR=$(MANTREE)/man8
44 .PHONY: all newsecrets install setup4 clean checkprograms
45
46
47
48 all:    $(PUBS) $(PRIVS) $(GENDFILES) $(LOCALS)
49 programs: all
50
51 ranbits:        ranbits.o
52         $(CC) $(CFLAGS) ranbits.o $(LIB) -o $@
53
54 rsasigkey:      rsasigkey.o
55         $(CC) $(CFLAGS) rsasigkey.o $(LIB) -lgmp -o $@
56
57 _copyright:     _copyright.o
58         $(CC) $(CFLAGS) _copyright.o $(LIB) -o $@
59
60 ipsec:  ipsec.in ../Makefile.ver
61         sed -e "s/xxx/$(IPSECVERSION)/" -e "s:@IPSEC_DIR@:$(FINALBINDIR):" \
62                 -e "s:@IPSEC_CONFS@:$(FINALCONFDIR):" ipsec.in >$@
63         chmod +x $@
64
65 send-pr: send-pr.sh
66         sed "s:@IPSEC_DIR@:$(FINALBINDIR):" send-pr.sh >$@
67         chmod +x $@
68
69 send-pr.8: send-pr.man
70         sed "s/xVERSIONx/$(IPSECVERSION)/" send-pr.man | sed "s:@IPSEC_DIR@:$(FINALBINDIR):" >$@
71
72 # generate RSA private key... if, and only if, /etc/ipsec.secrets does
73 # not already exist
74 BLURB=-- not filled in because ipsec.secrets existed at build time --
75 secrets.eg:     secrets.proto ranbits rsasigkey
76         rm -f $@
77         umask 077 ; ( \
78                 sed '/yyy/,$$d' secrets.proto ; \
79                 if test ! -f $(CONFDIR)/ipsec.secrets ; \
80                 then ./rsasigkey --verbose $(RSAKEYBITS) ; \
81                 else echo "     # $(BLURB)" ; \
82                 fi ; \
83                 sed '1,/yyy/d' secrets.proto ; \
84         ) | egrep -v RCSID >$@
85
86 # force full secrets-file build
87 newsecrets:
88         rm -f secrets.eg
89         $(MAKE) secrets.eg CONFDIR=.
90
91 conf.eg:        conf.proto ranbits randomize
92         rm -f $@
93         ./randomize conf.proto | egrep -v RCSI >$@
94
95 INSTMAN=$(INSTALL) $(INSTMANFLAGS)
96 INSTCONF=$(INSTALL) $(INSTCONFFLAGS)
97 install:        $(PUBS) $(PRIVS) $(MANS) $(GENDFILES) $(IPSEC_CMANS) 
98         mkdir -p $(PUBDIR) $(BINDIR) $(FMANDIR) $(CMANDIR) $(CONFDIR)
99         $(INSTALL) $(INSTBINFLAGS) $(PUBS) $(PUBDIR)
100         $(INSTALL) $(INSTBINFLAGS) $(PRIVS) $(BINDIR)
101         $(INSTALL) $(INSTCONFFLAGS) $(PUB) $(LIBFILES) $(BINDIR)
102         $(INSTALL) $(INSTMANFLAGS) $(PUB) ipsec.conf.5 $(FMANDIR)
103         $(INSTALL) $(INSTMANFLAGS) $(PUB) $(PLAIN_MANS) $(CMANDIR)
104         for f in $(IPSEC_CMANS) ; \
105         do \
106                 $(INSTMAN) $(PUB) $$f $(CMANDIR)/ipsec_$$f || exit 1 ; \
107                 ./manlink $(CMANDIR) ipsec_$$f ; \
108         done
109         test -f $(CONFDIR)/ipsec.secrets || \
110                 $(INSTCONF) $(PRIV) secrets.eg $(CONFDIR)/ipsec.secrets
111         test -f $(CONFDIR)/ipsec.conf || \
112                 $(INSTCONF) $(PUB) conf.eg $(CONFDIR)/ipsec.conf
113         # main copy must go in RCDIR, BINDIR may not be mounted at boot time
114         mkdir -p $(RCDIR)
115         $(INSTALL) $(INSTBINFLAGS) setup $(RCDIR)/ipsec
116         rm -f $(BINDIR)/setup
117         ln -s $(FINALRCDIR)/ipsec $(BINDIR)/setup
118         PATH=/sbin:/usr/sbin:$$PATH ; export PATH ; \
119         if test " $(DESTDIR)" != " " ; \
120         then : do nothing ; \
121         elif which chkconfig >/dev/null 2>&1 ; \
122         then chkconfig --add ipsec ; \
123         else $(MAKE) setup4 ; \
124         fi
125
126 setup4: $(RCDIR)/ipsec
127         # fallback rc install -- on in run states 2345, off in 016, with
128         # priorities matching those in setup's chkconfig line
129         -cd $(RCDIR)/../rc0.d ; ln -s ../init.d/ipsec K68ipsec
130         -cd $(RCDIR)/../rc1.d ; ln -s ../init.d/ipsec K68ipsec
131         -cd $(RCDIR)/../rc2.d ; ln -s ../init.d/ipsec S47ipsec
132         -cd $(RCDIR)/../rc3.d ; ln -s ../init.d/ipsec S47ipsec
133         -cd $(RCDIR)/../rc4.d ; ln -s ../init.d/ipsec S47ipsec
134         -cd $(RCDIR)/../rc5.d ; ln -s ../init.d/ipsec S47ipsec
135         -cd $(RCDIR)/../rc6.d ; ln -s ../init.d/ipsec K68ipsec
136
137 clean:
138         rm -f *.o $(BINS) $(GENDFILES) $(GENDSCRIPTS) $(LOCALS)
139
140 checkprograms: