1# $NetBSD: Makefile,v 1.127 2009/02/25 22:28:36 sketch Exp $ 2 3.include <bsd.own.mk> 4 5.if defined(HAVE_GCC) 6.if ${HAVE_GCC} == "4" 7TOOLCHAIN_BITS= gmake .WAIT 8.endif 9.if ${TOOLCHAIN_MISSING} == "no" 10TOOLCHAIN_BITS+= binutils .WAIT 11TOOLCHAIN_BITS+= gcc 12. if ${MKCROSSGDB:Uno} != "no" 13TOOLCHAIN_BITS+= gdb 14. endif 15TOOLCHAIN_BITS+= .WAIT dbsym mdsetimage 16# XXX Eventually, we want to be able to build dbsym and mdsetimage 17# XXX if EXTERNAL_TOOLCHAIN is set. 18.endif 19.endif 20 21.if defined(HAVE_PCC) 22TOOLCHAIN_BITS= gmake .WAIT 23.if ${TOOLCHAIN_MISSING} == "no" 24TOOLCHAIN_BITS+= binutils .WAIT 25TOOLCHAIN_BITS+= pcc 26.endif 27TOOLCHAIN_BITS+= .WAIT dbsym mdsetimage 28.endif 29 30LINT_BITS= 31.if ${MKLINT} != "no" 32LINT_BITS= lint lint2 33.endif 34 35# Dependencies in SUBDIR below ordered to maximize parallel ability. 36SUBDIR= host-mkdep .WAIT compat .WAIT \ 37 binstall .WAIT mktemp .WAIT sed .WAIT \ 38 cap_mkdb crunchgen ctags genassym gencat hexdump join \ 39 ${LINT_BITS} \ 40 lorder m4 makewhatis mkdep mtree rpcgen tsort uudecode \ 41 texinfo .WAIT \ 42 yacc .WAIT \ 43 awk .WAIT \ 44 lex .WAIT \ 45 ${TOOLCHAIN_BITS} \ 46 asn1_compile atf-compile cat cksum compile_et config db \ 47 file lint1 \ 48 makefs menuc mkcsmapper mkesdb mklocale mknod msgc \ 49 pax .WAIT \ 50 disklabel .WAIT \ 51 paxctl .WAIT \ 52 fdisk .WAIT \ 53 installboot .WAIT \ 54 pwd_mkdb stat strfile sunlabel zic 55 56.if ${MKMAN} != "no" || ${MKDOC} != "no" || ${MKHTML} != "no" 57SUBDIR+= groff 58.endif 59 60.if ${MKMAINTAINERTOOLS:Uno} != "no" 61SUBDIR+= autoconf .WAIT gettext 62.endif 63 64.if ${MACHINE} == "hp700" 65SUBDIR+= hp700-mkboot 66.endif 67 68.if ${MACHINE} == "ibmnws" 69SUBDIR+= ibmnws-ncdcs 70.endif 71 72.if ${MACHINE} == "macppc" 73SUBDIR+= macppc-fixcoff 74.endif 75 76.if (${MACHINE} == "prep" || ${MACHINE} == "rs6000" || ${MACHINE} == "bebox") 77SUBDIR+= powerpc-mkbootimage 78.endif 79 80.if (${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mipseb") 81SUBDIR+= mips-elf2ecoff 82.endif 83 84.if (${MACHINE} == "sgimips") 85SUBDIR+= sgivol 86.endif 87 88.if ${MACHINE} == "acorn32" 89SUBDIR+= sparkcrc 90.endif 91 92.if (${MACHINE_ARCH} == "sparc" || ${MACHINE_ARCH} == "sparc64") 93SUBDIR+= fgen 94.endif 95 96.if ${MACHINE} == "amiga" 97SUBDIR+= amiga-elf2bb 98SUBDIR+= amiga-txlt 99.endif 100 101.if ${MACHINE} == "hp300" 102SUBDIR+= hp300-mkboot 103.endif 104 105check_MKTOOLS: .PHONY .NOTMAIN 106.if ${MKTOOLS:Uyes} == "no" 107 @echo '*** WARNING: "MKTOOLS" is set to "no"; this will prevent building and' 108 @echo '*** updating your host toolchain. This should be used only as a' 109 @echo '*** temporary workaround for toolchain problems, as it will result' 110 @echo '*** in version skew and build errors over time!' 111.endif 112 113.if ${MKTOOLS:Uyes} == "no" || ${USETOOLS} != "yes" # { 114realall realdepend install: check_MKTOOLS 115 116.for dir in ${SUBDIR:N.WAIT} 117all-${dir} depend-${dir} dependall-${dir} install-${dir}: 118 @true 119.endfor 120.endif # } 121 122.include <bsd.subdir.mk> 123.include <bsd.obj.mk> 124 125.if !defined(PREVIOUSTOOLDIR) 126. if exists(PREVIOUSTOOLDIR) 127PREVIOUSTOOLDIR!= cat PREVIOUSTOOLDIR 128. else 129PREVIOUSTOOLDIR= 130. endif 131.endif 132 133CLEANFILES+= PREVIOUSTOOLDIR 134 135realall realdepend: .MAKE 136.if !empty(PREVIOUSTOOLDIR) && "${PREVIOUSTOOLDIR}" != "${TOOLDIR}" 137 @echo "*** WARNING: TOOLDIR has moved?" 138 @echo "*** PREVIOUSTOOLDIR '${PREVIOUSTOOLDIR}'" 139 @echo "*** != TOOLDIR '${TOOLDIR}'" 140 @echo "*** Cleaning mis-matched tools" 141 rm -f PREVIOUSTOOLDIR 142 (cd ${.CURDIR} && ${MAKE} PREVIOUSTOOLDIR=${TOOLDIR} cleandir) 143.endif 144 echo ${TOOLDIR} >PREVIOUSTOOLDIR 145 146# For each .WAIT point, make sure the immediately preceding target is 147# installed before building anything after that point. 148# (dsl: which means that with: 'a b .WAIT c' the build of 'c' waits for the 149# install of 'b', but not the install of 'a'.) 150# 151# We use the "internal" targets and dependencies generated by <bsd.subdir.mk> 152# to achieve this. These targets look like: 153# subdir-all: all-dir1 [.WAIT] all-dir2 etc.. 154# subdir-install: install-dir1 [.WAIT] install-dir2 etc.. 155# and so on for each element in ${TARGETS}, with .WAIT sources inserted at 156# places corresponding to the .WAITs in our $SUBDIR variable. 157# 158# Also, since we're now mixing `install' with `all' and `depend' targets 159# an order relationship between those in each individual subdirectory 160# must be established. 161# 162_deps:= 163_prev:= 164 165.for d in ${SUBDIR} # { 166_this:= ${d} 167 168.if ${_this} == ".WAIT" # { 169 170# setup dependency to apply to all/depend targets in the next group 171_deps:= ${_deps} ${_prev:S/^/install-/} 172 173# if we're building *only* individual targets (i.e. "dependall-yacc"), 174# make sure prerequisite tools build before installing 175# XXX: dsl: this is likely to generate a dependency loop since there is 176# a .ORDER releation between the nodes as well. 177.if !make(all) && !make(dependall) && !make(install) 178install-${_prev}: dependall-${_prev} 179.endif 180 181.else # ${_this} != ".WAIT" # } { 182 183# order depend/all/install targets for ${d} subdir. 184.ORDER: depend-${d} all-${d} dependall-${d} install-${d} 185 186# prevent cleandir in real{all,depend} from interfering with subdir makes 187.ORDER: realdepend dependall-${d} 188.ORDER: realdepend depend-${d} 189.ORDER: realall all-${d} 190 191# make all/depend-${d} dependent on list of install targets 192depend-${d} all-${d} dependall-${d}: ${_deps} 193 194.endif # ${_this} != ".WAIT" # } 195 196# stash current name in case the next entry is .WAIT 197_prev:= ${d} 198.endfor # } 199 200cleandir: 201 rm -f ${CLEANFILES} 202