1# $FreeBSD$ 2# 3# Makefile for building PICOBSD kernels and running crunchgen 4# 5# Needs SRC pointing to the source tree, 6# MY_TREE ponting to my tree 7# BUILDDIR pointing to the build directory 8# PICO_OBJ pointing to the object directory 9# When building a kernel, also need ${name} from the environment 10# and CONFIG may indicate an alternate config program 11 12BINMAKE?=make 13SRC?=/usr/src 14CONFIG?=config 15MODULES?=-DNO_MODULES # do not build them as a default 16KERNCONF ?= PICOBSD 17 18# caller will set MODULES to empty if modules are needed. 19# Indeed, it can be used to specify other Makefile options as well. 20 21# These 3 variables determine where the kernel is built. 22# If config were smart enough, we could place the config 23# file in some other place than ${SRC}/sys/${TARGET_ARCH}/conf, but 24# at the moment (Oct.2001) this is not possible yet. 25CONF=${SRC}/sys/${TARGET_ARCH}/conf 26#CONF=${BUILDDIR}/conf # XXX does not work yet 27CONFFILE=PICOBSD-${name} 28 29# We can, however, compile the kernel somewhere else 30#COMPILE=${CONF}/../compile/${CONFFILE} 31COMPILE=${BUILDDIR}/${CONFFILE} 32 33KERNFILE=${COMPILE}/kernel 34 35${BUILDDIR}/kernel: ${KERNFILE} 36 cp -p ${.OODATE} ${.TARGET} 37 strip ${.TARGET} 38 strip --remove-section=.note --remove-section=.comment ${.TARGET} 39 40${KERNFILE}: ${COMPILE} do_a_make_in_the_kernel_directory_anyways 41 42do_a_make_in_the_kernel_directory_anyways: 43 (cd ${COMPILE}; ${BINMAKE} KERNEL=kernel ${MODULES} ) 44 45${COMPILE}: ${CONF}/${CONFFILE} 46 cd ${CONF}; ${CONFIG} -d ${COMPILE} ${CONFFILE} 47 48${CONF}/${CONFFILE}: ${KERNCONF} 49 # -mkdir -p ${CONF} # XXX not needed yet. 50 cp ${.OODATE} ${.TARGET} 51 [ -f PICOBSD.hints ] && cp PICOBSD.hints ${CONF}/ 52 53# This part creates crunch1.conf and crunch.mk from crunch.conf 54${BUILDDIR}/crunch.mk: ${BUILDDIR}/crunch1.conf 55 -(cd ${BUILDDIR}/crunch ; \ 56 crunchgen -p ${PICO_OBJ} -o -m ${.TARGET} ${.OODATE} ) 57 58${BUILDDIR}/crunch1.conf: ${MY_TREE}/crunch.conf 59 (cd ${BUILDDIR}/crunch ; cat ${.OODATE} | \ 60 sed -e "s@/usr/src@${SRC}@" -e "s+@__CWD__@+${MY_TREE}+" > ${.TARGET} ) 61