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