Home | History | Annotate | Line # | Download | only in tools
Makefile revision 1.172
      1 #	$NetBSD: Makefile,v 1.172 2014/03/25 09:52:56 ozaki-r Exp $
      2 
      3 .include <bsd.own.mk>
      4 .include <bsd.endian.mk>
      5 
      6 # Make sure that the ordered build/install processing applies when using
      7 # plain make.
      8 .MAIN: build_install
      9 
     10 # TOOLDIR must be valid, unless MKTOOLS=no
     11 .if ${MKTOOLS:Uyes} != "no"
     12 .if "${TOOLDIR}" == ""
     13 .error "TOOLDIR is undefined or empty"
     14 .elif "${TOOLDIR:tW:M/*}" == ""
     15 .error "TOOLDIR is not an absolute path: ${TOOLDIR}"
     16 #.elif !exists(TOOLDIR) # XXX .exists fails for directories
     17 #.error "TOOLDIR does not exist: ${TOOLDIR}"
     18 .endif
     19 .endif # MKTOOLS != no
     20 
     21 # TOOLS_BUILDRUMP == yes builds only the subset of the tools required
     22 # for building rump kernels and the hypervisor.  It is typically used
     23 # when building rump kernels targeted for non-NetBSD systems (via
     24 # buildrump.sh), and should not be set for a regular "make build".
     25 TOOLS_BUILDRUMP?=no
     26 
     27 .if ${TOOLCHAIN_MISSING} == "no"
     28 .if defined(HAVE_GCC)
     29 TOOLCHAIN_BITS= gmake .WAIT
     30 .endif
     31 
     32 .if defined(HAVE_GCC)
     33 .if ${HAVE_GCC} >= 45
     34 TOOLCHAIN_BITS+= gmp .WAIT
     35 TOOLCHAIN_BITS+= mpfr .WAIT
     36 TOOLCHAIN_BITS+= mpc .WAIT
     37 .endif
     38 .endif
     39 .endif
     40 
     41 .if ${TOOLCHAIN_MISSING} == "no"
     42 TOOLCHAIN_BITS+= binutils .WAIT
     43 .endif
     44 
     45 .if defined(HAVE_GCC)
     46 .if ${TOOLCHAIN_MISSING} == "no"
     47 TOOLCHAIN_BITS+= gcc
     48 .  if ${MKCROSSGDB:Uno} != "no" || make(obj)
     49 TOOLCHAIN_BITS+= gdb
     50 .  endif
     51 TOOLCHAIN_BITS+= .WAIT
     52 .endif
     53 .endif
     54 
     55 .if defined(HAVE_PCC)
     56 .if ${TOOLCHAIN_MISSING} == "no"
     57 TOOLCHAIN_BITS+= pcc
     58 .endif
     59 .endif
     60 
     61 .if ${TOOLCHAIN_MISSING} == "no"
     62 # XXX Eventually, we want to be able to build dbsym and mdsetimage
     63 # XXX if EXTERNAL_TOOLCHAIN is set.
     64 TOOLCHAIN_BITS+= dbsym mdsetimage
     65 .endif
     66 
     67 DTRACE_BITS=
     68 .if ${MKDTRACE} != "no"
     69 DTRACE_BITS+= .WAIT libelf
     70 DTRACE_BITS+= .WAIT libdwarf
     71 DTRACE_BITS+= .WAIT libctf
     72 .endif
     73 .if ${MKCTF} != "no"
     74 DTRACE_BITS+= .WAIT ctfconvert ctfmerge
     75 .endif
     76 
     77 LINT_BITS=
     78 .if ${MKLINT} != "no"
     79 LINT_BITS= lint lint2
     80 .endif
     81 
     82 # All of host-mkdep, compat, and binstall are needed before anything
     83 # else.  Within this group, they must be built in a specific order, and
     84 # all of them must be built before any of them is installed.  They may
     85 # be installed in any order.  This can't be expressed using the .WAIT
     86 # notation inside the SUBDIR list.
     87 #
     88 # XXX .ORDER does not work when multiple targets are passed on the
     89 # make command line without "-j", so use dependencies in addition to .ORDER.
     90 #
     91 .ORDER: dependall-host-mkdep dependall-compat dependall-binstall
     92 .if make(dependall-host-mkdep) && make(dependall-compat)
     93 dependall-compat: dependall-host-mkdep
     94 .endif
     95 .if make(dependall-compat) && make(dependall-binstall)
     96 dependall-binstall: dependall-compat
     97 .endif
     98 
     99 # Dependencies in SUBDIR below ordered to maximize parallel ability.
    100 # See above for special treatment for host-mkdep, compat, and binstall.
    101 #
    102 SUBDIR=	host-mkdep compat binstall \
    103 	.WAIT mktemp .WAIT sed .WAIT
    104 .if ${TOOLS_BUILDRUMP} == "no"
    105 SUBDIR+= cap_mkdb crunchgen ctags genassym gencat hexdump \
    106 		${LINT_BITS} \
    107 		makewhatis mtree nbperf .WAIT rpcgen uudecode
    108 .endif
    109 
    110 SUBDIR+= join lorder m4 mkdep tsort .WAIT yacc .WAIT awk .WAIT lex
    111 
    112 .if ${TOOLS_BUILDRUMP} == "no"
    113 SUBDIR += .WAIT texinfo \
    114 	.WAIT tic \
    115 	.WAIT pax \
    116 	.WAIT ${TOOLCHAIN_BITS} \
    117 	${DTRACE_BITS} \
    118 		asn1_compile cat cksum compile_et db \
    119 		file lint1 slc \
    120 		makefs .WAIT menuc mkcsmapper mkesdb mklocale mknod msgc \
    121 		.WAIT disklabel \
    122 		.WAIT paxctl \
    123 		.WAIT fdisk \
    124 		.WAIT installboot \
    125 		pwd_mkdb stat strfile sunlabel zic
    126 .endif
    127 SUBDIR+= .WAIT config
    128 
    129 .if ${MKLLVM} != "no"
    130 SUBDIR+= \
    131 	llvm .WAIT \
    132 	llvm-lib/libLLVMSupport llvm-lib/libLLVMTableGen .WAIT \
    133 	llvm-tblgen llvm-clang-tblgen .WAIT \
    134 	llvm-include .WAIT \
    135 	llvm-lib .WAIT \
    136 	llvm-clang
    137 .if ${MKLLD} != "no"
    138 SUBDIR+=	llvm-lld
    139 .endif
    140 .if ${MKMCLINKER} != "no"
    141 SUBDIR+=	llvm-mcld
    142 .endif
    143 .endif
    144 
    145 .if ${MKMAN} != "no" || ${MKDOC} != "no" || ${MKHTML} != "no"
    146 .  if ${MKGROFF} != "no"
    147 SUBDIR+=	groff
    148 .  endif
    149 SUBDIR+=	mandoc
    150 .endif
    151 
    152 .if ${TOOLS_BUILDRUMP} == "no"
    153 
    154 .if ${MKMAINTAINERTOOLS:Uno} != "no"
    155 SUBDIR+=	autoconf .WAIT gettext
    156 .endif
    157 
    158 .if ${USE_PIGZGZIP} != "no"
    159 SUBDIR+=	pigz
    160 .endif
    161 
    162 .if ${MACHINE} == "hppa"
    163 SUBDIR+=	hppa-mkboot
    164 .endif
    165 
    166 .if ${MACHINE} == "ibmnws"
    167 SUBDIR+=	ibmnws-ncdcs
    168 .endif
    169 
    170 .if ${MACHINE} == "macppc"
    171 SUBDIR+=	macppc-fixcoff
    172 .endif
    173 
    174 .if (${MACHINE} == "prep" || ${MACHINE} == "rs6000" || ${MACHINE} == "bebox")
    175 SUBDIR+=	powerpc-mkbootimage
    176 .endif
    177 
    178 .if ${MACHINE_ARCH} == "m68k"
    179 SUBDIR+=	m68k-elf2aout
    180 .endif
    181 
    182 .if (${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mipseb" || \
    183      ${MACHINE_ARCH} == "mips64el" || ${MACHINE_ARCH} == "mips64eb")
    184 SUBDIR+=	mips-elf2ecoff
    185 .endif
    186 
    187 .if (${MACHINE} == "sgimips")
    188 SUBDIR+=	sgivol
    189 .endif
    190 
    191 .if ${MACHINE} == "acorn32"
    192 SUBDIR+=	sparkcrc
    193 .endif
    194 
    195 .if (${MACHINE_ARCH} == "sparc" || ${MACHINE_ARCH} == "sparc64")
    196 SUBDIR+=	fgen
    197 .endif
    198 
    199 .if ${MACHINE} == "amiga"
    200 SUBDIR+=	amiga-elf2bb
    201 SUBDIR+=	amiga-txlt
    202 .endif
    203 
    204 .if ${MACHINE} == "hp300"
    205 SUBDIR+=	hp300-mkboot
    206 .endif
    207 
    208 .if ${MACHINE} == "evbarm" \
    209     && ${MACHINE_CPU} == "arm" \
    210     && ${TARGET_ENDIANNESS} == "1234"
    211 SUBDIR+=	elftosb
    212 .endif
    213 
    214 .if ${MACHINE} == "evbarm" || ${MACHINE} == "evbmips" || \
    215     ${MACHINE} == "evbppc" || ${MACHINE} == "sandpoint"
    216 SUBDIR+=	mkubootimage
    217 .endif
    218 
    219 .endif # TOOLCHAIN_BUILDRUMP
    220 
    221 check_MKTOOLS: .PHONY .NOTMAIN
    222 .if ${MKTOOLS:Uyes} == "no"
    223 	@echo '*** WARNING: "MKTOOLS" is set to "no"; this will prevent building and'
    224 	@echo '*** updating your host toolchain.  This should be used only as a'
    225 	@echo '*** temporary workaround for toolchain problems, as it will result'
    226 	@echo '*** in version skew and build errors over time!'
    227 .endif
    228 
    229 .if ${MKTOOLS:Uyes} == "no" || ${USETOOLS} != "yes"	# {
    230 SUBDIR= # empty
    231 realall realdepend install: check_MKTOOLS
    232 .endif							# }
    233 
    234 .include <bsd.subdir.mk>
    235 .include <bsd.buildinstall.mk>
    236 .include <bsd.obj.mk>
    237 
    238 .if !defined(PREVIOUSTOOLDIR)
    239 .  if exists(PREVIOUSTOOLDIR)
    240 PREVIOUSTOOLDIR!=	cat PREVIOUSTOOLDIR
    241 .  else
    242 PREVIOUSTOOLDIR=
    243 .  endif
    244 .endif
    245 
    246 CLEANFILES+=	PREVIOUSTOOLDIR
    247 
    248 realall realdepend: .MAKE
    249 .if !empty(PREVIOUSTOOLDIR) && "${PREVIOUSTOOLDIR}" != "${TOOLDIR}"
    250 	@echo "*** WARNING: TOOLDIR has moved?"
    251 	@echo "*** PREVIOUSTOOLDIR '${PREVIOUSTOOLDIR}'"
    252 	@echo "***     !=  TOOLDIR '${TOOLDIR}'"
    253 	@echo "*** Cleaning mis-matched tools"
    254 	rm -f PREVIOUSTOOLDIR
    255 	(cd ${.CURDIR} && ${MAKE} PREVIOUSTOOLDIR=${TOOLDIR} cleandir)
    256 .endif
    257 	echo ${TOOLDIR} >PREVIOUSTOOLDIR
    258 
    259 cleandir:
    260 	rm -f ${CLEANFILES}
    261