1 1.72 matt # $NetBSD: Makefile,v 1.72 2003/10/19 03:35:30 matt Exp $ 2 1.1 tv 3 1.3 tv .include <bsd.own.mk> 4 1.3 tv 5 1.60 thorpej .if ${TOOLCHAIN_MISSING} != "yes" 6 1.70 mrg . if ${USE_TOOLS_TOOLCHAIN} != "yes" 7 1.70 mrg TOOLCHAIN_BITS= binutils .WAIT gcc 8 1.70 mrg . else 9 1.70 mrg TOOLCHAIN_BITS= toolchain 10 1.70 mrg . endif 11 1.70 mrg TOOLCHAIN_BITS+= .WAIT dbsym mdsetimage 12 1.58 thorpej # XXX Eventually, we want to be able to build dbsym and mdsetimage 13 1.58 thorpej # XXX if EXTERNAL_TOOLCHAIN is set. 14 1.31 tv .endif 15 1.31 tv 16 1.16 tv # Dependencies in SUBDIR below ordered to maximize parallel ability. 17 1.50 lukem .if !defined(NOSUBDIR) # { 18 1.50 lukem 19 1.29 tv SUBDIR= host-mkdep .WAIT compat .WAIT \ 20 1.57 chris binstall .WAIT mktemp .WAIT \ 21 1.62 thorpej cap_mkdb crunchgen ctags gencat hexdump lint lint2 lorder \ 22 1.32 tv m4 makewhatis mkdep mtree rpcgen tsort uudecode \ 23 1.32 tv texinfo .WAIT \ 24 1.16 tv yacc .WAIT \ 25 1.16 tv lex .WAIT \ 26 1.32 tv ${TOOLCHAIN_BITS} \ 27 1.64 lukem asn1_compile cat cksum compile_et config db file installboot \ 28 1.65 tshiozak lint1 makefs menuc mklocale mkcsmapper mkesdb msgc pax \ 29 1.68 lukem pwd_mkdb stat sunlabel zic 30 1.39 tv 31 1.39 tv .if ${MKMAN} != "no" 32 1.39 tv SUBDIR+= groff 33 1.39 tv .endif 34 1.22 tv 35 1.22 tv .if ${MKMAINTAINERTOOLS:Uno} != "no" 36 1.38 tv SUBDIR+= autoconf gettext 37 1.72 matt .endif 38 1.72 matt 39 1.72 matt .if ${MACHINE} == ibmnws 40 1.72 matt SUBDIR+= ibmnws-ncdcs 41 1.48 kleink .endif 42 1.48 kleink 43 1.48 kleink .if ${MACHINE} == prep 44 1.48 kleink SUBDIR+= prep-mkbootimage 45 1.22 tv .endif 46 1.37 gmcgarry 47 1.37 gmcgarry .if (${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mipseb") 48 1.37 gmcgarry SUBDIR+= mips-elf2ecoff 49 1.51 bjh21 .endif 50 1.51 bjh21 51 1.51 bjh21 .if (${MACHINE} == "sparc" || ${MACHINE} == "sparc64") 52 1.51 bjh21 SUBDIR+= fgen 53 1.37 gmcgarry .endif 54 1.37 gmcgarry 55 1.50 lukem .endif # ! NOSUBDIR # } 56 1.17 tv 57 1.66 lukem check_MKTOOLS: .PHONY .NOTMAIN 58 1.19 jmc .if ${MKTOOLS:Uyes} == "no" 59 1.17 tv @echo '*** WARNING: "MKTOOLS" is set to "no"; this will prevent building and' 60 1.17 tv @echo '*** updating your host toolchain. This should be used only as a' 61 1.17 tv @echo '*** temporary workaround for toolchain problems, as it will result' 62 1.23 wiz @echo '*** in version skew and build errors over time!' 63 1.18 jmc .endif 64 1.17 tv 65 1.66 lukem .if ${MKTOOLS:Uyes} == "no" || ${USETOOLS} != "yes" # { 66 1.67 lukem realall realdepend install: check_MKTOOLS 67 1.66 lukem 68 1.17 tv .for dir in ${SUBDIR:N.WAIT} 69 1.17 tv all-${dir} depend-${dir} dependall-${dir} install-${dir}: 70 1.17 tv @true 71 1.17 tv .endfor 72 1.66 lukem .endif # } 73 1.1 tv 74 1.1 tv .include <bsd.subdir.mk> 75 1.11 tv .include <bsd.obj.mk> 76 1.16 tv 77 1.66 lukem .if exists(PREVIOUSTOOLDIR) 78 1.66 lukem PREVIOUSTOOLDIR!= cat PREVIOUSTOOLDIR 79 1.66 lukem .else 80 1.66 lukem PREVIOUSTOOLDIR= 81 1.66 lukem .endif 82 1.66 lukem 83 1.66 lukem CLEANFILES+= PREVIOUSTOOLDIR 84 1.66 lukem 85 1.67 lukem realall realdepend: 86 1.66 lukem .if (${PREVIOUSTOOLDIR} != ${TOOLDIR}) 87 1.66 lukem @echo "*** WARNING: TOOLDIR has moved?" 88 1.66 lukem @echo "*** PREVIOUSTOOLDIR '${PREVIOUSTOOLDIR}'" 89 1.66 lukem @echo "*** != TOOLDIR '${TOOLDIR}'" 90 1.66 lukem @echo "*** Cleaning mis-matched tools" 91 1.71 lukem ${_MKCMD}\ 92 1.66 lukem rm -f PREVIOUSTOOLDIR 93 1.66 lukem ${MAKE} cleandir 94 1.66 lukem .endif 95 1.66 lukem echo ${TOOLDIR} > PREVIOUSTOOLDIR 96 1.66 lukem 97 1.40 tv # For each .WAIT point, make sure the immediately preceding target is 98 1.40 tv # installed before building anything after that point. 99 1.36 pk # 100 1.36 pk # We use the "internal" targets and dependencies generated by <bsd.subdir.mk> 101 1.36 pk # to achieve this. These targets look like: 102 1.36 pk # subdir-all: all-dir1 [.WAIT] all-dir2 etc.. 103 1.36 pk # subdir-install: install-dir1 [.WAIT] install-dir2 etc.. 104 1.36 pk # and so on for each element in ${TARGETS}, with .WAIT sources inserted at 105 1.36 pk # places corresponding to the .WAITs in our $SUBDIR variable. 106 1.36 pk # 107 1.36 pk # Also, since we're now mixing `install' with `all' and `depend' targets 108 1.36 pk # an order relationship between those in each individual subdirectory 109 1.36 pk # must be established. 110 1.36 pk # 111 1.40 tv _deps:= 112 1.40 tv _prev:= 113 1.40 tv 114 1.16 tv .for d in ${SUBDIR} 115 1.16 tv _this:= ${d} 116 1.40 tv 117 1.16 tv .if ${_this} == ".WAIT" 118 1.36 pk 119 1.36 pk # setup dependency to apply to all/depend targets in the next group 120 1.40 tv _deps:= ${_deps} ${_prev:S/^/install-/} 121 1.40 tv 122 1.40 tv # if we're building *only* individual targets (i.e. "dependall-yacc"), 123 1.40 tv # make sure prerequisite tools build before installing 124 1.40 tv .if !make(all) && !make(dependall) 125 1.40 tv install-${_prev}: dependall-${_prev} 126 1.40 tv .endif 127 1.36 pk 128 1.16 tv .else 129 1.36 pk 130 1.36 pk # order depend/all/install targets for ${d} subdir. Note the additional 131 1.36 pk # .WAIT to achieve "closure" of the predecessor/successor relationships. 132 1.36 pk .ORDER: depend-${d} all-${d} dependall-${d} .WAIT install-${d} 133 1.40 tv 134 1.40 tv # make all/depend-${d} dependent on list of install targets 135 1.40 tv depend-${d} all-${d} dependall-${d}: ${_deps} 136 1.36 pk 137 1.16 tv .endif 138 1.40 tv 139 1.40 tv # stash current name in case the next entry is .WAIT 140 1.40 tv _prev:= ${d} 141 1.16 tv .endfor 142 1.69 tron 143 1.69 tron cleandir: 144 1.71 lukem ${_MKCMD}\ 145 1.69 tron rm -f ${CLEANFILES} 146