1 # utilities build and install
2 # Copyright (C) 1998-2001 Henry Spencer.
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>.
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
14 # RCSID $Id: Makefile,v 1.106 2002/04/01 20:05:27 mcr Exp $
18 include ../Makefile.inc
19 include ../Makefile.ver
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
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
42 FMANDIR=$(MANTREE)/man5
43 CMANDIR=$(MANTREE)/man8
44 .PHONY: all newsecrets install setup4 clean checkprograms
48 all: $(PUBS) $(PRIVS) $(GENDFILES) $(LOCALS)
52 $(CC) $(CFLAGS) ranbits.o $(LIB) -o $@
54 rsasigkey: rsasigkey.o
55 $(CC) $(CFLAGS) rsasigkey.o $(LIB) -lgmp -o $@
57 _copyright: _copyright.o
58 $(CC) $(CFLAGS) _copyright.o $(LIB) -o $@
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 >$@
66 sed "s:@IPSEC_DIR@:$(FINALBINDIR):" send-pr.sh >$@
69 send-pr.8: send-pr.man
70 sed "s/xVERSIONx/$(IPSECVERSION)/" send-pr.man | sed "s:@IPSEC_DIR@:$(FINALBINDIR):" >$@
72 # generate RSA private key... if, and only if, /etc/ipsec.secrets does
74 BLURB=-- not filled in because ipsec.secrets existed at build time --
75 secrets.eg: secrets.proto ranbits rsasigkey
78 sed '/yyy/,$$d' secrets.proto ; \
79 if test ! -f $(CONFDIR)/ipsec.secrets ; \
80 then ./rsasigkey --verbose $(RSAKEYBITS) ; \
81 else echo " # $(BLURB)" ; \
83 sed '1,/yyy/d' secrets.proto ; \
84 ) | egrep -v RCSID >$@
86 # force full secrets-file build
89 $(MAKE) secrets.eg CONFDIR=.
91 conf.eg: conf.proto ranbits randomize
93 ./randomize conf.proto | egrep -v RCSI >$@
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) ; \
106 $(INSTMAN) $(PUB) $$f $(CMANDIR)/ipsec_$$f || exit 1 ; \
107 ./manlink $(CMANDIR) ipsec_$$f ; \
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
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 ; \
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
138 rm -f *.o $(BINS) $(GENDFILES) $(GENDSCRIPTS) $(LOCALS)