Home | History | Annotate | Line # | Download | only in tools
Makefile revision 1.153
      1 #	$NetBSD: Makefile,v 1.153 2011/11/02 20:36:41 christos 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 tic
     69 
     70 .if ${MKLLVM} != "no"
     71 SUBDIR+= \
     72 	llvm .WAIT \
     73 	llvm-lib/libLLVMSupport llvm-lib/libLLVMTableGen .WAIT \
     74 	llvm-tblgen llvm-clang-tblgen .WAIT \
     75 	llvm-include .WAIT \
     76 	llvm-lib .WAIT \
     77 	llvm-clang
     78 .endif
     79 
     80 .if ${MKMAN} != "no" || ${MKDOC} != "no" || ${MKHTML} != "no"
     81 .  if ${MKGROFF} != "no"
     82 SUBDIR+=	groff
     83 .  endif
     84 SUBDIR+=	mandoc
     85 .endif
     86 
     87 .if ${MKMAINTAINERTOOLS:Uno} != "no"
     88 SUBDIR+=	autoconf .WAIT gettext
     89 .endif
     90 
     91 .if ${USE_PIGZGZIP} != "no"
     92 SUBDIR+=	pigz
     93 .endif
     94 
     95 .if ${MACHINE} == "hp700"
     96 SUBDIR+=	hp700-mkboot
     97 .endif
     98 
     99 .if ${MACHINE} == "ibmnws"
    100 SUBDIR+=	ibmnws-ncdcs
    101 .endif
    102 
    103 .if ${MACHINE} == "macppc"
    104 SUBDIR+=	macppc-fixcoff
    105 .endif
    106 
    107 .if (${MACHINE} == "prep" || ${MACHINE} == "rs6000" || ${MACHINE} == "bebox")
    108 SUBDIR+=	powerpc-mkbootimage
    109 .endif
    110 
    111 .if ${MACHINE_ARCH} == "m68k"
    112 SUBDIR+=	m68k-elf2aout
    113 .endif
    114 
    115 .if (${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mipseb" || \
    116      ${MACHINE_ARCH} == "mips64el" || ${MACHINE_ARCH} == "mips64eb")
    117 SUBDIR+=	mips-elf2ecoff
    118 .endif
    119 
    120 .if (${MACHINE} == "sgimips")
    121 SUBDIR+=	sgivol
    122 .endif
    123 
    124 .if ${MACHINE} == "acorn32"
    125 SUBDIR+=	sparkcrc
    126 .endif
    127 
    128 .if (${MACHINE_ARCH} == "sparc" || ${MACHINE_ARCH} == "sparc64")
    129 SUBDIR+=	fgen
    130 .endif
    131 
    132 .if ${MACHINE} == "amiga"
    133 SUBDIR+=	amiga-elf2bb
    134 SUBDIR+=	amiga-txlt
    135 .endif
    136 
    137 .if ${MACHINE} == "hp300"
    138 SUBDIR+=	hp300-mkboot
    139 .endif
    140 
    141 .if ${MACHINE} == "evbarm" || ${MACHINE} == "evbmips" || \
    142     ${MACHINE} == "evbppc" || ${MACHINE} == "sandpoint"
    143 SUBDIR+=	mkubootimage
    144 .endif
    145 
    146 check_MKTOOLS: .PHONY .NOTMAIN
    147 .if ${MKTOOLS:Uyes} == "no"
    148 	@echo '*** WARNING: "MKTOOLS" is set to "no"; this will prevent building and'
    149 	@echo '*** updating your host toolchain.  This should be used only as a'
    150 	@echo '*** temporary workaround for toolchain problems, as it will result'
    151 	@echo '*** in version skew and build errors over time!'
    152 .endif
    153 
    154 .if ${MKTOOLS:Uyes} == "no" || ${USETOOLS} != "yes"	# {
    155 realall realdepend install: check_MKTOOLS
    156 
    157 .for dir in ${SUBDIR:N.WAIT}
    158 all-${dir} depend-${dir} dependall-${dir} install-${dir}:
    159 	@true
    160 .endfor
    161 .endif							# }
    162 
    163 .include <bsd.subdir.mk>
    164 .include <bsd.obj.mk>
    165 
    166 .if !defined(PREVIOUSTOOLDIR)
    167 .  if exists(PREVIOUSTOOLDIR)
    168 PREVIOUSTOOLDIR!=	cat PREVIOUSTOOLDIR
    169 .  else
    170 PREVIOUSTOOLDIR=	
    171 .  endif
    172 .endif
    173 
    174 CLEANFILES+=	PREVIOUSTOOLDIR
    175 
    176 realall realdepend: .MAKE
    177 .if !empty(PREVIOUSTOOLDIR) && "${PREVIOUSTOOLDIR}" != "${TOOLDIR}"
    178 	@echo "*** WARNING: TOOLDIR has moved?"
    179 	@echo "*** PREVIOUSTOOLDIR '${PREVIOUSTOOLDIR}'"
    180 	@echo "***     !=  TOOLDIR '${TOOLDIR}'"
    181 	@echo "*** Cleaning mis-matched tools"
    182 	rm -f PREVIOUSTOOLDIR
    183 	(cd ${.CURDIR} && ${MAKE} PREVIOUSTOOLDIR=${TOOLDIR} cleandir)
    184 .endif
    185 	echo ${TOOLDIR} >PREVIOUSTOOLDIR
    186 
    187 # For each .WAIT point, make sure the immediately preceding target is
    188 # installed before building anything after that point.
    189 # (dsl: which means that with: 'a b .WAIT c' the build of 'c' waits for the
    190 # install of 'b', but not the install of 'a'.)
    191 #
    192 # We use the "internal" targets and dependencies generated by <bsd.subdir.mk>
    193 # to achieve this. These targets look like:
    194 #	subdir-all:	all-dir1     [.WAIT] all-dir2     etc..
    195 #	subdir-install:	install-dir1 [.WAIT] install-dir2 etc..
    196 # and so on for each element in ${TARGETS}, with .WAIT sources inserted at
    197 # places corresponding to the .WAITs in our $SUBDIR variable.
    198 #
    199 # Also, since we're now mixing `install' with `all' and `depend' targets
    200 # an order relationship between those in each individual subdirectory
    201 # must be established.
    202 #
    203 _deps:=
    204 _prev:=
    205 
    206 .for d in ${SUBDIR}				# {
    207 _this:=		${d}
    208 
    209 .if ${_this} == ".WAIT"				# {
    210 
    211 # setup dependency to apply to all/depend targets in the next group
    212 _deps:=		${_deps} ${_prev:S/^/install-/}
    213 
    214 # if we're building *only* individual targets (i.e. "dependall-yacc"),
    215 # make sure prerequisite tools build before installing
    216 # XXX: dsl: this is likely to generate a dependency loop since there is
    217 # a .ORDER releation between the nodes as well.
    218 .if !make(all) && !make(dependall) && !make(install)
    219 install-${_prev}: dependall-${_prev}
    220 .endif
    221 
    222 .else # ${_this} != ".WAIT"			# } {
    223 
    224 # order depend/all/install targets for ${d} subdir.
    225 .ORDER: depend-${d} all-${d} dependall-${d} install-${d}
    226 
    227 # prevent cleandir in real{all,depend} from interfering with subdir makes
    228 .ORDER: realdepend dependall-${d}
    229 .ORDER: realdepend depend-${d}
    230 .ORDER: realall all-${d}
    231 
    232 # make all/depend-${d} dependent on list of install targets
    233 depend-${d} all-${d} dependall-${d}: ${_deps}
    234 
    235 .endif # ${_this} != ".WAIT"			# }
    236 
    237 # stash current name in case the next entry is .WAIT
    238 _prev:=		${d}
    239 .endfor						# }
    240 
    241 cleandir:
    242 	rm -f ${CLEANFILES}
    243