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