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