# FreeS/WAN master makefile # Copyright (C) 1998, 1999, 2000 Henry Spencer. # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 2 of the License, or (at your # option) any later version. See . # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. # # RCSID $Id: Makefile,v 1.108 2000/06/16 03:14:53 rgb Exp $ # install pathnames; DESTDIR can be used to supply a prefix to them all # PUBDIR is where the "ipsec" command goes; beware, many things define PATH # settings which are assumed to include it (or at least, to include *some* # copy of the "ipsec" command). PUBDIR=$(DESTDIR)/usr/local/sbin # PRIVDIR is where commands get put, REALPRIVDIR is where they think they # will be run from in the end (currently only used by utils/ipsec) REALPRIVDIR=/usr/local/lib/ipsec PRIVDIR=$(DESTDIR)$(REALPRIVDIR) # where manpages go MANTREE=$(DESTDIR)/usr/local/man # all relevant manpage subdirectories MANPLACES=man3 man5 man8 # where configuration files go CONFDIR=$(DESTDIR)/etc # RCDIR is where boot/shutdown scripts go (first RCDIRS that exists gets it); # REALRCDIR is where they think they will ultimately be (for utils/Makefile) RCDIRS=/etc/rc.d/init.d /etc/rc.d /etc/init.d /sbin/init.d REALRCDIR=$(shell for d in $(RCDIRS) ; \ do if test -d $$d ; \ then echo $$d ; exit 0 ; \ fi ; done ; echo /etc/rc.d/init.d ) RCDIR=$(DESTDIR)$(REALRCDIR) # kernel location, and location of kernel patches in the distribution KERNELSRC=/usr/src/linux DIRIN22=$(KERNELSRC)/net/netlink FILIN23=$(KERNELSRC)/net/khttpd/main.c KERNELREL=$(shell { test -f $(FILIN23) && echo 2.3; } || { test -d $(DIRIN22) && echo 2.2; } ) KCFILE=$(KERNELSRC)/.config VERFILE=$(KERNELSRC)/include/linux/version.h PATCHES=klips/patches$(KERNELREL) # note, some of the patches know the last part of this path KERNELKLIPS=$(KERNELSRC)/net/ipsec # kernel make name: zImage for 2.0.xx, bzImage for 2.2.xx and later, and # different foolishness on the Alpha (what ever happened to standards?) B=$(shell test -d $(DIRIN22) && echo b) KERNEL=$(shell if test " `uname -m`" = " alpha" ; then echo boot ; else echo $(B)zImage ; fi) # install stuff INSTALL=install SHELL=/bin/sh def: @echo "Please read doc/setup.html or INSTALL before running make" @false # everything that's necessary to put Klips into the kernel insert: patches klink klipsdefaults klink: rm -rf $(KERNELKLIPS) mkdir -p $(KERNELKLIPS)/libdes/asm mkdir -p $(KERNELKLIPS)/libfreeswan ln -s `pwd`/klips/net/ipsec/Makefile $(KERNELKLIPS) ln -s `pwd`/klips/net/ipsec/Config.in $(KERNELKLIPS) ln -s `pwd`/klips/net/ipsec/defconfig $(KERNELKLIPS) ln -s `pwd`/klips/net/ipsec/*.[ch] $(KERNELKLIPS) ln -s `pwd`/lib/Makefile.kernel $(KERNELKLIPS)/libfreeswan/Makefile ln -s `pwd`/lib/*.[ch] $(KERNELKLIPS)/libfreeswan ln -s `pwd`/libdes/Makefile $(KERNELKLIPS)/libdes ln -s `pwd`/libdes/*.[ch] $(KERNELKLIPS)/libdes ln -s `pwd`/libdes/asm/*.pl $(KERNELKLIPS)/libdes/asm ln -s `pwd`/libdes/asm/perlasm $(KERNELKLIPS)/libdes/asm PATCHER=utils/patcher patches: rm -f out.kpatch $(MAKE) _patches$(KERNELREL) >out.kpatch # Linux-2.0.x version _patches: @$(PATCHER) -v $(KERNELSRC) Documentation/Configure.help \ 'CONFIG_IPSEC' $(PATCHES)/Documentation.Configure.help # @$(PATCHER) -v $(KERNELSRC) drivers/isdn/isdn_net.c \ # 'IPPROTO_ESP' $(PATCHES)/drivers.isdn.isdn_net.c @$(PATCHER) -v $(KERNELSRC) include/linux/in.h \ 'IPPROTO_ESP' $(PATCHES)/include.linux.in.h @$(PATCHER) -v $(KERNELSRC) net/Config.in \ 'CONFIG_IPSEC' $(PATCHES)/net.Config.in @$(PATCHER) -v $(KERNELSRC) net/Makefile \ 'CONFIG_IPSEC' $(PATCHES)/net.Makefile @$(PATCHER) -v $(KERNELSRC) net/ipv4/af_inet.c \ 'CONFIG_IPSEC' $(PATCHES)/net.ipv4.af_inet.c @$(PATCHER) -v $(KERNELSRC) net/netlink.c \ 'open_map&=~.1<$$KERNELDEFCONFIG.tmp ; \ rm -f $$KERNELDEFCONFIG ; \ cp -a $$KERNELDEFCONFIG.tmp $$KERNELDEFCONFIG ; \ rm -f $$KERNELDEFCONFIG.tmp ; \ fi ; \ if ! egrep -q 'CONFIG_IPSEC' $$KERNELCONFIG ; \ then \ set -x ; \ cp -a $$KERNELCONFIG $$KERNELCONFIG.orig ; \ chmod u+w $$KERNELCONFIG ; \ cat $$KERNELCONFIG $(KERNELKLIPS)/defconfig \ >$$KERNELCONFIG.tmp ; \ rm -f $$KERNELCONFIG ; \ cp -a $$KERNELCONFIG.tmp $$KERNELCONFIG ; \ rm -f $$KERNELCONFIG.tmp ; \ fi # programs programs: cd lib ; $(MAKE) cd pluto ; $(MAKE) cd klips/utils ; $(MAKE) cd utils ; $(MAKE) SETTINGS=BINDIR=$(PRIVDIR) PUBDIR=$(PUBDIR) PRIVDIR=$(PRIVDIR) \ REALPRIVDIR=$(REALPRIVDIR) MANTREE=$(MANTREE) \ DESTDIR=$(DESTDIR) INSTALL="$(INSTALL)" FULLSET=$(SETTINGS) CONFDIR=$(CONFDIR) RCDIR=$(RCDIR) REALRCDIR=$(REALRCDIR) install: mkdir -p $(PRIVDIR) $(PUBDIR) for m in $(MANPLACES) ; do mkdir -p $(MANTREE)/$$m ; done cd lib ; $(MAKE) install $(SETTINGS) cd klips/utils ; $(MAKE) install $(SETTINGS) cd pluto ; $(MAKE) install $(SETTINGS) cd utils ; $(MAKE) install $(FULLSET) clean: cd lib ; $(MAKE) clean # looks after gmp and libdes too cd klips/utils ; $(MAKE) clean cd pluto ; $(MAKE) clean cd utils ; $(MAKE) clean # proxies for major kernel make operations # do-everything entries ogo: precheck insert pcf confcheck programs install kernel oldgo: precheck insert ocf confcheck programs install kernel menugo: precheck insert mcf confcheck programs install kernel xgo: precheck insert xcf confcheck programs install kernel # preliminaries precheck: @if test ! -f $(KCFILE) ; \ then \ echo '*** kernel has never been configured!!' ; \ echo '*** please do that first; the results are necessary.' ; \ exit 1 ; \ fi @if test ! -f $(VERFILE) ; \ then \ echo '*** kernel has never been compiled!!' ; \ echo '*** please do that first; the results are necessary.' ; \ exit 1 ; \ fi # configuring (exit statuses disregarded, something fishy here sometimes) xcf: -cd $(KERNELSRC) ; $(MAKE) xconfig mcf: -cd $(KERNELSRC) ; $(MAKE) menuconfig pcf: -cd $(KERNELSRC) ; $(MAKE) config ocf: -cd $(KERNELSRC) ; $(MAKE) oldconfig confcheck: @if test ! -f $(KCFILE) ; \ then echo '*** no kernel configuration file written!!' ; exit 1 ; \ fi @if ! egrep -q '^CONFIG_IPSEC=[my]' $(KCFILE) ; \ then echo '*** IPSEC not in kernel configuration!!' ; exit 1 ; \ fi @if egrep -q '^CONFIG_IPSEC=m' $(KCFILE) && \ ! egrep -q '^CONFIG_MODULES=y' $(KCFILE) ; \ then echo '*** IPSEC configured as module in kernel with no module support!!' ; exit 1 ; \ fi # kernel building, with error checks kernel: rm -f out.kbuild out.kinstall ( cd $(KERNELSRC) ; $(MAKE) dep clean $(KERNEL) ) 2>&1 | tee out.kbuild @if egrep -q '^CONFIG_MODULES=y' $(KCFILE) ; \ then set -x ; \ ( cd $(KERNELSRC) ; \ $(MAKE) modules 2>&1 ) | tee -a out.kbuild ; \ fi utils/errcheck out.kbuild # kernel install, with error checks kinstall: rm -f out.kinstall ( cd $(KERNELSRC) ; $(MAKE) install ) 2>&1 | tee out.kinstall @if egrep -q '^CONFIG_MODULES=y' $(KCFILE) ; \ then set -x ; \ ( cd $(KERNELSRC) ; \ $(MAKE) modules_install 2>&1 ) | tee -a out.kinstall ; \ fi utils/errcheck out.kinstall # some oddities meant for the developers, probably of no use to users # make developer version of symlinks dlinks: ln -s top/Makefile ../Makefile cd .. ; top/dtrmklinks -d