Add -L line into LIB= in Makefile
[genkernel.git] / gen_compile.sh
1 #!/bin/bash
2
3 compile_kernel_args() {
4         local ARGS
5
6         ARGS=''
7         if [ "${KERNEL_CROSS_COMPILE}" != '' ]
8         then
9                 ARGS="${ARGS} CROSS_COMPILE=\"${KERNEL_CROSS_COMPILE}\""
10         else
11                 if [ "${KERNEL_CC}" != '' ]
12                 then
13                         ARGS="CC=\"${KERNEL_CC}\""
14                 fi
15                 if [ "${KERNEL_LD}" != '' ]
16                 then
17                         ARGS="${ARGS} LD=\"${KERNEL_LD}\""
18                 fi
19                 if [ "${KERNEL_AS}" != '' ]
20                 then
21                         ARGS="${ARGS} AS=\"${KERNEL_AS}\""
22                 fi
23                 if [ -n "${KERNEL_ARCH}" ]
24                 then
25                         ARGS="${ARGS} ARCH=\"${KERNEL_ARCH}\""
26                 fi
27         fi
28         echo -n "${ARGS}"
29 }
30
31 compile_utils_args()
32 {
33         local ARGS
34
35         ARGS=''
36         if [ "${UTILS_ARCH}" != '' ]
37         then
38                 ARGS="ARCH=\"${UTILS_ARCH}\""
39         fi
40         if [ "${UTILS_CC}" != '' ]
41         then
42                 ARGS="CC=\"${UTILS_CC}\""
43         fi
44         if [ "${UTILS_LD}" != '' ]
45         then
46                 ARGS="${ARGS} LD=\"${UTILS_LD}\""
47         fi
48         if [ "${UTILS_AS}" != '' ]
49         then
50                 ARGS="${ARGS} AS=\"${UTILS_AS}\""
51         fi
52
53         echo -n "${ARGS}"
54 }
55
56 export_utils_args()
57 {
58         save_args
59         if [ "${UTILS_ARCH}" != '' ]
60         then
61                 export ARCH="${UTILS_ARCH}"
62         fi
63         if [ "${UTILS_CC}" != '' ]
64         then
65                 export CC="${UTILS_CC}"
66         fi
67         if [ "${UTILS_LD}" != '' ]
68         then
69                 export LD="${UTILS_LD}"
70         fi
71         if [ "${UTILS_AS}" != '' ]
72         then
73                 export AS="${UTILS_AS}"
74         fi
75 }
76
77 unset_utils_args()
78 {
79         if [ "${UTILS_ARCH}" != '' ]
80         then
81                 unset ARCH
82         fi
83         if [ "${UTILS_CC}" != '' ]
84         then
85                 unset CC
86         fi
87         if [ "${UTILS_LD}" != '' ]
88         then
89                 unset LD
90         fi
91         if [ "${UTILS_AS}" != '' ]
92         then
93                 unset AS
94         fi
95         reset_args
96 }
97
98 export_kernel_args()
99 {
100         if [ "${KERNEL_CC}" != '' ]
101         then
102                 export CC="${KERNEL_CC}"
103         fi
104         if [ "${KERNEL_LD}" != '' ]
105         then
106                 export LD="${KERNEL_LD}"
107         fi
108         if [ "${KERNEL_AS}" != '' ]
109         then
110                 export AS="${KERNEL_AS}"
111         fi
112         if [ "${KERNEL_CROSS_COMPILE}" != '' ]
113         then
114                 export CROSS_COMPILE="${KERNEL_CROSS_COMPILE}"
115         fi
116 }
117
118 unset_kernel_args()
119 {
120         if [ "${KERNEL_CC}" != '' ]
121         then
122                 unset CC
123         fi
124         if [ "${KERNEL_LD}" != '' ]
125         then
126                 unset LD
127         fi
128         if [ "${KERNEL_AS}" != '' ]
129         then
130                 unset AS
131         fi
132         if [ "${KERNEL_CROSS_COMPILE}" != '' ]
133         then
134                 unset CROSS_COMPILE
135         fi
136 }
137 save_args()
138 {
139         if [ "${ARCH}" != '' ]
140         then
141                 export ORIG_ARCH="${ARCH}"
142         fi
143         if [ "${CC}" != '' ]
144         then
145                 export ORIG_CC="${CC}"
146         fi
147         if [ "${LD}" != '' ]
148         then
149                 export ORIG_LD="${LD}"
150         fi
151         if [ "${AS}" != '' ]
152         then
153                 export ORIG_AS="${AS}"
154         fi
155         if [ "${CROSS_COMPILE}" != '' ]
156         then
157                 export ORIG_CROSS_COMPILE="${CROSS_COMPILE}"
158         fi
159 }
160 reset_args()
161 {
162         if [ "${ORIG_ARCH}" != '' ]
163         then
164                 export ARCH="${ORIG_ARCH}"
165                 unset ORIG_ARCH
166         fi
167         if [ "${ORIG_CC}" != '' ]
168         then
169                 export CC="${ORIG_CC}"
170                 unset ORIG_CC
171         fi
172         if [ "${ORIG_LD}" != '' ]
173         then
174                 export LD="${ORIG_LD}"
175                 unset ORIG_LD
176         fi
177         if [ "${ORIG_AS}" != '' ]
178         then
179                 export AS="${ORIG_AS}"
180                 unset ORIG_AS
181         fi
182         if [ "${ORIG_CROSS_COMPILE}" != '' ]
183         then
184                 export CROSS_COMPILE="${ORIG_CROSS_COMPILE}"
185                 unset ORIG_CROSS_COMPILE
186         fi
187 }
188
189 apply_patches() {
190         util=$1
191         version=$2
192
193         if [ -d "${GK_SHARE}/patches/${util}/${version}" ]
194         then
195                 print_info 1 "${util}: >> Applying patches..."
196                 for i in ${GK_SHARE}/patches/${util}/${version}/*{diff,patch}
197                 do
198                         patch_success=0
199                         for j in `seq 0 5`
200                         do
201                                 patch -p${j} --backup-if-mismatch -f < "${i}" >/dev/null
202                                 if [ $? = 0 ]
203                                 then
204                                         patch_success=1
205                                         break
206                                 fi
207                         done
208                         if [ ${patch_success} != 1 ]
209                         then
210                                 gen_die "could not apply patch ${i} for ${util}-${version}"
211                         fi
212                 done
213         fi
214 }
215
216 compile_generic() {
217         local RET
218         [ "$#" -lt '2' ] &&
219                 gen_die 'compile_generic(): improper usage!'
220         local target=${1}
221         local argstype=${2}
222
223         if [ "${argstype}" = 'kernel' ] || [ "${argstype}" = 'runtask' ]
224         then
225                 export_kernel_args
226                 MAKE=${KERNEL_MAKE}
227         elif [ "${2}" = 'utils' ]
228         then
229                 export_utils_args
230                 MAKE=${UTILS_MAKE}
231         fi
232         case "${argstype}" in
233                 kernel) ARGS="`compile_kernel_args`" ;;
234                 utils) ARGS="`compile_utils_args`" ;;
235                 *) ARGS="" ;; # includes runtask
236         esac
237         shift 2
238
239         # the eval usage is needed in the next set of code
240         # as ARGS can contain spaces and quotes, eg:
241         # ARGS='CC="ccache gcc"'
242         if [ "${argstype}" == 'runtask' ]
243         then
244                 print_info 2 "COMMAND: ${MAKE} ${MAKEOPTS/-j?/j1} ${ARGS} ${target} $*" 1 0 1
245                 eval ${MAKE} -s ${MAKEOPTS/-j?/-j1} "${ARGS}" ${target} $*
246                 RET=$?
247         elif [ "${LOGLEVEL}" -gt "1" ]
248         then
249                 # Output to stdout and logfile
250                 print_info 2 "COMMAND: ${MAKE} ${MAKEOPTS} ${ARGS} ${target} $*" 1 0 1
251                 eval ${MAKE} ${MAKEOPTS} ${ARGS} ${target} $* 2>&1 | tee -a ${LOGFILE}
252                 RET=${PIPESTATUS[0]}
253         else
254                 # Output to logfile only
255                 print_info 2 "COMMAND: ${MAKE} ${MAKEOPTS} ${ARGS} ${1} $*" 1 0 1
256                 eval ${MAKE} ${MAKEOPTS} ${ARGS} ${target} $* >> ${LOGFILE} 2>&1
257                 RET=$?
258         fi
259         [ "${RET}" -ne '0' ] &&
260                 gen_die "Failed to compile the \"${target}\" target..."
261
262         unset MAKE
263         unset ARGS
264         if [ "${argstype}" = 'kernel' ]
265         then
266                 unset_kernel_args
267         elif [ "${argstype}" = 'utils' ]
268         then
269                 unset_utils_args
270         fi
271 }
272
273 compile_modules() {
274         print_info 1 "        >> Compiling ${KV} modules..."
275         cd ${KERNEL_DIR}
276         compile_generic modules kernel
277         export UNAME_MACHINE="${ARCH}"
278         [ "${INSTALL_MOD_PATH}" != '' ] && export INSTALL_MOD_PATH
279         compile_generic "modules_install" kernel
280         unset UNAME_MACHINE
281 }
282
283 compile_kernel() {
284         [ "${KERNEL_MAKE}" = '' ] &&
285                 gen_die "KERNEL_MAKE undefined - I don't know how to compile a kernel for this arch!"
286         cd ${KERNEL_DIR}
287         print_info 1 "        >> Compiling ${KV} ${KERNEL_MAKE_DIRECTIVE/_install/ [ install ]/}..."
288         compile_generic "${KERNEL_MAKE_DIRECTIVE}" kernel
289         if [ "${KERNEL_MAKE_DIRECTIVE_2}" != '' ]
290         then
291                 print_info 1 "        >> Starting supplimental compile of ${KV}: ${KERNEL_MAKE_DIRECTIVE_2}..."
292                 compile_generic "${KERNEL_MAKE_DIRECTIVE_2}" kernel
293         fi
294         if ! isTrue "${CMD_NOINSTALL}"
295         then
296                 copy_image_with_preserve "kernel" \
297                         "${KERNEL_BINARY}" \
298                         "kernel-${KNAME}-${ARCH}-${KV}"
299
300                 copy_image_with_preserve "System.map" \
301                         "System.map" \
302                         "System.map-${KNAME}-${ARCH}-${KV}"
303
304                 if isTrue "${GENZIMAGE}"
305                 then
306                         copy_image_with_preserve "kernelz" \
307                                 "${KERNEL_BINARY_2}" \
308                                 "kernelz-${KV}"
309                 fi
310         else
311                 cp "${KERNEL_BINARY}" "${TMPDIR}/kernel-${KNAME}-${ARCH}-${KV}" ||
312                         gen_die "Could not copy the kernel binary to ${TMPDIR}!"
313                 cp "System.map" "${TMPDIR}/System.map-${KNAME}-${ARCH}-${KV}" ||
314                         gen_die "Could not copy System.map to ${TMPDIR}!"
315                 if isTrue "${GENZIMAGE}"
316                 then
317                         cp "${KERNEL_BINARY_2}" "${TMPDIR}/kernelz-${KV}" ||
318                                 gen_die "Could not copy the kernelz binary to ${TMPDIR}!"
319                 fi
320         fi
321 }
322
323 compile_busybox() {
324         [ -f "${BUSYBOX_SRCTAR}" ] ||
325                 gen_die "Could not find busybox source tarball: ${BUSYBOX_SRCTAR}!"
326         [ -f "${BUSYBOX_CONFIG}" ] ||
327                 gen_die "Cound not find busybox config file: ${BUSYBOX_CONFIG}!"
328
329         # Delete cache if stored config's MD5 does not match one to be used
330         if [ -f "${BUSYBOX_BINCACHE}" ]
331         then
332                 oldconfig_md5=$(tar -xjf "${BUSYBOX_BINCACHE}" -O .config.gk_orig 2>/dev/null | md5sum)
333                 newconfig_md5=$(md5sum < "${BUSYBOX_CONFIG}")
334                 if [ "${oldconfig_md5}" != "${newconfig_md5}" ]
335                 then
336                         print_info 1 "busybox: >> Removing stale cache..."
337                         rm -rf "${BUSYBOX_BINCACHE}"
338                 else
339                         print_info 1 "busybox: >> Using cache"
340                 fi
341         fi
342
343         if [ ! -f "${BUSYBOX_BINCACHE}" ]
344         then
345                 cd "${TEMP}"
346                 rm -rf "${BUSYBOX_DIR}" > /dev/null
347                 /bin/tar -jxpf ${BUSYBOX_SRCTAR} ||
348                         gen_die 'Could not extract busybox source tarball!'
349                 [ -d "${BUSYBOX_DIR}" ] ||
350                         gen_die 'Busybox directory ${BUSYBOX_DIR} is invalid!'
351                 cp "${BUSYBOX_CONFIG}" "${BUSYBOX_DIR}/.config"
352                 cp "${BUSYBOX_CONFIG}" "${BUSYBOX_DIR}/.config.gk_orig"
353                 cd "${BUSYBOX_DIR}"
354                 apply_patches busybox ${BUSYBOX_VER}
355                 print_info 1 'busybox: >> Configuring...'
356                 yes '' 2>/dev/null | compile_generic oldconfig utils
357
358                 print_info 1 'busybox: >> Compiling...'
359                 compile_generic all utils
360                 print_info 1 'busybox: >> Copying to cache...'
361                 [ -f "${TEMP}/${BUSYBOX_DIR}/busybox" ] ||
362                         gen_die 'Busybox executable does not exist!'
363                 strip "${TEMP}/${BUSYBOX_DIR}/busybox" ||
364                         gen_die 'Could not strip busybox binary!'
365                 tar -cj -C "${TEMP}/${BUSYBOX_DIR}" -f "${BUSYBOX_BINCACHE}" busybox .config .config.gk_orig ||
366                         gen_die 'Could not create the busybox bincache!'
367
368                 cd "${TEMP}"
369                 rm -rf "${BUSYBOX_DIR}" > /dev/null
370         fi
371 }
372
373 compile_lvm() {
374         compile_device_mapper
375         if [ ! -f "${LVM_BINCACHE}" ]
376         then
377                 [ -f "${LVM_SRCTAR}" ] ||
378                         gen_die "Could not find LVM source tarball: ${LVM_SRCTAR}! Please place it there, or place another version, changing /etc/genkernel.conf as necessary!"
379                 cd "${TEMP}"
380                 rm -rf ${LVM_DIR} > /dev/null
381                 /bin/tar -zxpf ${LVM_SRCTAR} ||
382                         gen_die 'Could not extract LVM source tarball!'
383                 [ -d "${LVM_DIR}" ] ||
384                         gen_die 'LVM directory ${LVM_DIR} is invalid!'
385                 rm -rf "${TEMP}/device-mapper" > /dev/null
386                 /bin/tar -jxpf "${DEVICE_MAPPER_BINCACHE}" -C "${TEMP}" ||
387                         gen_die "Could not extract device-mapper binary cache!";
388                 
389                 cd "${LVM_DIR}"
390                 print_info 1 'lvm: >> Configuring...'
391                         LDFLAGS="-L${TEMP}/device-mapper/lib" \
392                         CFLAGS="-I${TEMP}/device-mapper/include" \
393                         CPPFLAGS="-I${TEMP}/device-mapper/include" \
394                         ./configure --enable-static_link --prefix=${TEMP}/lvm >> ${LOGFILE} 2>&1 ||
395                                 gen_die 'Configure of lvm failed!'
396                 print_info 1 'lvm: >> Compiling...'
397                         compile_generic '' utils
398                         compile_generic 'install' utils
399
400                 cd "${TEMP}/lvm"
401                 print_info 1 '      >> Copying to bincache...'
402                 strip "sbin/lvm.static" ||
403                         gen_die 'Could not strip lvm.static!'
404                 /bin/tar -cjf "${LVM_BINCACHE}" sbin/lvm.static ||
405                         gen_die 'Could not create binary cache'
406
407                 cd "${TEMP}"
408                 rm -rf "${TEMP}/device-mapper" > /dev/null
409                 rm -rf "${LVM_DIR}" lvm
410         fi
411 }
412
413 compile_dmraid() {
414         compile_device_mapper
415         if [ ! -f "${DMRAID_BINCACHE}" ]
416         then
417                 [ -f "${DMRAID_SRCTAR}" ] ||
418                         gen_die "Could not find DMRAID source tarball: ${DMRAID_SRCTAR}! Please place it there, or place another version, changing /etc/genkernel.conf as necessary!"
419                 cd "${TEMP}"
420                 rm -rf ${DMRAID_DIR} > /dev/null
421                 /bin/tar -jxpf ${DMRAID_SRCTAR} ||
422                         gen_die 'Could not extract DMRAID source tarball!'
423                 [ -d "${DMRAID_DIR}" ] ||
424                         gen_die 'DMRAID directory ${DMRAID_DIR} is invalid!'
425                 rm -rf "${TEMP}/device-mapper" > /dev/null
426                 /bin/tar -jxpf "${DEVICE_MAPPER_BINCACHE}" -C "${TEMP}" ||
427                         gen_die "Could not extract device-mapper binary cache!";
428                 
429                 cd "${DMRAID_DIR}"
430                 print_info 1 'dmraid: >> Configuring...'
431                 
432                 LDFLAGS="-L${TEMP}/device-mapper/lib" \
433                 CFLAGS="-I${TEMP}/device-mapper/include" \
434                 CPPFLAGS="-I${TEMP}/device-mapper/include" \
435                 ./configure --enable-static_link --prefix=${TEMP}/dmraid >> ${LOGFILE} 2>&1 ||
436                         gen_die 'Configure of dmraid failed!'
437
438                 # We dont necessarily have selinux installed yet... look into
439                 # selinux global support in the future.
440                 sed -i tools/Makefile -e "s|DMRAIDLIBS += -lselinux||g"
441                 ###echo "DMRAIDLIBS += -lselinux -lsepol" >> tools/Makefile
442                 mkdir -p "${TEMP}/dmraid"
443                 print_info 1 'dmraid: >> Compiling...'
444                 # Force dmraid to be built with -j1 for bug #188273
445                 MAKEOPTS=-j1 compile_generic '' utils
446                 #compile_generic 'install' utils
447                 mkdir ${TEMP}/dmraid/sbin
448                 install -m 0755 -s tools/dmraid "${TEMP}/dmraid/sbin/dmraid"
449                 print_info 1 '      >> Copying to bincache...'
450                 cd "${TEMP}/dmraid"
451                 /bin/tar -cjf "${DMRAID_BINCACHE}" sbin/dmraid ||
452                         gen_die 'Could not create binary cache'
453
454                 cd "${TEMP}"
455                 rm -rf "${TEMP}/device-mapper" > /dev/null
456                 rm -rf "${DMRAID_DIR}" dmraid
457         fi
458 }
459
460 compile_device_mapper() {
461         if [ ! -f "${DEVICE_MAPPER_BINCACHE}" ]
462         then
463                 [ ! -f "${DEVICE_MAPPER_SRCTAR}" ] &&
464                         gen_die "Could not find device-mapper source tarball: ${DEVICE_MAPPER_SRCTAR}. Please place it there, or place another version, changing /etc/genkernel.conf as necessary!"
465                 cd "${TEMP}"
466                 rm -rf "${DEVICE_MAPPER_DIR}"
467                 /bin/tar -zxpf "${DEVICE_MAPPER_SRCTAR}"
468                 [ ! -d "${DEVICE_MAPPER_DIR}" ] &&
469                         gen_die "device-mapper directory ${DEVICE_MAPPER_DIR} invalid"
470                 cd "${DEVICE_MAPPER_DIR}"
471                 ./configure --prefix=${TEMP}/device-mapper --enable-static_link \
472                         --disable-selinux >> ${LOGFILE} 2>&1 ||
473                         gen_die 'Configuring device-mapper failed!'
474                 print_info 1 'device-mapper: >> Compiling...'
475                 compile_generic '' utils
476                 compile_generic 'install' utils
477                 print_info 1 '        >> Copying to cache...'
478                 cd "${TEMP}"
479                 rm -rf "${TEMP}/device-mapper/man" ||
480                         gen_die 'Could not remove manual pages!'
481                 strip "${TEMP}/device-mapper/sbin/dmsetup" ||
482                         gen_die 'Could not strip dmsetup binary!'
483                 /bin/tar -jcpf "${DEVICE_MAPPER_BINCACHE}" device-mapper ||
484                         gen_die 'Could not tar up the device-mapper binary!'
485                 [ -f "${DEVICE_MAPPER_BINCACHE}" ] ||
486                         gen_die 'device-mapper cache not created!'
487                 cd "${TEMP}"
488                 rm -rf "${DEVICE_MAPPER_DIR}" > /dev/null
489                 rm -rf "${TEMP}/device-mapper" > /dev/null
490         fi
491 }
492
493 compile_e2fsprogs() {
494         if [ ! -f "${BLKID_BINCACHE}" ]
495         then
496                 [ ! -f "${E2FSPROGS_SRCTAR}" ] &&
497                         gen_die "Could not find e2fsprogs source tarball: ${E2FSPROGS_SRCTAR}. Please place it there, or place another version, changing /etc/genkernel.conf as necessary!"
498                 cd "${TEMP}"
499                 rm -rf "${E2FSPROGS_DIR}"
500                 tar -zxpf "${E2FSPROGS_SRCTAR}"
501                 [ ! -d "${E2FSPROGS_DIR}" ] &&
502                         gen_die "e2fsprogs directory ${E2FSPROGS_DIR} invalid"
503                 cd "${E2FSPROGS_DIR}"
504                 print_info 1 'e2fsprogs: >> Configuring...'
505                 ./configure  --with-ldopts=-static >> ${LOGFILE} 2>&1 ||
506                         gen_die 'Configuring e2fsprogs failed!'
507                 print_info 1 'e2fsprogs: >> Compiling...'
508                 MAKE=${UTILS_MAKE} compile_generic "" ""
509                 print_info 1 'blkid: >> Copying to cache...'
510                 [ -f "${TEMP}/${E2FSPROGS_DIR}/misc/blkid" ] ||
511                         gen_die 'Blkid executable does not exist!'
512                 strip "${TEMP}/${E2FSPROGS_DIR}/misc/blkid" ||
513                         gen_die 'Could not strip blkid binary!'
514                 bzip2 "${TEMP}/${E2FSPROGS_DIR}/misc/blkid" ||
515                         gen_die 'bzip2 compression of blkid failed!'
516                 mv "${TEMP}/${E2FSPROGS_DIR}/misc/blkid.bz2" "${BLKID_BINCACHE}" ||
517                         gen_die 'Could not copy the blkid binary to the package directory, does the directory exist?'
518
519                 cd "${TEMP}"
520                 rm -rf "${E2FSPROGS_DIR}" > /dev/null
521         fi
522 }
523
524 compile_fuse() {
525         if [ ! -f "${FUSE_BINCACHE}" ]
526         then
527                 [ ! -f "${FUSE_SRCTAR}" ] &&
528                         gen_die "Could not find fuse source tarball: ${FUSE_SRCTAR}. Please place it there, or place another version, changing /etc/genkernel.conf as necessary!"
529                 cd "${TEMP}"
530                 rm -rf "${FUSE_DIR}"
531                 tar -zxpf "${FUSE_SRCTAR}"
532                 [ ! -d "${FUSE_DIR}" ] &&
533                         gen_die "fuse directory ${FUSE_DIR} invalid"
534                 cd "${FUSE_DIR}"
535                 print_info 1 'fuse: >> Configuring...'
536                 ./configure  --disable-kernel-module --disable-example >> ${LOGFILE} 2>&1 ||
537                         gen_die 'Configuring fuse failed!'
538                 print_info 1 'fuse: >> Compiling...'
539                 MAKE=${UTILS_MAKE} compile_generic "" ""
540                 print_info 1 'libfuse: >> Copying to cache...'
541                 [ -f "${TEMP}/${FUSE_DIR}/lib/.libs/libfuse.so" ] ||
542                         gen_die 'libfuse.so does not exist!'
543                 strip "${TEMP}/${FUSE_DIR}/lib/.libs/libfuse.so" ||
544                         gen_die 'Could not strip libfuse.so!'
545                 cd "${TEMP}/${FUSE_DIR}/lib/.libs"
546                 tar -cjf "${FUSE_BINCACHE}" libfuse*so* ||
547                         gen_die 'Could not create fuse bincache!'
548
549                 cd "${TEMP}"
550 #               rm -rf "${FUSE_DIR}" > /dev/null
551         fi
552 }
553
554 compile_unionfs_fuse() {
555         if [ ! -f "${UNIONFS_FUSE_BINCACHE}" ]
556         then
557                 [ ! -f "${UNIONFS_FUSE_SRCTAR}" ] &&
558                         gen_die "Could not find unionfs-fuse source tarball: ${UNIONFS_FUSE_SRCTAR}. Please place it there, or place another version, changing /etc/genkernel.conf as necessary!"
559                 cd "${TEMP}"
560                 rm -rf "${UNIONFS_FUSE_DIR}"
561                 tar -jxpf "${UNIONFS_FUSE_SRCTAR}"
562                 [ ! -d "${UNIONFS_FUSE_DIR}" ] &&
563                         gen_die "unionfs-fuse directory ${UNIONFS_FUSE_DIR} invalid"
564                 cd "${UNIONFS_FUSE_DIR}"
565 #               mkdir "fuse_tmp"
566 #               cd "fuse_tmp"
567 #               tar -zxpf "${FUSE_SRCTAR}"
568 #               cd ..
569                 print_info 1 'unionfs-fuse: >> Compiling...'
570                 sed -i "/^\(CFLAGS\|CPPFLAGS\)/s:^\\(.*\\)$:\\1 -I${TEMP}/${FUSE_DIR}/include -L${TEMP}/${FUSE_DIR}/lib/.libs:" Makefile src/Makefile
571                 sed -i "/^LIB = /s:^LIB = \(.*\)$:LIB = -L${TEMP}/${FUSE_DIR}/lib/.libs \1:" Makefile src/Makefile
572                 cat Makefile src/Makefile
573                 bash
574                 MAKE=${UTILS_MAKE} compile_generic "" ""
575                 print_info 1 'unionfs-fuse: >> Copying to cache...'
576                 [ -f "${TEMP}/${UNIONFS_FUSE_DIR}/src/unionfs" ] ||
577                         gen_die 'unionfs binary does not exist!'
578                 strip "${TEMP}/${UNIONFS_FUSE_DIR}/src/unionfs" ||
579                         gen_die 'Could not strip unionfs binary!'
580                 bzip2 "${TEMP}/${UNIONFS_FUSE_DIR}/src/unionfs" ||
581                         gen_die 'bzip2 compression of unionfs binary failed!'
582                 mv "${TEMP}/${UNIONFS_FUSE_DIR}/src/unionfs.bz2" "${UNIONFS_FUSE_BINCACHE}" ||
583                         gen_die 'Could not copy the unionfs binary to the package directory, does the directory exist?'
584
585                 cd "${TEMP}"
586                 rm -rf "${UNIONFS_FUSE_DIR}" > /dev/null
587         fi
588 }