Home | History | Annotate | Line # | Download | only in tools
Makefile revision 1.214.2.1
      1 #	$NetBSD: Makefile,v 1.214.2.1 2024/07/03 18:38:54 martin 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 elftoolchain
     62 DTRACE_BITS+= .WAIT libctf
     63 .endif
     64 .if ${MKCTF} != "no"
     65 DTRACE_BITS+= .WAIT ctfconvert ctfmerge
     66 .endif
     67 
     68 LINT_BITS=
     69 .if ${MKLINT} != "no"
     70 LINT_BITS= lint lint2
     71 .endif
     72 
     73 # All of host-mkdep, compat, and binstall are needed before anything
     74 # else.  Within this group, they must be built in a specific order, and
     75 # all of them must be built before any of them is installed.  They may
     76 # be installed in any order.  This can't be expressed using the .WAIT
     77 # notation inside the SUBDIR list.
     78 #
     79 # XXX .ORDER does not work when multiple targets are passed on the
     80 # make command line without "-j", so use dependencies in addition to .ORDER.
     81 #
     82 .ORDER: dependall-host-mkdep dependall-compat dependall-binstall \
     83 	dependall-date
     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 .if make(dependall-date)
     91 dependall-date: dependall-host-mkdep dependall-compat
     92 .endif
     93 
     94 # Dependencies in SUBDIR below ordered to maximize parallel ability.
     95 # See above for special treatment for host-mkdep, compat, and binstall.
     96 #
     97 SUBDIR=	host-mkdep compat binstall date \
     98 	.WAIT mktemp .WAIT sed .WAIT genassym
     99 .if ${TOOLS_BUILDRUMP} == "no"
    100 SUBDIR+= cap_mkdb crunchgen ctags gencat hexdump \
    101 		${LINT_BITS} \
    102 		makewhatis mtree nbperf .WAIT uudecode
    103 .endif
    104 
    105 SUBDIR+= cat rpcgen join lorder m4 mkdep tsort .WAIT yacc .WAIT awk .WAIT lex
    106 .if ${TOOLS_BUILDRUMP} == "no"
    107 SUBDIR+= xz-include .WAIT grep xz-lib pax .WAIT libprop
    108 
    109 SUBDIR += .WAIT texinfo \
    110 	.WAIT tic \
    111 	.WAIT ${TOOLCHAIN_BITS} \
    112 	${DTRACE_BITS} \
    113 		asn1_compile cksum compile_et db \
    114 		file lint1 slc \
    115 		makefs sortinfo \
    116 		.WAIT menuc mkcsmapper mkesdb mklocale mknod msgc \
    117 		.WAIT disklabel gpt \
    118 		.WAIT paxctl \
    119 		.WAIT fdisk \
    120 		.WAIT installboot \
    121 		pwd_mkdb strfile sunlabel vgrind zic
    122 .endif
    123 SUBDIR+= stat .WAIT config
    124 .if ${TOOLS_BUILDRUMP} == "no"
    125 SUBDIR+= xz-bin
    126 .endif
    127 
    128 .if ${MKLLVM} != "no" || ${MKLLVMRT} != "no"
    129 SUBDIR+= \
    130 	llvm .WAIT \
    131 	llvm-lib/libLLVMDemangle llvm-lib/libLLVMSupport llvm-lib/libLLVMTableGen .WAIT \
    132 	llvm-tblgen
    133 .endif
    134 .if ${MKLLVM} != "no"
    135 SUBDIR+= \
    136 	llvm-clang-tblgen
    137 .endif
    138 .if ${MKLLVM} != "no" && !defined(EXTERNAL_TOOLCHAIN)
    139 SUBDIR+= \
    140 	.WAIT llvm-include .WAIT \
    141 	llvm-lib .WAIT \
    142 	llvm-clang
    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 SUBDIR+=	macppc_installboot
    173 .endif
    174 
    175 .if (${MACHINE} == "prep" || ${MACHINE} == "rs6000" || ${MACHINE} == "bebox")
    176 SUBDIR+=	powerpc-mkbootimage
    177 .endif
    178 
    179 .if ${MACHINE_CPU} == "arm"
    180 SUBDIR+=	arm-elf2aout
    181 .endif
    182 
    183 .if ${MACHINE_CPU} == "m68k"
    184 SUBDIR+=	m68k-elf2aout
    185 .endif
    186 
    187 .if !empty(MACHINE_ARCH:Mmips*)
    188 SUBDIR+=	mips-elf2ecoff
    189 .endif
    190 
    191 .if (${MACHINE} == "sgimips")
    192 SUBDIR+=	sgivol
    193 .endif
    194 
    195 .if ${MACHINE} == "acorn32"
    196 SUBDIR+=	sparkcrc
    197 .endif
    198 
    199 .if (${MACHINE_ARCH} == "sparc" || ${MACHINE_ARCH} == "sparc64")
    200 SUBDIR+=	fgen
    201 .endif
    202 
    203 .if ${MACHINE} == "amiga"
    204 SUBDIR+=	amiga-elf2bb
    205 SUBDIR+=	amiga-txlt
    206 .endif
    207 
    208 .if ${MACHINE} == "hp300"
    209 SUBDIR+=	hp300-mkboot
    210 .endif
    211 
    212 .if ${MACHINE} == "evbarm" \
    213     && ${MACHINE_CPU} == "arm" \
    214     && ${TARGET_ENDIANNESS} == "1234"
    215 SUBDIR+=	elftosb
    216 .endif
    217 
    218 .if ${MACHINE} == "evbarm" || ${MACHINE} == "evbmips" || \
    219     ${MACHINE} == "evbppc" || ${MACHINE} == "evbsh3" || \
    220     ${MACHINE} == "sandpoint"
    221 SUBDIR+=	mkubootimage
    222 .endif
    223 
    224 .if ${MACHINE} == "evbarm" || ${MACHINE} == "evbmips" || \
    225     ${MACHINE} == "evbppc" || ${MACHINE} == "evbsh3" || \
    226     ${MACHINE} == "sandpoint" || \
    227     ${MACHINE_CPU} == "riscv"
    228 SUBDIR+=	libfdt .WAIT
    229 SUBDIR+=	dtc
    230 .endif
    231 
    232 .if ${MACHINE} == "mvme68k"
    233 SUBDIR+=	mvme68k-wrtvid
    234 .endif
    235 
    236 .if ${MACHINE} == "mac68k" || ${MACHINE} == "macppc"
    237 SUBDIR+=	mkhybrid
    238 .endif
    239 
    240 .if ${MKX11} != "no"
    241 SUBDIR+=	makestrs
    242 SUBDIR+=	makekeys
    243 .endif
    244 
    245 SUBDIR+= cvslatest
    246 
    247 .endif # TOOLS_BUILDRUMP != no
    248 
    249 check_MKTOOLS: .PHONY .NOTMAIN
    250 .if ${MKTOOLS:Uyes} == "no"
    251 	@echo '*** WARNING: "MKTOOLS" is set to "no"; this will prevent building and'
    252 	@echo '*** updating your host toolchain.  This should be used only as a'
    253 	@echo '*** temporary workaround for toolchain problems, as it will result'
    254 	@echo '*** in version skew and build errors over time!'
    255 .endif
    256 
    257 .if ${MKTOOLS:Uyes} == "no" || ${USETOOLS} != "yes"	# {
    258 SUBDIR= # empty
    259 realall realdepend install: check_MKTOOLS
    260 .endif							# }
    261 
    262 .include <bsd.subdir.mk>
    263 .include <bsd.buildinstall.mk>
    264 .include <bsd.obj.mk>
    265 
    266 .if !defined(PREVIOUSTOOLDIR)
    267 .  if exists(PREVIOUSTOOLDIR)
    268 PREVIOUSTOOLDIR!=	cat PREVIOUSTOOLDIR
    269 .  else
    270 PREVIOUSTOOLDIR=
    271 .  endif
    272 .endif
    273 
    274 CLEANFILES+=	PREVIOUSTOOLDIR
    275 
    276 realall realdepend: .MAKE
    277 .if !empty(PREVIOUSTOOLDIR) && "${PREVIOUSTOOLDIR}" != "${TOOLDIR}"
    278 	@echo "*** WARNING: TOOLDIR has moved?"
    279 	@echo "*** PREVIOUSTOOLDIR '${PREVIOUSTOOLDIR}'"
    280 	@echo "***     !=  TOOLDIR '${TOOLDIR}'"
    281 	@echo "*** Cleaning mis-matched tools"
    282 	rm -f PREVIOUSTOOLDIR
    283 	(cd ${.CURDIR} && ${MAKE} PREVIOUSTOOLDIR=${TOOLDIR} cleandir)
    284 .endif
    285 	echo ${TOOLDIR} >PREVIOUSTOOLDIR
    286 
    287 cleandir:
    288 	rm -f ${CLEANFILES}
    289