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
517 # selinux global support in the future.
518 sed -i tools/Makefile -e "s|DMRAIDLIBS += -lselinux||g"
519 ###echo "DMRAIDLIBS += -lselinux -lsepol" >> tools/Makefile
520 mkdir -p "${TEMP}/dmraid"
521 print_info 1 'dmraid: >> Compiling...'
522 compile_generic '' utils
523 #compile_generic 'install' utils
524 mkdir ${TEMP}/dmraid/sbin
525 install -m 0755 -s tools/dmraid "${TEMP}/dmraid/sbin/dmraid"
526 print_info 1 ' >> Copying to bincache...'
528 /bin/tar -cjf "${DMRAID_BINCACHE}" sbin/dmraid ||
529 gen_die 'Could not create binary cache'
532 rm -rf "${TEMP}/device-mapper" > /dev/null
533 rm -rf "${DMRAID_DIR}" dmraid
538 [ -f "${SUSPEND_BINCACHE}" ] && return
539 [ -f "${SUSPEND_SRCTAR}" ] ||
540 gen_die "Could not find SUSPEND source tarball: ${SUSPEND_SRCTAR}! Please place it there, or place another version, changing /etc/genkernel.conf as necessary!"
542 rm -rf ${SUSPEND_DIR} > /dev/null
543 /bin/tar -zxpf ${SUSPEND_SRCTAR} ||
544 gen_die 'Could not extract SUSPEND source tarball!'
545 [ -d "${SUSPEND_DIR}" ] ||
546 gen_die "SUSPEND directory ${DMRAID_DIR} is invalid!"
549 if [ -f "${GK_SHARE}/pkg/suspend-0.5-Makefile.patch" ]
552 ${GK_SHARE}/pkg/suspend-0.5-Makefile.patch \
553 || gen_die "Failed patching suspend"
556 print_info 1 'suspend: >> Compiling...'
557 compile_generic '' utils CC_FLAGS= LD_FLAGS=
559 print_info 1 ' >> Copying to bincache...'
560 mkdir -p "${TEMP}/bincache/sbin"
561 cp -f resume "${TEMP}/bincache/sbin" ||
562 gen_die 'Could not copy resume binary'
563 cd "${TEMP}/bincache"
564 /bin/tar -cjf "${SUSPEND_BINCACHE}" * ||
565 gen_die 'Could not create suspend binary cache'
567 rm -rf bincache suspend-0.5
571 # I've disabled dietlibc support for the time being since the
572 # version we use misses a few needed system calls.
575 if [ ! -f "${MODUTILS_BINCACHE}" ]
577 [ ! -f "${MODUTILS_SRCTAR}" ] &&
578 gen_die "Could not find modutils source tarball: ${MODUTILS_SRCTAR}!"
580 rm -rf "${MODUTILS_DIR}"
581 /bin/tar -jxpf "${MODUTILS_SRCTAR}"
582 [ ! -d "${MODUTILS_DIR}" ] &&
583 gen_die "Modutils directory ${MODUTILS_DIR} invalid!"
585 print_info 1 "modutils: >> Configuring..."
587 # if [ "${USE_DIETLIBC}" -eq '1' ]
589 # extract_dietlibc_bincache
590 # OLD_CC="${UTILS_CC}"
591 # UTILS_CC="${TEMP}/diet/bin/diet ${UTILS_CC}"
596 ./configure --disable-combined --enable-insmod-static >> ${DEBUGFILE} 2>&1 ||
597 gen_die 'Configuring modutils failed!'
600 print_info 1 'modutils: >> Compiling...'
601 compile_generic all utils
603 # if [ "${USE_DIETLIBC}" -eq '1' ]
605 # clean_dietlibc_bincache
606 # UTILS_CC="${OLD_CC}"
609 print_info 1 'modutils: >> Copying to cache...'
610 [ -f "${TEMP}/${MODUTILS_DIR}/insmod/insmod.static" ] ||
611 gen_die 'insmod.static does not exist after the compilation of modutils!'
612 strip "${TEMP}/${MODUTILS_DIR}/insmod/insmod.static" ||
613 gen_die 'Could not strip insmod.static!'
614 bzip2 "${TEMP}/${MODUTILS_DIR}/insmod/insmod.static" ||
615 gen_die 'Compression of insmod.static failed!'
616 mv "${TEMP}/${MODUTILS_DIR}/insmod/insmod.static.bz2" "${MODUTILS_BINCACHE}" ||
617 gen_die 'Could not move the compressed insmod binary to the package cache!'
620 rm -rf "${MODULE_INIT_TOOLS_DIR}" > /dev/null
624 compile_module_init_tools() {
625 # I've disabled dietlibc support for the time being since the
626 # version we use misses a few needed system calls.
629 if [ ! -f "${MODULE_INIT_TOOLS_BINCACHE}" ]
631 [ ! -f "${MODULE_INIT_TOOLS_SRCTAR}" ] &&
632 gen_die "Could not find module-init-tools source tarball: ${MODULE_INIT_TOOLS_SRCTAR}"
634 rm -rf "${MODULE_INIT_TOOLS_DIR}"
635 /bin/tar -jxpf "${MODULE_INIT_TOOLS_SRCTAR}"
636 [ ! -d "${MODULE_INIT_TOOLS_DIR}" ] &&
637 gen_die "Module-init-tools directory ${MODULE_INIT_TOOLS_DIR} is invalid"
638 cd "${MODULE_INIT_TOOLS_DIR}"
639 print_info 1 'module-init-tools: >> Configuring'
641 # if [ "${USE_DIETLIBC}" -eq '1' ]
643 # extract_dietlibc_bincache
644 # OLD_CC="${UTILS_CC}"
645 # UTILS_CC="${TEMP}/diet/bin/diet ${UTILS_CC}"
649 ./configure >> ${DEBUGFILE} 2>&1 ||
650 gen_die 'Configure of module-init-tools failed!'
652 print_info 1 ' >> Compiling...'
653 compile_generic "all" utils
655 # if [ "${USE_DIETLIBC}" -eq '1' ]
657 # clean_dietlibc_bincache
658 # UTILS_CC="${OLD_CC}"
661 print_info 1 ' >> Copying to cache...'
662 [ -f "${TEMP}/${MODULE_INIT_TOOLS_DIR}/insmod.static" ] ||
663 gen_die 'insmod.static does not exist after the compilation of module-init-tools!'
664 strip "${TEMP}/${MODULE_INIT_TOOLS_DIR}/insmod.static" ||
665 gen_die 'Could not strip insmod.static!'
666 bzip2 "${TEMP}/${MODULE_INIT_TOOLS_DIR}/insmod.static" ||
667 gen_die 'Compression of insmod.static failed!'
668 [ -f "${TEMP}/${MODULE_INIT_TOOLS_DIR}/insmod.static.bz2" ] ||
669 gen_die 'Could not find compressed insmod.static.bz2 binary!'
670 mv "${TEMP}/${MODULE_INIT_TOOLS_DIR}/insmod.static.bz2" "${MODULE_INIT_TOOLS_BINCACHE}" ||
671 gen_die 'Could not move the compressed insmod binary to the package cache!'
674 rm -rf "${MODULE_INIT_TOOLS_DIR}" > /dev/null
679 # I've disabled dietlibc support for the time being since the
680 # version we use misses a few needed system calls.
683 if [ ! -f "${DEVFSD_BINCACHE}" ]
685 [ ! -f "${DEVFSD_SRCTAR}" ] &&
686 gen_die "Could not find devfsd source tarball: ${DEVFSD_SRCTAR}"
688 rm -rf "${DEVFSD_DIR}"
689 /bin/tar -jxpf "${DEVFSD_SRCTAR}"
690 [ ! -d "${DEVFSD_DIR}" ] &&
691 gen_die "Devfsd directory ${DEVFSD_DIR} invalid"
694 # if [ "${USE_DIETLIBC}" -eq '1' ]
696 # extract_dietlibc_bincache
697 # OLD_CC="${UTILS_CC}"
698 # UTILS_CC="${TEMP}/diet/bin/diet ${UTILS_CC}"
701 print_info 1 'devfsd: >> Compiling...'
702 # if [ "${USE_DIETLIBC}" -eq '1' ]
704 # compile_generic 'has_dlopen=0 has_rpcsvc=0' utils
706 compile_generic 'LDFLAGS=-static' utils
709 # if [ "${USE_DIETLIBC}" -eq '1' ]
711 # clean_dietlibc_bincache
712 # UTILS_CC="${OLD_CC}"
715 print_info 1 ' >> Copying to cache...'
716 [ -f "${TEMP}/${DEVFSD_DIR}/devfsd" ] || gen_die 'The devfsd executable does not exist after the compilation of devfsd!'
717 strip "${TEMP}/${DEVFSD_DIR}/devfsd" || gen_die 'Could not strip devfsd!'
718 bzip2 "${TEMP}/${DEVFSD_DIR}/devfsd" || gen_die 'Compression of devfsd failed!'
719 [ -f "${TEMP}/${DEVFSD_DIR}/devfsd.bz2" ] || gen_die 'Could not find compressed devfsd.bz2 binary!'
720 mv "${TEMP}/${DEVFSD_DIR}/devfsd.bz2" "${DEVFSD_BINCACHE}" || gen_die 'Could not move compressed binary to the package cache!'
722 # [ -f "${TEMP}/${DEVFSD_DIR}/devfsd.conf" ] || gen_die 'devfsd.conf does not exist after the compilation of devfsd!'
723 # bzip2 "${TEMP}/${DEVFSD_DIR}/devfsd.conf" || gen_die 'Compression of devfsd.conf failed!'
724 # mv "${TEMP}/${DEVFSD_DIR}/devfsd.conf.bz2" "${DEVFSD_CONF_BINCACHE}" || gen_die 'Could not move the compressed configuration to the package cache!'
727 rm -rf "${DEVFSD_DIR}" > /dev/null
731 compile_device_mapper() {
732 if [ ! -f "${DEVICE_MAPPER_BINCACHE}" ]
734 [ ! -f "${DEVICE_MAPPER_SRCTAR}" ] &&
735 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!"
737 rm -rf "${DEVICE_MAPPER_DIR}"
738 /bin/tar -zxpf "${DEVICE_MAPPER_SRCTAR}"
739 [ ! -d "${DEVICE_MAPPER_DIR}" ] &&
740 gen_die "device-mapper directory ${DEVICE_MAPPER_DIR} invalid"
741 cd "${DEVICE_MAPPER_DIR}"
742 mymapperconf="--enable-static_link"
743 ###mymapperconf="--disable-selinux ${mymapperconf}"
744 ./configure --prefix=${TEMP}/device-mapper ${mymapperconf} \
745 >> ${DEBUGFILE} 2>&1 || gen_die 'Configuring device-mapper failed!'
746 print_info 1 'device-mapper: >> Compiling...'
747 compile_generic '' utils
748 compile_generic 'install' utils
749 print_info 1 ' >> Copying to cache...'
751 rm -r "${TEMP}/device-mapper/man" ||
752 gen_die 'Could not remove manual pages!'
753 strip "${TEMP}/device-mapper/sbin/dmsetup" ||
754 gen_die 'Could not strip dmsetup binary!'
755 /bin/tar -jcpf "${DEVICE_MAPPER_BINCACHE}" device-mapper ||
756 gen_die 'Could not tar up the device-mapper binary!'
757 [ -f "${DEVICE_MAPPER_BINCACHE}" ] ||
758 gen_die 'device-mapper cache not created!'
760 rm -rf "${DEVICE_MAPPER_DIR}" > /dev/null
761 rm -rf "${TEMP}/device-mapper" > /dev/null
770 [ ! -f "${DIETLIBC_BINCACHE}" ] && BUILD_DIETLIBC=1
771 [ ! -f "${DIETLIBC_BINCACHE_TEMP}" ] && BUILD_DIETLIBC=1
772 if ! isTrue "${BUILD_DIETLIBC}"
774 ORIGTEMP=`cat "${DIETLIBC_BINCACHE_TEMP}"`
775 if [ "${TEMP}" != "${ORIGTEMP}" ]
777 print_warning 1 'dietlibc: Bincache exists, but the current temporary directory'
778 print_warning 1 ' is different to the original. Rebuilding.'
783 if [ "${BUILD_DIETLIBC}" -eq '1' ]
785 [ -f "${DIETLIBC_SRCTAR}" ] ||
786 gen_die "Could not find dietlibc source tarball: ${DIETLIBC_SRCTAR}"
788 rm -rf "${DIETLIBC_DIR}" > /dev/null
789 /bin/tar -jxpf "${DIETLIBC_SRCTAR}" ||
790 gen_die 'Could not extract dietlibc source tarball'
791 [ -d "${DIETLIBC_DIR}" ] ||
792 gen_die "Dietlibc directory ${DIETLIBC_DIR} is invalid!"
794 print_info 1 "dietlibc: >> Compiling..."
795 compile_generic "prefix=${TEMP}/diet" utils
796 print_info 1 " >> Installing..."
797 compile_generic "prefix=${TEMP}/diet install" utils
798 print_info 1 " >> Copying to bincache..."
800 /bin/tar -jcpf "${DIETLIBC_BINCACHE}" diet ||
801 gen_die 'Could not tar up the dietlibc binary!'
802 [ -f "${DIETLIBC_BINCACHE}" ] ||
803 gen_die 'Dietlibc cache not created!'
804 echo "${TEMP}" > "${DIETLIBC_BINCACHE_TEMP}"
807 rm -rf "${DIETLIBC_DIR}" > /dev/null
808 rm -rf "${TEMP}/diet" > /dev/null
813 rm -rf "${KLIBC_DIR}" klibc-build
814 [ ! -f "${KLIBC_SRCTAR}" ] &&
815 gen_die "Could not find klibc tarball: ${KLIBC_SRCTAR}"
816 /bin/tar jxpf "${KLIBC_SRCTAR}" ||
817 gen_die 'Could not extract klibc tarball'
818 [ ! -d "${KLIBC_DIR}" ] &&
819 gen_die "klibc tarball ${KLIBC_SRCTAR} is invalid"
821 if [ -f ${GK_SHARE}/pkg/klibc-1.1.16-sparc2.patch ]
824 ${GK_SHARE}/pkg/klibc-1.1.16-sparc2.patch \
825 || gen_die "Failed patching klibc"
827 if [ -f "${GK_SHARE}/pkg/klibc-1.2.1-nostdinc-flags.patch" ]
830 ${GK_SHARE}/pkg/klibc-1.2.1-nostdinc-flags.patch \
831 || gen_die "Failed patching klibc"
834 # Don't install to "//lib" fix
835 sed -e 's:SHLIBDIR = /lib:SHLIBDIR = $(INSTALLROOT)$(INSTALLDIR)/$(KLIBCCROSS)lib:' -i scripts/Kbuild.install
836 print_info 1 'klibc: >> Compiling...'
837 ln -snf "${KERNEL_DIR}" linux || gen_die "Could not link to ${KERNEL_DIR}"
838 sed -i Makefile -e "s|prefix = /usr|prefix = ${TEMP}/klibc-build|g"
839 if [ "${UTILS_ARCH}" != '' ]
841 sed -i Makefile -e "s|export ARCH.*|export ARCH := ${UTILS_ARCH}|g"
843 if [ "${ARCH}" = 'um' ]
845 compile_generic "ARCH=um" utils
846 elif [ "${ARCH}" = 'x86' ]
848 compile_generic "ARCH=i386" utils
849 elif [ "${UTILS_CROSS_COMPILE}" != '' ]
851 compile_generic "CROSS=${UTILS_CROSS_COMPILE}" utils
853 compile_generic "" utils
856 compile_generic "install" utils
860 if [ ! -f "${UDEV_BINCACHE}" ]
862 # PPC fixup for 2.6.14
863 # Headers are moving around .. need to make them available
864 if [ "${VER}" -eq '2' -a "${PAT}" -eq '6' -a "${SUB}" -ge '14' ]
866 if [ "${ARCH}" = 'ppc' -o "${ARCH}" = 'ppc64' ]
869 echo 'Applying hack to workaround 2.6.14+ PPC header breakages...'
870 compile_generic 'include/asm' kernel
875 rm -rf "${UDEV_DIR}" udev
876 [ ! -f "${UDEV_SRCTAR}" ] &&
877 gen_die "Could not find udev tarball: ${UDEV_SRCTAR}"
878 /bin/tar -jxpf "${UDEV_SRCTAR}" ||
879 gen_die 'Could not extract udev tarball'
880 [ ! -d "${UDEV_DIR}" ] &&
881 gen_die "Udev tarball ${UDEV_SRCTAR} is invalid"
884 local extras="extras/scsi_id extras/volume_id extras/ata_id extras/run_directory extras/usb_id extras/floppy extras/cdrom_id extras/firmware"
885 # No selinux support yet .. someday maybe
886 #use selinux && myconf="${myconf} USE_SELINUX=true"
887 print_info 1 'udev: >> Compiling...'
889 if [ "${UTILS_ARCH}" = 'sparc' ]
891 echo "CFLAGS += -mcpu=v8 -mtune=v8" >> Makefile
893 # PPC fixup for 2.6.14
894 if [ "${VER}" -eq '2' -a "${PAT}" -eq '6' -a "${SUB}" -ge '14' ]
896 if [ "${ARCH}" = 'ppc' -o "${ARCH}" = 'ppc64' ]
898 # Headers are moving around .. need to make them available
899 echo "CFLAGS += -I${KERNEL_DIR}/arch/${ARCH}/include" >> Makefile
903 if [ "${ARCH}" = 'um' ]
905 compile_generic "EXTRAS=\"${extras}\" ARCH=um USE_KLIBC=true KLCC=${TEMP}/klibc-build/bin/klcc USE_LOG=false DEBUG=false udevdir=/dev all" utils
907 # This *needs* to be runtask, or else it breakson most
908 # architectures. -- wolf31o2
909 compile_generic "EXTRAS=\"${extras}\" USE_KLIBC=true KLCC=${TEMP}/klibc-build/bin/klcc USE_LOG=false DEBUG=false udevdir=/dev all" runtask
913 print_info 1 ' >> Installing...'
914 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"||
915 gen_die 'Could not create directory hierarchy'
917 install -c etc/udev/gentoo/udev.rules "${TEMP}/udev/etc/udev/rules.d/50-udev.rules" ||
918 gen_die 'Could not copy gentoo udev.rules to 50-udev.rules'
920 # compile_generic "EXTRAS=\"${extras}\" DESTDIR=${TEMP}/udev install-config" utils
921 # compile_generic "EXTRAS=\"${extras}\" DESTDIR=${TEMP}/udev install-bin" utils
922 # We are going to install our files by hand. Why are we doing this?
923 # Well, the udev ebuild does so, and I tend to think that Greg
924 # Kroah-Hartman knows what he's doing with regards to udev.
925 for i in udev udevd udevsend udevstart udevtrigger
927 install -D $i "${TEMP}/udev/sbin"
929 install -c extras/ide-devfs.sh "${TEMP}/udev/etc/udev/scripts"
930 install -c extras/scsi-devfs.sh "${TEMP}/udev/etc/udev/scripts"
931 install -c extras/raid-devfs.sh "${TEMP}/udev/etc/udev/scripts"
934 print_info 1 ' >> Copying to bincache...'
935 /bin/tar -cjf "${UDEV_BINCACHE}" * ||
936 gen_die 'Could not create binary cache'
939 rm -rf "${UDEV_DIR}" udev
941 # PPC fixup for 2.6.14
942 if [ "${VER}" -eq '2' -a "${PAT}" -eq '6' -a "${SUB}" -ge '14' ]
944 if [ "${ARCH}" = 'ppc' -o "${ARCH}" = 'ppc64' ]
947 compile_generic 'archclean' kernel
954 compile_e2fsprogs() {
955 if [ ! -f "${BLKID_BINCACHE}" ]
957 [ ! -f "${E2FSPROGS_SRCTAR}" ] &&
958 gen_die "Could not find e2fsprogs source tarball: ${E2FSPROGS_SRCTAR}. Please place it there, or place another version, changing /etc/genkernel.conf as necessary!"
960 rm -rf "${E2FSPROGS_DIR}"
961 tar -zxpf "${E2FSPROGS_SRCTAR}"
962 [ ! -d "${E2FSPROGS_DIR}" ] &&
963 gen_die "e2fsprogs directory ${E2FSPROGS_DIR} invalid"
964 cd "${E2FSPROGS_DIR}"
965 print_info 1 'e2fsprogs: >> Configuring...'
966 ./configure --with-ldopts=-static >> ${DEBUGFILE} 2>&1 ||
967 gen_die 'Configuring e2fsprogs failed!'
968 print_info 1 'e2fsprogs: >> Compiling...'
969 MAKE=${UTILS_MAKE} compile_generic "" ""
970 print_info 1 'blkid: >> Copying to cache...'
971 [ -f "${TEMP}/${E2FSPROGS_DIR}/misc/blkid" ] ||
972 gen_die 'Blkid executable does not exist!'
973 strip "${TEMP}/${E2FSPROGS_DIR}/misc/blkid" ||
974 gen_die 'Could not strip blkid binary!'
975 bzip2 "${TEMP}/${E2FSPROGS_DIR}/misc/blkid" ||
976 gen_die 'bzip2 compression of blkid failed!'
977 mv "${TEMP}/${E2FSPROGS_DIR}/misc/blkid.bz2" "${BLKID_BINCACHE}" ||
978 gen_die 'Could not copy the blkid binary to the package directory, does the directory exist?'
981 rm -rf "${E2FSPROGS_DIR}" > /dev/null