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 compile_generic "modules_install" kernel
194 [ "${KERNEL_MAKE}" = "" ] && gen_die "KERNEL_MAKE undefined. Don't know how to compile kernel for arch."
196 print_info 1 "kernel: Starting compile of linux ${KV} ${KERNEL_MAKE_DIRECTIVE}"
197 compile_generic "${KERNEL_MAKE_DIRECTIVE}" kernel
198 if [ "${KERNEL_MAKE_DIRECTIVE_2}" != "" ]
200 print_info 1 "kernel: Starting suppliment compile of linux ${KV} ${KERNEL_MAKE_DIRECTIVE_2}"
201 compile_generic "${KERNEL_MAKE_DIRECTIVE_2}" kernel
203 cp "${KERNEL_BINARY}" "/boot/kernel-${KV}" || gen_die "Could not copy kernel binary to boot"
207 if [ ! -f "${BUSYBOX_BINCACHE}" ]
209 [ ! -f "${BUSYBOX_SRCTAR}" ] && gen_die "Could not find busybox source tarball: ${BUSYBOX_SRCTAR}"
210 [ ! -f "${BUSYBOX_CONFIG}" ] && gen_die "Cound not find busybox config file: ${BUSYBOX_CONFIG}"
212 rm -rf ${BUSYBOX_DIR} > /dev/null
213 tar -jxpf ${BUSYBOX_SRCTAR} || gen_die "Could not extract busybox source tarball"
214 [ ! -d "${BUSYBOX_DIR}" ] && gen_die "Busybox directory ${BUSYBOX_DIR} invalid"
215 cp "${BUSYBOX_CONFIG}" "${BUSYBOX_DIR}/.config"
217 # Busybox and dietlibc don't play nice right now
218 # if [ "${USE_DIETLIBC}" -eq "1" ]
220 # extract_dietlibc_bincache
221 # OLD_CC="${UTILS_CC}"
222 # UTILS_CC="${TEMP}/diet/bin/diet ${UTILS_CC}"
224 print_info 1 "Busybox: make oldconfig"
225 yes "" | compile_generic "oldconfig" utils
226 print_info 1 "Busybox: make all"
227 compile_generic "all" utils
228 # Busybox and dietlibc don't play nice right now
229 # if [ "${USE_DIETLIBC}" -eq "1" ]
231 # clean_dietlibc_bincache
232 # UTILS_CC="${OLD_CC}"
234 print_info 1 "Busybox: copying to bincache"
235 [ ! -f "${TEMP}/${BUSYBOX_DIR}/busybox" ] && gen_die "busybox executable does not exist after compile, error"
236 strip "${TEMP}/${BUSYBOX_DIR}/busybox" || gen_die "could not strip busybox"
237 bzip2 "${TEMP}/${BUSYBOX_DIR}/busybox" || gen_die "bzip2 compression of busybox failed"
238 [ ! -f "${TEMP}/${BUSYBOX_DIR}/busybox.bz2" ] && gen_die "could not find compressed busybox binary"
239 mv "${TEMP}/${BUSYBOX_DIR}/busybox.bz2" "${BUSYBOX_BINCACHE}" || gen_die "could not copy busybox binary to arch package directory, does the directory exist?"
241 print_info 1 "Busybox: cleaning up"
243 rm -rf "${BUSYBOX_DIR}" > /dev/null
245 print_info 1 "Busybox: Found bincache at ${BUSYBOX_BINCACHE}"
251 if [ ! -f "${MODUTILS_BINCACHE}" ]
253 [ ! -f "${MODUTILS_SRCTAR}" ] && gen_die "Could not find modutils source tarball: ${MODUTILS_SRCTAR}"
255 rm -rf "${MODUTILS_DIR}"
256 tar -jxpf "${MODUTILS_SRCTAR}"
257 [ ! -d "${MODUTILS_DIR}" ] && gen_die "Modutils directory ${MODUTILS_DIR} invalid"
259 print_info 1 "modutils: configure"
261 if [ "${USE_DIETLIBC}" -eq "1" ]
263 extract_dietlibc_bincache
265 UTILS_CC="${TEMP}/diet/bin/diet ${UTILS_CC}"
269 ./configure --disable-combined --enable-insmod-static >> ${DEBUGFILE} 2>&1 || gen_die "Configure of modutils failed"
272 print_info 1 "modutils: make all"
273 compile_generic "all" utils
275 if [ "${USE_DIETLIBC}" -eq "1" ]
277 clean_dietlibc_bincache
281 print_info 1 "modutils: copying to bincache"
282 [ ! -f "${TEMP}/${MODUTILS_DIR}/insmod/insmod.static" ] && gen_die "insmod.static does not exist after compilation of modutils"
283 strip "${TEMP}/${MODUTILS_DIR}/insmod/insmod.static" || gen_die "could not strip insmod.static"
284 bzip2 "${TEMP}/${MODUTILS_DIR}/insmod/insmod.static" || gen_die "compression of insmod.static failed"
285 [ ! -f "${TEMP}/${MODUTILS_DIR}/insmod/insmod.static.bz2" ] && gen_die "could not find compressed insmod.static.bz2 binary"
286 mv "${TEMP}/${MODUTILS_DIR}/insmod/insmod.static.bz2" "${MODUTILS_BINCACHE}" || gen_die "could not move compress binary to bincache"
288 print_info 1 "modutils: cleaning up"
290 rm -rf "${MODULE_INIT_TOOLS_DIR}" > /dev/null
292 print_info 1 "modutils: Found bincache at ${MODUTILS_BINCACHE}"
296 compile_module_init_tools() {
298 if [ ! -f "${MODULE_INIT_TOOLS_BINCACHE}" ]
300 [ ! -f "${MODULE_INIT_TOOLS_SRCTAR}" ] && gen_die "Could not find module-init-tools source tarball: ${MODULE_INIT_TOOLS_SRCTAR}"
302 rm -rf "${MODULE_INIT_TOOLS_DIR}"
303 tar -jxpf "${MODULE_INIT_TOOLS_SRCTAR}"
304 [ ! -d "${MODULE_INIT_TOOLS_DIR}" ] && gen_die "Module-init-tools directory ${MODULE_INIT_TOOLS_DIR} invalid"
305 cd "${MODULE_INIT_TOOLS_DIR}"
306 print_info 1 "module-init-tools: configure"
308 if [ "${USE_DIETLIBC}" -eq "1" ]
310 extract_dietlibc_bincache
312 UTILS_CC="${TEMP}/diet/bin/diet ${UTILS_CC}"
316 ./configure >> ${DEBUGFILE} 2>&1 || gen_die "Configure of module-init-tools failed"
318 print_info 1 "module-init-tools: make all"
319 compile_generic "all" utils
321 if [ "${USE_DIETLIBC}" -eq "1" ]
323 clean_dietlibc_bincache
327 print_info 1 "module-init-tools: copying to bincache"
328 [ ! -f "${TEMP}/${MODULE_INIT_TOOLS_DIR}/insmod.static" ] && gen_die "insmod.static does not exist after compilation of module-init-tools"
329 strip "${TEMP}/${MODULE_INIT_TOOLS_DIR}/insmod.static" || gen_die "could not strip insmod.static"
330 bzip2 "${TEMP}/${MODULE_INIT_TOOLS_DIR}/insmod.static" || gen_die "compression of insmod.static failed"
331 [ ! -f "${TEMP}/${MODULE_INIT_TOOLS_DIR}/insmod.static.bz2" ] && gen_die "could not find compressed insmod.static.bz2 binary"
332 mv "${TEMP}/${MODULE_INIT_TOOLS_DIR}/insmod.static.bz2" "${MODULE_INIT_TOOLS_BINCACHE}" || gen_die "could not move compressed binary to bincache"
334 print_info 1 "module-init-tools: cleaning up"
336 rm -rf "${MODULE_INIT_TOOLS_DIR}" > /dev/null
338 print_info 1 "module-init-tools: Found bincache at ${MODULE_INIT_TOOLS_BINCACHE}"
344 if [ ! -f "${DEVFSD_BINCACHE}" -o ! -f "${DEVFSD_CONF_BINCACHE}" ]
346 [ ! -f "${DEVFSD_SRCTAR}" ] && gen_die "Could not find devfsd source tarball: ${DEVFSD_SRCTAR}"
348 rm -rf "${DEVFSD_DIR}"
349 tar -jxpf "${DEVFSD_SRCTAR}"
350 [ ! -d "${DEVFSD_DIR}" ] && gen_die "Devfsd directory ${DEVFSD_DIR} invalid"
353 if [ "${USE_DIETLIBC}" -eq "1" ]
355 extract_dietlibc_bincache
357 UTILS_CC="${TEMP}/diet/bin/diet ${UTILS_CC}"
360 print_info 1 "devfsd: make all"
362 if [ "${USE_DIETLIBC}" -eq "1" ]
364 compile_generic "has_dlopen=0 has_rpcsvc=0" utils
366 compile_generic "LDFLAGS=-static" utils
369 if [ "${USE_DIETLIBC}" -eq "1" ]
371 clean_dietlibc_bincache
375 print_info 1 "devfsd: copying to bincache"
376 [ ! -f "${TEMP}/${DEVFSD_DIR}/devfsd" ] && gen_die "devfsd executable does not exist after compilation of devfsd"
377 strip "${TEMP}/${DEVFSD_DIR}/devfsd" || gen_die "could not strip devfsd"
378 bzip2 "${TEMP}/${DEVFSD_DIR}/devfsd" || gen_die "compression of devfsd failed"
379 [ ! -f "${TEMP}/${DEVFSD_DIR}/devfsd.bz2" ] && gen_die "could not find compressed devfsd.bz2 binary"
380 mv "${TEMP}/${DEVFSD_DIR}/devfsd.bz2" "${DEVFSD_BINCACHE}" || gen_die "could not move compressed binary to bincache"
382 [ ! -f "${TEMP}/${DEVFSD_DIR}/devfsd.conf" ] && gen_die "devfsd.conf does not exist after compilation of devfsd"
383 bzip2 "${TEMP}/${DEVFSD_DIR}/devfsd.conf" || gen_die "compression of devfsd.conf failed"
384 [ ! -f "${TEMP}/${DEVFSD_DIR}/devfsd.conf.bz2" ] && gen_die "could not find compressed devfsd.conf.bz2 binary"
385 mv "${TEMP}/${DEVFSD_DIR}/devfsd.conf.bz2" "${DEVFSD_CONF_BINCACHE}" || gen_die "could not move compressed binary to bincache"
387 print_info 1 "devfsd: cleaning up"
389 rm -rf "${DEVFSD_DIR}" > /dev/null
391 print_info 1 "devfsd: Found bincache at ${DEVFSD_BINCACHE} and ${DEVFSD_CONF_BINCACHE}"
400 [ ! -f "${DIETLIBC_BINCACHE}" ] && BUILD_DIETLIBC=1
401 [ ! -f "${DIETLIBC_BINCACHE_TEMP}" ] && BUILD_DIETLIBC=1
402 if [ "${BUILD_DIETLIBC}" -eq "0" ]
404 ORIGTEMP=`cat "${DIETLIBC_BINCACHE_TEMP}"`
405 if [ "${TEMP}" != "${ORIGTEMP}" ]
407 print_info 1 "Dietlibc: Bincache exists, but current temp directory is different than original. Rebuilding."
412 if [ "${BUILD_DIETLIBC}" -eq "1" ]
414 [ ! -f "${DIETLIBC_SRCTAR}" ] && gen_die "Could not find dietlibc source tarball: ${DIETLIBC_SRCTAR}"
416 rm -rf "${DIETLIBC_DIR}" > /dev/null
417 tar -jxpf ${DIETLIBC_SRCTAR} || gen_die "Could not extract dietlibc source tarball"
418 [ ! -d "${DIETLIBC_DIR}" ] && gen_die "Dietlibc directory ${DIETLIBC_DIR} invalid"
420 print_info 1 "Dietlibc: make"
421 compile_generic "prefix=${TEMP}/diet" utils
422 print_info 1 "Dietlibc: installing"
423 compile_generic "prefix=${TEMP}/diet install" utils
424 print_info 1 "Dietlibc: copying to bincache"
426 tar -jcpf "${DIETLIBC_BINCACHE}" diet || gen_die "Could not tar up dietlibc bin"
427 [ ! -f "${DIETLIBC_BINCACHE}" ] && gen_die "bincache not created"
428 echo "${TEMP}" > "${DIETLIBC_BINCACHE_TEMP}"
430 print_info 1 "Dietlibc: cleaning up"
432 rm -rf "${DIETLIBC_DIR}" > /dev/null
433 rm -rf "${TEMP}/diet" > /dev/null
435 print_info 1 "Dietlibc: Found bincache at ${DIETLIBC_BINCACHE}"