- import of strongswan-2.7.0
[strongswan.git] / 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.4 2004/11/14 21:50:59 as Exp $
15
16
17 FREESWANSRCDIR=$(shell pwd)
18 export FREESWANSRCDIR
19
20 include Makefile.inc
21
22
23
24 PATCHES=linux
25 # where KLIPS goes in the kernel
26 # note, some of the patches know the last part of this path
27 KERNELKLIPS=$(KERNELSRC)/net/ipsec
28 KERNELCRYPTODES=$(KERNELSRC)/crypto/ciphers/des
29 KERNELLIBFREESWAN=$(KERNELSRC)/lib/libfreeswan
30 KERNELLIBZLIB=$(KERNELSRC)/lib/zlib
31 KERNELLIBCRYPTO=$(KERNELSRC)/lib/libcrypto
32 KERNELINCLUDE=$(KERNELSRC)/include
33 KERNELALG=$(KERNELKLIPS)/alg
34
35 MAKEUTILS=packaging/utils
36 ERRCHECK=${MAKEUTILS}/errcheck
37 KVUTIL=${MAKEUTILS}/kernelversion
38 KVSHORTUTIL=${MAKEUTILS}/kernelversion-short
39
40 # kernel details
41 # what variant of our patches should we use, and where is it
42 KERNELREL=$(shell ${KVSHORTUTIL} ${KERNELSRC}/Makefile)
43
44 # directories visited by all recursion
45 SUBDIRS=doc lib programs linux
46
47 # declaration for make's benefit
48 .PHONY: def insert kpatch klink klibcryptolink patches _patches _patches2.2 _patches2.4 \
49 klipsdefaults programs install clean distclean \
50 ogo oldgo menugo xgo \
51 omod oldmod menumod xmod \
52 pcf ocf mcf xcf rcf nopromptgo \
53 precheck verset confcheck kernel module kinstall minstall \
54 backup unpatch uinstall install_file_list \
55 snapready relready ready buildready devready uml check taroldinstall \
56 umluserland
57
58
59 # dummy default rule
60 def:
61 @echo "Please read doc/intro.html or INSTALL before running make"
62 @false
63
64 # everything that's necessary to put Klips into the kernel
65 insert: patches klink klipsdefaults
66
67 kpatch: unapplypatch applypatch klipsdefaults
68
69 unapplypatch:
70 -if [ -f ${KERNELSRC}/freeswan.patch ]; then \
71 echo Undoing previous patches; \
72 cat ${KERNELSRC}/freeswan.patch | (cd ${KERNELSRC} && patch -p1 -R --force -E -z .preipsec --reverse --ignore-whitespace ); \
73 fi
74
75 applypatch:
76 echo Now performing forward patches;
77 make kernelpatch${KERNELREL} | tee ${KERNELSRC}/freeswan.patch | (cd ${KERNELSRC} && patch -p1 -b -z .preipsec --forward --ignore-whitespace )
78
79 kdiff:
80 echo Comparing ${KERNELSRC} to ${FREESWANSRCDIR}/linux.
81 packaging/utils/kerneldiff ${KERNELSRC}
82
83 # create KERNELKLIPS and populate it with symlinks to the sources
84 klink:
85 -[ -L $(KERNELKLIPS)/ipsec_init.c ] && rm -rf ${KERNELKLIPS}
86 -[ -L $(KERNELCRYPTODES)/cbc_enc.c ] && rm -rf ${KERNELCRYPTODES}
87 -[ -L $(KERNELLIBFREESWAN)/subnettoa.c ] && rm -rf ${KERNELLIBFREESWAN}
88 -[ -L ${KERNELLIBZLIB}/deflate.c ] && rm -rf ${KERNELLIBZLIB}
89 -[ -L ${KERNELINCLUDE}/freeswan.h ] && for i in linux/include/*; do rm -f ${KERNELINCLUDE}/$$i; done
90 -[ -L $(KERNELALG)/Makefile ] && rm -rf $(KERNELALG)
91 -[ -L $(KERNELLIBCRYPTO) ] && rm -f $(KERNELLIBCRYPTO)
92 mkdir -p $(KERNELKLIPS)
93 mkdir -p $(KERNELCRYPTODES)
94 mkdir -p $(KERNELLIBFREESWAN)
95 mkdir -p $(KERNELLIBZLIB)
96 mkdir -p $(KERNELALG)
97 $(KLIPSLINK) `pwd`/Makefile.ver $(KERNELKLIPS)
98 $(KLIPSLINK) `pwd`/linux/include/* $(KERNELINCLUDE)
99 $(KLIPSLINK) `pwd`/linux/net/ipsec/Makefile* $(KERNELKLIPS)
100 $(KLIPSLINK) `pwd`/linux/net/ipsec/Config.in $(KERNELKLIPS)
101 $(KLIPSLINK) `pwd`/linux/net/ipsec/defconfig $(KERNELKLIPS)
102 $(KLIPSLINK) `pwd`/linux/net/ipsec/*.[ch] $(KERNELKLIPS)
103 $(KLIPSLINK) `pwd`/linux/net/ipsec/alg/Makefile* $(KERNELALG)
104 $(KLIPSLINK) `pwd`/linux/net/ipsec/alg/Config.* $(KERNELALG)
105 $(KLIPSLINK) `pwd`/linux/net/ipsec/alg/ipsec_alg*.[ch] $(KERNELALG)
106 $(KLIPSLINK) `pwd`/linux/net/ipsec/alg/scripts $(KERNELALG)
107 # Each ALGo does it own symlinks
108 $(KLIPSLINK) `pwd`/lib/libcrypto $(KERNELLIBCRYPTO)
109 $(KLIPSLINK) `pwd`/linux/lib/zlib/*.[ch] $(KERNELLIBZLIB)
110 $(KLIPSLINK) `pwd`/linux/lib/zlib/Makefile* $(KERNELLIBZLIB)
111 $(KLIPSLINK) `pwd`/linux/lib/libfreeswan/*.[ch] $(KERNELLIBFREESWAN)
112 $(KLIPSLINK) `pwd`/linux/lib/libfreeswan/Makefile* $(KERNELLIBFREESWAN)
113 $(KLIPSLINK) `pwd`/linux/crypto/ciphers/des/*.[chsS] $(KERNELCRYPTODES)
114 $(KLIPSLINK) `pwd`/linux/crypto/ciphers/des/Makefile* $(KERNELCRYPTODES)
115 sed '/"/s/xxx/$(IPSECVERSION)/' linux/lib/libfreeswan/version.in.c >$(KERNELKLIPS)/version.c
116
117 # create libcrypto symlink
118 klibcryptolink:
119 -[ -L $(KERNELLIBCRYPTO) ] && rm -f $(KERNELLIBCRYPTO)
120 $(KLIPSLINK) `pwd`/lib/libcrypto $(KERNELLIBCRYPTO)
121
122 # patch kernel
123 PATCHER=packaging/utils/patcher
124
125 patches:
126 @echo \"make patches\" is obsolete. See \"make kpatch\".
127 exit 1
128
129 _patches:
130 echo "===============" >>out.kpatch
131 echo "`date` `cd $(KERNELSRC) ; pwd`" >>out.kpatch
132 $(MAKE) __patches$(KERNELREL) >>out.kpatch
133
134 # Linux-2.0.x version
135 __patches __patches2.0:
136 @$(PATCHER) -v $(KERNELSRC) Documentation/Configure.help \
137 'CONFIG_IPSEC' $(PATCHES)/Documentation/Configure.help.fs2_0.patch
138 @$(PATCHER) -v $(KERNELSRC) net/Config.in \
139 'CONFIG_IPSEC' $(PATCHES)/net/Config.in.fs2_0.patch
140 @$(PATCHER) -v $(KERNELSRC) net/Makefile \
141 'CONFIG_IPSEC' $(PATCHES)/net/Makefile.fs2_0.patch
142 @$(PATCHER) -v $(KERNELSRC) net/ipv4/af_inet.c \
143 'CONFIG_IPSEC' $(PATCHES)/net/ipv4/af_inet.c.fs2_0.patch
144 # Removed patches, will unpatch automatically.
145 @$(PATCHER) -v $(KERNELSRC) include/linux/proc_fs.h
146 @$(PATCHER) -v $(KERNELSRC) net/core/dev.c
147 @$(PATCHER) -v $(KERNELSRC) net/ipv4/protocol.c
148 @$(PATCHER) -v $(KERNELSRC) drivers/net/Space.c
149 @$(PATCHER) -v $(KERNELSRC) net/netlink.c
150 @$(PATCHER) -v $(KERNELSRC) drivers/isdn/isdn_net.c
151
152 # Linux-2.2.x version
153 PATCHES24=klips/patches2.3
154 __patches2.2:
155 @$(PATCHER) -v -c $(KERNELSRC) Documentation/Configure.help \
156 'CONFIG_IPSEC' $(PATCHES)/Documentation/Configure.help.fs2_2.patch
157 @$(PATCHER) -v $(KERNELSRC) net/Config.in \
158 'CONFIG_IPSEC' $(PATCHES)/net/Config.in.fs2_2.patch
159 @$(PATCHER) -v $(KERNELSRC) net/Makefile \
160 'CONFIG_IPSEC' $(PATCHES)/net/Makefile.fs2_2.patch
161 @$(PATCHER) -v $(KERNELSRC) net/ipv4/af_inet.c \
162 'CONFIG_IPSEC' $(PATCHES)/net/ipv4/af_inet.c.fs2_2.patch
163 @$(PATCHER) -v $(KERNELSRC) net/ipv4/udp.c \
164 'CONFIG_IPSEC' $(PATCHES)/net/ipv4/udp.c.fs2_2.patch
165 @$(PATCHER) -v $(KERNELSRC) include/net/sock.h \
166 'CONFIG_IPSEC' $(PATCHES)/net/include.net.sock.h.fs2_2.patch
167 # Removed patches, will unpatch automatically.
168 @$(PATCHER) -v $(KERNELSRC) include/linux/proc_fs.h
169 @$(PATCHER) -v $(KERNELSRC) net/core/dev.c
170 @$(PATCHER) -v $(KERNELSRC) net/ipv4/protocol.c
171 @$(PATCHER) -v $(KERNELSRC) drivers/net/Space.c
172 @$(PATCHER) -v $(KERNELSRC) include/linux/netlink.h
173 @$(PATCHER) -v $(KERNELSRC) net/netlink/af_netlink.c
174 @$(PATCHER) -v $(KERNELSRC) net/netlink/netlink_dev.c
175 @$(PATCHER) -v $(KERNELSRC) include/linux/socket.h
176 @$(PATCHER) -v $(KERNELSRC) drivers/isdn/isdn_net.c
177
178 # Linux-2.4.0 version
179 PATCHES22=klips/patches2.2
180 __patches2.3 __patches2.4:
181 @$(PATCHER) -v -c $(KERNELSRC) Documentation/Configure.help \
182 'CONFIG_IPSEC' $(PATCHES)/Documentation/Configure.help.fs2_2.patch
183 @$(PATCHER) -v $(KERNELSRC) net/Config.in \
184 'CONFIG_IPSEC' $(PATCHES)/net/Config.in.fs2_4.patch
185 @$(PATCHER) -v $(KERNELSRC) net/Makefile \
186 'CONFIG_IPSEC' $(PATCHES)/net/Makefile.fs2_4.patch
187 @$(PATCHER) -v $(KERNELSRC) net/ipv4/af_inet.c \
188 'CONFIG_IPSEC' $(PATCHES)/net/ipv4/af_inet.c.fs2_4.patch
189 @$(PATCHER) -v $(KERNELSRC) net/ipv4/udp.c \
190 'CONFIG_IPSEC' $(PATCHES)/net/ipv4/udp.c.fs2_4.patch
191 @$(PATCHER) -v $(KERNELSRC) include/net/sock.h \
192 'CONFIG_IPSEC' $(PATCHES)/net/include.net.sock.h.fs2_4.patch
193 # Removed patches, will unpatch automatically.
194 @$(PATCHER) -v $(KERNELSRC) include/linux/proc_fs.h
195 @$(PATCHER) -v $(KERNELSRC) net/core/dev.c
196 @$(PATCHER) -v $(KERNELSRC) net/ipv4/protocol.c
197 @$(PATCHER) -v $(KERNELSRC) drivers/net/Space.c
198 @$(PATCHER) -v $(KERNELSRC) include/linux/netlink.h
199 @$(PATCHER) -v $(KERNELSRC) net/netlink/af_netlink.c
200 @$(PATCHER) -v $(KERNELSRC) net/netlink/netlink_dev.c
201 @$(PATCHER) -v $(KERNELSRC) drivers/isdn/isdn_net.c
202
203 klipsdefaults:
204 @KERNELDEFCONFIG=$(KERNELSRC)/arch/$(ARCH)/defconfig ; \
205 KERNELCONFIG=$(KCFILE) ; \
206 if ! egrep -q 'CONFIG_IPSEC' $$KERNELDEFCONFIG ; \
207 then \
208 set -x ; \
209 cp -a $$KERNELDEFCONFIG $$KERNELDEFCONFIG.orig ; \
210 chmod u+w $$KERNELDEFCONFIG ; \
211 cat $$KERNELDEFCONFIG $(KERNELKLIPS)/defconfig \
212 >$$KERNELDEFCONFIG.tmp ; \
213 rm -f $$KERNELDEFCONFIG ; \
214 cp -a $$KERNELDEFCONFIG.tmp $$KERNELDEFCONFIG ; \
215 rm -f $$KERNELDEFCONFIG.tmp ; \
216 fi ; \
217 if ! egrep -q 'CONFIG_IPSEC' $$KERNELCONFIG ; \
218 then \
219 set -x ; \
220 cp -a $$KERNELCONFIG $$KERNELCONFIG.orig ; \
221 chmod u+w $$KERNELCONFIG ; \
222 cat $$KERNELCONFIG $(KERNELKLIPS)/defconfig \
223 >$$KERNELCONFIG.tmp ; \
224 rm -f $$KERNELCONFIG ; \
225 cp -a $$KERNELCONFIG.tmp $$KERNELCONFIG ; \
226 rm -f $$KERNELCONFIG.tmp ; \
227 fi
228
229
230
231 # programs
232
233 checkv199install:
234 if [ -f ${LIBDIR}/pluto ]; \
235 then \
236 echo WARNING: FreeS/WAN 1.99 still installed. ;\
237 echo WARNING: moving ${LIBDIR} to ${LIBDIR}.v1 ;\
238 mv ${LIBDIR} ${LIBDIR}.v1 ;\
239 fi
240
241 install:: checkv199install
242
243 programs install clean checkprograms::
244 @for d in $(SUBDIRS) ; \
245 do \
246 (cd $$d && $(MAKE) FREESWANSRCDIR=.. $@ ) || exit 1; \
247 done; \
248
249 clean::
250 rm -rf $(RPMTMPDIR) $(RPMDEST)
251 rm -f out.*build out.*install # but leave out.kpatch
252 rm -f rpm.spec
253
254 distclean: clean
255 rm -f out.kpatch
256 if [ -f umlsetup.sh ]; then source umlsetup.sh; if [ -d "$$POOLSPACE" ]; then rm -rf $$POOLSPACE; fi; fi
257
258
259
260 # proxies for major kernel make operations
261
262 # do-everything entries
263 KINSERT_PRE=precheck verset insert
264 PRE=precheck verset kpatch klibcryptolink
265 POST=confcheck programs kernel install
266 MPOST=confcheck programs module install
267 ogo: $(PRE) pcf $(POST)
268 oldgo: $(PRE) ocf $(POST)
269 nopromptgo: $(PRE) rcf $(POST)
270 menugo: $(PRE) mcf $(POST)
271 xgo: $(PRE) xcf $(POST)
272 omod: $(PRE) pcf $(MPOST)
273 oldmod: $(PRE) ocf $(MPOST)
274 menumod: $(PRE) mcf $(MPOST)
275 xmod: $(PRE) xcf $(MPOST)
276
277 # preliminaries
278 precheck:
279 @if test ! -d $(KERNELSRC) -a ! -L $(KERNELSRC) ; \
280 then \
281 echo '*** cannot find directory "$(KERNELSRC)"!!' ; \
282 echo '*** may be necessary to add symlink to kernel source' ; \
283 exit 1 ; \
284 fi
285 @if ! cd $(KERNELSRC) ; \
286 then \
287 echo '*** cannot "cd $(KERNELSRC)"!!' ; \
288 echo '*** may be necessary to add symlink to kernel source' ; \
289 exit 1 ; \
290 fi
291 @if test ! -f $(KCFILE) ; \
292 then \
293 echo '*** cannot find "$(KCFILE)"!!' ; \
294 echo '*** perhaps kernel has never been configured?' ; \
295 echo '*** please do that first; the results are necessary.' ; \
296 exit 1 ; \
297 fi
298 @if test ! -f $(VERFILE) ; \
299 then \
300 echo '*** cannot find "$(VERFILE)"!!' ; \
301 echo '*** perhaps kernel has never been compiled?' ; \
302 echo '*** please do that first; the results are necessary.' ; \
303 exit 1 ; \
304 fi
305
306 # set version code if this is a fresh CVS checkout
307 ifeq ($(wildcard cvs.datemark),cvs.datemark)
308 verset Makefile.ver: cvs.datemark
309 echo IPSECVERSION=`date -r cvs.datemark +cvs%Y%b%d_%H:%M:%S` >Makefile.ver
310 rm -f cvs.datemark;
311 else
312 verset Makefile.ver:
313 @grep IPSECVERSION Makefile.ver
314 endif
315
316 Makefile: Makefile.ver
317
318 # configuring (exit statuses disregarded, something fishy here sometimes)
319 xcf:
320 -cd $(KERNELSRC) ; $(MAKE) $(KERNMAKEOPTS) xconfig
321 mcf:
322 -cd $(KERNELSRC) ; $(MAKE) $(KERNMAKEOPTS) menuconfig
323 pcf:
324 -cd $(KERNELSRC) ; $(MAKE) $(KERNMAKEOPTS) config
325
326 ocf:
327 -cd $(KERNELSRC) ; $(MAKE) $(KERNMAKEOPTS) oldconfig
328
329 rcf:
330 cd $(KERNELSRC) ; $(MAKE) $(KERNMAKEOPTS) oldconfig_nonint </dev/null
331 cd $(KERNELSRC) ; $(MAKE) $(KERNMAKEOPTS) dep >/dev/null
332
333 confcheck:
334 @if test ! -f $(KCFILE) ; \
335 then echo '*** no kernel configuration file written!!' ; exit 1 ; \
336 fi
337 @if ! egrep -q '^CONFIG_IPSEC=[my]' $(KCFILE) ; \
338 then echo '*** IPsec not in kernel config ($(KCFILE))!!' ; exit 1 ; \
339 fi
340 @if ! egrep -q 'CONFIG_IPSEC[ ]+1' $(ACFILE) && \
341 ! egrep -q 'CONFIG_IPSEC_MODULE[ ]+1' $(ACFILE) ; \
342 then echo '*** IPsec in kernel config ($(KCFILE)),' ; \
343 echo '*** but not in config header file ($(ACFILE))!!' ; \
344 exit 1 ; \
345 fi
346 @if egrep -q '^CONFIG_IPSEC=m' $(KCFILE) && \
347 ! egrep -q '^CONFIG_MODULES=y' $(KCFILE) ; \
348 then echo '*** IPsec configured as module in kernel with no module support!!' ; exit 1 ; \
349 fi
350 @if ! egrep -q 'CONFIG_IPSEC_AH[ ]+1' $(ACFILE) && \
351 ! egrep -q 'CONFIG_IPSEC_ESP[ ]+1' $(ACFILE) ; \
352 then echo '*** IPsec configuration must include AH or ESP!!' ; exit 1 ; \
353 fi
354
355 # kernel building, with error checks
356 kernel:
357 rm -f out.kbuild out.kinstall
358 # undocumented kernel folklore: clean BEFORE dep.
359 # we run make dep seperately, because there is no point in running ERRCHECK
360 # on the make dep output.
361 # see LKML thread "clean before or after dep?"
362 ( cd $(KERNELSRC) ; $(MAKE) $(KERNMAKEOPTS) $(KERNCLEAN) $(KERNDEP) )
363 ( cd $(KERNELSRC) ; $(MAKE) $(KERNMAKEOPTS) $(KERNEL) ) 2>&1 | tee out.kbuild
364 @if egrep -q '^CONFIG_MODULES=y' $(KCFILE) ; \
365 then set -x ; \
366 ( cd $(KERNELSRC) ; \
367 $(MAKE) $(KERNMAKEOPTS) modules 2>&1 ) | tee -a out.kbuild ; \
368 fi
369 ${ERRCHECK} out.kbuild
370
371 # this target takes a kernel source tree and it builds a link tree,
372 # and then does make oldconfig for each .config file that was found in configs.
373 # The location for the disk space required for the link tree is found via
374 # $RH_KERNELSRC_POOL
375 preprhkern4module:
376 if [ -z "${RH_KERNELSRC_POOL}" ]; then echo Please set RH_KERNELSRC_POOL.; exit 1; fi
377 mkdir -p ${RH_KERNELSRC_POOL}
378 KV=`${KVUTIL} $(RH_KERNELSRC)/Makefile` ; \
379 cd ${RH_KERNELSRC_POOL} && \
380 mkdir -p $$KV && cd $$KV && \
381 for config in ${RH_KERNELSRC}/configs/*; do \
382 basecfg=`basename $$config` ;\
383 mkdir -p ${RH_KERNELSRC_POOL}/$$KV/$$basecfg && \
384 cd ${RH_KERNELSRC_POOL}/$$KV/$$basecfg && \
385 lndir ${RH_KERNELSRC} . && \
386 rm -rf include/asm && \
387 (cd include/linux && sed -e '/#include "\/boot\/kernel.h"/d' <rhconfig.h >rhconfig.h-new && mv rhconfig.h-new rhconfig.h ) && \
388 rm -f include/linux/modules/*.stamp && \
389 make dep && \
390 make oldconfig; \
391 done;
392
393 # module-only building, with error checks
394 ifneq ($(strip $(MODBUILDDIR)),)
395 ${MODBUILDDIR}/Makefile : ${FREESWANSRCDIR}/packaging/makefiles/module.make
396 mkdir -p ${MODBUILDDIR}
397 cp ${FREESWANSRCDIR}/packaging/makefiles/module.make ${MODBUILDDIR}/Makefile
398 echo "# " >>${MODBUILDDIR}/Makefile
399 echo "# Local Variables: " >>${MODBUILDDIR}/Makefile
400 echo "# compile-command: \"${MAKE} FREESWANSRCDIR=${FREESWANSRCDIR} ARCH=${ARCH} ${MODULE_FLAGS} MODULE_DEF_INCLUDE=${MODULE_DEF_INCLUDE} ipsec.o\"" >>${MODBUILDDIR}/Makefile
401 echo "# End: " >>${MODBUILDDIR}/Makefile
402
403 # clean out the linux/net/ipsec directory so that VPATH will work properly
404 module: ${MODBUILDDIR}/Makefile
405 ${MAKE} -C linux/net/ipsec ${MODULE_FLAGS} MODULE_DEF_INCLUDE=${MODULE_DEF_INCLUDE} clean
406 ${MAKE} -C ${MODBUILDDIR} ARCH=${ARCH} ${MODULE_FLAGS} MODULE_DEF_INCLUDE=${MODULE_DEF_INCLUDE} ipsec.o
407 ${MAKE} -C ${MODBUILDDIR} ARCH=${ARCH} ${MODULE_FLAGS} MODULE_DEF_INCLUDE=${MODULE_DEF_INCLUDE} LIBCRYPTO=${FREESWANSRCDIR}/lib/libcrypto MODULE_FLAGS="$(MODULE_FLAGS)" alg_modules
408
409 modclean: ${MODBUILDDIR}/Makefile
410 ${MAKE} -C ${MODBUILDDIR} clean
411
412 # module-only install, with error checks
413 minstall:
414 ( FSMODLIB=`make -C $(KERNELSRC) -p dummy | ( sed -n -e '/^MODLIB/p' -e '/^MODLIB/q' ; cat > /dev/null ) | sed -e 's/^MODLIB[ :=]*\([^;]*\).*/\1/'` ; \
415 if [ -z "$$FSMODLIB" ] ; then \
416 FSMODLIB=`make -C $(KERNELSRC) -n -p modules_install | ( sed -n -e '/^MODLIB/p' -e '/^MODLIB/q' ; cat > /dev/null ) | sed -e 's/^MODLIB[ :=]*\([^;]*\).*/\1/'` ; \
417 fi ; \
418 if [ -z "$$FSMODLIB" ] ; then \
419 echo "No known place to install module. Aborting." ; \
420 exit 93 ; \
421 fi ; \
422 set -x ; \
423 mkdir -p $$FSMODLIB/kernel/net/ipsec ; \
424 cp $(MODBUILDDIR)/ipsec.o $$FSMODLIB/kernel/net/ipsec ; \
425 mkdir -p $$FSMODLIB/kernel/net/ipsec/alg ; \
426 for i in `sed -n '/IPSEC_ALG/s/CONFIG_IPSEC_ALG_\(.*\)=[Mm]/ipsec_\1.o/p' $(KCFILE) | tr '[A-Z]' '[a-z]'`;do \
427 echo "installing $$i"; \
428 cp $(MODBUILDDIR)/alg/$$i $$FSMODLIB/kernel/net/ipsec/alg ;\
429 done )
430
431 else
432 module:
433 ${MAKE} -C linux/net/ipsec ARCH=${ARCH} ${MODULE_FLAGS} MODULE_DEF_INCLUDE=${MODULE_DEF_INCLUDE} ipsec.o
434 ${MAKE} -C linux/net/ipsec ARCH=${ARCH} ${MODULE_FLAGS} MODULE_DEF_INCLUDE=${MODULE_DEF_INCLUDE} LIBCRYPTO=${FREESWANSRCDIR}/lib/libcrypto MODULE_FLAGS="$(MODULE_FLAGS)" alg_modules
435
436 modclean:
437 ${MAKE} -C linux/net/ipsec ARCH=${ARCH} ${MODULE_FLAGS} MODULE_DEF_INCLUDE=${MODULE_DEF_INCLUDE} clean
438
439 # module-only install, with error checks
440 minstall:
441 ( FSMODLIB=`make -C $(KERNELSRC) -p dummy | ( sed -n -e '/^MODLIB/p' -e '/^MODLIB/q' ; cat > /dev/null ) | sed -e 's/^MODLIB[ :=]*\([^;]*\).*/\1/'` ; \
442 if [ -z "$$FSMODLIB" ] ; then \
443 FSMODLIB=`make -C $(KERNELSRC) -n -p modules_install | ( sed -n -e '/^MODLIB/p' -e '/^MODLIB/q' ; cat > /dev/null ) | sed -e 's/^MODLIB[ :=]*\([^;]*\).*/\1/'` ; \
444 fi ; \
445 if [ -z "$$FSMODLIB" ] ; then \
446 echo "No known place to install module. Aborting." ; \
447 exit 93 ; \
448 fi ; \
449 set -x ; \
450 mkdir -p $$FSMODLIB/kernel/net/ipsec ; \
451 cp linux/net/ipsec/ipsec.o $$FSMODLIB/kernel/net/ipsec ; \
452 mkdir -p $$FSMODLIB/kernel/net/ipsec/alg ; \
453 for i in `sed -n '/IPSEC_ALG/s/CONFIG_IPSEC_ALG_\(.*\)=[Mm]/ipsec_\1.o/p' $(KCFILE) | tr '[A-Z]' '[a-z]'`;do \
454 echo "installing $$i"; \
455 cp linux/net/ipsec/alg/$$i $$FSMODLIB/kernel/net/ipsec/alg ;\
456 done )
457
458 endif
459
460 # kernel install, with error checks
461 kinstall:
462 rm -f out.kinstall
463 >out.kinstall
464 # undocumented kernel folklore: modules_install must precede install (observed on RHL8.0)
465 @if egrep -q '^CONFIG_MODULES=y' $(KCFILE) ; \
466 then set -x ; \
467 ( cd $(KERNELSRC) ; \
468 $(MAKE) $(KERNMAKEOPTS) modules_install 2>&1 ) | tee -a out.kinstall ; \
469 fi
470 ( cd $(KERNELSRC) ; $(MAKE) $(KERNMAKEOPTS) install ) 2>&1 | tee -a out.kinstall
471 ${ERRCHECK} out.kinstall
472
473 kernelpatch2.5:
474 packaging/utils/kernelpatch 2.5
475
476 kernelpatch2.4 kernelpatch:
477 packaging/utils/kernelpatch 2.4
478
479 kernelpatch2.2:
480 packaging/utils/kernelpatch 2.2
481
482 kernelpatch2.0:
483 packaging/utils/kernelpatch 2.0
484
485 install_file_list:
486 @for d in $(SUBDIRS) ; \
487 do \
488 (cd $$d && $(MAKE) --no-print-directory FREESWANSRCDIR=.. install_file_list ) || exit 1; \
489 done;
490
491 # take all the patches out of the kernel
492 # (Note, a couple of files are modified by non-patch means; they are
493 # included in "make backup".)
494 unpatch:
495 @echo \"make unpatch\" is obsolete. See make unapplypatch.
496 exit 1
497
498 _unpatch:
499 for f in `find $(KERNELSRC)/. -name '*.preipsec' -print` ; \
500 do \
501 echo "restoring $$f:" ; \
502 dir=`dirname $$f` ; \
503 core=`basename $$f .preipsec` ; \
504 cd $$dir ; \
505 mv -f $$core.preipsec $$core ; \
506 rm -f $$core.wipsec $$core.ipsecmd5 ; \
507 done
508
509 # uninstall, as much as possible
510 uninstall:
511 $(MAKE) --no-print-directory install_file_list | egrep -v '(/ipsec.conf$$|/ipsec.d/)' | xargs rm -f
512
513 taroldinstall:
514 tar --ignore-failed-read -c -z -f oldFreeSWAN.tar.gz `$(MAKE) --no-print-directory install_file_list`
515
516 # some oddities meant for the developers, probably of no use to users
517
518 # make tags and TAGS files from ctags and etags for vi and emacs, respectively.
519 tags TAGS: dummy
520 etags `find lib programs linux -name '*.[ch]'`
521 ctags `find lib programs linux -name '*.[ch]'`
522
523 dummy:
524
525 # at the moment there is no difference between snapshot and release build
526 snapready: buildready
527 relready: buildready
528 ready: devready
529
530 # set up for build
531 buildready:
532 rm -f dtrmakefile cvs.datemark
533 cd doc ; $(MAKE) -s
534
535 uml: programs checkprograms
536 @echo XXX do some checks to see if all the manual pieces are done.
537 -chmod +x testing/utils/make-uml.sh
538 testing/utils/make-uml.sh `pwd`
539
540 umluserland:
541 (touch Makefile.inc && source umlsetup.sh && cd $$POOLSPACE && make $$FREESWANHOSTS $$REGULARHOSTS )
542
543
544 # DESTDIR is normally set in Makefile.inc
545 # These recipes explicitly pass it to the second-level makes so that
546 # DESTDIR can be adjusted for building for UML without changing Makefile.inc
547 # See testing/utils/functions.sh
548 # testing/utils/make-uml.sh
549 # testing/utils/uml-functions.sh
550 check: uml Makefile.ver
551 ifneq ($(strip(${REGRESSRESULTS})),)
552 mkdir -p ${REGRESSRESULTS}
553 endif
554 @for d in $(SUBDIRS); do (cd $$d && $(MAKE) DESTDIR=${DESTDIR} checkprograms || exit 1); done
555 @for d in $(SUBDIRS); \
556 do \
557 echo ===================================; \
558 echo Now making check in $$d; \
559 echo ===================================; \
560 (cd $$d && $(MAKE) DESTDIR=${DESTDIR} check || exit 1);\
561 done
562 ifneq ($(strip(${REGRESSRESULTS})),)
563 -perl testing/utils/regress-summarize-results.pl ${REGRESSRESULTS}
564 endif
565
566
567 rpm:
568 @echo please cd packaging/redhat and
569 @echo run "make RH_KERNELSRC=/some/path/to/kernel/src rpm"
570
571 ipkg_strip:
572 @echo "Minimizing size for ipkg binaries..."
573 @cd $(DESTDIR)$(INC_USRLOCAL)/lib/ipsec && \
574 for f in *; do (if file $$f | grep ARM > /dev/null; then ( $(STRIP) --strip-unneeded $$f); fi); done
575 @rm -r $(DESTDIR)$(INC_USRLOCAL)/man
576 @rm -f $(DESTDIR)$(INC_RCDEFAULT)/*.old
577 @rm -f $(DESTDIR)$(INC_USRLOCAL)/lib/ipsec/*.old
578 @rm -f $(DESTDIR)$(INC_USRLOCAL)/libexec/ipsec/*.old
579 @rm -f $(DESTDIR)$(INC_USRLOCAL)/sbin/*.old
580
581 ipkg_module:
582 @echo "Moving ipsec.o into temporary location..."
583 KV=$(shell ${KVUTIL} ${KERNELSRC}/Makefile) && \
584 mkdir -p $(FREESWANSRCDIR)/packaging/ipkg/kernel-module/lib/modules/$$KV/net/ipsec
585 KV=$(shell ${KVUTIL} ${KERNELSRC}/Makefile) && \
586 cp linux/net/ipsec/ipsec.o $(FREESWANSRCDIR)/packaging/ipkg/kernel-module/lib/modules/$$KV/net/ipsec/
587 KV=$(shell ${KVUTIL} ${KERNELSRC}/Makefile)
588
589 ipkg_clean:
590 rm -rf $(FREESWANSRCDIR)/packaging/ipkg/kernel-module/
591 rm -rf $(FREESWANSRCDIR)/packaging/ipkg/ipkg/
592 rm -f $(FREESWANSRCDIR)/packaging/ipkg/control-freeswan
593 rm -f $(FREESWANSRCDIR)/packaging/ipkg/control-freeswan-module
594
595
596 ipkg: programs install ipkg_strip ipkg_module
597 @echo "Generating ipkg...";
598 DESTDIR=${DESTDIR} FREESWANSRCDIR=${FREESWANSRCDIR} ARCH=${ARCH} IPSECVERSION=${IPSECVERSION} ./packaging/ipkg/generate-ipkg
599
600
601
602