OSDN Git Service

2013.10.24
[uclinux-h8/uClinux-dist.git] / freeswan / Makefile
1 # FreeS/WAN master makefile
2 # Copyright (C) 1998-2002  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.163.2.5 2002/04/12 04:08:31 mcr Exp $
15
16
17
18 include Makefile.inc
19 include Makefile.ver
20
21
22
23 # kernel details
24 # what variant of our patches should we use, and where is it
25 # don't take KERNELREL too seriously; "2.3" does include 2.4
26 KERNELREL=$(shell { test -f $(FILIN24) && echo 2.3; } || \
27                 { test -d $(DIRIN22) && echo 2.2; } )
28 PATCHES=klips/patches$(KERNELREL)
29 # where KLIPS goes in the kernel
30 # note, some of the patches know the last part of this path
31 KERNELKLIPS=$(KERNELSRC)/net/ipsec
32
33 # directories visited install, programs, check, etc.
34 SUBDIRS=libdes lib pluto klips utils testing
35
36 # declaration for make's benefit
37 .PHONY: def insert klink patches _patches _patches2.2 _patches2.3 \
38         klipsdefaults programs install clean distclean \
39         ogo oldgo menugo xgo \
40         omod oldmod menumod xmod \
41         orpm oldrpm menurpm xrpm rpm\
42         pcf ocf mcf xcf \
43         precheck verset confcheck kernel module kinstall minstall \
44         rpminstall rpmkinstall rpms backup unpatch uinstall_freeswan \
45         snapready relready ready buildready devready uml check
46
47 # dummy default rule
48 def:
49         @echo "Please read doc/intro.html or INSTALL before running make"
50         @false
51
52 # everything that's necessary to put Klips into the kernel
53 insert: patches klink klipsdefaults
54
55 # create KERNELKLIPS and populate it with symlinks to the sources
56 klink:
57         rm -rf $(KERNELKLIPS)
58         mkdir -p $(KERNELKLIPS)/libdes/asm
59         mkdir -p $(KERNELKLIPS)/libfreeswan
60         mkdir -p $(KERNELKLIPS)/zlib
61         $(KLIPSLINK) `pwd`/klips/net/ipsec/Makefile $(KERNELKLIPS)
62         $(KLIPSLINK) `pwd`/Makefile.inc $(KERNELKLIPS)
63         $(KLIPSLINK) `pwd`/Makefile.ver $(KERNELKLIPS)
64         $(KLIPSLINK) `pwd`/klips/net/ipsec/Config.in $(KERNELKLIPS)
65         $(KLIPSLINK) `pwd`/klips/net/ipsec/defconfig $(KERNELKLIPS)
66         $(KLIPSLINK) `pwd`/klips/net/ipsec/*.[ch] $(KERNELKLIPS)
67         mkdir $(KERNELKLIPS)/alg
68         $(KLIPSLINK) `pwd`/klips/net/ipsec/alg/* $(KERNELKLIPS)/alg
69         $(KLIPSLINK) `pwd`/libcrypto $(KERNELKLIPS)/libcrypto
70         $(KLIPSLINK) `pwd`/lib/Makefile.kernel $(KERNELKLIPS)/libfreeswan/Makefile
71         $(KLIPSLINK) `pwd`/lib/*.[ch] $(KERNELKLIPS)/libfreeswan
72         $(KLIPSLINK) `pwd`/libdes/Makefile $(KERNELKLIPS)/libdes
73         $(KLIPSLINK) `pwd`/libdes/*.[ch] $(KERNELKLIPS)/libdes
74         $(KLIPSLINK) `pwd`/libdes/asm/*.pl $(KERNELKLIPS)/libdes/asm
75         $(KLIPSLINK) `pwd`/libdes/asm/perlasm $(KERNELKLIPS)/libdes/asm
76         $(KLIPSLINK) `pwd`/zlib/Makefile $(KERNELKLIPS)/zlib
77         $(KLIPSLINK) `pwd`/zlib/*.[chS] $(KERNELKLIPS)/zlib
78
79 # patch kernel
80 PATCHER=utils/patcher
81 patches:
82         echo "===============" >>out.kpatch
83         echo "`date` `cd $(KERNELSRC) ; pwd`" >>out.kpatch
84         $(MAKE) _patches$(KERNELREL) >>out.kpatch
85
86 # Linux-2.0.x version
87 _patches:
88         @$(PATCHER) -v $(KERNELSRC) Documentation/Configure.help \
89                 'CONFIG_IPSEC' $(PATCHES)/Documentation.Configure.help
90         @$(PATCHER) -v $(KERNELSRC) include/linux/in.h \
91                 'IPPROTO_ESP' $(PATCHES)/include.linux.in.h
92         @$(PATCHER) -v $(KERNELSRC) net/Config.in \
93                 'CONFIG_IPSEC' $(PATCHES)/net.Config.in
94         @$(PATCHER) -v $(KERNELSRC) net/Makefile \
95                 'CONFIG_IPSEC' $(PATCHES)/net.Makefile
96         @$(PATCHER) -v $(KERNELSRC) net/ipv4/af_inet.c \
97                 'CONFIG_IPSEC' $(PATCHES)/net.ipv4.af_inet.c
98         @$(PATCHER) -v $(KERNELSRC) net/netsyms.c \
99                 'ip_fragment' $(PATCHES)/net.netsyms.c
100         @$(PATCHER) -v $(KERNELSRC) include/linux/socket.h \
101                 'PF_KEY' $(PATCHES)/include.linux.socket.h
102 # Removed patches, will unpatch automatically.
103         @$(PATCHER) -v $(KERNELSRC) include/linux/proc_fs.h
104         @$(PATCHER) -v $(KERNELSRC) net/core/dev.c
105         @$(PATCHER) -v $(KERNELSRC) net/ipv4/protocol.c
106         @$(PATCHER) -v $(KERNELSRC) drivers/net/Space.c
107         @$(PATCHER) -v $(KERNELSRC) net/netlink.c
108         @$(PATCHER) -v $(KERNELSRC) drivers/isdn/isdn_net.c
109
110 # Linux-2.2.x version
111 PATCHES24=klips/patches2.3
112 _patches2.2:
113         @$(PATCHER) -v -c $(KERNELSRC) Documentation/Configure.help \
114                 'CONFIG_IPSEC' $(PATCHES)/Doc.Configure.help
115         @$(PATCHER) -v $(KERNELSRC) include/linux/in.h \
116                 'IPPROTO_ESP' $(PATCHES)/include.linux.in.h
117         @$(PATCHER) -v $(KERNELSRC) net/Config.in \
118                 'CONFIG_IPSEC' $(PATCHES24)/net.Config.in
119         @$(PATCHER) -v $(KERNELSRC) net/Makefile \
120                 'CONFIG_IPSEC' $(PATCHES)/net.Makefile
121         @$(PATCHER) -v $(KERNELSRC) net/ipv4/af_inet.c \
122                 'CONFIG_IPSEC' $(PATCHES)/net.ipv4.af_inet.c
123         @$(PATCHER) -v $(KERNELSRC) net/netsyms.c \
124                 'neigh_compat_output' $(PATCHES)/net.netsyms.c.1 \
125                 'inet_addr_type' $(PATCHES)/net.netsyms.c.2
126         @$(PATCHER) -v $(KERNELSRC) net/ipv4/udp.c \
127                 'CONFIG_IPSEC' $(PATCHES)/net.ipv4.udp.c
128         @$(PATCHER) -v $(KERNELSRC) include/net/sock.h \
129                 'CONFIG_IPSEC' $(PATCHES)/include.net.sock.h
130 #       @$(PATCHER) -v $(KERNELSRC) include/linux/socket.h \
131 #               'define.AF_KEY' $(PATCHES)/include.linux.socket.h
132 # Removed patches, will unpatch automatically.
133         @$(PATCHER) -v $(KERNELSRC) include/linux/proc_fs.h
134         @$(PATCHER) -v $(KERNELSRC) net/core/dev.c
135         @$(PATCHER) -v $(KERNELSRC) net/ipv4/protocol.c
136         @$(PATCHER) -v $(KERNELSRC) drivers/net/Space.c
137         @$(PATCHER) -v $(KERNELSRC) include/linux/netlink.h
138         @$(PATCHER) -v $(KERNELSRC) net/netlink/af_netlink.c
139         @$(PATCHER) -v $(KERNELSRC) net/netlink/netlink_dev.c
140         @$(PATCHER) -v $(KERNELSRC) include/linux/socket.h
141         @$(PATCHER) -v $(KERNELSRC) drivers/isdn/isdn_net.c
142
143 # Linux-2.4.0 version
144 PATCHES22=klips/patches2.2
145 _patches2.3:
146         @$(PATCHER) -v -c $(KERNELSRC) Documentation/Configure.help \
147                 'CONFIG_IPSEC' $(PATCHES22)/Doc.Configure.help
148         @$(PATCHER) -v $(KERNELSRC) net/Config.in \
149                 'CONFIG_IPSEC' $(PATCHES)/net.Config.in
150         @$(PATCHER) -v $(KERNELSRC) net/Makefile \
151                 'CONFIG_IPSEC' $(PATCHES)/net.Makefile
152         @$(PATCHER) -v $(KERNELSRC) net/ipv4/af_inet.c \
153                 'CONFIG_IPSEC' $(PATCHES)/net.ipv4.af_inet.c
154         @$(PATCHER) -v $(KERNELSRC) net/ipv4/udp.c \
155                 'CONFIG_IPSEC' $(PATCHES)/net.ipv4.udp.c
156         @$(PATCHER) -v $(KERNELSRC) include/net/sock.h \
157                 'CONFIG_IPSEC' $(PATCHES)/include.net.sock.h
158 # Removed patches, will unpatch automatically.
159         @$(PATCHER) -v $(KERNELSRC) include/linux/proc_fs.h
160         @$(PATCHER) -v $(KERNELSRC) net/core/dev.c
161         @$(PATCHER) -v $(KERNELSRC) net/ipv4/protocol.c
162         @$(PATCHER) -v $(KERNELSRC) drivers/net/Space.c
163         @$(PATCHER) -v $(KERNELSRC) include/linux/netlink.h
164         @$(PATCHER) -v $(KERNELSRC) net/netlink/af_netlink.c
165         @$(PATCHER) -v $(KERNELSRC) net/netlink/netlink_dev.c
166         @$(PATCHER) -v $(KERNELSRC) drivers/isdn/isdn_net.c
167
168 # supply kernel-configuration defaults
169 ifeq ($(ARCH),)
170 ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/)
171 endif
172 klipsdefaults:
173         @KERNELDEFCONFIG=$(KERNELSRC)/arch/$(ARCH)/defconfig ; \
174         KERNELCONFIG=$(KCFILE) ; \
175         if ! egrep -q 'CONFIG_IPSEC' $$KERNELDEFCONFIG ; \
176         then \
177                 set -x ; \
178                 cp -a $$KERNELDEFCONFIG $$KERNELDEFCONFIG.orig ; \
179                 chmod u+w $$KERNELDEFCONFIG ; \
180                 cat $$KERNELDEFCONFIG $(KERNELKLIPS)/defconfig \
181                         >$$KERNELDEFCONFIG.tmp ; \
182                 rm -f $$KERNELDEFCONFIG ; \
183                 cp -a $$KERNELDEFCONFIG.tmp $$KERNELDEFCONFIG ; \
184                 rm -f $$KERNELDEFCONFIG.tmp ; \
185         fi ; \
186         if ! egrep -q 'CONFIG_IPSEC' $$KERNELCONFIG ; \
187         then \
188                 set -x ; \
189                 cp -a $$KERNELCONFIG $$KERNELCONFIG.orig ; \
190                 chmod u+w $$KERNELCONFIG ; \
191                 cat $$KERNELCONFIG $(KERNELKLIPS)/defconfig \
192                         >$$KERNELCONFIG.tmp ; \
193                 rm -f $$KERNELCONFIG ; \
194                 cp -a $$KERNELCONFIG.tmp $$KERNELCONFIG ; \
195                 rm -f $$KERNELCONFIG.tmp ; \
196         fi
197
198
199
200 # programs
201
202 programs:
203         @for d in $(SUBDIRS); do (cd $$d && $(MAKE) DESTDIR=${DESTDIR} programs); done
204
205 install:
206         mkdir -p $(PRIVDIR) $(PUBDIR)
207         mkdir -p -m 755 $(CONFDIR)/ipsec.d
208         mkdir -p -m 755 $(CONFDIR)/ipsec.d/cacerts
209         mkdir -p -m 755 $(CONFDIR)/ipsec.d/crls
210         mkdir -p -m 700 $(CONFDIR)/ipsec.d/private
211         for m in $(MANPLACES) ; do mkdir -p $(MANTREE)/$$m || exit 1 ; done
212         @for d in $(SUBDIRS); do (cd $$d && $(MAKE) DESTDIR=${DESTDIR} install); done
213
214 clean:
215         @for d in $(SUBDIRS); do (cd $$d && $(MAKE) DESTDIR=${DESTDIR} clean); done
216         rm -rf $(RPMTMPDIR) $(RPMDEST)
217         rm -f out.*build out.*install   # but leave out.kpatch
218         rm -f rpm.spec
219
220 distclean:      clean
221         rm -f out.kpatch
222
223
224
225 # proxies for major kernel make operations
226
227 # do-everything entries
228 PRE=precheck verset insert
229 POST=confcheck programs install kernel
230 MPOST=confcheck programs install module
231 RPOST=confcheck programs rpminstall module rpmkinstall rpms
232 ogo:    $(PRE) pcf $(POST)
233 oldgo:  $(PRE) ocf $(POST)
234 menugo: $(PRE) mcf $(POST)
235 xgo:    $(PRE) xcf $(POST)
236 omod:   $(PRE) pcf $(MPOST)
237 oldmod: $(PRE) ocf $(MPOST)
238 menumod:        $(PRE) mcf $(MPOST)
239 xmod:   $(PRE) xcf $(MPOST) 
240 orpm:   $(PRE) pcf $(RPOST) 
241 modrpm: $(PRE) ocf confcheck module rpmkmodinstall 
242 oldrpm: $(PRE) ocf $(RPOST) 
243 menurpm:        $(PRE) mcf $(RPOST) 
244 xrpm:   $(PRE) xcf $(RPOST) 
245
246 # preliminaries
247 precheck:
248         @if test ! -d $(KERNELSRC) -a ! -L $(KERNELSRC) ; \
249         then \
250                 echo '*** cannot find directory "$(KERNELSRC)"!!' ; \
251                 echo '*** may be necessary to add symlink to kernel source' ; \
252                 exit 1 ; \
253         fi
254         @if ! cd $(KERNELSRC) ; \
255         then \
256                 echo '*** cannot "cd $(KERNELSRC)"!!' ; \
257                 echo '*** may be necessary to add symlink to kernel source' ; \
258                 exit 1 ; \
259         fi
260         @if test ! -f $(KCFILE) ; \
261         then \
262                 echo '*** cannot find "$(KCFILE)"!!' ; \
263                 echo '*** perhaps kernel has never been configured?' ; \
264                 echo '*** please do that first; the results are necessary.' ; \
265                 exit 1 ; \
266         fi
267         @if test ! -f $(VERFILE) ; \
268         then \
269                 echo '*** cannot find "$(VERFILE)"!!' ; \
270                 echo '*** perhaps kernel has never been compiled?' ; \
271                 echo '*** please do that first; the results are necessary.' ; \
272                 exit 1 ; \
273         fi
274
275 # set version code if this is a fresh CVS checkout
276 verset: 
277         if test -f cvs.datemark ; \
278         then \
279                 sed "/^IPSECVERSION=xxx/s/xxx/` \
280                         date -r cvs.datemark +cvs%Y%b%d_%H:%M:%S \
281                 `/" Makefile.ver >Makefile.ver$$$$ && \
282                 mv Makefile.ver$$$$ Makefile.ver ; \
283                 rm -f cvs.datemark ; \
284         fi
285
286 # configuring (exit statuses disregarded, something fishy here sometimes)
287 xcf:
288         -cd $(KERNELSRC) ; $(MAKE) $(KERNMAKEOPTS) xconfig
289 mcf:
290         -cd $(KERNELSRC) ; $(MAKE) $(KERNMAKEOPTS) menuconfig
291 pcf:
292         -cd $(KERNELSRC) ; $(MAKE) $(KERNMAKEOPTS) config
293
294 ocf:
295         -cd $(KERNELSRC) ; $(MAKE) $(KERNMAKEOPTS) oldconfig dep </dev/null >/dev/null
296
297 rpm:
298         mkdir -p ${RPMKERNDIR}
299         rm -rf $(RPMTMPDIR)
300         if [ ! -d ${RH_KERNELSRC}/configs ]; then echo "Please fix RH_KERNELSRC in Makefile.inc"; exit 1; fi
301         cd ${RPMKERNDIR} && lndir ${RH_KERNELSRC} .
302         # this is a fixup for problems with having include/asm exist, and
303         # being unable to replace it during the build
304         rm -f ${RPMKERNDIR}/include/asm
305         for cfg in ${RPMKERNDIR}/configs/*.config; \
306         do \
307                 cfgshort=`basename $$cfg .config | sed -e 's/kernel-[^-]*-\(.*\)/\1/'`; \
308                 cp $$cfg ${RPMKERNDIR}/.config; \
309                 echo ============= Building for config file $$cfgshort =========== ; \
310                 make KERNELSRC=${RPMKERNDIR} KERNMAKEOPTS="EXTRAVERSION=-$$cfgshort" CFGSHORT=$$cfgshort modclean ocf; \
311                 make KERNELSRC=${RPMKERNDIR} KERNMAKEOPTS="EXTRAVERSION=-$$cfgshort" CFGSHORT=$$cfgshort modrpm || exit 1; \
312         done; 
313         make KERNELSRC=${RPMKERNDIR} programs 
314         make KERNELSRC=${RPMKERNDIR} rpminstall 
315         make KERNELSRC=${RPMKERNDIR} rpms
316
317 confcheck:
318         @if test ! -f $(KCFILE) ; \
319         then echo '*** no kernel configuration file written!!' ; exit 1 ; \
320         fi
321         @if ! egrep -q '^CONFIG_IPSEC=[my]' $(KCFILE) ; \
322         then echo '*** IPsec not in kernel config ($(KCFILE))!!' ; exit 1 ; \
323         fi
324         @if ! egrep -q 'CONFIG_IPSEC[   ]+1' $(ACFILE) && \
325                 ! egrep -q 'CONFIG_IPSEC_MODULE[        ]+1' $(ACFILE) ; \
326         then echo '*** IPsec in kernel config ($(KCFILE)),' ; \
327                 echo '***       but not in config header file ($(ACFILE))!!' ; \
328                 exit 1 ; \
329         fi
330         @if egrep -q '^CONFIG_IPSEC=m' $(KCFILE) && \
331                 ! egrep -q '^CONFIG_MODULES=y' $(KCFILE) ; \
332         then echo '*** IPsec configured as module in kernel with no module support!!' ; exit 1 ; \
333         fi
334         @if ! egrep -q 'CONFIG_IPSEC_AH[        ]+1' $(ACFILE) && \
335                 ! egrep -q 'CONFIG_IPSEC_ESP[   ]+1' $(ACFILE) ; \
336         then echo '*** IPsec configuration must include AH or ESP!!' ; exit 1 ; \
337         fi
338
339 # kernel building, with error checks
340 kernel:
341         rm -f out.kbuild out.kinstall
342         ( cd $(KERNELSRC) ; $(MAKE) $(KERNMAKEOPTS) $(KERNDEP) $(KERNCLEAN) $(KERNEL) ) 2>&1 | tee out.kbuild
343         @if egrep -q '^CONFIG_MODULES=y' $(KCFILE) ; \
344         then set -x ; \
345                 ( cd $(KERNELSRC) ; \
346                 $(MAKE) $(KERNMAKEOPTS) modules 2>&1 ) | tee -a out.kbuild ; \
347         fi
348         utils/errcheck out.kbuild
349
350 # module-only building, with error checks
351 module:
352         rm -f out.kbuild out.kinstall
353         egrep -q '^CONFIG_MODULES=y' $(KCFILE)
354         egrep -q '^CONFIG_IPSEC=m' $(KCFILE)
355         ( cd $(KERNELSRC) ; \
356                 $(MAKE) $(KERNMAKEOPTS) SUBDIRS=net/ipsec modules 2>&1 ) | tee out.kbuild
357         utils/errcheck out.kbuild
358
359 modclean:
360         cd $(KERNELSRC) ; $(MAKE) $(KERNMAKEOPTS) SUBDIRS=net/ipsec clean 
361
362 # kernel install, with error checks
363 kinstall:
364         rm -f out.kinstall
365         ( cd $(KERNELSRC) ; $(MAKE) $(KERNMAKEOPTS) install ) 2>&1 | tee out.kinstall
366         @if egrep -q '^CONFIG_MODULES=y' $(KCFILE) ; \
367         then set -x ; \
368                 ( cd $(KERNELSRC) ; \
369                 $(MAKE) $(KERNMAKEOPTS) modules_install 2>&1 ) | tee -a out.kinstall ; \
370         fi
371         utils/errcheck out.kinstall
372
373 # module-only install, with error checks
374 minstall:
375         rm -f out.kinstall
376         egrep -q '^CONFIG_MODULES=y' $(KCFILE)
377         egrep -q '^CONFIG_IPSEC=m' $(KCFILE)
378         ( cd $(KERNELSRC) ; \
379                 $(MAKE) $(KERNMAKEOPTS) SUBDIRS=net/ipsec modules_install 2>&1 ) | tee out.kinstall
380         utils/errcheck out.kinstall
381
382 # RPM-build userland install in temporary directory
383 rpminstall:
384         mkdir -p $(RPMTMPDIR)
385         $(MAKE) install DESTDIR=$(RPMTMPDIR)
386
387 # RPM-build kinstall in temporary directory
388 # Some of this is not really right for non-x86 systems, but alas, there's no
389 # override like INSTALL_MOD_PATH for kernel itself, so must do it by hand.
390 RPMBOOT=$(RPMTMPDIR)/boot
391 rpmkinstall:
392         mkdir -p $(RPMBOOT)
393         ( KV=`utils/kernelversion $(KERNELSRC)/Makefile` ; \
394                 cd $(KERNELSRC) ; \
395                 if egrep -q '^CONFIG_MODULES=y' $(KCFILE) ; \
396                 then $(MAKE) $(KERNMAKEOPTS) INSTALL_MOD_PATH=$(RPMTMPDIR) \
397                         SUBDIRS=net/ipsec modules_install ; \
398                 else \
399                   cp arch/$(ARCH)/boot/$(KERNEL) $(RPMBOOT)/vmlinuz-$$KV ; \
400                   cp System.map $(RPMBOOT)/System.map-$$KV ; \
401                 fi; \
402         ) 2>&1 | tee out.rpmkinstall
403         utils/errcheck out.rpmkinstall
404
405 rpmkmodinstall:
406         mkdir -p $(RPMBOOT)
407         ( KV=`utils/kernelversion $(KERNELSRC)/Makefile` ; \
408                 cd $(KERNELSRC) ; \
409                 mkdir -p ${RPMTMPDIR}/lib/modules/ipsec; \
410                 cp net/ipsec/ipsec.o ${RPMTMPDIR}/lib/modules/ipsec/ipsec.o-${CFGSHORT}; \
411                 goo="`nm -g net/ipsec/ipsec.o | sed -n '/ netif_rx_R/s/.*_R//p'`"; \
412                 cp net/ipsec/ipsec.o ${RPMTMPDIR}/lib/modules/ipsec/$$goo; \
413         ) 2>&1 | tee out.rpmkinstall
414         utils/errcheck out.rpmkinstall
415
416 # build RPMs
417 rpms:   rpm.spec $(RPMTMPDIR)
418         rm -rf $(RPMDEST)
419         mkdir $(RPMDEST)
420         cd $(RPMDEST) ; mkdir SRPMS BUILD RPMS SPECS SOURCES
421         cd $(RPMDEST)/RPMS ; mkdir $(ARCH) noarch
422         rpm -bb --define "buildroot $(RPMTMPDIR)" \
423                 --define "_topdir $(RPMDEST)" rpm.spec
424         # that has, incidentally, gotten rid of $(RPMTMPDIR)
425
426 # build spec file for building RPMs
427 rpm.spec:       rpm.in $(KERNELSRC)/Makefile $(KCFILE)
428         KV=`utils/kernelversion $(KERNELSRC)/Makefile | sed -e 's/-/_/'` ; \
429         if egrep -q '^CONFIG_MODULES=y' $(KCFILE) ; \
430         then KMO='/^@km */s///' ; \
431         else KMO='/^@km */d' ; \
432         fi ; \
433         if egrep -q '^CONFIG_IPSEC=m' $(KCFILE) ; \
434         then FMO='/^@fm */s///' ; \
435         else FMO='/^@fm */d' ; \
436         fi ; \
437         sed -e "/@KERNELVERSION@/s;;$$KV;" \
438                 -e '/@IPSECVERSION@/s;;$(IPSECVERSION);' \
439                 -e "$$KMO" \
440                 -e "$$FMO" \
441                 -e '/@PUBDIR@/s;;$(PUBDIR);' \
442                 -e '/@FINALBINDIR@/s;;$(FINALBINDIR);' \
443                 -e '/@MANTREE@/s;;$(MANTREE);' rpm.in >$@
444
445 # backup of (almost) everything an install touches
446 TARNAME=$(shell date | awk '{print "backup-" $$6 "-" $$2 "-" $$3 ".tar.gz"}')
447 THEM=$(PUBDIR)/ipsec $(PRIVDIR)/* $(MANTREE)/*/ipsec* \
448         $(CONFDIR)/ipsec.conf $(CONFDIR)/ipsec.secrets \
449         $(RCDIR)/ipsec $(KCFILE) \
450         $(KERNELSRC)/arch/$(ARCH)/defconfig \
451         $(RCDIR)/../rc[0-6].d/[KS]??ipsec
452 backup:
453         tar -cz --ignore-failed-read -f $(TARNAME) $(THEM)
454         chmod -w $(TARNAME)
455
456 # take all the patches out of the kernel
457 # (Note, a couple of files are modified by non-patch means; they are
458 # included in "make backup".)
459 unpatch:
460         for f in `find $(KERNELSRC)/. -name '*.preipsec' -print` ; \
461         do \
462                 echo "restoring $$f:" ; \
463                 dir=`dirname $$f` ; \
464                 core=`basename $$f .preipsec` ; \
465                 cd $$dir ; \
466                 mv -f $$core.preipsec $$core ; \
467                 rm -f $$core.wipsec $$core.ipsecmd5 ; \
468         done
469
470 # uninstall, as much as possible
471 uninstall_freeswan:
472         rm -f $(RCDIR)/ipsec $(PUBDIR)/ipsec
473         mv $(CONFDIR)/ipsec.* /tmp
474         rm -rf $(BINDIR)
475         rm -f $(MANTREE)/man?/ipsec[._]*
476         : kernel must be uninstalled manually
477
478
479
480 # some oddities meant for the developers, probably of no use to users
481
482 # make tags and TAGS files from ctags and etags for vi and emacs, respectively.
483 tags TAGS: dummy
484         etags `find lib pluto klips/utils klips/net/ipsec -name '*.[ch]'`
485         ctags `find lib pluto klips/utils klips/net/ipsec -name '*.[ch]'`
486
487 dummy:
488
489 # things in top to be linked up for developers
490 LINKUP=BUGS CHANGES COPYING CREDITS INSTALL Makefile Makefile.inc \
491         Makefile.ver README
492
493 # at the moment there is no difference between snapshot and release build
494 snapready:      buildready
495 relready:       buildready
496 ready:          devready
497
498 # set up for build
499 buildready:
500         rm -f dtrmakefile cvs.datemark
501         cd doc ; $(MAKE) -s
502
503 # set up for developer use
504 devready:       verset
505         cd .. ; for f in $(LINKUP) ; do ln -sfn top/$$f || exit 1 ; done
506
507 uml:    programs
508         @echo XXX do some checks to see if all the manual pieces are done.
509         -chmod +x testing/utils/make-uml.sh
510         testing/utils/make-uml.sh `pwd`
511
512 check:  uml 
513         @for d in $(SUBDIRS); do (cd $$d && $(MAKE) DESTDIR=${DESTDIR} checkprograms); done
514         @for d in $(SUBDIRS); \
515         do \
516                 echo ===================================; \
517                 echo Now making check in $$d; \
518                 echo ===================================; \
519                 (cd $$d && $(MAKE) DESTDIR=${DESTDIR} check);\
520         done
521