150479Speter# $FreeBSD$ 250186Sdwhite# 378541Sluigi# Makefile for building PICOBSD kernels and running crunchgen 478541Sluigi# 578541Sluigi# Needs SRC pointing to the source tree, 678541Sluigi# MY_TREE ponting to my tree 778541Sluigi# BUILDDIR pointing to the build directory 878541Sluigi# PICO_OBJ pointing to the object directory 978541Sluigi# When building a kernel, also need ${name} from the environment 1078541Sluigi# and CONFIG may indicate an alternate config program 1150186Sdwhite 12173597SluigiBINMAKE?=make 1350186SdwhiteSRC?=/usr/src 1478541SluigiCONFIG?=config 1585833SluigiMODULES?=-DNO_MODULES # do not build them as a default 1650186Sdwhite 1785833Sluigi# caller will set MODULES to empty if modules are needed. 1885833Sluigi# Indeed, it can be used to specify other Makefile options as well. 1985833Sluigi 2084376Sluigi# These 3 variables determine where the kernel is built. 2184603Sluigi# If config were smart enough, we could place the config 22230009Sluigi# file in some other place than ${SRC}/sys/${TARGET_ARCH}/conf, but 2384376Sluigi# at the moment (Oct.2001) this is not possible yet. 24230009SluigiCONF=${SRC}/sys/${TARGET_ARCH}/conf 2584376Sluigi#CONF=${BUILDDIR}/conf # XXX does not work yet 2675881SjoeCONFFILE=PICOBSD-${name} 2784376Sluigi 2884376Sluigi# We can, however, compile the kernel somewhere else 2984376Sluigi#COMPILE=${CONF}/../compile/${CONFFILE} 3084376SluigiCOMPILE=${BUILDDIR}/${CONFFILE} 3184376Sluigi 3278541SluigiKERNFILE=${COMPILE}/kernel 3350186Sdwhite 3482917Sluigi${BUILDDIR}/kernel: ${KERNFILE} 3582917Sluigi cp -p ${.OODATE} ${.TARGET} 3682917Sluigi strip ${.TARGET} 3782917Sluigi strip --remove-section=.note --remove-section=.comment ${.TARGET} 3850186Sdwhite 3978541Sluigi${KERNFILE}: ${COMPILE} do_a_make_in_the_kernel_directory_anyways 4057038Sluigi 4175881Sjoedo_a_make_in_the_kernel_directory_anyways: 42173597Sluigi (cd ${COMPILE}; ${BINMAKE} KERNEL=kernel ${MODULES} ) 4350186Sdwhite 4457038Sluigi${COMPILE}: ${CONF}/${CONFFILE} 4584376Sluigi (cd ${CONF}; ${CONFIG} -d ${COMPILE} ${CONFFILE}; \ 46173597Sluigi cd ${COMPILE}; ${BINMAKE} KERNEL=kernel ${MODULES} depend ) 4757038Sluigi 48230009Sluigi${CONF}/${CONFFILE}: ${KERNCONF} 4984376Sluigi # -mkdir -p ${CONF} # XXX not needed yet. 5078541Sluigi cp ${.OODATE} ${.TARGET} 51230009Sluigi [ -f PICOBSD.hints ] && cp PICOBSD.hints ${CONF}/ 5257038Sluigi 5378541Sluigi# This part creates crunch1.conf and crunch.mk from crunch.conf 5478541Sluigi${BUILDDIR}/crunch.mk: ${BUILDDIR}/crunch1.conf 5578541Sluigi -(cd ${BUILDDIR}/crunch ; \ 5682598Sluigi crunchgen -p ${PICO_OBJ} -o -m ${.TARGET} ${.OODATE} ) 5778541Sluigi 5878541Sluigi${BUILDDIR}/crunch1.conf: ${MY_TREE}/crunch.conf 5978541Sluigi (cd ${BUILDDIR}/crunch ; cat ${.OODATE} | \ 6084603Sluigi sed -e "s@/usr/src@${SRC}@" -e "s+@__CWD__@+${MY_TREE}+" > ${.TARGET} ) 61