Home | History | Annotate | Line # | Download | only in tools
Makefile revision 1.208
      1 #	$NetBSD: Makefile,v 1.208 2021/04/25 15:11:28 christos 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) && ${HAVE_GCC} > 0) || \
     29      (defined(HAVE_GDB) && ${HAVE_GDB} > 0 && ${MKCROSSGDB:Uno} != "no")
     30 TOOLCHAIN_BITS+= gmake .WAIT
     31 TOOLCHAIN_BITS+= gmp .WAIT
     32 TOOLCHAIN_BITS+= mpfr .WAIT
     33 TOOLCHAIN_BITS+= mpc .WAIT
     34 . endif
     35 
     36 TOOLCHAIN_BITS+= binutils .WAIT
     37 
     38 . if defined(HAVE_GCC) && ${HAVE_GCC} > 0
     39 TOOLCHAIN_BITS+= gcc
     40 . endif
     41 
     42 . if defined(HAVE_GDB) && ${HAVE_GDB} > 0 && ${MKCROSSGDB:Uno} != "no"
     43 TOOLCHAIN_BITS+= gdb
     44 . endif
     45 
     46 TOOLCHAIN_BITS+= .WAIT
     47 .endif
     48 
     49 .if defined(HAVE_PCC)
     50 . if ${TOOLCHAIN_MISSING} == "no"
     51 TOOLCHAIN_BITS+= pcc
     52 . endif
     53 .endif
     54 
     55 .if ${TOOLCHAIN_MISSING} == "no" || defined(EXTERNAL_TOOLCHAIN)
     56 TOOLCHAIN_BITS+= dbsym mdsetimage
     57 .endif
     58 
     59 DTRACE_BITS=
     60 .if ${MKDTRACE} != "no" || ${MKCTF} != "no"
     61 DTRACE_BITS+= .WAIT libelf
     62 DTRACE_BITS+= .WAIT libdwarf
     63 DTRACE_BITS+= .WAIT libctf
     64 .endif
     65 .if ${MKCTF} != "no"
     66 DTRACE_BITS+= .WAIT ctfconvert ctfmerge
     67 .endif
     68 
     69 LINT_BITS=
     70 .if ${MKLINT} != "no"
     71 LINT_BITS= lint lint2
     72 .endif
     73 
     74 # All of host-mkdep, compat, and binstall are needed before anything
     75 # else.  Within this group, they must be built in a specific order, and
     76 # all of them must be built before any of them is installed.  They may
     77 # be installed in any order.  This can't be expressed using the .WAIT
     78 # notation inside the SUBDIR list.
     79 #
     80 # XXX .ORDER does not work when multiple targets are passed on the
     81 # make command line without "-j", so use dependencies in addition to .ORDER.
     82 #
     83 .ORDER: dependall-host-mkdep dependall-compat dependall-binstall
     84 .if make(dependall-host-mkdep) && make(dependall-compat)
     85 dependall-compat: dependall-host-mkdep
     86 .endif
     87 .if make(dependall-compat) && make(dependall-binstall)
     88 dependall-binstall: dependall-compat
     89 .endif
     90 
     91 # Dependencies in SUBDIR below ordered to maximize parallel ability.
     92 # See above for special treatment for host-mkdep, compat, and binstall.
     93 #
     94 SUBDIR=	host-mkdep compat binstall \
     95 	.WAIT mktemp .WAIT sed .WAIT genassym
     96 .if ${TOOLS_BUILDRUMP} == "no"
     97 SUBDIR+= cap_mkdb crunchgen ctags gencat hexdump \
     98 		${LINT_BITS} \
     99 		makewhatis mtree nbperf .WAIT uudecode
    100 .endif
    101 
    102 SUBDIR+= cat rpcgen join lorder m4 mkdep tsort .WAIT yacc .WAIT awk .WAIT lex
    103 .if ${TOOLS_BUILDRUMP} == "no"
    104 SUBDIR+= xz-include .WAIT grep xz-lib pax .WAIT libprop
    105 
    106 SUBDIR += .WAIT texinfo \
    107 	.WAIT tic \
    108 	.WAIT ${TOOLCHAIN_BITS} \
    109 	${DTRACE_BITS} \
    110 		asn1_compile cksum compile_et db \
    111 		file lint1 slc \
    112 		makefs sortinfo \
    113 		.WAIT menuc mkcsmapper mkesdb mklocale mknod msgc \
    114 		.WAIT disklabel gpt \
    115 		.WAIT paxctl \
    116 		.WAIT fdisk \
    117 		.WAIT installboot \
    118 		pwd_mkdb strfile sunlabel vgrind zic
    119 .endif
    120 SUBDIR+= stat .WAIT config
    121 .if ${TOOLS_BUILDRUMP} == "no"
    122 SUBDIR+= xz-bin
    123 .endif
    124 
    125 .if ${MKLLVM} != "no" || ${MKLLVMRT} != "no"
    126 SUBDIR+= \
    127 	llvm .WAIT \
    128 	llvm-lib/libLLVMDemangle llvm-lib/libLLVMSupport llvm-lib/libLLVMTableGen .WAIT \
    129 	llvm-tblgen
    130 .endif
    131 .if ${MKLLVM} != "no"
    132 SUBDIR+= \
    133 	llvm-clang-tblgen
    134 .endif
    135 .if ${MKLLVM} != "no" && !defined(EXTERNAL_TOOLCHAIN)
    136 SUBDIR+= \
    137 	.WAIT llvm-include .WAIT \
    138 	llvm-lib .WAIT \
    139 	llvm-clang
    140 .endif
    141 
    142 .if ${MKMAN} != "no" || ${MKDOC} != "no" || ${MKHTML} != "no"
    143 . if ${MKGROFF} != "no"
    144 SUBDIR+=	groff
    145 . endif
    146 SUBDIR+=	mandoc
    147 .endif
    148 
    149 .if ${TOOLS_BUILDRUMP} == "no"
    150 
    151 .if ${MKMAINTAINERTOOLS:Uno} != "no"
    152 SUBDIR+=	autoconf .WAIT gettext
    153 .endif
    154 
    155 .if ${USE_PIGZGZIP} != "no"
    156 SUBDIR+=	pigz
    157 .endif
    158 
    159 .if ${MACHINE} == "hppa"
    160 SUBDIR+=	hppa-mkboot
    161 .endif
    162 
    163 .if ${MACHINE} == "ibmnws"
    164 SUBDIR+=	ibmnws-ncdcs
    165 .endif
    166 
    167 .if ${MACHINE} == "macppc"
    168 SUBDIR+=	macppc-fixcoff
    169 .endif
    170 
    171 .if (${MACHINE} == "prep" || ${MACHINE} == "rs6000" || ${MACHINE} == "bebox")
    172 SUBDIR+=	powerpc-mkbootimage
    173 .endif
    174 
    175 .if ${MACHINE_CPU} == "arm"
    176 SUBDIR+=	arm-elf2aout
    177 .endif
    178 
    179 .if ${MACHINE_CPU} == "m68k"
    180 SUBDIR+=	m68k-elf2aout
    181 .endif
    182 
    183 .if !empty(MACHINE_ARCH:Mmips*)
    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} == "evbsh3" || \
    216     ${MACHINE} == "sandpoint"
    217 SUBDIR+=	mkubootimage
    218 SUBDIR+=	libfdt .WAIT
    219 SUBDIR+=	dtc
    220 .endif
    221 
    222 .if ${MKX11} != "no"
    223 SUBDIR+=	makestrs
    224 SUBDIR+=	makekeys
    225 .endif
    226 
    227 SUBDIR+= cvslatest
    228 
    229 .endif # TOOLS_BUILDRUMP != no
    230 
    231 check_MKTOOLS: .PHONY .NOTMAIN
    232 .if ${MKTOOLS:Uyes} == "no"
    233 	@echo '*** WARNING: "MKTOOLS" is set to "no"; this will prevent building and'
    234 	@echo '*** updating your host toolchain.  This should be used only as a'
    235 	@echo '*** temporary workaround for toolchain problems, as it will result'
    236 	@echo '*** in version skew and build errors over time!'
    237 .endif
    238 
    239 .if ${MKTOOLS:Uyes} == "no" || ${USETOOLS} != "yes"	# {
    240 SUBDIR= # empty
    241 realall realdepend install: check_MKTOOLS
    242 .endif							# }
    243 
    244 .include <bsd.subdir.mk>
    245 .include <bsd.buildinstall.mk>
    246 .include <bsd.obj.mk>
    247 
    248 .if !defined(PREVIOUSTOOLDIR)
    249 .  if exists(PREVIOUSTOOLDIR)
    250 PREVIOUSTOOLDIR!=	cat PREVIOUSTOOLDIR
    251 .  else
    252 PREVIOUSTOOLDIR=
    253 .  endif
    254 .endif
    255 
    256 CLEANFILES+=	PREVIOUSTOOLDIR
    257 
    258 realall realdepend: .MAKE
    259 .if !empty(PREVIOUSTOOLDIR) && "${PREVIOUSTOOLDIR}" != "${TOOLDIR}"
    260 	@echo "*** WARNING: TOOLDIR has moved?"
    261 	@echo "*** PREVIOUSTOOLDIR '${PREVIOUSTOOLDIR}'"
    262 	@echo "***     !=  TOOLDIR '${TOOLDIR}'"
    263 	@echo "*** Cleaning mis-matched tools"
    264 	rm -f PREVIOUSTOOLDIR
    265 	(cd ${.CURDIR} && ${MAKE} PREVIOUSTOOLDIR=${TOOLDIR} cleandir)
    266 .endif
    267 	echo ${TOOLDIR} >PREVIOUSTOOLDIR
    268 
    269 cleandir:
    270 	rm -f ${CLEANFILES}
    271