Makefile.conf revision 227878
1191762Simp# $FreeBSD: head/release/picobsd/build/Makefile.conf 227878 2011-11-23 12:05:39Z luigi $
2191762Simp#
3191762Simp# Makefile for building PICOBSD kernels and running crunchgen
4191762Simp#
5191762Simp# Needs SRC pointing to the source tree,
6191762Simp# MY_TREE ponting to my tree
7191762Simp# BUILDDIR pointing to the build directory
8191762Simp# PICO_OBJ pointing to the object directory
9191762Simp# When building a kernel, also need ${name} from the environment
10191762Simp# and CONFIG may indicate an alternate config program
11191762Simp
12191762SimpBINMAKE?=make
13191762SimpSRC?=/usr/src
14191762SimpCONFIG?=config
15191762SimpMODULES?=-DNO_MODULES	# do not build them as a default
16191762Simp
17191762Simp# caller will set MODULES to empty if modules are needed.
18191762Simp# Indeed, it can be used to specify other Makefile options as well.
19191762Simp
20191762Simp# These 3 variables determine where the kernel is built.
21191762Simp# If config were smart enough, we could place the config
22191762Simp# file in some other place than ${SRC}/sys/${TARGET_ARCH}/conf, but
23191762Simp# at the moment (Oct.2001) this is not possible yet.
24191762SimpCONF=${SRC}/sys/${TARGET_ARCH}/conf
25191762Simp#CONF=${BUILDDIR}/conf         # XXX does not work yet
26191762SimpCONFFILE=PICOBSD-${name}
27191762Simp
28191762Simp# We can, however, compile the kernel somewhere else
29191762Simp#COMPILE=${CONF}/../compile/${CONFFILE}
30191762SimpCOMPILE=${BUILDDIR}/${CONFFILE}
31191762Simp
32191762SimpKERNFILE=${COMPILE}/kernel
33191762Simp
34191762Simp${BUILDDIR}/kernel: ${KERNFILE}
35191762Simp	cp -p ${.OODATE} ${.TARGET}
36191762Simp	strip ${.TARGET}
37191762Simp	strip --remove-section=.note --remove-section=.comment ${.TARGET}
38191762Simp
39191762Simp${KERNFILE}: ${COMPILE} do_a_make_in_the_kernel_directory_anyways
40191762Simp
41191762Simpdo_a_make_in_the_kernel_directory_anyways:
42191762Simp	(cd ${COMPILE}; ${BINMAKE} KERNEL=kernel ${MODULES} )
43191762Simp
44191762Simp${COMPILE}: ${CONF}/${CONFFILE}
45191762Simp	(cd ${CONF}; ${CONFIG} -d ${COMPILE} ${CONFFILE}; \
46191762Simp	cd ${COMPILE}; ${BINMAKE} KERNEL=kernel ${MODULES} depend )
47191762Simp
48191762Simp${CONF}/${CONFFILE}: PICOBSD
49191762Simp	# -mkdir -p ${CONF}		# XXX not needed yet.
50191762Simp	cp ${.OODATE} ${.TARGET}
51191762Simp	if [ -f PICOBSD.hints ] ; then cp PICOBSD.hints ${CONF}/PICOBSD.hints ; fi
52191762Simp
53191762Simp# This part creates crunch1.conf and crunch.mk from crunch.conf
54191762Simp${BUILDDIR}/crunch.mk: ${BUILDDIR}/crunch1.conf
55191762Simp	-(cd ${BUILDDIR}/crunch ; \
56191762Simp	crunchgen -p ${PICO_OBJ} -o -m ${.TARGET} ${.OODATE} )
57191762Simp
58191762Simp${BUILDDIR}/crunch1.conf: ${MY_TREE}/crunch.conf
59191762Simp	(cd ${BUILDDIR}/crunch ; cat ${.OODATE} | \
60283639Sglebius	    sed -e "s@/usr/src@${SRC}@" -e "s+@__CWD__@+${MY_TREE}+" > ${.TARGET} )
61191762Simp