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