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