Makefile.conf revision 229511
168673Sobrien# $FreeBSD: head/release/picobsd/build/Makefile.conf 229511 2012-01-04 19:37:25Z luigi $
278828Sobrien#
368673Sobrien# Makefile for building PICOBSD kernels and running crunchgen
468673Sobrien#
568673Sobrien# Needs SRC pointing to the source tree,
668673Sobrien# MY_TREE ponting to my tree
768673Sobrien# BUILDDIR pointing to the build directory
868673Sobrien# PICO_OBJ pointing to the object directory
968673Sobrien# When building a kernel, also need ${name} from the environment
1068673Sobrien# and CONFIG may indicate an alternate config program
1168673Sobrien
1268673SobrienBINMAKE?=make
1368673SobrienSRC?=/usr/src
1468673SobrienCONFIG?=config
1568673SobrienMODULES?=-DNO_MODULES	# do not build them as a default
1668673SobrienKERNCONF ?= PICOBSD
1768673Sobrien
18218822Sdim# caller will set MODULES to empty if modules are needed.
1968673Sobrien# Indeed, it can be used to specify other Makefile options as well.
2068673Sobrien
2168673Sobrien# These 3 variables determine where the kernel is built.
2268673Sobrien# If config were smart enough, we could place the config
2368673Sobrien# file in some other place than ${SRC}/sys/${TARGET_ARCH}/conf, but
2468673Sobrien# at the moment (Oct.2001) this is not possible yet.
2568673SobrienCONF=${SRC}/sys/${TARGET_ARCH}/conf
2668673Sobrien#CONF=${BUILDDIR}/conf         # XXX does not work yet
2768673SobrienCONFFILE=PICOBSD-${name}
2868673Sobrien
2968673Sobrien# We can, however, compile the kernel somewhere else
3068673Sobrien#COMPILE=${CONF}/../compile/${CONFFILE}
3168673SobrienCOMPILE=${BUILDDIR}/${CONFFILE}
3268673Sobrien
3368673SobrienKERNFILE=${COMPILE}/kernel
3468673Sobrien
3568673Sobrien${BUILDDIR}/kernel: ${KERNFILE}
3668673Sobrien	cp -p ${.OODATE} ${.TARGET}
3768673Sobrien	strip ${.TARGET}
3868673Sobrien	strip --remove-section=.note --remove-section=.comment ${.TARGET}
3968673Sobrien
4068673Sobrien${KERNFILE}: ${COMPILE} do_a_make_in_the_kernel_directory_anyways
4177298Sobrien
4268673Sobriendo_a_make_in_the_kernel_directory_anyways:
4368673Sobrien	(cd ${COMPILE}; ${BINMAKE} KERNEL=kernel ${MODULES} )
4468673Sobrien
4568673Sobrien${COMPILE}: ${CONF}/${CONFFILE}
4668673Sobrien	(cd ${CONF}; ${CONFIG} -d ${COMPILE} ${CONFFILE}; \
47	cd ${COMPILE}; ${BINMAKE} KERNEL=kernel ${MODULES} depend )
48
49${CONF}/${CONFFILE}: ${KERNCONF}
50	# -mkdir -p ${CONF}		# XXX not needed yet.
51	cp ${.OODATE} ${.TARGET}
52	[ -f PICOBSD.hints ] && cp PICOBSD.hints ${CONF}/
53
54# This part creates crunch1.conf and crunch.mk from crunch.conf
55${BUILDDIR}/crunch.mk: ${BUILDDIR}/crunch1.conf
56	-(cd ${BUILDDIR}/crunch ; \
57	crunchgen -p ${PICO_OBJ} -o -m ${.TARGET} ${.OODATE} )
58
59${BUILDDIR}/crunch1.conf: ${MY_TREE}/crunch.conf
60	(cd ${BUILDDIR}/crunch ; cat ${.OODATE} | \
61	    sed -e "s@/usr/src@${SRC}@" -e "s+@__CWD__@+${MY_TREE}+" > ${.TARGET} )
62