8 if [ "${KERNEL_CC}" != "" ]
10 ARGS="CC=\"${KERNEL_CC}\""
12 if [ "${KERNEL_LD}" != "" ]
14 ARGS="${ARGS} LD=\"${KERNEL_LD}\""
17 if [ "${KERNEL_AS}" != "" ]
19 ARGS="${ARGS} AS=\"${KERNEL_AS}\""
30 if [ "${UTILS_CC}" != "" ]
32 ARGS="CC=\"${UTILS_CC}\""
34 if [ "${UTILS_LD}" != "" ]
36 ARGS="${ARGS} LD=\"${UTILS_LD}\""
39 if [ "${UTILS_AS}" != "" ]
41 ARGS="${ARGS} AS=\"${UTILS_AS}\""
49 if [ "${UTILS_CC}" != "" ]
51 export CC="${UTILS_CC}"
53 if [ "${UTILS_LD}" != "" ]
55 export LD="${UTILS_LD}"
57 if [ "${UTILS_AS}" != "" ]
59 export AS="${UTILS_AS}"
65 if [ "${UTILS_CC}" != "" ]
69 if [ "${UTILS_LD}" != "" ]
73 if [ "${UTILS_AS}" != "" ]
81 if [ "${KERNEL_CC}" != "" ]
83 export CC="${KERNEL_CC}"
85 if [ "${KERNEL_LD}" != "" ]
87 export LD="${KERNEL_LD}"
89 if [ "${KERNEL_AS}" != "" ]
91 export AS="${KERNEL_AS}"
97 if [ "${KERNEL_CC}" != "" ]
101 if [ "${KERNEL_LD}" != "" ]
105 if [ "${KERNEL_AS}" != "" ]
115 gen_die "compile_generic(): improper usage"
118 if [ "${2}" = "kernel" ]
122 elif [ "${2}" = "utils" ]
128 if [ "${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 "compile of ${1} failed"
143 if [ "${2}" = "kernel" ]
146 elif [ "${2}" = "utils" ]
153 extract_dietlibc_bincache() {
154 print_info 1 "extracting dietlibc bincache"
157 rm -rf "${TEMP}/diet" > /dev/null
158 tar -jxpf "${DIETLIBC_BINCACHE}" || gen_die "Could not extract dietlibc bincache"
159 [ ! -d "${TEMP}/diet" ] && gen_die "${TEMP}/diet directory not found"
163 clean_dietlibc_bincache() {
164 print_info 1 "cleaning up dietlibc bincache"
167 rm -rf "${TEMP}/diet" > /dev/null
173 # Only make dep for 2.4 kernels
174 if [ "${PAT}" -gt "4" ]
176 print_info 1 "kernel: skipping make dep for non 2.4 kernels"
178 print_info 1 "kernel: Making dependencies for linux ${KV}"
180 compile_generic "dep" kernel
185 print_info 1 "kernel: Starting compile of linux ${KV} modules"
187 compile_generic "modules" kernel
188 export UNAME_MACHINE="${ARCH}"
189 # On 2.4 kernels, if MAKEOPTS > -j1 it can cause failures
190 MAKEOPTS_SAVE="${MAKEOPTS}"
192 compile_generic "modules_install" kernel
193 MAKEOPTS="${MAKEOPTS_SAVE}"
199 [ "${KERNEL_MAKE}" = "" ] && gen_die "KERNEL_MAKE undefined. Don't know how to compile kernel for arch."
201 print_info 1 "kernel: Starting compile of linux ${KV} ${KERNEL_MAKE_DIRECTIVE}"
202 compile_generic "${KERNEL_MAKE_DIRECTIVE}" kernel
203 if [ "${KERNEL_MAKE_DIRECTIVE_2}" != "" ]
205 print_info 1 "kernel: Starting suppliment compile of linux ${KV} ${KERNEL_MAKE_DIRECTIVE_2}"
206 compile_generic "${KERNEL_MAKE_DIRECTIVE_2}" kernel
208 cp "${KERNEL_BINARY}" "/boot/kernel-${KV}" || gen_die "Could not copy kernel binary to boot"
212 if [ ! -f "${BUSYBOX_BINCACHE}" ]
214 [ ! -f "${BUSYBOX_SRCTAR}" ] && gen_die "Could not find busybox source tarball: ${BUSYBOX_SRCTAR}"
215 [ ! -f "${BUSYBOX_CONFIG}" ] && gen_die "Cound not find busybox config file: ${BUSYBOX_CONFIG}"
217 rm -rf ${BUSYBOX_DIR} > /dev/null
218 tar -jxpf ${BUSYBOX_SRCTAR} || gen_die "Could not extract busybox source tarball"
219 [ ! -d "${BUSYBOX_DIR}" ] && gen_die "Busybox directory ${BUSYBOX_DIR} invalid"
220 cp "${BUSYBOX_CONFIG}" "${BUSYBOX_DIR}/.config"
222 # Busybox and dietlibc don't play nice right now
223 # if [ "${USE_DIETLIBC}" -eq "1" ]
225 # extract_dietlibc_bincache
226 # OLD_CC="${UTILS_CC}"
227 # UTILS_CC="${TEMP}/diet/bin/diet ${UTILS_CC}"
229 print_info 1 "Busybox: make oldconfig"
230 yes "" | compile_generic "oldconfig" utils
231 print_info 1 "Busybox: make all"
232 compile_generic "all" utils
233 # Busybox and dietlibc don't play nice right now
234 # if [ "${USE_DIETLIBC}" -eq "1" ]
236 # clean_dietlibc_bincache
237 # UTILS_CC="${OLD_CC}"
239 print_info 1 "Busybox: copying to bincache"
240 [ ! -f "${TEMP}/${BUSYBOX_DIR}/busybox" ] && gen_die "busybox executable does not exist after compile, error"
241 strip "${TEMP}/${BUSYBOX_DIR}/busybox" || gen_die "could not strip busybox"
242 bzip2 "${TEMP}/${BUSYBOX_DIR}/busybox" || gen_die "bzip2 compression of busybox failed"
243 [ ! -f "${TEMP}/${BUSYBOX_DIR}/busybox.bz2" ] && gen_die "could not find compressed busybox binary"
244 mv "${TEMP}/${BUSYBOX_DIR}/busybox.bz2" "${BUSYBOX_BINCACHE}" || gen_die "could not copy busybox binary to arch package directory, does the directory exist?"
246 print_info 1 "Busybox: cleaning up"
248 rm -rf "${BUSYBOX_DIR}" > /dev/null
250 print_info 1 "Busybox: Found bincache at ${BUSYBOX_BINCACHE}"
256 if [ ! -f "${MODUTILS_BINCACHE}" ]
258 [ ! -f "${MODUTILS_SRCTAR}" ] && gen_die "Could not find modutils source tarball: ${MODUTILS_SRCTAR}"
260 rm -rf "${MODUTILS_DIR}"
261 tar -jxpf "${MODUTILS_SRCTAR}"
262 [ ! -d "${MODUTILS_DIR}" ] && gen_die "Modutils directory ${MODUTILS_DIR} invalid"
264 print_info 1 "modutils: configure"
266 if [ "${USE_DIETLIBC}" -eq "1" ]
268 extract_dietlibc_bincache
270 UTILS_CC="${TEMP}/diet/bin/diet ${UTILS_CC}"
274 ./configure --disable-combined --enable-insmod-static >> ${DEBUGFILE} 2>&1 || gen_die "Configure of modutils failed"
277 print_info 1 "modutils: make all"
278 compile_generic "all" utils
280 if [ "${USE_DIETLIBC}" -eq "1" ]
282 clean_dietlibc_bincache
286 print_info 1 "modutils: copying to bincache"
287 [ ! -f "${TEMP}/${MODUTILS_DIR}/insmod/insmod.static" ] && gen_die "insmod.static does not exist after 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 [ ! -f "${TEMP}/${MODUTILS_DIR}/insmod/insmod.static.bz2" ] && gen_die "could not find compressed insmod.static.bz2 binary"
291 mv "${TEMP}/${MODUTILS_DIR}/insmod/insmod.static.bz2" "${MODUTILS_BINCACHE}" || gen_die "could not move compress binary to bincache"
293 print_info 1 "modutils: cleaning up"
295 rm -rf "${MODULE_INIT_TOOLS_DIR}" > /dev/null
297 print_info 1 "modutils: Found bincache at ${MODUTILS_BINCACHE}"
301 compile_module_init_tools() {
303 if [ ! -f "${MODULE_INIT_TOOLS_BINCACHE}" ]
305 [ ! -f "${MODULE_INIT_TOOLS_SRCTAR}" ] && gen_die "Could not find module-init-tools source tarball: ${MODULE_INIT_TOOLS_SRCTAR}"
307 rm -rf "${MODULE_INIT_TOOLS_DIR}"
308 tar -jxpf "${MODULE_INIT_TOOLS_SRCTAR}"
309 [ ! -d "${MODULE_INIT_TOOLS_DIR}" ] && gen_die "Module-init-tools directory ${MODULE_INIT_TOOLS_DIR} invalid"
310 cd "${MODULE_INIT_TOOLS_DIR}"
311 print_info 1 "module-init-tools: configure"
313 if [ "${USE_DIETLIBC}" -eq "1" ]
315 extract_dietlibc_bincache
317 UTILS_CC="${TEMP}/diet/bin/diet ${UTILS_CC}"
321 ./configure >> ${DEBUGFILE} 2>&1 || gen_die "Configure of module-init-tools failed"
323 print_info 1 "module-init-tools: make all"
324 compile_generic "all" utils
326 if [ "${USE_DIETLIBC}" -eq "1" ]
328 clean_dietlibc_bincache
332 print_info 1 "module-init-tools: copying to bincache"
333 [ ! -f "${TEMP}/${MODULE_INIT_TOOLS_DIR}/insmod.static" ] && gen_die "insmod.static does not exist after compilation of module-init-tools"
334 strip "${TEMP}/${MODULE_INIT_TOOLS_DIR}/insmod.static" || gen_die "could not strip insmod.static"
335 bzip2 "${TEMP}/${MODULE_INIT_TOOLS_DIR}/insmod.static" || gen_die "compression of insmod.static failed"
336 [ ! -f "${TEMP}/${MODULE_INIT_TOOLS_DIR}/insmod.static.bz2" ] && gen_die "could not find compressed insmod.static.bz2 binary"
337 mv "${TEMP}/${MODULE_INIT_TOOLS_DIR}/insmod.static.bz2" "${MODULE_INIT_TOOLS_BINCACHE}" || gen_die "could not move compressed binary to bincache"
339 print_info 1 "module-init-tools: cleaning up"
341 rm -rf "${MODULE_INIT_TOOLS_DIR}" > /dev/null
343 print_info 1 "module-init-tools: Found bincache at ${MODULE_INIT_TOOLS_BINCACHE}"
349 if [ ! -f "${DEVFSD_BINCACHE}" -o ! -f "${DEVFSD_CONF_BINCACHE}" ]
351 [ ! -f "${DEVFSD_SRCTAR}" ] && gen_die "Could not find devfsd source tarball: ${DEVFSD_SRCTAR}"
353 rm -rf "${DEVFSD_DIR}"
354 tar -jxpf "${DEVFSD_SRCTAR}"
355 [ ! -d "${DEVFSD_DIR}" ] && gen_die "Devfsd directory ${DEVFSD_DIR} invalid"
358 if [ "${USE_DIETLIBC}" -eq "1" ]
360 extract_dietlibc_bincache
362 UTILS_CC="${TEMP}/diet/bin/diet ${UTILS_CC}"
365 print_info 1 "devfsd: make all"
367 if [ "${USE_DIETLIBC}" -eq "1" ]
369 compile_generic "has_dlopen=0 has_rpcsvc=0" utils
371 compile_generic "LDFLAGS=-static" utils
374 if [ "${USE_DIETLIBC}" -eq "1" ]
376 clean_dietlibc_bincache
380 print_info 1 "devfsd: copying to bincache"
381 [ ! -f "${TEMP}/${DEVFSD_DIR}/devfsd" ] && gen_die "devfsd executable does not exist after compilation of devfsd"
382 strip "${TEMP}/${DEVFSD_DIR}/devfsd" || gen_die "could not strip devfsd"
383 bzip2 "${TEMP}/${DEVFSD_DIR}/devfsd" || gen_die "compression of devfsd failed"
384 [ ! -f "${TEMP}/${DEVFSD_DIR}/devfsd.bz2" ] && gen_die "could not find compressed devfsd.bz2 binary"
385 mv "${TEMP}/${DEVFSD_DIR}/devfsd.bz2" "${DEVFSD_BINCACHE}" || gen_die "could not move compressed binary to bincache"
387 [ ! -f "${TEMP}/${DEVFSD_DIR}/devfsd.conf" ] && gen_die "devfsd.conf does not exist after compilation of devfsd"
388 bzip2 "${TEMP}/${DEVFSD_DIR}/devfsd.conf" || gen_die "compression of devfsd.conf failed"
389 [ ! -f "${TEMP}/${DEVFSD_DIR}/devfsd.conf.bz2" ] && gen_die "could not find compressed devfsd.conf.bz2 binary"
390 mv "${TEMP}/${DEVFSD_DIR}/devfsd.conf.bz2" "${DEVFSD_CONF_BINCACHE}" || gen_die "could not move compressed binary to bincache"
392 print_info 1 "devfsd: cleaning up"
394 rm -rf "${DEVFSD_DIR}" > /dev/null
396 print_info 1 "devfsd: Found bincache at ${DEVFSD_BINCACHE} and ${DEVFSD_CONF_BINCACHE}"
405 [ ! -f "${DIETLIBC_BINCACHE}" ] && BUILD_DIETLIBC=1
406 [ ! -f "${DIETLIBC_BINCACHE_TEMP}" ] && BUILD_DIETLIBC=1
407 if [ "${BUILD_DIETLIBC}" -eq "0" ]
409 ORIGTEMP=`cat "${DIETLIBC_BINCACHE_TEMP}"`
410 if [ "${TEMP}" != "${ORIGTEMP}" ]
412 print_info 1 "Dietlibc: Bincache exists, but current temp directory is different than original. Rebuilding."
417 if [ "${BUILD_DIETLIBC}" -eq "1" ]
419 [ ! -f "${DIETLIBC_SRCTAR}" ] && gen_die "Could not find dietlibc source tarball: ${DIETLIBC_SRCTAR}"
421 rm -rf "${DIETLIBC_DIR}" > /dev/null
422 tar -jxpf ${DIETLIBC_SRCTAR} || gen_die "Could not extract dietlibc source tarball"
423 [ ! -d "${DIETLIBC_DIR}" ] && gen_die "Dietlibc directory ${DIETLIBC_DIR} invalid"
425 print_info 1 "Dietlibc: make"
426 compile_generic "prefix=${TEMP}/diet" utils
427 print_info 1 "Dietlibc: installing"
428 compile_generic "prefix=${TEMP}/diet install" utils
429 print_info 1 "Dietlibc: copying to bincache"
431 tar -jcpf "${DIETLIBC_BINCACHE}" diet || gen_die "Could not tar up dietlibc bin"
432 [ ! -f "${DIETLIBC_BINCACHE}" ] && gen_die "bincache not created"
433 echo "${TEMP}" > "${DIETLIBC_BINCACHE_TEMP}"
435 print_info 1 "Dietlibc: cleaning up"
437 rm -rf "${DIETLIBC_DIR}" > /dev/null
438 rm -rf "${TEMP}/diet" > /dev/null
440 print_info 1 "Dietlibc: Found bincache at ${DIETLIBC_BINCACHE}"