8 if [ "${KERNEL_CC}" != '' ]
10 ARGS="CC=\"${KERNEL_CC}\""
12 if [ "${KERNEL_LD}" != '' ]
14 ARGS="${ARGS} LD=\"${KERNEL_LD}\""
16 if [ "${KERNEL_AS}" != '' ]
18 ARGS="${ARGS} AS=\"${KERNEL_AS}\""
29 if [ "${UTILS_CC}" != '' ]
31 ARGS="CC=\"${UTILS_CC}\""
33 if [ "${UTILS_LD}" != '' ]
35 ARGS="${ARGS} LD=\"${UTILS_LD}\""
37 if [ "${UTILS_AS}" != '' ]
39 ARGS="${ARGS} AS=\"${UTILS_AS}\""
47 if [ "${UTILS_CC}" != '' ]
49 export CC="${UTILS_CC}"
51 if [ "${UTILS_LD}" != '' ]
53 export LD="${UTILS_LD}"
55 if [ "${UTILS_AS}" != '' ]
57 export AS="${UTILS_AS}"
63 if [ "${UTILS_CC}" != '' ]
67 if [ "${UTILS_LD}" != '' ]
71 if [ "${UTILS_AS}" != '' ]
79 if [ "${KERNEL_CC}" != '' ]
81 export CC="${KERNEL_CC}"
83 if [ "${KERNEL_LD}" != '' ]
85 export LD="${KERNEL_LD}"
87 if [ "${KERNEL_AS}" != '' ]
89 export AS="${KERNEL_AS}"
95 if [ "${KERNEL_CC}" != '' ]
99 if [ "${KERNEL_LD}" != '' ]
103 if [ "${KERNEL_AS}" != '' ]
111 [ "$#" -lt '2' ] && gen_die "compile_generic(): improper usage"
113 if [ "${2}" = 'kernel' ] || [ "${2}" = 'runtask' ]
117 elif [ "${2}" = 'utils' ]
123 if [ "${2}" == 'runtask' ]
125 print_info 2 "COMMAND: ${MAKE} ${MAKEOPTS} ${1}" 1 0 1
126 ${MAKE} -s ${MAKEOPTS/-j?/-j1} ${1}
128 elif [ "${DEBUGLEVEL}" -gt "1" ]
130 # Output to stdout and debugfile
131 print_info 2 "COMMAND: ${MAKE} ${MAKEOPTS} ${1}" 1 0 1
132 ${MAKE} ${MAKEOPTS} ${1} 2>&1 | tee -a ${DEBUGFILE}
135 # Output to debugfile only
136 print_info 2 "COMMAND: ${MAKE} ${MAKEOPTS} ${1}" 1 0 1
137 ${MAKE} ${MAKEOPTS} ${1} >> ${DEBUGFILE} 2>&1
140 [ "${RET}" -ne '0' ] && gen_die "Failed to compile the \"${1}\" target..."
143 if [ "${2}" = 'kernel' ]
146 elif [ "${2}" = 'utils' ]
152 extract_dietlibc_bincache() {
154 rm -rf "${TEMP}/diet" > /dev/null
155 tar -jxpf "${DIETLIBC_BINCACHE}" || gen_die "Could not extract dietlibc bincache!"
156 [ ! -d "${TEMP}/diet" ] && gen_die "${TEMP}/diet directory not found!"
160 clean_dietlibc_bincache() {
162 rm -rf "${TEMP}/diet" > /dev/null
167 # Only run ``make dep'' for 2.4 kernels
168 if [ "${VER}" -eq '2' -a "${PAT}" -le '4' ]
170 print_info 1 "kernel: >> Making dependencies..."
172 compile_generic dep kernel
177 print_info 1 " >> Compiling ${KV} modules..."
179 compile_generic modules kernel
180 export UNAME_MACHINE="${ARCH}"
181 # On 2.4 kernels, if MAKEOPTS > -j1 it can cause failures
182 if [ "${VER}" -eq '2' -a "${PAT}" -le '4' ]
184 MAKEOPTS_SAVE="${MAKEOPTS}"
187 [ "${INSTALL_MOD_PATH}" != '' ] && export INSTALL_MOD_PATH
188 compile_generic "modules_install" kernel
189 [ "${VER}" -eq '2' -a "${PAT}" -le '4' ] && MAKEOPTS="${MAKEOPTS_SAVE}"
195 [ "${KERNEL_MAKE}" = '' ] && gen_die "KERNEL_MAKE undefined - I don't know how to compile a kernel for this arch!"
197 print_info 1 " >> Compiling ${KV} ${KERNEL_MAKE_DIRECTIVE/_install/ [ install ]/}..."
198 compile_generic "${KERNEL_MAKE_DIRECTIVE}" kernel
199 if [ "${KERNEL_MAKE_DIRECTIVE_2}" != '' ]
201 print_info 1 " >> Starting supplimental compile of ${KV}: ${KERNEL_MAKE_DIRECTIVE_2}..."
202 compile_generic "${KERNEL_MAKE_DIRECTIVE_2}" kernel
204 if ! isTrue "${CMD_NOINSTALL}"
206 cp "${KERNEL_BINARY}" "/boot/kernel-${KV}" || gen_die 'Could not copy the kernel binary to /boot!'
207 cp "System.map" "/boot/System.map-${KV}" || gen_die 'Could not copy System.map to /boot!'
209 cp "${KERNEL_BINARY}" "${TEMP}/kernel-${KV}" || gen_die "Could not copy the kernel binary to ${TEMP}!"
210 cp "System.map" "${TEMP}/System.map-${KV}" || gen_die "Could not copy System.map to ${TEMP}!"
215 if [ ! -f "${BUSYBOX_BINCACHE}" ]
217 [ -f "${BUSYBOX_SRCTAR}" ] || gen_die "Could not find busybox source tarball: ${BUSYBOX_SRCTAR}!"
218 [ -f "${BUSYBOX_CONFIG}" ] || gen_die "Cound not find busybox config file: ${BUSYBOX_CONFIG}!"
220 rm -rf ${BUSYBOX_DIR} > /dev/null
221 tar -jxpf ${BUSYBOX_SRCTAR} || gen_die 'Could not extract busybox source tarball!'
222 [ -d "${BUSYBOX_DIR}" ] || gen_die 'Busybox directory ${BUSYBOX_DIR} is invalid!'
223 cp "${BUSYBOX_CONFIG}" "${BUSYBOX_DIR}/.config"
225 # Busybox and dietlibc don't play nice right now
226 # if [ "${USE_DIETLIBC}" -eq "1" ]
228 # extract_dietlibc_bincache
229 # OLD_CC="${UTILS_CC}"
230 # UTILS_CC="${TEMP}/diet/bin/diet ${UTILS_CC}"
232 print_info 1 'busybox: >> Configuring...'
233 yes '' | compile_generic oldconfig utils
234 print_info 1 'busybox: >> Compiling...'
235 compile_generic all utils
236 # Busybox and dietlibc don't play nice right now
237 # if [ "${USE_DIETLIBC}" -eq "1" ]
239 # clean_dietlibc_bincache
240 # UTILS_CC="${OLD_CC}"
242 print_info 1 'busybox: >> Copying to cache...'
243 [ -f "${TEMP}/${BUSYBOX_DIR}/busybox" ] || gen_die 'Busybox executable does not exist!'
244 strip "${TEMP}/${BUSYBOX_DIR}/busybox" || gen_die 'Could not strip busybox binary!'
245 bzip2 "${TEMP}/${BUSYBOX_DIR}/busybox" || gen_die 'bzip2 compression of busybox failed!'
246 mv "${TEMP}/${BUSYBOX_DIR}/busybox.bz2" "${BUSYBOX_BINCACHE}" || gen_die 'Could not copy the busybox binary to package directory, does the directory exist?'
249 rm -rf "${BUSYBOX_DIR}" > /dev/null
255 if [ ! -f "${MODUTILS_BINCACHE}" ]
257 [ ! -f "${MODUTILS_SRCTAR}" ] && gen_die "Could not find modutils source tarball: ${MODUTILS_SRCTAR}!"
259 rm -rf "${MODUTILS_DIR}"
260 tar -jxpf "${MODUTILS_SRCTAR}"
261 [ ! -d "${MODUTILS_DIR}" ] && gen_die "Modutils directory ${MODUTILS_DIR} invalid!"
263 print_info 1 "modutils: >> Configuring..."
265 if [ "${USE_DIETLIBC}" -eq '1' ]
267 extract_dietlibc_bincache
269 UTILS_CC="${TEMP}/diet/bin/diet ${UTILS_CC}"
274 ./configure --disable-combined --enable-insmod-static >> ${DEBUGFILE} 2>&1 || gen_die 'Configuring modutils failed!'
277 print_info 1 'modutils: >> Compiling...'
278 compile_generic all utils
280 if [ "${USE_DIETLIBC}" -eq '1' ]
282 clean_dietlibc_bincache
286 print_info 1 'modutils: >> Copying to cache...'
287 [ -f "${TEMP}/${MODUTILS_DIR}/insmod/insmod.static" ] || gen_die "insmod.static does not exist after the compilation of modutils!"
288 strip "${TEMP}/${MODUTILS_DIR}/insmod/insmod.static" || gen_die 'Could not strip insmod.static!'
289 bzip2 "${TEMP}/${MODUTILS_DIR}/insmod/insmod.static" || gen_die 'Compression of insmod.static failed!'
290 mv "${TEMP}/${MODUTILS_DIR}/insmod/insmod.static.bz2" "${MODUTILS_BINCACHE}" || gen_die 'Could not move the compressed insmod binary to the package cache!'
293 rm -rf "${MODULE_INIT_TOOLS_DIR}" > /dev/null
297 compile_module_init_tools() {
299 if [ ! -f "${MODULE_INIT_TOOLS_BINCACHE}" ]
301 [ ! -f "${MODULE_INIT_TOOLS_SRCTAR}" ] && gen_die "Could not find module-init-tools source tarball: ${MODULE_INIT_TOOLS_SRCTAR}"
303 rm -rf "${MODULE_INIT_TOOLS_DIR}"
304 tar -jxpf "${MODULE_INIT_TOOLS_SRCTAR}"
305 [ ! -d "${MODULE_INIT_TOOLS_DIR}" ] && gen_die "Module-init-tools directory ${MODULE_INIT_TOOLS_DIR} invalid"
306 cd "${MODULE_INIT_TOOLS_DIR}"
307 print_info 1 'module-init-tools: >> Configuring'
309 if [ "${USE_DIETLIBC}" -eq '1' ]
311 extract_dietlibc_bincache
313 UTILS_CC="${TEMP}/diet/bin/diet ${UTILS_CC}"
317 ./configure >> ${DEBUGFILE} 2>&1 || gen_die 'Configure of module-init-tools failed!'
319 print_info 1 ' >> Compiling...'
320 compile_generic "all" utils
322 if [ "${USE_DIETLIBC}" -eq '1' ]
324 clean_dietlibc_bincache
328 print_info 1 ' >> Copying to cache...'
329 [ -f "${TEMP}/${MODULE_INIT_TOOLS_DIR}/insmod.static" ] || gen_die 'insmod.static does not exist after the compilation of module-init-tools!'
330 strip "${TEMP}/${MODULE_INIT_TOOLS_DIR}/insmod.static" || gen_die 'Could not strip insmod.static!'
331 bzip2 "${TEMP}/${MODULE_INIT_TOOLS_DIR}/insmod.static" || gen_die 'Compression of insmod.static failed!'
332 [ -f "${TEMP}/${MODULE_INIT_TOOLS_DIR}/insmod.static.bz2" ] || gen_die 'Could not find compressed insmod.static.bz2 binary!'
333 mv "${TEMP}/${MODULE_INIT_TOOLS_DIR}/insmod.static.bz2" "${MODULE_INIT_TOOLS_BINCACHE}" || gen_die 'Could not move the compressed insmod binary to the package cache!'
336 rm -rf "${MODULE_INIT_TOOLS_DIR}" > /dev/null
342 if [ ! -f "${DEVFSD_BINCACHE}" -o ! -f "${DEVFSD_CONF_BINCACHE}" ]
344 [ ! -f "${DEVFSD_SRCTAR}" ] && gen_die "Could not find devfsd source tarball: ${DEVFSD_SRCTAR}"
346 rm -rf "${DEVFSD_DIR}"
347 tar -jxpf "${DEVFSD_SRCTAR}"
348 [ ! -d "${DEVFSD_DIR}" ] && gen_die "Devfsd directory ${DEVFSD_DIR} invalid"
351 if [ "${USE_DIETLIBC}" -eq '1' ]
353 extract_dietlibc_bincache
355 UTILS_CC="${TEMP}/diet/bin/diet ${UTILS_CC}"
358 print_info 1 'devfsd: >> Compiling...'
359 if [ "${USE_DIETLIBC}" -eq '1' ]
361 compile_generic 'has_dlopen=0 has_rpcsvc=0' utils
363 compile_generic 'LDFLAGS=-static' utils
366 if [ "${USE_DIETLIBC}" -eq '1' ]
368 clean_dietlibc_bincache
372 print_info 1 ' >> Copying to cache...'
373 [ -f "${TEMP}/${DEVFSD_DIR}/devfsd" ] || gen_die 'The devfsd executable does not exist after the compilation of devfsd!'
374 strip "${TEMP}/${DEVFSD_DIR}/devfsd" || gen_die 'Could not strip devfsd!'
375 bzip2 "${TEMP}/${DEVFSD_DIR}/devfsd" || gen_die 'Compression of devfsd failed!'
376 [ -f "${TEMP}/${DEVFSD_DIR}/devfsd.bz2" ] || gen_die 'Could not find compressed devfsd.bz2 binary!'
377 mv "${TEMP}/${DEVFSD_DIR}/devfsd.bz2" "${DEVFSD_BINCACHE}" || gen_die 'Could not move compressed binary to the package cache!'
379 [ -f "${TEMP}/${DEVFSD_DIR}/devfsd.conf" ] || gen_die 'devfsd.conf does not exist after the compilation of devfsd!'
380 bzip2 "${TEMP}/${DEVFSD_DIR}/devfsd.conf" || gen_die 'Compression of devfsd.conf failed!'
381 mv "${TEMP}/${DEVFSD_DIR}/devfsd.conf.bz2" "${DEVFSD_CONF_BINCACHE}" || gen_die 'Could not move the compressed configuration to the package cache!'
384 rm -rf "${DEVFSD_DIR}" > /dev/null
393 [ ! -f "${DIETLIBC_BINCACHE}" ] && BUILD_DIETLIBC=1
394 [ ! -f "${DIETLIBC_BINCACHE_TEMP}" ] && BUILD_DIETLIBC=1
395 if ! isTrue "${BUILD_DIETLIBC}"
397 ORIGTEMP=`cat "${DIETLIBC_BINCACHE_TEMP}"`
398 if [ "${TEMP}" != "${ORIGTEMP}" ]
400 print_warning 1 'dietlibc: Bincache exists, but the current temporary directory'
401 print_warning 1 ' is different to the original. Rebuilding.'
406 if [ "${BUILD_DIETLIBC}" -eq '1' ]
408 [ -f "${DIETLIBC_SRCTAR}" ] || gen_die "Could not find dietlibc source tarball: ${DIETLIBC_SRCTAR}"
410 rm -rf "${DIETLIBC_DIR}" > /dev/null
411 tar -jxpf ${DIETLIBC_SRCTAR} || gen_die "Could not extract dietlibc source tarball"
412 [ -d "${DIETLIBC_DIR}" ] || gen_die "Dietlibc directory ${DIETLIBC_DIR} is invalid!"
414 print_info 1 "dietlibc: >> Compiling..."
415 compile_generic "prefix=${TEMP}/diet" utils
416 print_info 1 " >> Installing..."
417 compile_generic "prefix=${TEMP}/diet install" utils
418 print_info 1 " >> Copying to bincache..."
420 tar -jcpf "${DIETLIBC_BINCACHE}" diet || gen_die "Could not tar up the dietlibc binary!"
421 [ -f "${DIETLIBC_BINCACHE}" ] || gen_die 'Dietlibc cache not created!'
422 echo "${TEMP}" > "${DIETLIBC_BINCACHE_TEMP}"
425 rm -rf "${DIETLIBC_DIR}" > /dev/null
426 rm -rf "${TEMP}/diet" > /dev/null