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