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 16229511SluigiKERNCONF ?= PICOBSD 1750186Sdwhite 1885833Sluigi# caller will set MODULES to empty if modules are needed. 1985833Sluigi# Indeed, it can be used to specify other Makefile options as well. 2085833Sluigi 2184376Sluigi# These 3 variables determine where the kernel is built. 2284603Sluigi# If config were smart enough, we could place the config 23227878Sluigi# file in some other place than ${SRC}/sys/${TARGET_ARCH}/conf, but 2484376Sluigi# at the moment (Oct.2001) this is not possible yet. 25227878SluigiCONF=${SRC}/sys/${TARGET_ARCH}/conf 2684376Sluigi#CONF=${BUILDDIR}/conf # XXX does not work yet 2775881SjoeCONFFILE=PICOBSD-${name} 2884376Sluigi 2984376Sluigi# We can, however, compile the kernel somewhere else 3084376Sluigi#COMPILE=${CONF}/../compile/${CONFFILE} 3184376SluigiCOMPILE=${BUILDDIR}/${CONFFILE} 3284376Sluigi 3378541SluigiKERNFILE=${COMPILE}/kernel 3450186Sdwhite 3582917Sluigi${BUILDDIR}/kernel: ${KERNFILE} 3682917Sluigi cp -p ${.OODATE} ${.TARGET} 3782917Sluigi strip ${.TARGET} 3882917Sluigi strip --remove-section=.note --remove-section=.comment ${.TARGET} 3950186Sdwhite 4078541Sluigi${KERNFILE}: ${COMPILE} do_a_make_in_the_kernel_directory_anyways 4157038Sluigi 4275881Sjoedo_a_make_in_the_kernel_directory_anyways: 43173597Sluigi (cd ${COMPILE}; ${BINMAKE} KERNEL=kernel ${MODULES} ) 4450186Sdwhite 4557038Sluigi${COMPILE}: ${CONF}/${CONFFILE} 4684376Sluigi (cd ${CONF}; ${CONFIG} -d ${COMPILE} ${CONFFILE}; \ 47173597Sluigi cd ${COMPILE}; ${BINMAKE} KERNEL=kernel ${MODULES} depend ) 4857038Sluigi 49229511Sluigi${CONF}/${CONFFILE}: ${KERNCONF} 5084376Sluigi # -mkdir -p ${CONF} # XXX not needed yet. 5178541Sluigi cp ${.OODATE} ${.TARGET} 52229511Sluigi [ -f PICOBSD.hints ] && cp PICOBSD.hints ${CONF}/ 5357038Sluigi 5478541Sluigi# This part creates crunch1.conf and crunch.mk from crunch.conf 5578541Sluigi${BUILDDIR}/crunch.mk: ${BUILDDIR}/crunch1.conf 5678541Sluigi -(cd ${BUILDDIR}/crunch ; \ 5782598Sluigi crunchgen -p ${PICO_OBJ} -o -m ${.TARGET} ${.OODATE} ) 5878541Sluigi 5978541Sluigi${BUILDDIR}/crunch1.conf: ${MY_TREE}/crunch.conf 6078541Sluigi (cd ${BUILDDIR}/crunch ; cat ${.OODATE} | \ 6184603Sluigi sed -e "s@/usr/src@${SRC}@" -e "s+@__CWD__@+${MY_TREE}+" > ${.TARGET} ) 62