Home | History | Annotate | Line # | Download | only in tools
Makefile revision 1.215
      1 #	$NetBSD: Makefile,v 1.215 2023/11/30 06:29:33 rin 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 .endif
    173 
    174 .if (${MACHINE} == "prep" || ${MACHINE} == "rs6000" || ${MACHINE} == "bebox")
    175 SUBDIR+=	powerpc-mkbootimage
    176 .endif
    177 
    178 .if ${MACHINE_CPU} == "arm"
    179 SUBDIR+=	arm-elf2aout
    180 .endif
    181 
    182 .if ${MACHINE_CPU} == "m68k"
    183 SUBDIR+=	m68k-elf2aout
    184 .endif
    185 
    186 .if !empty(MACHINE_ARCH:Mmips*)
    187 SUBDIR+=	mips-elf2ecoff
    188 .endif
    189 
    190 .if (${MACHINE} == "sgimips")
    191 SUBDIR+=	sgivol
    192 .endif
    193 
    194 .if ${MACHINE} == "acorn32"
    195 SUBDIR+=	sparkcrc
    196 .endif
    197 
    198 .if (${MACHINE_ARCH} == "sparc" || ${MACHINE_ARCH} == "sparc64")
    199 SUBDIR+=	fgen
    200 .endif
    201 
    202 .if ${MACHINE} == "amiga"
    203 SUBDIR+=	amiga-elf2bb
    204 SUBDIR+=	amiga-txlt
    205 .endif
    206 
    207 .if ${MACHINE} == "hp300"
    208 SUBDIR+=	hp300-mkboot
    209 .endif
    210 
    211 .if ${MACHINE} == "evbarm" \
    212     && ${MACHINE_CPU} == "arm" \
    213     && ${TARGET_ENDIANNESS} == "1234"
    214 SUBDIR+=	elftosb
    215 .endif
    216 
    217 .if ${MACHINE} == "evbarm" || ${MACHINE} == "evbmips" || \
    218     ${MACHINE} == "evbppc" || ${MACHINE} == "evbsh3" || \
    219     ${MACHINE} == "sandpoint"
    220 SUBDIR+=	mkubootimage
    221 .endif
    222 
    223 .if ${MACHINE} == "evbarm" || ${MACHINE} == "evbmips" || \
    224     ${MACHINE} == "evbppc" || ${MACHINE} == "evbsh3" || \
    225     ${MACHINE} == "sandpoint" || \
    226     ${MACHINE_CPU} == "riscv"
    227 SUBDIR+=	libfdt .WAIT
    228 SUBDIR+=	dtc
    229 .endif
    230 
    231 .if ${MACHINE} == "mvme68k"
    232 SUBDIR+=	mvme68k-wrtvid
    233 .endif
    234 
    235 .if ${MKX11} != "no"
    236 SUBDIR+=	makestrs
    237 SUBDIR+=	makekeys
    238 .endif
    239 
    240 SUBDIR+= cvslatest
    241 
    242 .endif # TOOLS_BUILDRUMP == no
    243 
    244 check_MKTOOLS: .PHONY .NOTMAIN
    245 .if ${MKTOOLS:Uyes} == "no"
    246 	@echo '*** WARNING: "MKTOOLS" is set to "no"; this will prevent building and'
    247 	@echo '*** updating your host toolchain.  This should be used only as a'
    248 	@echo '*** temporary workaround for toolchain problems, as it will result'
    249 	@echo '*** in version skew and build errors over time!'
    250 .endif
    251 
    252 .if ${MKTOOLS:Uyes} == "no" || ${USETOOLS} != "yes"	# {
    253 SUBDIR= # empty
    254 realall realdepend install: check_MKTOOLS
    255 .endif							# }
    256 
    257 .include <bsd.subdir.mk>
    258 .include <bsd.buildinstall.mk>
    259 .include <bsd.obj.mk>
    260 
    261 .if !defined(PREVIOUSTOOLDIR)
    262 .  if exists(PREVIOUSTOOLDIR)
    263 PREVIOUSTOOLDIR!=	cat PREVIOUSTOOLDIR
    264 .  else
    265 PREVIOUSTOOLDIR=
    266 .  endif
    267 .endif
    268 
    269 CLEANFILES+=	PREVIOUSTOOLDIR
    270 
    271 realall realdepend: .MAKE
    272 .if !empty(PREVIOUSTOOLDIR) && "${PREVIOUSTOOLDIR}" != "${TOOLDIR}"
    273 	@echo "*** WARNING: TOOLDIR has moved?"
    274 	@echo "*** PREVIOUSTOOLDIR '${PREVIOUSTOOLDIR}'"
    275 	@echo "***     !=  TOOLDIR '${TOOLDIR}'"
    276 	@echo "*** Cleaning mis-matched tools"
    277 	rm -f PREVIOUSTOOLDIR
    278 	(cd ${.CURDIR} && ${MAKE} PREVIOUSTOOLDIR=${TOOLDIR} cleandir)
    279 .endif
    280 	echo ${TOOLDIR} >PREVIOUSTOOLDIR
    281 
    282 cleandir:
    283 	rm -f ${CLEANFILES}
    284