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