8 if [ "${KERNEL_CROSS_COMPILE}" != '' ]
10 ARGS="${ARGS} CROSS_COMPILE=\"${KERNEL_CROSS_COMPILE}\""
12 if [ "${KERNEL_CC}" != '' ]
14 ARGS="CC=\"${KERNEL_CC}\""
16 if [ "${KERNEL_LD}" != '' ]
18 ARGS="${ARGS} LD=\"${KERNEL_LD}\""
20 if [ "${KERNEL_AS}" != '' ]
22 ARGS="${ARGS} AS=\"${KERNEL_AS}\""
33 if [ "${UTILS_ARCH}" != '' ]
35 ARGS="ARCH=\"${UTILS_ARCH}\""
37 if [ "${UTILS_CC}" != '' ]
39 ARGS="CC=\"${UTILS_CC}\""
41 if [ "${UTILS_LD}" != '' ]
43 ARGS="${ARGS} LD=\"${UTILS_LD}\""
45 if [ "${UTILS_AS}" != '' ]
47 ARGS="${ARGS} AS=\"${UTILS_AS}\""
56 if [ "${UTILS_ARCH}" != '' ]
58 export ARCH="${UTILS_ARCH}"
60 if [ "${UTILS_CC}" != '' ]
62 export CC="${UTILS_CC}"
64 if [ "${UTILS_LD}" != '' ]
66 export LD="${UTILS_LD}"
68 if [ "${UTILS_AS}" != '' ]
70 export AS="${UTILS_AS}"
76 if [ "${UTILS_ARCH}" != '' ]
80 if [ "${UTILS_CC}" != '' ]
84 if [ "${UTILS_LD}" != '' ]
88 if [ "${UTILS_AS}" != '' ]
97 if [ "${KERNEL_CC}" != '' ]
99 export CC="${KERNEL_CC}"
101 if [ "${KERNEL_LD}" != '' ]
103 export LD="${KERNEL_LD}"
105 if [ "${KERNEL_AS}" != '' ]
107 export AS="${KERNEL_AS}"
109 if [ "${KERNEL_CROSS_COMPILE}" != '' ]
111 export CROSS_COMPILE="${KERNEL_CROSS_COMPILE}"
117 if [ "${KERNEL_CC}" != '' ]
121 if [ "${KERNEL_LD}" != '' ]
125 if [ "${KERNEL_AS}" != '' ]
129 if [ "${KERNEL_CROSS_COMPILE}" != '' ]
136 if [ "${ARCH}" != '' ]
138 export ORIG_ARCH="${ARCH}"
142 export ORIG_CC="${CC}"
146 export ORIG_LD="${LD}"
150 export ORIG_AS="${AS}"
152 if [ "${CROSS_COMPILE}" != '' ]
154 export ORIG_CROSS_COMPILE="${CROSS_COMPILE}"
159 if [ "${ORIG_ARCH}" != '' ]
161 export ARCH="${ORIG_ARCH}"
164 if [ "${ORIG_CC}" != '' ]
166 export CC="${ORIG_CC}"
169 if [ "${ORIG_LD}" != '' ]
171 export LD="${ORIG_LD}"
174 if [ "${ORIG_AS}" != '' ]
176 export AS="${ORIG_AS}"
179 if [ "${ORIG_CROSS_COMPILE}" != '' ]
181 export CROSS_COMPILE="${ORIG_CROSS_COMPILE}"
182 unset ORIG_CROSS_COMPILE
189 gen_die 'compile_generic(): improper usage!'
193 if [ "${argstype}" = 'kernel' ] || [ "${argstype}" = 'runtask' ]
197 elif [ "${2}" = 'utils' ]
202 case "${argstype}" in
203 kernel) ARGS="`compile_kernel_args`" ;;
204 utils) ARGS="`compile_utils_args`" ;;
205 *) ARGS="" ;; # includes runtask
210 # the eval usage is needed in the next set of code
211 # as ARGS can contain spaces and quotes, eg:
212 # ARGS='CC="ccache gcc"'
213 if [ "${argstype}" == 'runtask' ]
215 print_info 2 "COMMAND: ${MAKE} ${MAKEOPTS/-j?/j1} ${ARGS} ${target} $*" 1 0 1
216 eval ${MAKE} -s ${MAKEOPTS/-j?/-j1} "${ARGS}" ${target} $*
218 elif [ "${DEBUGLEVEL}" -gt "1" ]
220 # Output to stdout and debugfile
221 print_info 2 "COMMAND: ${MAKE} ${MAKEOPTS} ${ARGS} ${target} $*" 1 0 1
222 eval ${MAKE} ${MAKEOPTS} ${ARGS} ${target} $* 2>&1 | tee -a ${DEBUGFILE}
225 # Output to debugfile only
226 print_info 2 "COMMAND: ${MAKE} ${MAKEOPTS} ${ARGS} ${1} $*" 1 0 1
227 eval ${MAKE} ${MAKEOPTS} ${ARGS} ${target} $* >> ${DEBUGFILE} 2>&1
230 [ "${RET}" -ne '0' ] &&
231 gen_die "Failed to compile the \"${target}\" target..."
235 if [ "${argstype}" = 'kernel' ]
238 elif [ "${argstype}" = 'utils' ]
244 extract_dietlibc_bincache() {
246 rm -rf "${TEMP}/diet" > /dev/null
247 /bin/tar -jxpf "${DIETLIBC_BINCACHE}" ||
248 gen_die 'Could not extract dietlibc bincache!'
249 [ ! -d "${TEMP}/diet" ] &&
250 gen_die "${TEMP}/diet directory not found!"
254 clean_dietlibc_bincache() {
256 rm -rf "${TEMP}/diet" > /dev/null
261 # Only run ``make dep'' for 2.4 kernels
262 if [ "${VER}" -eq '2' -a "${KERN_24}" -eq '1' ]
264 print_info 1 "kernel: >> Making dependencies..."
266 compile_generic dep kernel
271 print_info 1 " >> Compiling ${KV} modules..."
273 compile_generic modules kernel
274 export UNAME_MACHINE="${ARCH}"
275 # On 2.4 kernels, if MAKEOPTS > -j1 it can cause failures
276 if [ "${VER}" -eq '2' -a "${KERN_24}" -eq '1' ]
278 MAKEOPTS_SAVE="${MAKEOPTS}"
279 MAKEOPTS="${MAKEOPTS_SAVE/-j?/-j1}"
281 [ "${INSTALL_MOD_PATH}" != '' ] && export INSTALL_MOD_PATH
282 compile_generic "modules_install" kernel
283 [ "${VER}" -eq '2' -a "${KERN_24}" -eq '1' ] && MAKEOPTS="${MAKEOPTS_SAVE}"
289 [ "${KERNEL_MAKE}" = '' ] &&
290 gen_die "KERNEL_MAKE undefined - I don't know how to compile a kernel for this arch!"
292 print_info 1 " >> Compiling ${KV} ${KERNEL_MAKE_DIRECTIVE/_install/ [ install ]/}..."
293 compile_generic "${KERNEL_MAKE_DIRECTIVE}" kernel
294 if [ "${KERNEL_MAKE_DIRECTIVE_2}" != '' ]
296 print_info 1 " >> Starting supplimental compile of ${KV}: ${KERNEL_MAKE_DIRECTIVE_2}..."
297 compile_generic "${KERNEL_MAKE_DIRECTIVE_2}" kernel
299 if ! isTrue "${CMD_NOINSTALL}"
301 cp "${KERNEL_BINARY}" "${BOOTDIR}/kernel-${KNAME}-${ARCH}-${KV}" ||
302 gen_die 'Could not copy the kernel binary to ${BOOTDIR}!'
303 cp "System.map" "${BOOTDIR}/System.map-${KNAME}-${ARCH}-${KV}" ||
304 gen_die 'Could not copy System.map to ${BOOTDIR}!'
305 if [ "${KERNEL_BINARY_2}" != '' -a "${GENERATE_Z_IMAGE}" = '1' ]
307 cp "${KERNEL_BINARY_2}" "${BOOTDIR}/kernelz-${KV}" ||
308 gen_die 'Could not copy the kernelz binary to ${BOOTDIR}!'
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 [ "${KERNEL_BINARY_2}" != '' -a "${GENERATE_Z_IMAGE}" = '1' ]
317 cp "${KERNEL_BINARY_2}" "${TMPDIR}/kernelz-${KV}" ||
318 gen_die "Could not copy the kernelz binary to ${TMPDIR}!"
323 compile_unionfs_modules() {
324 if [ ! -f "${UNIONFS_MODULES_BINCACHE}" ]
326 [ -f "${UNIONFS_SRCTAR}" ] ||
327 gen_die "Could not find unionfs source tarball: ${UNIONFS_SRCTAR}!"
329 rm -rf ${UNIONFS_DIR} > /dev/null
330 rm -rf unionfs > /dev/null
332 /bin/tar -zxpf ${UNIONFS_SRCTAR} ||
333 gen_die 'Could not extract unionfs source tarball!'
334 [ -d "${UNIONFS_DIR}" ] ||
335 gen_die 'Unionfs directory ${UNIONFS_DIR} is invalid!'
337 print_info 1 'unionfs modules: >> Compiling...'
338 echo "LINUXSRC=${KERNEL_DIR}" >> fistdev.mk
339 echo 'TOPINC=-I$(LINUXSRC)/include' >> fistdev.mk
340 echo "MODDIR= /lib/modules/${KV}" >> fistdev.mk
341 echo "KERNELVERSION=${KV}" >> fistdev.mk
342 # Fix for hardened/selinux systems to have extened attributes
343 # per r2d2's request. Also add -DUNIONFS_UNSUPPORTED for 2.6.16
344 echo "EXTRACFLAGS=-DUNIONFS_XATTR -DFIST_SETXATTR_CONSTVOID -DUNIONFS_UNSUPPORTED" \
346 # Here we do something really nasty and disable debugging, along with
347 # change our default CFLAGS
348 echo "UNIONFS_DEBUG_CFLAG=-DUNIONFS_NDEBUG" >> fistdev.mk
349 echo "UNIONFS_OPT_CFLAG= -O2 -pipe" >> fistdev.mk
351 if [ "${PAT}" -ge '6' ]
355 # Compile unionfs module within the unionfs
356 # environment not within the kernelsrc dir
357 make unionfs.ko || gen_die 'failed to compile unionfs'
359 gen_die 'unionfs is only supported on 2.6 targets'
361 print_info 1 'unionfs: >> Copying to cache...'
363 mkdir -p ${TEMP}/unionfs/lib/modules/${KV}/kernel/fs/unionfs
367 cp -f unionfs.ko ${TEMP}/unionfs/lib/modules/${KV}/kernel/fs/unionfs
369 cp -f unionfs.o ${TEMP}/unionfs/lib/modules/${KV}/kernel/fs/unionfs
373 /bin/tar -cjf "${UNIONFS_MODULES_BINCACHE}" . ||
374 gen_die 'Could not create unionfs modules binary cache'
377 rm -rf "${UNIONFS_DIR}" > /dev/null
378 rm -rf unionfs > /dev/null
382 compile_unionfs_utils() {
383 if [ ! -f "${UNIONFS_BINCACHE}" ]
385 [ -f "${UNIONFS_SRCTAR}" ] ||
386 gen_die "Could not find unionfs source tarball: ${UNIONFS_SRCTAR}!"
388 rm -rf ${UNIONFS_DIR} > /dev/null
389 rm -rf unionfs > /dev/null
390 mkdir -p unionfs/sbin
391 /bin/tar -zxpf ${UNIONFS_SRCTAR} ||
392 gen_die 'Could not extract unionfs source tarball!'
393 [ -d "${UNIONFS_DIR}" ] ||
394 gen_die 'Unionfs directory ${UNIONFS_DIR} is invalid!'
396 print_info 1 'unionfs tools: >> Compiling...'
397 sed -i Makefile -e 's|${CC} -o|${CC} -static -o|g'
398 compile_generic utils utils
400 print_info 1 'unionfs: >> Copying to cache...'
401 strip uniondbg unionctl
402 cp uniondbg ${TEMP}/unionfs/sbin/ ||
403 gen_die 'Could not copy the uniondbg binary to the tmp directory'
404 cp unionctl ${TEMP}/unionfs/sbin/ ||
405 gen_die 'Could not copy the unionctl binary to the tmp directory'
407 /bin/tar -cjf "${UNIONFS_BINCACHE}" . ||
408 gen_die 'Could not create unionfs tools binary cache'
411 rm -rf "${UNIONFS_DIR}" > /dev/null
412 rm -rf unionfs > /dev/null
417 if [ ! -f "${BUSYBOX_BINCACHE}" ]
419 [ -f "${BUSYBOX_SRCTAR}" ] ||
420 gen_die "Could not find busybox source tarball: ${BUSYBOX_SRCTAR}!"
421 [ -f "${BUSYBOX_CONFIG}" ] ||
422 gen_die "Cound not find busybox config file: ${BUSYBOX_CONFIG}!"
424 rm -rf ${BUSYBOX_DIR} > /dev/null
425 /bin/tar -jxpf ${BUSYBOX_SRCTAR} ||
426 gen_die 'Could not extract busybox source tarball!'
427 [ -d "${BUSYBOX_DIR}" ] ||
428 gen_die 'Busybox directory ${BUSYBOX_DIR} is invalid!'
429 cp "${BUSYBOX_CONFIG}" "${BUSYBOX_DIR}/.config"
430 sed -i ${BUSYBOX_DIR}/.config -e 's/#\? \?CONFIG_FEATURE_INSTALLER[ =].*/CONFIG_FEATURE_INSTALLER=y/g'
432 print_info 1 'busybox: >> Configuring...'
433 yes '' 2>/dev/null | compile_generic oldconfig utils
434 print_info 1 'busybox: >> Compiling...'
435 compile_generic all utils
436 print_info 1 'busybox: >> Copying to cache...'
437 [ -f "${TEMP}/${BUSYBOX_DIR}/busybox" ] ||
438 gen_die 'Busybox executable does not exist!'
439 strip "${TEMP}/${BUSYBOX_DIR}/busybox" ||
440 gen_die 'Could not strip busybox binary!'
441 bzip2 "${TEMP}/${BUSYBOX_DIR}/busybox" ||
442 gen_die 'bzip2 compression of busybox failed!'
443 mv "${TEMP}/${BUSYBOX_DIR}/busybox.bz2" "${BUSYBOX_BINCACHE}" ||
444 gen_die 'Could not copy the busybox binary to the package directory, does the directory exist?'
447 rm -rf "${BUSYBOX_DIR}" > /dev/null
452 compile_device_mapper
453 if [ ! -f "${LVM2_BINCACHE}" ]
455 [ -f "${LVM2_SRCTAR}" ] ||
456 gen_die "Could not find LVM2 source tarball: ${LVM2_SRCTAR}! Please place it there, or place another version, changing /etc/genkernel.conf as necessary!"
458 rm -rf ${LVM2_DIR} > /dev/null
459 /bin/tar -zxpf ${LVM2_SRCTAR} ||
460 gen_die 'Could not extract LVM2 source tarball!'
461 [ -d "${LVM2_DIR}" ] ||
462 gen_die 'LVM2 directory ${LVM2_DIR} is invalid!'
463 rm -rf "${TEMP}/device-mapper" > /dev/null
464 /bin/tar -jxpf "${DEVICE_MAPPER_BINCACHE}" -C "${TEMP}" ||
465 gen_die "Could not extract device-mapper binary cache!";
468 print_info 1 'lvm2: >> Configuring...'
469 LDFLAGS="-L${TEMP}/device-mapper/lib" \
470 CFLAGS="-I${TEMP}/device-mapper/include" \
471 CPPFLAGS="-I${TEMP}/device-mapper/include" \
472 ./configure --enable-static_link --prefix=${TEMP}/lvm2 >> ${DEBUGFILE} 2>&1 ||
473 gen_die 'Configure of lvm2 failed!'
474 print_info 1 'lvm2: >> Compiling...'
475 compile_generic '' utils
476 compile_generic 'install' utils
479 print_info 1 ' >> Copying to bincache...'
480 strip "sbin/lvm.static" ||
481 gen_die 'Could not strip lvm.static!'
482 /bin/tar -cjf "${LVM2_BINCACHE}" sbin/lvm.static ||
483 gen_die 'Could not create binary cache'
486 rm -rf "${TEMP}/device-mapper" > /dev/null
487 rm -rf "${LVM2_DIR}" lvm2
492 compile_device_mapper
493 if [ ! -f "${DMRAID_BINCACHE}" ]
495 [ -f "${DMRAID_SRCTAR}" ] ||
496 gen_die "Could not find DMRAID source tarball: ${DMRAID_SRCTAR}! Please place it there, or place another version, changing /etc/genkernel.conf as necessary!"
498 rm -rf ${DMRAID_DIR} > /dev/null
499 /bin/tar -jxpf ${DMRAID_SRCTAR} ||
500 gen_die 'Could not extract DMRAID source tarball!'
501 [ -d "${DMRAID_DIR}" ] ||
502 gen_die 'DMRAID directory ${DMRAID_DIR} is invalid!'
503 rm -rf "${TEMP}/device-mapper" > /dev/null
504 /bin/tar -jxpf "${DEVICE_MAPPER_BINCACHE}" -C "${TEMP}" ||
505 gen_die "Could not extract device-mapper binary cache!";
508 print_info 1 'dmraid: >> Configuring...'
510 LDFLAGS="-L${TEMP}/device-mapper/lib" \
511 CFLAGS="-I${TEMP}/device-mapper/include" \
512 CPPFLAGS="-I${TEMP}/device-mapper/include" \
513 ./configure --enable-static_link --prefix=${TEMP}/dmraid >> ${DEBUGFILE} 2>&1 ||
514 gen_die 'Configure of dmraid failed!'
516 #We dont necessarily have selinux installed yet .. look into selinux global support in the future.
517 sed -i tools/Makefile -e "s|DMRAIDLIBS += -lselinux||g"
518 mkdir -p "${TEMP}/dmraid"
519 print_info 1 'dmraid: >> Compiling...'
520 compile_generic '' utils
521 #compile_generic 'install' utils
522 mkdir ${TEMP}/dmraid/sbin
523 install -m 0755 -s tools/dmraid "${TEMP}/dmraid/sbin/dmraid"
524 print_info 1 ' >> Copying to bincache...'
526 /bin/tar -cjf "${DMRAID_BINCACHE}" sbin/dmraid ||
527 gen_die 'Could not create binary cache'
530 rm -rf "${TEMP}/device-mapper" > /dev/null
531 rm -rf "${DMRAID_DIR}" dmraid
536 [ -f "${SUSPEND_BINCACHE}" ] && return
537 [ -f "${SUSPEND_SRCTAR}" ] ||
538 gen_die "Could not find SUSPEND source tarball: ${SUSPEND_SRCTAR}! Please place it there, or place another version, changing /etc/genkernel.conf as necessary!"
540 rm -rf ${SUSPEND_DIR} > /dev/null
541 /bin/tar -zxpf ${SUSPEND_SRCTAR} ||
542 gen_die 'Could not extract SUSPEND source tarball!'
543 [ -d "${SUSPEND_DIR}" ] ||
544 gen_die "SUSPEND directory ${DMRAID_DIR} is invalid!"
547 if [ -f "${GK_SHARE}/pkg/suspend-0.5-Makefile.patch" ]
550 ${GK_SHARE}/pkg/suspend-0.5-Makefile.patch \
551 || gen_die "Failed patching suspend"
554 print_info 1 'suspend: >> Compiling...'
555 compile_generic '' utils CC_FLAGS= LD_FLAGS=
557 print_info 1 ' >> Copying to bincache...'
558 mkdir -p "${TEMP}/bincache/sbin"
559 cp -f resume "${TEMP}/bincache/sbin" ||
560 gen_die 'Could not copy resume binary'
561 cd "${TEMP}/bincache"
562 /bin/tar -cjf "${SUSPEND_BINCACHE}" * ||
563 gen_die 'Could not create suspend binary cache'
565 rm -rf bincache suspend-0.5
569 # I've disabled dietlibc support for the time being since the
570 # version we use misses a few needed system calls.
573 if [ ! -f "${MODUTILS_BINCACHE}" ]
575 [ ! -f "${MODUTILS_SRCTAR}" ] &&
576 gen_die "Could not find modutils source tarball: ${MODUTILS_SRCTAR}!"
578 rm -rf "${MODUTILS_DIR}"
579 /bin/tar -jxpf "${MODUTILS_SRCTAR}"
580 [ ! -d "${MODUTILS_DIR}" ] &&
581 gen_die "Modutils directory ${MODUTILS_DIR} invalid!"
583 print_info 1 "modutils: >> Configuring..."
585 # if [ "${USE_DIETLIBC}" -eq '1' ]
587 # extract_dietlibc_bincache
588 # OLD_CC="${UTILS_CC}"
589 # UTILS_CC="${TEMP}/diet/bin/diet ${UTILS_CC}"
594 ./configure --disable-combined --enable-insmod-static >> ${DEBUGFILE} 2>&1 ||
595 gen_die 'Configuring modutils failed!'
598 print_info 1 'modutils: >> Compiling...'
599 compile_generic all utils
601 # if [ "${USE_DIETLIBC}" -eq '1' ]
603 # clean_dietlibc_bincache
604 # UTILS_CC="${OLD_CC}"
607 print_info 1 'modutils: >> Copying to cache...'
608 [ -f "${TEMP}/${MODUTILS_DIR}/insmod/insmod.static" ] ||
609 gen_die 'insmod.static does not exist after the compilation of modutils!'
610 strip "${TEMP}/${MODUTILS_DIR}/insmod/insmod.static" ||
611 gen_die 'Could not strip insmod.static!'
612 bzip2 "${TEMP}/${MODUTILS_DIR}/insmod/insmod.static" ||
613 gen_die 'Compression of insmod.static failed!'
614 mv "${TEMP}/${MODUTILS_DIR}/insmod/insmod.static.bz2" "${MODUTILS_BINCACHE}" ||
615 gen_die 'Could not move the compressed insmod binary to the package cache!'
618 rm -rf "${MODULE_INIT_TOOLS_DIR}" > /dev/null
622 compile_module_init_tools() {
623 # I've disabled dietlibc support for the time being since the
624 # version we use misses a few needed system calls.
627 if [ ! -f "${MODULE_INIT_TOOLS_BINCACHE}" ]
629 [ ! -f "${MODULE_INIT_TOOLS_SRCTAR}" ] &&
630 gen_die "Could not find module-init-tools source tarball: ${MODULE_INIT_TOOLS_SRCTAR}"
632 rm -rf "${MODULE_INIT_TOOLS_DIR}"
633 /bin/tar -jxpf "${MODULE_INIT_TOOLS_SRCTAR}"
634 [ ! -d "${MODULE_INIT_TOOLS_DIR}" ] &&
635 gen_die "Module-init-tools directory ${MODULE_INIT_TOOLS_DIR} is invalid"
636 cd "${MODULE_INIT_TOOLS_DIR}"
637 print_info 1 'module-init-tools: >> Configuring'
639 # if [ "${USE_DIETLIBC}" -eq '1' ]
641 # extract_dietlibc_bincache
642 # OLD_CC="${UTILS_CC}"
643 # UTILS_CC="${TEMP}/diet/bin/diet ${UTILS_CC}"
647 ./configure >> ${DEBUGFILE} 2>&1 ||
648 gen_die 'Configure of module-init-tools failed!'
650 print_info 1 ' >> Compiling...'
651 compile_generic "all" utils
653 # if [ "${USE_DIETLIBC}" -eq '1' ]
655 # clean_dietlibc_bincache
656 # UTILS_CC="${OLD_CC}"
659 print_info 1 ' >> Copying to cache...'
660 [ -f "${TEMP}/${MODULE_INIT_TOOLS_DIR}/insmod.static" ] ||
661 gen_die 'insmod.static does not exist after the compilation of module-init-tools!'
662 strip "${TEMP}/${MODULE_INIT_TOOLS_DIR}/insmod.static" ||
663 gen_die 'Could not strip insmod.static!'
664 bzip2 "${TEMP}/${MODULE_INIT_TOOLS_DIR}/insmod.static" ||
665 gen_die 'Compression of insmod.static failed!'
666 [ -f "${TEMP}/${MODULE_INIT_TOOLS_DIR}/insmod.static.bz2" ] ||
667 gen_die 'Could not find compressed insmod.static.bz2 binary!'
668 mv "${TEMP}/${MODULE_INIT_TOOLS_DIR}/insmod.static.bz2" "${MODULE_INIT_TOOLS_BINCACHE}" ||
669 gen_die 'Could not move the compressed insmod binary to the package cache!'
672 rm -rf "${MODULE_INIT_TOOLS_DIR}" > /dev/null
677 # I've disabled dietlibc support for the time being since the
678 # version we use misses a few needed system calls.
681 if [ ! -f "${DEVFSD_BINCACHE}" ]
683 [ ! -f "${DEVFSD_SRCTAR}" ] &&
684 gen_die "Could not find devfsd source tarball: ${DEVFSD_SRCTAR}"
686 rm -rf "${DEVFSD_DIR}"
687 /bin/tar -jxpf "${DEVFSD_SRCTAR}"
688 [ ! -d "${DEVFSD_DIR}" ] &&
689 gen_die "Devfsd directory ${DEVFSD_DIR} invalid"
692 # if [ "${USE_DIETLIBC}" -eq '1' ]
694 # extract_dietlibc_bincache
695 # OLD_CC="${UTILS_CC}"
696 # UTILS_CC="${TEMP}/diet/bin/diet ${UTILS_CC}"
699 print_info 1 'devfsd: >> Compiling...'
700 # if [ "${USE_DIETLIBC}" -eq '1' ]
702 # compile_generic 'has_dlopen=0 has_rpcsvc=0' utils
704 compile_generic 'LDFLAGS=-static' utils
707 # if [ "${USE_DIETLIBC}" -eq '1' ]
709 # clean_dietlibc_bincache
710 # UTILS_CC="${OLD_CC}"
713 print_info 1 ' >> Copying to cache...'
714 [ -f "${TEMP}/${DEVFSD_DIR}/devfsd" ] || gen_die 'The devfsd executable does not exist after the compilation of devfsd!'
715 strip "${TEMP}/${DEVFSD_DIR}/devfsd" || gen_die 'Could not strip devfsd!'
716 bzip2 "${TEMP}/${DEVFSD_DIR}/devfsd" || gen_die 'Compression of devfsd failed!'
717 [ -f "${TEMP}/${DEVFSD_DIR}/devfsd.bz2" ] || gen_die 'Could not find compressed devfsd.bz2 binary!'
718 mv "${TEMP}/${DEVFSD_DIR}/devfsd.bz2" "${DEVFSD_BINCACHE}" || gen_die 'Could not move compressed binary to the package cache!'
720 # [ -f "${TEMP}/${DEVFSD_DIR}/devfsd.conf" ] || gen_die 'devfsd.conf does not exist after the compilation of devfsd!'
721 # bzip2 "${TEMP}/${DEVFSD_DIR}/devfsd.conf" || gen_die 'Compression of devfsd.conf failed!'
722 # mv "${TEMP}/${DEVFSD_DIR}/devfsd.conf.bz2" "${DEVFSD_CONF_BINCACHE}" || gen_die 'Could not move the compressed configuration to the package cache!'
725 rm -rf "${DEVFSD_DIR}" > /dev/null
729 compile_device_mapper() {
730 if [ ! -f "${DEVICE_MAPPER_BINCACHE}" ]
732 [ ! -f "${DEVICE_MAPPER_SRCTAR}" ] &&
733 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!"
735 rm -rf "${DEVICE_MAPPER_DIR}"
736 /bin/tar -zxpf "${DEVICE_MAPPER_SRCTAR}"
737 [ ! -d "${DEVICE_MAPPER_DIR}" ] &&
738 gen_die "device-mapper directory ${DEVICE_MAPPER_DIR} invalid"
739 cd "${DEVICE_MAPPER_DIR}"
740 ./configure --prefix=${TEMP}/device-mapper --enable-static_link >> ${DEBUGFILE} 2>&1 ||
741 gen_die 'Configuring device-mapper failed!'
742 print_info 1 'device-mapper: >> Compiling...'
743 compile_generic '' utils
744 compile_generic 'install' utils
745 print_info 1 ' >> Copying to cache...'
747 rm -r "${TEMP}/device-mapper/man" ||
748 gen_die 'Could not remove manual pages!'
749 strip "${TEMP}/device-mapper/sbin/dmsetup" ||
750 gen_die 'Could not strip dmsetup binary!'
751 /bin/tar -jcpf "${DEVICE_MAPPER_BINCACHE}" device-mapper ||
752 gen_die 'Could not tar up the device-mapper binary!'
753 [ -f "${DEVICE_MAPPER_BINCACHE}" ] ||
754 gen_die 'device-mapper cache not created!'
756 rm -rf "${DEVICE_MAPPER_DIR}" > /dev/null
757 rm -rf "${TEMP}/device-mapper" > /dev/null
766 [ ! -f "${DIETLIBC_BINCACHE}" ] && BUILD_DIETLIBC=1
767 [ ! -f "${DIETLIBC_BINCACHE_TEMP}" ] && BUILD_DIETLIBC=1
768 if ! isTrue "${BUILD_DIETLIBC}"
770 ORIGTEMP=`cat "${DIETLIBC_BINCACHE_TEMP}"`
771 if [ "${TEMP}" != "${ORIGTEMP}" ]
773 print_warning 1 'dietlibc: Bincache exists, but the current temporary directory'
774 print_warning 1 ' is different to the original. Rebuilding.'
779 if [ "${BUILD_DIETLIBC}" -eq '1' ]
781 [ -f "${DIETLIBC_SRCTAR}" ] ||
782 gen_die "Could not find dietlibc source tarball: ${DIETLIBC_SRCTAR}"
784 rm -rf "${DIETLIBC_DIR}" > /dev/null
785 /bin/tar -jxpf "${DIETLIBC_SRCTAR}" ||
786 gen_die 'Could not extract dietlibc source tarball'
787 [ -d "${DIETLIBC_DIR}" ] ||
788 gen_die "Dietlibc directory ${DIETLIBC_DIR} is invalid!"
790 print_info 1 "dietlibc: >> Compiling..."
791 compile_generic "prefix=${TEMP}/diet" utils
792 print_info 1 " >> Installing..."
793 compile_generic "prefix=${TEMP}/diet install" utils
794 print_info 1 " >> Copying to bincache..."
796 /bin/tar -jcpf "${DIETLIBC_BINCACHE}" diet ||
797 gen_die 'Could not tar up the dietlibc binary!'
798 [ -f "${DIETLIBC_BINCACHE}" ] ||
799 gen_die 'Dietlibc cache not created!'
800 echo "${TEMP}" > "${DIETLIBC_BINCACHE_TEMP}"
803 rm -rf "${DIETLIBC_DIR}" > /dev/null
804 rm -rf "${TEMP}/diet" > /dev/null
809 rm -rf "${KLIBC_DIR}" klibc-build
810 [ ! -f "${KLIBC_SRCTAR}" ] &&
811 gen_die "Could not find klibc tarball: ${KLIBC_SRCTAR}"
812 /bin/tar jxpf "${KLIBC_SRCTAR}" ||
813 gen_die 'Could not extract klibc tarball'
814 [ ! -d "${KLIBC_DIR}" ] &&
815 gen_die "klibc tarball ${KLIBC_SRCTAR} is invalid"
817 if [ -f ${GK_SHARE}/pkg/klibc-1.1.16-sparc2.patch ]
820 ${GK_SHARE}/pkg/klibc-1.1.16-sparc2.patch \
821 || gen_die "Failed patching klibc"
823 if [ -f "${GK_SHARE}/pkg/klibc-1.2.1-nostdinc-flags.patch" ]
826 ${GK_SHARE}/pkg/klibc-1.2.1-nostdinc-flags.patch \
827 || gen_die "Failed patching klibc"
830 # Don't install to "//lib" fix
831 sed -e 's:SHLIBDIR = /lib:SHLIBDIR = $(INSTALLROOT)$(INSTALLDIR)/$(KLIBCCROSS)lib:' -i scripts/Kbuild.install
832 print_info 1 'klibc: >> Compiling...'
833 ln -snf "${KERNEL_DIR}" linux || gen_die "Could not link to ${KERNEL_DIR}"
834 sed -i Makefile -e "s|prefix = /usr|prefix = ${TEMP}/klibc-build|g"
835 if [ "${UTILS_ARCH}" != '' ]
837 sed -i Makefile -e "s|export ARCH.*|export ARCH := ${UTILS_ARCH}|g"
839 if [ "${ARCH}" = 'um' ]
841 compile_generic "ARCH=um" utils
842 elif [ "${ARCH}" = 'x86' ]
844 compile_generic "ARCH=i386" utils
845 elif [ "${UTILS_CROSS_COMPILE}" != '' ]
847 compile_generic "CROSS=${UTILS_CROSS_COMPILE}" utils
849 compile_generic "" utils
852 compile_generic "install" utils
856 if [ ! -f "${UDEV_BINCACHE}" ]
858 # PPC fixup for 2.6.14
859 # Headers are moving around .. need to make them available
860 if [ "${VER}" -eq '2' -a "${PAT}" -eq '6' -a "${SUB}" -ge '14' ]
862 if [ "${ARCH}" = 'ppc' -o "${ARCH}" = 'ppc64' ]
865 echo 'Applying hack to workaround 2.6.14+ PPC header breakages...'
866 compile_generic 'include/asm' kernel
871 rm -rf "${UDEV_DIR}" udev
872 [ ! -f "${UDEV_SRCTAR}" ] &&
873 gen_die "Could not find udev tarball: ${UDEV_SRCTAR}"
874 /bin/tar -jxpf "${UDEV_SRCTAR}" ||
875 gen_die 'Could not extract udev tarball'
876 [ ! -d "${UDEV_DIR}" ] &&
877 gen_die "Udev tarball ${UDEV_SRCTAR} is invalid"
880 local extras="extras/scsi_id extras/volume_id extras/ata_id extras/run_directory extras/usb_id extras/floppy extras/cdrom_id extras/firmware"
881 # No selinux support yet .. someday maybe
882 #use selinux && myconf="${myconf} USE_SELINUX=true"
883 print_info 1 'udev: >> Compiling...'
885 if [ "${UTILS_ARCH}" = 'sparc' ]
887 echo "CFLAGS += -mcpu=v8 -mtune=v8" >> Makefile
889 # PPC fixup for 2.6.14
890 if [ "${VER}" -eq '2' -a "${PAT}" -eq '6' -a "${SUB}" -ge '14' ]
892 if [ "${ARCH}" = 'ppc' -o "${ARCH}" = 'ppc64' ]
894 # Headers are moving around .. need to make them available
895 echo "CFLAGS += -I${KERNEL_DIR}/arch/${ARCH}/include" >> Makefile
899 if [ "${ARCH}" = 'um' ]
901 compile_generic "EXTRAS=\"${extras}\" ARCH=um USE_KLIBC=true KLCC=${TEMP}/klibc-build/bin/klcc USE_LOG=false DEBUG=false udevdir=/dev all" utils
903 # This *needs* to be runtask, or else it breakson most
904 # architectures. -- wolf31o2
905 compile_generic "EXTRAS=\"${extras}\" USE_KLIBC=true KLCC=${TEMP}/klibc-build/bin/klcc USE_LOG=false DEBUG=false udevdir=/dev all" runtask
909 print_info 1 ' >> Installing...'
910 install -d "${TEMP}/udev/etc/udev" "${TEMP}/udev/sbin" "${TEMP}/udev/etc/udev/scripts" "${TEMP}/udev/etc/udev/rules.d" "${TEMP}/udev/etc/udev/permissions.d" "${TEMP}/udev/etc/udev/extras" "${TEMP}/udev/etc" "${TEMP}/udev/sbin" "${TEMP}/udev/usr/" "${TEMP}/udev/usr/bin" "${TEMP}/udev/usr/sbin"||
911 gen_die 'Could not create directory hierarchy'
913 install -c etc/udev/gentoo/udev.rules "${TEMP}/udev/etc/udev/rules.d/50-udev.rules" ||
914 gen_die 'Could not copy gentoo udev.rules to 50-udev.rules'
916 # compile_generic "EXTRAS=\"${extras}\" DESTDIR=${TEMP}/udev install-config" utils
917 # compile_generic "EXTRAS=\"${extras}\" DESTDIR=${TEMP}/udev install-bin" utils
918 # We are going to install our files by hand. Why are we doing this?
919 # Well, the udev ebuild does so, and I tend to think that Greg
920 # Kroah-Hartman knows what he's doing with regards to udev.
921 for i in udev udevd udevsend udevstart udevtrigger
923 install -D $i "${TEMP}/udev/sbin"
925 install -c extras/ide-devfs.sh "${TEMP}/udev/etc/udev/scripts"
926 install -c extras/scsi-devfs.sh "${TEMP}/udev/etc/udev/scripts"
927 install -c extras/raid-devfs.sh "${TEMP}/udev/etc/udev/scripts"
930 print_info 1 ' >> Copying to bincache...'
931 /bin/tar -cjf "${UDEV_BINCACHE}" * ||
932 gen_die 'Could not create binary cache'
935 rm -rf "${UDEV_DIR}" udev
937 # PPC fixup for 2.6.14
938 if [ "${VER}" -eq '2' -a "${PAT}" -eq '6' -a "${SUB}" -ge '14' ]
940 if [ "${ARCH}" = 'ppc' -o "${ARCH}" = 'ppc64' ]
943 compile_generic 'archclean' kernel
950 compile_e2fsprogs() {
951 if [ ! -f "${BLKID_BINCACHE}" ]
953 [ ! -f "${E2FSPROGS_SRCTAR}" ] &&
954 gen_die "Could not find e2fsprogs source tarball: ${E2FSPROGS_SRCTAR}. Please place it there, or place another version, changing /etc/genkernel.conf as necessary!"
956 rm -rf "${E2FSPROGS_DIR}"
957 tar -zxpf "${E2FSPROGS_SRCTAR}"
958 [ ! -d "${E2FSPROGS_DIR}" ] &&
959 gen_die "e2fsprogs directory ${E2FSPROGS_DIR} invalid"
960 cd "${E2FSPROGS_DIR}"
961 print_info 1 'e2fsprogs: >> Configuring...'
962 ./configure --with-ldopts=-static >> ${DEBUGFILE} 2>&1 ||
963 gen_die 'Configuring e2fsprogs failed!'
964 print_info 1 'e2fsprogs: >> Compiling...'
965 MAKE=${UTILS_MAKE} compile_generic "" ""
966 print_info 1 'blkid: >> Copying to cache...'
967 [ -f "${TEMP}/${E2FSPROGS_DIR}/misc/blkid" ] ||
968 gen_die 'Blkid executable does not exist!'
969 strip "${TEMP}/${E2FSPROGS_DIR}/misc/blkid" ||
970 gen_die 'Could not strip blkid binary!'
971 bzip2 "${TEMP}/${E2FSPROGS_DIR}/misc/blkid" ||
972 gen_die 'bzip2 compression of blkid failed!'
973 mv "${TEMP}/${E2FSPROGS_DIR}/misc/blkid.bz2" "${BLKID_BINCACHE}" ||
974 gen_die 'Could not copy the blkid binary to the package directory, does the directory exist?'
977 rm -rf "${E2FSPROGS_DIR}" > /dev/null