From d0e44d05152d0b5324dbe315d646e3fd020d00eb Mon Sep 17 00:00:00 2001 From: luigi Date: Thu, 21 Jun 2001 08:49:46 +0000 Subject: Move handling of crunch* files into Makefile.conf, which is a better place to handle dependencies. Make another step at helping cross-compiling: when the user specifies an alternate source tree, the script takes care of creating include files and libraries for the new tree. Furthermore, build and use a version of the "config" program which matches the new sources. It takes a long time to create libraries, and it might even not do the right thing at once, there might be some dependencies that i have forgotten. At any rate, with this code i have been able to build a working picobsd image using -CURRENT sources on -STABLE MFC after: 3 days --- release/picobsd/build/Makefile.conf | 33 +++++++++++++++++------ release/picobsd/build/picobsd | 54 ++++++++++++++++++++++--------------- 2 files changed, 58 insertions(+), 29 deletions(-) (limited to 'release') diff --git a/release/picobsd/build/Makefile.conf b/release/picobsd/build/Makefile.conf index 231487a..dad3964 100644 --- a/release/picobsd/build/Makefile.conf +++ b/release/picobsd/build/Makefile.conf @@ -1,24 +1,41 @@ # $FreeBSD$ # -# Makefile for building PICOBSD kernels +# Makefile for building PICOBSD kernels and running crunchgen +# +# Needs SRC pointing to the source tree, +# MY_TREE ponting to my tree +# BUILDDIR pointing to the build directory +# PICO_OBJ pointing to the object directory +# When building a kernel, also need ${name} from the environment +# and CONFIG may indicate an alternate config program SRC?=/usr/src -CONF?=$(SRC)/sys/i386/conf +CONF?=${SRC}/sys/i386/conf +CONFIG?=config CONFFILE=PICOBSD-${name} -COMPILE=$(SRC)/sys/compile/$(CONFFILE) -KERNFILE=$(COMPILE)/kernel +COMPILE=${SRC}/sys/compile/${CONFFILE} +KERNFILE=${COMPILE}/kernel -$(KERNFILE): ${COMPILE} do_a_make_in_the_kernel_directory_anyways +${KERNFILE}: ${COMPILE} do_a_make_in_the_kernel_directory_anyways do_a_make_in_the_kernel_directory_anyways: (cd ${COMPILE}; make KERNEL=kernel -DNO_MODULES) ${COMPILE}: ${CONF}/${CONFFILE} - (cd ${CONF}; config $(CONFFILE); \ + (cd ${CONF}; ${CONFIG} ${CONFFILE}; \ cd ${COMPILE}; make KERNEL=kernel -DNO_MODULES depend ) -$(CONF)/${CONFFILE}: PICOBSD - cp PICOBSD $(CONF)/${CONFFILE} +${CONF}/${CONFFILE}: PICOBSD + cp ${.OODATE} ${.TARGET} + if [ -f PICOBSD.hints ] ; then cp PICOBSD.hints ${CONF}/PICOBSD.hints ; fi + +# This part creates crunch1.conf and crunch.mk from crunch.conf +${BUILDDIR}/crunch.mk: ${BUILDDIR}/crunch1.conf + -(cd ${BUILDDIR}/crunch ; \ + crunchgen -p ${PICO_OBJ} -m ${.TARGET} ${.OODATE} ) +${BUILDDIR}/crunch1.conf: ${MY_TREE}/crunch.conf + (cd ${BUILDDIR}/crunch ; cat ${.OODATE} | \ + sed -e "s@/usr/src@${SRC}@" -e "s@CWD@${MY_TREE}@" > ${.TARGET} ) diff --git a/release/picobsd/build/picobsd b/release/picobsd/build/picobsd index 1b2aebd..bb8ded9 100755 --- a/release/picobsd/build/picobsd +++ b/release/picobsd/build/picobsd @@ -345,10 +345,6 @@ init_stage1() { . ${MY_TREE}/config fi - export MFS_MOUNTPOINT # used in the makefiles. - export PICO_OBJ # used in the makefiles - export SRC # used in the makefiles. - PICO_OBJ=${OBJ}/picobsd/${TYPE} if [ ! -d ${BUILDDIR} ]; then @@ -367,8 +363,8 @@ init_stage1() { # Then copy it here and strip as much as possible. do_kernel() { # OK log "---> Preparing kernel \"$name\" in $MY_TREE" - export name SRC # used in this makefile - (cd $MY_TREE; make -v -f ${PICO_TREE}/build/Makefile.conf ) + (cd $MY_TREE; export name SRC CONFIG # used in this makefile ; + make -v -f ${PICO_TREE}/build/Makefile.conf ) cp -p ${SRC}/sys/compile/PICOBSD-${name}/kernel ${BUILDDIR}/kernel || \ fail $? missing_kernel (cd ${BUILDDIR}; @@ -493,14 +489,13 @@ populate_mfs() { cd ${BUILDDIR}/crunch log "---> Making and installing crunch1 from `pwd`..." a=${BUILDDIR}/crunch1.conf - cat ${MY_TREE}/crunch.conf|sed -e "s@/usr/src@${SRC}@" | \ - sed -e "s@CWD@${MY_TREE}@" > $a - arg="" - if [ -f ${MY_TREE}/crunch.inc ] ; then - h="-h ${MY_TREE}/crunch.inc" + ( export BUILDDIR SRC MY_TREE PICO_OBJ ; + make -v -f ${PICO_TREE}/build/Makefile.conf ${BUILDDIR}/crunch.mk ) + # update crunch.mk for new libs + if [ "${LIBS}" != "" ] ; then + sed -e "s@^LIBS=@ LIBS= ${LIBS}@" ${BUILDDIR}/crunch.mk > ${BUILDDIR}/crunch1.mk + mv ${BUILDDIR}/crunch1.mk ${BUILDDIR}/crunch.mk fi - crunchgen -p ${PICO_OBJ} -o $arg -m ${BUILDDIR}/crunch.mk $a || true - # failure is not critical here log "Now make -f crunch.mk" make ${makeopts} -f ${BUILDDIR}/crunch.mk strip --remove-section=.note --remove-section=.comment crunch1 @@ -510,7 +505,7 @@ populate_mfs() { for i in `crunchgen -l $a` ; do ln ${MFS_MOUNTPOINT}/stand/crunch ${MFS_MOUNTPOINT}/stand/${i}; done - rm $a + # rm $a # do not remove! ) || fail $? crunch if [ -f ${MFS_MOUNTPOINT}/stand/sshd ] ; then @@ -668,13 +663,30 @@ while [ true ]; do # accordingly. Note that you will still need the right # libraries... - #i=${SRC}/usr/include # the include directory... - #if [ \! -d $i ] ; then - # echo "Create \"$i\" as include directory" - # mkdir -p $i - # (cd ${SRC}; DESTDIR=${SRC} make includes ) - #fi - #CFLAGS="-nostdinc -I$i" ; export CFLAGS + i=${SRC}/usr/include # the include directory... + if [ \! -d $i ] ; then + echo "Create \"$i\" as include directory" + mkdir -p $i + (cd ${SRC}; + INCOWN=`id -un` DESTDIR=${SRC} make includes + ) + fi + CFLAGS="-nostdinc -I$i" ; export CFLAGS + i=${SRC}/usr/lib + if [ \! -d $i ]; then + echo "Create libraries (this takes long...)" + mkdir -p $i + (cd ${SRC}; + BINOWN=`id -un` DESTDIR=${SRC} \ + make -DNOHTML -DNOINFO -DNOMAN -DNOFSCHG libraries + ) + fi + LIBS=" -L$i" + (cd ${SRC}/usr.sbin/config ; + make + ) + CONFIG=${SRC}/usr.sbin/config/config + shift ;; --floppy_size) -- cgit v1.1