Home | History | Annotate | Line # | Download | only in mk
      1 #      $NetBSD: bsd.own.mk,v 1.1482 2026/05/10 14:19:10 tls Exp $
      2 
      3 # This needs to be before bsd.init.mk
      4 .if defined(BSD_MK_COMPAT_FILE)
      5 .include <${BSD_MK_COMPAT_FILE}>
      6 .endif
      7 
      8 .if !defined(_BSD_OWN_MK_)
      9 _BSD_OWN_MK_=1
     10 
     11 MAKECONF?=	/etc/mk.conf
     12 .-include "${MAKECONF}"
     13 
     14 #
     15 # CPU model, derived from MACHINE_ARCH
     16 #
     17 MACHINE_CPU=	${MACHINE_ARCH:C/mips.*e[bl]/mips/:C/sh3e[bl]/sh3/:S/coldfire/m68k/:S/m68000/m68k/:S/m68ksf/m68k/:C/e?arm.*/arm/:S/powerpc64/powerpc/:S/aarch64eb/aarch64/:S/or1knd/or1k/:C/riscv../riscv/}
     18 
     19 .if (${MACHINE_ARCH} == "mips64el" || \
     20      ${MACHINE_ARCH} == "mips64eb" || \
     21      ${MACHINE_ARCH} == "mipsn64el" || \
     22      ${MACHINE_ARCH} == "mipsn64eb")
     23 MACHINE_MIPS64= 	1
     24 .else
     25 MACHINE_MIPS64= 	0
     26 .endif
     27 
     28 .if ${MACHINE_ARCH} == "m68ksf"
     29 BFD_MACHINE_ARCH=m68k
     30 BINUTILS_MACHINE_ARCH=m68k
     31 GCC_MACHINE_ARCH=m68k
     32 GDB_MACHINE_ARCH=m68k
     33 GMP_MACHINE_ARCH=m68k
     34 GOMP_MACHINE_ARCH=m68k
     35 LDELFSO_MACHINE_ARCH=m68k
     36 LIBC_MACHINE_ARCH=m68k
     37 LIBEXECINFO_MACHINE_ARCH=m68k
     38 LIBEXEC_MACHINE_ARCH=m68k
     39 LIBGCC_MACHINE_ARCH=m68k
     40 LIBKERN_ARCH=m68k
     41 .endif
     42 
     43 #
     44 # Subdirectory used below ${RELEASEDIR} when building a release
     45 #
     46 .if \
     47     ${MACHINE:Mevbarm} || \
     48     ${MACHINE:Mevbmips} || \
     49     ${MACHINE:Mevbsh3} || \
     50     ${MACHINE:Mriscv}
     51 RELEASEMACHINEDIR?=	${MACHINE}-${MACHINE_ARCH}
     52 .else
     53 RELEASEMACHINEDIR?=	${MACHINE}
     54 .endif
     55 
     56 #
     57 # Subdirectory or path component used for the following paths:
     58 #   distrib/${RELEASEMACHINE}
     59 #   distrib/notes/${RELEASEMACHINE}
     60 #   etc/etc.${RELEASEMACHINE}
     61 # Used when building a release.
     62 #
     63 RELEASEMACHINE?=	${MACHINE}
     64 
     65 #
     66 # NEED_OWN_INSTALL_TARGET is set to "no" by pkgsrc/mk/bsd.pkg.mk to
     67 # ensure that things defined by <bsd.own.mk> (default targets,
     68 # INSTALL_FILE, etc.) are not conflicting with bsd.pkg.mk.
     69 #
     70 NEED_OWN_INSTALL_TARGET?=	yes
     71 
     72 #
     73 # This lists the platforms which do not have working in-tree toolchains.  For
     74 # the in-tree gcc toolchain, this list is empty.
     75 #
     76 # If some future port is not supported by the in-tree toolchain, this should
     77 # be set to "yes" for that port only.
     78 #
     79 # .if ${MACHINE} == "playstation2"
     80 # TOOLCHAIN_MISSING?=	yes
     81 # .endif
     82 
     83 TOOLCHAIN_MISSING?=	no
     84 
     85 #
     86 # GCC Using platforms.
     87 #
     88 .if ${MKGCC:Uyes} != "no"						# {
     89 
     90 #
     91 # What GCC is used?
     92 #
     93 .if \
     94     ${MACHINE} == "alpha" || \
     95     ${MACHINE_CPU} == "m68k"
     96 HAVE_GCC?=	12
     97 .endif
     98 
     99 HAVE_GCC?=	14
    100 
    101 #
    102 # Platforms that can't run a modern GCC natively
    103 .if ${MACHINE_ARCH} == "m68000"
    104 MKGCCCMDS?=	no
    105 .endif
    106 
    107 #
    108 # We import the old gcc as "gcc.old" when upgrading.  EXTERNAL_GCC_SUBDIR is
    109 # set to the relevant subdirectory in src/external/gpl3 for this HAVE_GCC.
    110 #
    111 .if ${HAVE_GCC} == 12
    112 EXTERNAL_GCC_SUBDIR?=	gcc.old
    113 .elif ${HAVE_GCC} == 14
    114 EXTERNAL_GCC_SUBDIR?=	gcc
    115 .else
    116 EXTERNAL_GCC_SUBDIR?=	/does/not/exist
    117 .endif
    118 
    119 .else	# MKGCC == no							# } {
    120 MKGCCCMDS?=	no
    121 .endif	# MKGCC == no							# }
    122 
    123 #
    124 # Build GCC with the "isl" library enabled.
    125 # The alpha port does not work with it, see GCC PR's 84204 and 84353.
    126 # Other ports don't have vector units GCC can target.
    127 #
    128 .if ${MACHINE} == "alpha" || \
    129     ${MACHINE_CPU} == "m68k" || \
    130     ${MACHINE_CPU} == "sh3" || \
    131     ${MACHINE} == "vax"
    132 NOGCCISL=	# defined
    133 .endif
    134 
    135 #
    136 # Build GCC with libquadmath.
    137 # E.g.:  grep '#define HAVE_FLOAT128 1' lib/libgfortran/arch/*/config.h
    138 #
    139 .if ${MACHINE_ARCH} == "i386" || \
    140     ${MACHINE_ARCH} == "ia64" || \
    141     ${MACHINE_ARCH} == "x86_64"
    142 HAVE_QUADMATH?=	yes
    143 .endif
    144 HAVE_QUADMATH?=	no
    145 
    146 #
    147 # What binutils is used?
    148 #
    149 HAVE_BINUTILS?= 246
    150 
    151 .if ${HAVE_BINUTILS} == 246
    152 EXTERNAL_BINUTILS_SUBDIR=	binutils
    153 .elif ${HAVE_BINUTILS} == 245
    154 EXTERNAL_BINUTILS_SUBDIR=	binutils.old
    155 .else
    156 EXTERNAL_BINUTILS_SUBDIR=	/does/not/exist
    157 .endif
    158 
    159 #
    160 # What GDB is used?
    161 #
    162 HAVE_GDB?=	1710
    163 
    164 .if ${HAVE_GDB} == 1710
    165 EXTERNAL_GDB_SUBDIR=		gdb
    166 .elif ${HAVE_GDB} == 1630
    167 EXTERNAL_GDB_SUBDIR=		gdb.old
    168 .else
    169 EXTERNAL_GDB_SUBDIR=		/does/not/exist
    170 .endif
    171 
    172 .if ${MACHINE_ARCH} == "x86_64"
    173 MKGDBSERVER?=	yes
    174 .endif
    175 MKGDBSERVER?=	no
    176 
    177 #
    178 # What OpenSSL is used?
    179 #
    180 HAVE_OPENSSL?=	35
    181 
    182 .if ${HAVE_OPENSSL} == 35
    183 EXTERNAL_OPENSSL_SUBDIR=apache2/openssl
    184 .elif ${HAVE_OPENSSL} == 30
    185 EXTERNAL_OPENSSL_SUBDIR=bsd/openssl
    186 .elif ${HAVE_OPENSSL} == 11
    187 EXTERNAL_OPENSSL_SUBDIR=bsd/openssl.old
    188 .else
    189 EXTERNAL_OPENSSL_SUBDIR=/does/not/exist
    190 .endif
    191 
    192 #
    193 # Does the platform support ACPI?
    194 #
    195 .if \
    196     ${MACHINE_ARCH:Maarch64*} || \
    197     ${MACHINE} == "amd64" || \
    198     ${MACHINE} == "i386" || \
    199     ${MACHINE} == "ia64"
    200 HAVE_ACPI=	yes
    201 .else
    202 HAVE_ACPI=	no
    203 .endif
    204 
    205 #
    206 # Does the platform support UEFI?
    207 #
    208 .if \
    209     ${MACHINE_ARCH:Maarch64*} || \
    210     ${MACHINE} == "amd64" || \
    211     ${MACHINE_ARCH:Mearmv7*} || \
    212     ${MACHINE} == "i386" || \
    213     ${MACHINE} == "ia64" || \
    214     ${MACHINE_ARCH} == "riscv64"
    215 HAVE_UEFI=	yes
    216 .else
    217 HAVE_UEFI=	no
    218 .endif
    219 
    220 #
    221 # Does the platform support EFI RT services?
    222 #
    223 .if ${HAVE_UEFI} == "yes" && ${MACHINE_ARCH:M*eb} == ""
    224 HAVE_EFI_RT=	yes
    225 .else
    226 HAVE_EFI_RT=	no
    227 .endif
    228 
    229 #
    230 # Does the platform support NVMM?
    231 #
    232 .if ${MACHINE_ARCH} == "x86_64"
    233 HAVE_NVMM=	yes
    234 .else
    235 HAVE_NVMM=	no
    236 .endif
    237 
    238 
    239 .if ${MACHINE_ARCH:Mearm*}
    240 _LIBC_COMPILER_RT.${MACHINE_ARCH}=	yes
    241 .endif
    242 
    243 _LIBC_COMPILER_RT.aarch64=	yes
    244 _LIBC_COMPILER_RT.aarch64eb=	yes
    245 _LIBC_COMPILER_RT.i386=		yes
    246 _LIBC_COMPILER_RT.powerpc=	yes
    247 _LIBC_COMPILER_RT.powerpc64=	yes
    248 _LIBC_COMPILER_RT.sparc=	yes
    249 _LIBC_COMPILER_RT.sparc64=	yes
    250 _LIBC_COMPILER_RT.x86_64=	yes
    251 
    252 .if ${HAVE_LLVM:Uno} == "yes" && ${_LIBC_COMPILER_RT.${MACHINE_ARCH}:Uno} == "yes"
    253 HAVE_LIBGCC?=	no
    254 .else
    255 HAVE_LIBGCC?=	yes
    256 .endif
    257 
    258 
    259 # Should libgcc have unwinding code?
    260 .if ${HAVE_LLVM:Uno} == "yes" || ${MACHINE_ARCH:Mearm*}
    261 HAVE_LIBGCC_EH?=	no
    262 .else
    263 HAVE_LIBGCC_EH?=	yes
    264 .endif
    265 
    266 # Coverity does not like SSP
    267 .if defined(COVERITY_TOP_CONFIG) || \
    268     ${MACHINE} == "alpha" || \
    269     ${MACHINE} == "hppa" || \
    270     ${MACHINE} == "ia64"
    271 HAVE_SSP?=	no
    272 .else
    273 HAVE_SSP?=	yes
    274 .if !defined(NOFORT) && ${USE_FORT:Uno} != "no"
    275 USE_SSP?=	yes
    276 .endif
    277 .endif
    278 
    279 #
    280 # What version of jemalloc we use (100 is the one
    281 # built-in to libc from 2005 (pre version 3).
    282 #
    283 .if \
    284     ${MACHINE} == "sun2" || \
    285     ${MACHINE_ARCH} == "vax"
    286 HAVE_JEMALLOC?=		100
    287 .else
    288 HAVE_JEMALLOC?=		531
    289 .endif
    290 
    291 .if ${HAVE_JEMALLOC} == 531 || ${HAVE_JEMALLOC} == 100
    292 EXTERNAL_JEMALLOC_SUBDIR = jemalloc
    293 .elif ${HAVE_JEMALLOC} == 530
    294 EXTERNAL_JEMALLOC_SUBDIR = jemalloc.old
    295 .else
    296 EXTERNAL_JEMALLOC_SUBDIR = /does/not/exist
    297 .endif
    298 
    299 .if empty(.MAKEFLAGS:tW:M*-V .OBJDIR*)
    300 .if defined(MAKEOBJDIRPREFIX) || defined(MAKEOBJDIR)
    301 PRINTOBJDIR=	${MAKE} -B -r -V .OBJDIR -f /dev/null xxx
    302 .else
    303 PRINTOBJDIR=	${MAKE} -B -V .OBJDIR
    304 .endif
    305 .else
    306 PRINTOBJDIR=	echo /error/bsd.own.mk/PRINTOBJDIR # avoid infinite recursion
    307 .endif
    308 
    309 #
    310 # Make sure we set _NETBSD_REVISIONID in CPPFLAGS if requested.
    311 #
    312 .ifdef NETBSD_REVISIONID
    313 _NETBSD_REVISIONID_STR=	"${NETBSD_REVISIONID}"
    314 CPPFLAGS+=	-D_NETBSD_REVISIONID=${_NETBSD_REVISIONID_STR:Q}
    315 .endif
    316 
    317 #
    318 # Determine if running in the NetBSD source tree by checking for the
    319 # existence of build.sh and tools/ in the current or a parent directory,
    320 # and setting _SRC_TOP_ to the result.
    321 #
    322 .if !defined(_SRC_TOP_)			# {
    323 _SRC_TOP_!= cd "${.CURDIR}"; while :; do \
    324 		here=$$(pwd); \
    325 		[ -f build.sh  ] && [ -d tools ] && { echo $$here; break; }; \
    326 		case $$here in /) echo ""; break;; esac; \
    327 		cd ..; done
    328 
    329 .MAKEOVERRIDES+=	_SRC_TOP_
    330 
    331 .endif					# }
    332 
    333 #
    334 # If _SRC_TOP_ != "", we're within the NetBSD source tree.
    335 # * Set defaults for NETBSDSRCDIR and _SRC_TOP_OBJ_.
    336 # * Define _NETBSD_VERSION_DEPENDS.  Targets that depend on the
    337 #   NetBSD version, or on variables defined at build time, can
    338 #   declare a dependency on ${_NETBSD_VERSION_DEPENDS}.
    339 #
    340 .if (${_SRC_TOP_} != "")		# {
    341 
    342 NETBSDSRCDIR?=	${_SRC_TOP_}
    343 
    344 .if !defined(_SRC_TOP_OBJ_)
    345 _SRC_TOP_OBJ_!=		cd "${_SRC_TOP_}" && ${PRINTOBJDIR}
    346 .MAKEOVERRIDES+=	_SRC_TOP_OBJ_
    347 .endif
    348 
    349 _NETBSD_VERSION_DEPENDS=	${_SRC_TOP_OBJ_}/params
    350 _NETBSD_VERSION_DEPENDS+=	${NETBSDSRCDIR}/sys/sys/param.h
    351 _NETBSD_VERSION_DEPENDS+=	${NETBSDSRCDIR}/sys/conf/newvers.sh
    352 _NETBSD_VERSION_DEPENDS+=	${NETBSDSRCDIR}/sys/conf/osrelease.sh
    353 ${_SRC_TOP_OBJ_}/params: .NOTMAIN .OPTIONAL # created by top level "make build"
    354 
    355 .endif	# _SRC_TOP_ != ""		# }
    356 
    357 
    358 .if (${_SRC_TOP_} != "") && \
    359     (${TOOLCHAIN_MISSING} == "no" || defined(EXTERNAL_TOOLCHAIN))
    360 USETOOLS?=	yes
    361 .endif
    362 USETOOLS?=	no
    363 
    364 
    365 .if \
    366     ${MACHINE_ARCH} == "mips" || \
    367     ${MACHINE_ARCH} == "mips64" || \
    368     ${MACHINE_ARCH} == "sh3"
    369 .BEGIN:
    370 	@echo "Must set MACHINE_ARCH to one of ${MACHINE_ARCH}eb or ${MACHINE_ARCH}el"
    371 	@false
    372 .elif defined(REQUIRETOOLS) && \
    373       (${TOOLCHAIN_MISSING} == "no" || defined(EXTERNAL_TOOLCHAIN)) && \
    374       ${USETOOLS} == "no"
    375 .BEGIN:
    376 	@echo "USETOOLS=no, but this component requires a version-specific host toolchain"
    377 	@false
    378 .endif
    379 
    380 #
    381 # Host platform information; may be overridden
    382 #
    383 .include <bsd.host.mk>
    384 
    385 .if ${USETOOLS} == "yes"						# {
    386 
    387 #
    388 # Provide a default for TOOLDIR.
    389 #
    390 .if !defined(TOOLDIR)
    391 TOOLDIR:=	${_SRC_TOP_OBJ_}/tooldir.${HOST_OSTYPE}
    392 .MAKEOVERRIDES+= TOOLDIR
    393 .endif
    394 
    395 #
    396 # This is the prefix used for the NetBSD-sourced tools.
    397 #
    398 _TOOL_PREFIX?=	nb
    399 
    400 #
    401 # If an external toolchain base is specified, use it.
    402 #
    403 .if defined(EXTERNAL_TOOLCHAIN)						# {
    404 AR=		${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-ar
    405 AS=		${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-as
    406 ELFEDIT=	${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-elfedit
    407 LD=		${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-ld
    408 NM=		${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-nm
    409 OBJCOPY=	${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-objcopy
    410 OBJDUMP=	${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-objdump
    411 RANLIB=		${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-ranlib
    412 READELF=	${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-readelf
    413 SIZE=		${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-size
    414 STRINGS=	${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-strings
    415 STRIP=		${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-strip
    416 
    417 TOOL_CC.gcc=		${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-gcc
    418 TOOL_CPP.gcc=		${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-cpp
    419 TOOL_CXX.gcc=		${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-c++
    420 TOOL_FC.gcc=		${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-gfortran
    421 TOOL_OBJC.gcc=		${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-gcc
    422 
    423 TOOL_CC.clang=		${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-clang
    424 TOOL_CPP.clang=		${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-clang-cpp
    425 TOOL_CXX.clang=		${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-clang++
    426 TOOL_OBJC.clang=	${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-clang
    427 .else									# } {
    428 # Define default locations for common tools.
    429 .if ${USETOOLS_BINUTILS:Uyes} == "yes"					#  {
    430 AR=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-ar
    431 AS=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-as
    432 ELFEDIT=	${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-elfedit
    433 LD=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-ld
    434 NM=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-nm
    435 OBJCOPY=	${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-objcopy
    436 OBJDUMP=	${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-objdump
    437 RANLIB=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-ranlib
    438 READELF=	${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-readelf
    439 SIZE=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-size
    440 STRINGS=	${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-strings
    441 STRIP=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-strip
    442 
    443 # GCC supports C, C++, Fortran and Objective C
    444 TOOL_CC.gcc=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-gcc
    445 TOOL_CPP.gcc=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-cpp
    446 TOOL_CXX.gcc=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-c++
    447 TOOL_FC.gcc=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-gfortran
    448 TOOL_OBJC.gcc=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-gcc
    449 .endif									#  }
    450 
    451 # Clang supports C, C++ and Objective C
    452 TOOL_CC.clang=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-clang
    453 TOOL_CPP.clang=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-clang-cpp
    454 TOOL_CXX.clang=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-clang++
    455 TOOL_OBJC.clang=	${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-clang
    456 
    457 # PCC supports C and Fortran
    458 TOOL_CC.pcc=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-pcc
    459 TOOL_CPP.pcc=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-pcpp
    460 TOOL_CXX.pcc=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-p++
    461 .endif	# EXTERNAL_TOOLCHAIN						# }
    462 
    463 #
    464 # Make sure DESTDIR is set, so that builds with these tools always
    465 # get appropriate -nostdinc, -nostdlib, etc. handling.  The default is
    466 # <empty string>, meaning start from /, the root directory.
    467 #
    468 DESTDIR?=
    469 
    470 # Don't append another copy of sysroot (coming from COMPATCPPFLAGS etc.)
    471 # because it confuses Coverity. Still we need to cov-configure specially
    472 # for each specific sysroot argument.
    473 # Also don't add a sysroot at all if a rumpkernel build.
    474 .if !defined(HOSTPROG) && !defined(HOSTLIB) && !defined(RUMPRUN)
    475 .  if ${DESTDIR} != ""
    476 .	if empty(CPPFLAGS:M*--sysroot=*)
    477 CPPFLAGS+=	--sysroot=${DESTDIR}
    478 .	endif
    479 LDFLAGS+=	--sysroot=${DESTDIR}
    480 .  else
    481 .	if empty(CPPFLAGS:M*--sysroot=*)
    482 CPPFLAGS+=	--sysroot=/
    483 .	endif
    484 LDFLAGS+=	--sysroot=/
    485 .  endif
    486 .endif
    487 
    488 ARM_ELF2AOUT=	${TOOLDIR}/bin/${_TOOL_PREFIX}arm-elf2aout
    489 DBSYM=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-dbsym
    490 INSTALL=	${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-install
    491 LEX=		${TOOLDIR}/bin/${_TOOL_PREFIX}lex
    492 LINT=		CC=${CC:Q} ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-lint
    493 LORDER=		NM=${NM:Q} MKTEMP=${TOOL_MKTEMP:Q} ${TOOLDIR}/bin/${_TOOL_PREFIX}lorder
    494 M68K_ELF2AOUT=	${TOOLDIR}/bin/${_TOOL_PREFIX}m68k-elf2aout
    495 MIPS_ELF2ECOFF=	${TOOLDIR}/bin/${_TOOL_PREFIX}mips-elf2ecoff
    496 MKDEP=		CC=${CC:Q} ${TOOLDIR}/bin/${_TOOL_PREFIX}mkdep
    497 MKDEPCXX=	CC=${CXX:Q} ${TOOLDIR}/bin/${_TOOL_PREFIX}mkdep
    498 PAXCTL=		${TOOLDIR}/bin/${_TOOL_PREFIX}paxctl
    499 TSORT=		${TOOLDIR}/bin/${_TOOL_PREFIX}tsort -q
    500 YACC=		${TOOLDIR}/bin/${_TOOL_PREFIX}yacc
    501 
    502 GROFF_SHARE_PATH=	${TOOLDIR}/share/groff
    503 TOOL_GROFF_ENV= \
    504     GROFF_ENCODING= \
    505     GROFF_BIN_PATH=${TOOLDIR}/lib/groff \
    506     GROFF_FONT_PATH=${GROFF_SHARE_PATH}/site-font:${GROFF_SHARE_PATH}/font \
    507     GROFF_TMAC_PATH=${GROFF_SHARE_PATH}/site-tmac:${GROFF_SHARE_PATH}/tmac
    508 
    509 TOOL_AMIGAAOUT2BB=	${TOOLDIR}/bin/${_TOOL_PREFIX}amiga-aout2bb
    510 TOOL_AMIGAELF2BB=	${TOOLDIR}/bin/${_TOOL_PREFIX}amiga-elf2bb
    511 TOOL_AMIGATXLT=		${TOOLDIR}/bin/${_TOOL_PREFIX}amiga-txlt
    512 TOOL_ARMELF2AOUT=	${TOOLDIR}/bin/${_TOOL_PREFIX}arm-elf2aout
    513 TOOL_ASN1_COMPILE=	${TOOLDIR}/bin/${_TOOL_PREFIX}asn1_compile
    514 TOOL_AWK=		${TOOLDIR}/bin/${_TOOL_PREFIX}awk
    515 TOOL_CAP_MKDB=		${TOOLDIR}/bin/${_TOOL_PREFIX}cap_mkdb
    516 TOOL_CAT=		${TOOLDIR}/bin/${_TOOL_PREFIX}cat
    517 TOOL_CKSUM=		${TOOLDIR}/bin/${_TOOL_PREFIX}cksum
    518 TOOL_CLANG_TBLGEN=	${TOOLDIR}/bin/${_TOOL_PREFIX}clang-tblgen
    519 TOOL_COMPILE_ET=	${TOOLDIR}/bin/${_TOOL_PREFIX}compile_et
    520 TOOL_CONFIG=		${TOOLDIR}/bin/${_TOOL_PREFIX}config
    521 TOOL_CRUNCHGEN=		MAKE=${.MAKE:Q} ${TOOLDIR}/bin/${_TOOL_PREFIX}crunchgen
    522 TOOL_CTAGS=		${TOOLDIR}/bin/${_TOOL_PREFIX}ctags
    523 TOOL_CTFCONVERT=	${TOOLDIR}/bin/${_TOOL_PREFIX}ctfconvert
    524 TOOL_CTFMERGE=		${TOOLDIR}/bin/${_TOOL_PREFIX}ctfmerge
    525 TOOL_CVSLATEST=		${TOOLDIR}/bin/${_TOOL_PREFIX}cvslatest
    526 TOOL_DATE=		${TOOLDIR}/bin/${_TOOL_PREFIX}date
    527 TOOL_DB=		${TOOLDIR}/bin/${_TOOL_PREFIX}db
    528 TOOL_DISKLABEL=		${TOOLDIR}/bin/${_TOOL_PREFIX}disklabel
    529 TOOL_DTC=		${TOOLDIR}/bin/${_TOOL_PREFIX}dtc
    530 TOOL_ELFTOSB=		${TOOLDIR}/bin/${_TOOL_PREFIX}elftosb
    531 TOOL_EQN=		${TOOLDIR}/bin/${_TOOL_PREFIX}eqn
    532 TOOL_FDISK=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-fdisk
    533 TOOL_FGEN=		${TOOLDIR}/bin/${_TOOL_PREFIX}fgen
    534 TOOL_FILE=		${TOOLDIR}/bin/${_TOOL_PREFIX}file
    535 TOOL_GENASSYM=		${TOOLDIR}/bin/${_TOOL_PREFIX}genassym
    536 TOOL_GENCAT=		${TOOLDIR}/bin/${_TOOL_PREFIX}gencat
    537 TOOL_GMAKE=		${TOOLDIR}/bin/${_TOOL_PREFIX}gmake
    538 TOOL_GPT=		${TOOLDIR}/bin/${_TOOL_PREFIX}gpt
    539 TOOL_GREP=		${TOOLDIR}/bin/${_TOOL_PREFIX}grep
    540 TOOL_GROFF=		${TOOL_GROFF_ENV} ${TOOLDIR}/bin/${_TOOL_PREFIX}groff ${GROFF_FLAGS}
    541 TOOL_GROPS=		${TOOL_GROFF_ENV} ${TOOLDIR}/lib/groff/grops
    542 TOOL_HEXDUMP=		${TOOLDIR}/bin/${_TOOL_PREFIX}hexdump
    543 TOOL_HP300MKBOOT=	${TOOLDIR}/bin/${_TOOL_PREFIX}hp300-mkboot
    544 TOOL_HPPAMKBOOT=	${TOOLDIR}/bin/${_TOOL_PREFIX}hppa-mkboot
    545 TOOL_INDXBIB=		${TOOLDIR}/bin/${_TOOL_PREFIX}indxbib
    546 TOOL_INSTALLBOOT=	${TOOLDIR}/bin/${_TOOL_PREFIX}installboot
    547 TOOL_INSTALL_INFO=	${TOOLDIR}/bin/${_TOOL_PREFIX}install-info
    548 TOOL_JOIN=		${TOOLDIR}/bin/${_TOOL_PREFIX}join
    549 TOOL_LLVM_TBLGEN=	${TOOLDIR}/bin/${_TOOL_PREFIX}llvm-tblgen
    550 TOOL_M4=		${TOOLDIR}/bin/${_TOOL_PREFIX}m4
    551 TOOL_M68KELF2AOUT=	${TOOLDIR}/bin/${_TOOL_PREFIX}m68k-elf2aout
    552 TOOL_MACPPCFIXCOFF=	${TOOLDIR}/bin/${_TOOL_PREFIX}macppc-fixcoff
    553 TOOL_MACPPCINSTALLBOOT=	${TOOLDIR}/bin/${_TOOL_PREFIX}macppc_installboot
    554 TOOL_MACPPCMKBOOTHFS=	${TOOLDIR}/bin/${_TOOL_PREFIX}macppc_mkboothfs
    555 TOOL_MAKEFS=		${TOOLDIR}/bin/${_TOOL_PREFIX}makefs
    556 TOOL_MAKEINFO=		${TOOLDIR}/bin/${_TOOL_PREFIX}makeinfo
    557 TOOL_MAKEKEYS=		${TOOLDIR}/bin/${_TOOL_PREFIX}makekeys
    558 TOOL_MAKESTRS=		${TOOLDIR}/bin/${_TOOL_PREFIX}makestrs
    559 TOOL_MAKEWHATIS=	${TOOLDIR}/bin/${_TOOL_PREFIX}makewhatis
    560 TOOL_MANDOC_ASCII=	${TOOLDIR}/bin/${_TOOL_PREFIX}mandoc -Tascii
    561 TOOL_MANDOC_HTML=	${TOOLDIR}/bin/${_TOOL_PREFIX}mandoc -Thtml
    562 TOOL_MANDOC_LINT=	${TOOLDIR}/bin/${_TOOL_PREFIX}mandoc -Tlint
    563 TOOL_MDSETIMAGE=	${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-mdsetimage
    564 TOOL_MENUC=		MENUDEF=${TOOLDIR}/share/misc ${TOOLDIR}/bin/${_TOOL_PREFIX}menuc
    565 TOOL_MIPSELF2ECOFF=	${TOOLDIR}/bin/${_TOOL_PREFIX}mips-elf2ecoff
    566 TOOL_MKCSMAPPER=	${TOOLDIR}/bin/${_TOOL_PREFIX}mkcsmapper
    567 TOOL_MKESDB=		${TOOLDIR}/bin/${_TOOL_PREFIX}mkesdb
    568 TOOL_MKHYBRID=		${TOOLDIR}/bin/${_TOOL_PREFIX}mkhybrid
    569 TOOL_MKLOCALE=		${TOOLDIR}/bin/${_TOOL_PREFIX}mklocale
    570 TOOL_MKMAGIC=		${TOOLDIR}/bin/${_TOOL_PREFIX}file
    571 TOOL_MKNOD=		${TOOLDIR}/bin/${_TOOL_PREFIX}mknod
    572 TOOL_MKTEMP=		${TOOLDIR}/bin/${_TOOL_PREFIX}mktemp
    573 TOOL_MKUBOOTIMAGE=	${TOOLDIR}/bin/${_TOOL_PREFIX}mkubootimage
    574 TOOL_MSGC=		MSGDEF=${TOOLDIR}/share/misc ${TOOLDIR}/bin/${_TOOL_PREFIX}msgc
    575 TOOL_MTREE=		${TOOLDIR}/bin/${_TOOL_PREFIX}mtree
    576 TOOL_MVME68KWRTVID=	${TOOLDIR}/bin/${_TOOL_PREFIX}mvme68k-wrtvid
    577 TOOL_NBPERF=		${TOOLDIR}/bin/${_TOOL_PREFIX}perf
    578 TOOL_NCDCS=		${TOOLDIR}/bin/${_TOOL_PREFIX}ibmnws-ncdcs
    579 TOOL_PAX=		${TOOLDIR}/bin/${_TOOL_PREFIX}pax
    580 TOOL_PIC=		${TOOLDIR}/bin/${_TOOL_PREFIX}pic
    581 TOOL_PIGZ=		${TOOLDIR}/bin/${_TOOL_PREFIX}pigz
    582 TOOL_PKG_CREATE=	${TOOLDIR}/bin/${_TOOL_PREFIX}pkg_create
    583 TOOL_POWERPCMKBOOTIMAGE=${TOOLDIR}/bin/${_TOOL_PREFIX}powerpc-mkbootimage
    584 TOOL_PWD_MKDB=		${TOOLDIR}/bin/${_TOOL_PREFIX}pwd_mkdb
    585 TOOL_REFER=		${TOOLDIR}/bin/${_TOOL_PREFIX}refer
    586 TOOL_ROFF_ASCII=	${TOOL_GROFF_ENV} ${TOOLDIR}/bin/${_TOOL_PREFIX}nroff
    587 TOOL_ROFF_DOCASCII=	${TOOL_GROFF} -Tascii
    588 TOOL_ROFF_DOCHTML=	${TOOL_GROFF} -Thtml
    589 TOOL_ROFF_DVI=		${TOOL_GROFF} -Tdvi ${ROFF_PAGESIZE}
    590 TOOL_ROFF_HTML=		${TOOL_GROFF} -Tlatin1 -mdoc2html
    591 TOOL_ROFF_PS=		${TOOL_GROFF} -Tps ${ROFF_PAGESIZE}
    592 TOOL_ROFF_RAW=		${TOOL_GROFF} -Z
    593 TOOL_RPCGEN=		RPCGEN_CPP=${CPP:Q} ${TOOLDIR}/bin/${_TOOL_PREFIX}rpcgen
    594 TOOL_SED=		${TOOLDIR}/bin/${_TOOL_PREFIX}sed
    595 TOOL_SLC=		${TOOLDIR}/bin/${_TOOL_PREFIX}slc
    596 TOOL_SOELIM=		${TOOLDIR}/bin/${_TOOL_PREFIX}soelim
    597 TOOL_SORTINFO=		${TOOLDIR}/bin/${_TOOL_PREFIX}sortinfo
    598 TOOL_SPARKCRC=		${TOOLDIR}/bin/${_TOOL_PREFIX}sparkcrc
    599 TOOL_STAT=		${TOOLDIR}/bin/${_TOOL_PREFIX}stat
    600 TOOL_STRFILE=		${TOOLDIR}/bin/${_TOOL_PREFIX}strfile
    601 TOOL_SUNLABEL=		${TOOLDIR}/bin/${_TOOL_PREFIX}sunlabel
    602 TOOL_TBL=		${TOOLDIR}/bin/${_TOOL_PREFIX}tbl
    603 TOOL_TIC=		${TOOLDIR}/bin/${_TOOL_PREFIX}tic
    604 TOOL_UUDECODE=		${TOOLDIR}/bin/${_TOOL_PREFIX}uudecode
    605 TOOL_VAXMOPCOPY=	${TOOLDIR}/bin/${_TOOL_PREFIX}vax-mopcopy
    606 TOOL_VFONTEDPR=		${TOOLDIR}/libexec/${_TOOL_PREFIX}vfontedpr
    607 TOOL_VGRIND=		${TOOLDIR}/bin/${_TOOL_PREFIX}vgrind -f
    608 TOOL_XZ=		${TOOLDIR}/bin/${_TOOL_PREFIX}xz
    609 TOOL_ZIC=		${TOOLDIR}/bin/${_TOOL_PREFIX}zic
    610 
    611 .else	# USETOOLS != yes						# } {
    612 
    613 # Clang supports C, C++ and Objective C
    614 TOOL_CC.clang=		clang
    615 TOOL_CPP.clang=		clang-cpp
    616 TOOL_CXX.clang=		clang++
    617 TOOL_OBJC.clang=	clang
    618 
    619 # GCC supports C, C++, Fortran and Objective C
    620 TOOL_CC.gcc=		gcc
    621 TOOL_CPP.gcc=		cpp
    622 TOOL_CXX.gcc=		c++
    623 TOOL_FC.gcc=		gfortran
    624 TOOL_OBJC.gcc=		gcc
    625 
    626 # PCC supports C and Fortran
    627 TOOL_CC.pcc=		pcc
    628 TOOL_CPP.pcc=		pcpp
    629 TOOL_CXX.pcc=		p++
    630 
    631 TOOL_AMIGAAOUT2BB=	amiga-aout2bb
    632 TOOL_AMIGAELF2BB=	amiga-elf2bb
    633 TOOL_AMIGATXLT=		amiga-txlt
    634 TOOL_ARMELF2AOUT=	arm-elf2aout
    635 TOOL_ASN1_COMPILE=	asn1_compile
    636 TOOL_AWK=		awk
    637 TOOL_CAP_MKDB=		cap_mkdb
    638 TOOL_CAT=		cat
    639 TOOL_CKSUM=		cksum
    640 TOOL_CLANG_TBLGEN=	clang-tblgen
    641 TOOL_COMPILE_ET=	compile_et
    642 TOOL_CONFIG=		config
    643 TOOL_CRUNCHGEN=		crunchgen
    644 TOOL_CTAGS=		ctags
    645 TOOL_CTFCONVERT=	ctfconvert
    646 TOOL_CTFMERGE=		ctfmerge
    647 TOOL_CVSLATEST=		cvslatest
    648 TOOL_DATE=		date
    649 TOOL_DB=		db
    650 TOOL_DISKLABEL=		disklabel
    651 TOOL_DTC=		dtc
    652 TOOL_ELFTOSB=		elftosb
    653 TOOL_EQN=		eqn
    654 TOOL_FDISK=		fdisk
    655 TOOL_FGEN=		fgen
    656 TOOL_FILE=		file
    657 TOOL_GENASSYM=		genassym
    658 TOOL_GENCAT=		gencat
    659 TOOL_GMAKE=		gmake
    660 TOOL_GPT=		gpt
    661 TOOL_GREP=		grep
    662 TOOL_GROFF=		groff
    663 TOOL_GROPS=		grops
    664 TOOL_HEXDUMP=		hexdump
    665 TOOL_HP300MKBOOT=	hp300-mkboot
    666 TOOL_HPPAMKBOOT=	hppa-mkboot
    667 TOOL_INDXBIB=		indxbib
    668 TOOL_INSTALLBOOT=	installboot
    669 TOOL_INSTALL_INFO=	install-info
    670 TOOL_JOIN=		join
    671 TOOL_LLVM_TBLGEN=	llvm-tblgen
    672 TOOL_M4=		m4
    673 TOOL_M68KELF2AOUT=	m68k-elf2aout
    674 TOOL_MACPPCFIXCOFF=	macppc-fixcoff
    675 TOOL_MAKEFS=		makefs
    676 TOOL_MAKEINFO=		makeinfo
    677 TOOL_MAKEKEYS=		makekeys
    678 TOOL_MAKESTRS=		makestrs
    679 TOOL_MAKEWHATIS=	/usr/libexec/makewhatis
    680 TOOL_MANDOC_ASCII=	mandoc -Tascii
    681 TOOL_MANDOC_HTML=	mandoc -Thtml
    682 TOOL_MANDOC_LINT=	mandoc -Tlint
    683 TOOL_MDSETIMAGE=	mdsetimage
    684 TOOL_MENUC=		menuc
    685 TOOL_MIPSELF2ECOFF=	mips-elf2ecoff
    686 TOOL_MKCSMAPPER=	mkcsmapper
    687 TOOL_MKESDB=		mkesdb
    688 TOOL_MKLOCALE=		mklocale
    689 TOOL_MKMAGIC=		file
    690 TOOL_MKNOD=		mknod
    691 TOOL_MKTEMP=		mktemp
    692 TOOL_MKUBOOTIMAGE=	mkubootimage
    693 TOOL_MSGC=		msgc
    694 TOOL_MTREE=		mtree
    695 TOOL_MVME68KWRTVID=	wrtvid
    696 TOOL_NBPERF=		nbperf
    697 TOOL_NCDCS=		ncdcs
    698 TOOL_PAX=		pax
    699 TOOL_PIC=		pic
    700 TOOL_PIGZ=		pigz
    701 TOOL_PKG_CREATE=	pkg_create
    702 TOOL_POWERPCMKBOOTIMAGE=powerpc-mkbootimage
    703 TOOL_PWD_MKDB=		pwd_mkdb
    704 TOOL_REFER=		refer
    705 TOOL_ROFF_ASCII=	nroff
    706 TOOL_ROFF_DOCASCII=	${TOOL_GROFF} -Tascii
    707 TOOL_ROFF_DOCHTML=	${TOOL_GROFF} -Thtml
    708 TOOL_ROFF_DVI=		${TOOL_GROFF} -Tdvi ${ROFF_PAGESIZE}
    709 TOOL_ROFF_HTML=		${TOOL_GROFF} -Tlatin1 -mdoc2html
    710 TOOL_ROFF_PS=		${TOOL_GROFF} -Tps ${ROFF_PAGESIZE}
    711 TOOL_ROFF_RAW=		${TOOL_GROFF} -Z
    712 TOOL_RPCGEN=		rpcgen
    713 TOOL_SED=		sed
    714 TOOL_SOELIM=		soelim
    715 TOOL_SORTINFO=		sortinfo
    716 TOOL_SPARKCRC=		sparkcrc
    717 TOOL_STAT=		stat
    718 TOOL_STRFILE=		strfile
    719 TOOL_SUNLABEL=		sunlabel
    720 TOOL_TBL=		tbl
    721 TOOL_TIC=		tic
    722 TOOL_UUDECODE=		uudecode
    723 TOOL_VAXMOPCOPY=	vax-mopcopy
    724 TOOL_VFONTEDPR=		/usr/libexec/vfontedpr
    725 TOOL_VGRIND=		vgrind -f
    726 TOOL_XZ=		xz
    727 TOOL_ZIC=		zic
    728 
    729 .endif	# USETOOLS != yes						# }
    730 
    731 # Standalone code should not be compiled with PIE or CTF
    732 # Should create a better test
    733 .if defined(BINDIR) && ${BINDIR} == "/usr/mdec"
    734 NOCTF=			# defined
    735 NOPIE=			# defined
    736 .elif ${MACHINE} == "sun2"
    737 NOPIE=			# we don't have PIC, so no PIE
    738 .endif
    739 
    740 # Fallback to ensure that all variables are defined to something
    741 TOOL_CC.false=		false
    742 TOOL_CPP.false=		false
    743 TOOL_CXX.false=		false
    744 TOOL_FC.false=		false
    745 TOOL_OBJC.false=	false
    746 
    747 AVAILABLE_COMPILER?=	${HAVE_PCC:Dpcc} ${HAVE_LLVM:Dclang} ${HAVE_GCC:Dgcc} false
    748 
    749 .for _t in CC CPP CXX FC OBJC
    750 ACTIVE_${_t}=	${AVAILABLE_COMPILER:@.c.@ ${ !defined(UNSUPPORTED_COMPILER.${.c.}) && defined(TOOL_${_t}.${.c.}) :? ${.c.} : }@:[1]}
    751 SUPPORTED_${_t}=${AVAILABLE_COMPILER:Nfalse:@.c.@ ${ !defined(UNSUPPORTED_COMPILER.${.c.}) && defined(TOOL_${_t}.${.c.}) :? ${.c.} : }@}
    752 .endfor
    753 # make bugs prevent moving this into the .for loop
    754 CC=		${TOOL_CC.${ACTIVE_CC}}
    755 CPP=		${TOOL_CPP.${ACTIVE_CPP}}
    756 CXX=		${TOOL_CXX.${ACTIVE_CXX}}
    757 FC=		${TOOL_FC.${ACTIVE_FC}}
    758 OBJC=		${TOOL_OBJC.${ACTIVE_OBJC}}
    759 
    760 #
    761 # Clang and GCC compiler-specific options, usually to disable warnings.
    762 # The naming convention is "CC" + the compiler flag converted
    763 # to upper case, with '-' and '=' changed to '_' a la `tr -=a-z __A-Z`.
    764 # For variable naming purposes, treat -Werror=FLAG as -WFLAG,
    765 # and -Wno-error=FLAG as -Wno-FLAG (usually from Clang).
    766 #
    767 # E.g., CC_WNO_ADDRESS_OF_PACKED_MEMBER contains
    768 # both -Wno-error=address-of-packed-member for Clang,
    769 # and -Wno-address-of-packed-member for GCC 9+.
    770 #
    771 # Use these with e.g.
    772 #	COPTS.foo.c+= ${CC_WNO_ADDRESS_OF_PACKED_MEMBER}
    773 #
    774 CC_WNO_ADDRESS_OF_PACKED_MEMBER=${${ACTIVE_CC} == "clang" :? -Wno-error=address-of-packed-member :} \
    775 				${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 9:? -Wno-address-of-packed-member :}
    776 
    777 CC_WNO_ARRAY_BOUNDS=		${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 12:? -Wno-array-bounds :}
    778 CC_WNO_CALLOC_TRANSPOSED_ARGS=	${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 14:? -Wno-calloc-transposed-args :}
    779 CC_WNO_CAST_FUNCTION_TYPE=	${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 8:? -Wno-cast-function-type :}
    780 CC_WNO_DANGLING_POINTER=	${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 14:? -Wno-dangling-pointer :}
    781 CC_WNO_ENUM_INT_MISMATCH=	${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 14:? -Wno-enum-int-mismatch :}
    782 CC_WNO_FORMAT_OVERFLOW=		${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 7:? -Wno-format-overflow :}
    783 CC_WNO_FORMAT_TRUNCATION=	${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 7:? -Wno-format-truncation :}
    784 CC_WNO_IMPLICIT_FALLTHROUGH=	${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 7:? -Wno-implicit-fallthrough :}
    785 CC_WNO_MAYBE_UNINITIALIZED=	${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 10:? -Wno-maybe-uninitialized :}
    786 CC_WNO_MISSING_TEMPLATE_KEYWORD=${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 12:? -Wno-missing-template-keyword :}
    787 CC_WNO_REGISTER=		${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 12:? -Wno-register :}
    788 CC_WNO_RETURN_LOCAL_ADDR=	${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 10:? -Wno-return-local-addr :}
    789 CC_WNO_STRINGOP_OVERFLOW=	${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 7:? -Wno-stringop-overflow :}
    790 CC_WNO_STRINGOP_OVERREAD=	${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 12:? -Wno-stringop-overread :}
    791 CC_WNO_STRINGOP_TRUNCATION=	${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 8:? -Wno-stringop-truncation :}
    792 
    793 # relative relocs are only supported in gnu ld for ppc64 and x86
    794 .if \
    795     ${MACHINE_ARCH} == "i386"  || \
    796     ${MACHINE_ARCH} == "powerpc64" || \
    797     ${MACHINE_ARCH} == "x86_64"
    798 LD_PACK_RELATIVE_RELOCS=	-Wl,-z,pack-relative-relocs
    799 LD_NOPACK_RELATIVE_RELOCS=	-Wl,-z,nopack-relative-relocs
    800 .endif
    801 
    802 # For each ${MACHINE_CPU}, list the ports that use it.
    803 MACHINES.aarch64=	evbarm
    804 MACHINES.alpha=		alpha
    805 MACHINES.arm=		acorn32 cats epoc32 evbarm hpcarm \
    806 			iyonix netwinder shark zaurus
    807 MACHINES.coldfire=	evbcf
    808 MACHINES.hppa=		hppa
    809 MACHINES.i386=		i386
    810 MACHINES.ia64=		ia64
    811 MACHINES.m68000=	sun2
    812 MACHINES.m68k=		amiga atari cesfic hp300 luna68k mac68k \
    813 			mvme68k news68k next68k sun3 virt68k x68k
    814 MACHINES.m68ksf=	mac68k
    815 MACHINES.mips=		algor arc cobalt emips evbmips ews4800mips \
    816 			hpcmips mipsco newsmips pmax sbmips sgimips
    817 MACHINES.or1k=		or1k
    818 MACHINES.powerpc=	amigappc bebox evbppc ibmnws macppc mvmeppc \
    819 			ofppc prep rs6000 sandpoint
    820 MACHINES.riscv=		riscv
    821 MACHINES.sh3=		dreamcast evbsh3 hpcsh landisk mmeye
    822 MACHINES.sparc=		sparc sparc64
    823 MACHINES.sparc64=	sparc64
    824 MACHINES.vax=		vax
    825 MACHINES.x86_64=	amd64
    826 
    827 # OBJCOPY flags to create a.out binaries for old firmware
    828 # shared among src/distrib and ${MACHINE}/conf/Makefile.${MACHINE}.inc
    829 .if ${MACHINE_CPU} == "arm"
    830 OBJCOPY_ELF2AOUT_FLAGS?=	\
    831 	-O a.out-arm-netbsd	\
    832 	-R .ident		\
    833 	-R .ARM.attributes	\
    834 	-R .ARM.exidx		\
    835 	-R .ARM.extab		\
    836 	-R .SUNW_ctf		\
    837 	-R .arm.atpcs		\
    838 	-R .comment		\
    839 	-R .debug_abbrev	\
    840 	-R .debug_aranges	\
    841 	-R .debug_info		\
    842 	-R .debug_line		\
    843 	-R .debug_frame		\
    844 	-R .debug_loc		\
    845 	-R .debug_pubnames	\
    846 	-R .debug_pubtypes	\
    847 	-R .debug_ranges	\
    848 	-R .debug_str		\
    849 	-R .debug_macinfo	\
    850 	-R .eh_frame		\
    851 	-R .note.netbsd.ident
    852 .endif
    853 
    854 #
    855 # Targets to check if DESTDIR or RELEASEDIR is provided
    856 #
    857 .if !target(check_DESTDIR)
    858 check_DESTDIR: .PHONY .NOTMAIN
    859 .if !defined(DESTDIR)
    860 	@echo "setenv DESTDIR before doing that!"
    861 	@false
    862 .else
    863 	@true
    864 .endif
    865 .endif
    866 
    867 .if !target(check_RELEASEDIR)
    868 check_RELEASEDIR: .PHONY .NOTMAIN
    869 .if !defined(RELEASEDIR)
    870 	@echo "setenv RELEASEDIR before doing that!"
    871 	@false
    872 .else
    873 	@true
    874 .endif
    875 .endif
    876 
    877 #
    878 # Where the system object and source trees are kept; can be configurable
    879 # by the user in case they want them in ~/foosrc and ~/fooobj (for example).
    880 #
    881 BSDSRCDIR?=	/usr/src
    882 BSDOBJDIR?=	/usr/obj
    883 NETBSDSRCDIR?=	${BSDSRCDIR}
    884 
    885 BINGRP?=	wheel
    886 BINOWN?=	root
    887 BINMODE?=	555
    888 NONBINMODE?=	444
    889 
    890 # These are here mainly because we don't want suid root in case
    891 # a Makefile defines BINMODE.
    892 RUMPBINGRP?=	wheel
    893 RUMPBINOWN?=	root
    894 RUMPBINMODE?=	555
    895 RUMPNONBINMODE?=444
    896 
    897 MANDIR?=	/usr/share/man
    898 MANGRP?=	wheel
    899 MANOWN?=	root
    900 MANMODE?=	${NONBINMODE}
    901 MANINSTALL?=	${_MANINSTALL}
    902 
    903 INFODIR?=	/usr/share/info
    904 INFOGRP?=	wheel
    905 INFOOWN?=	root
    906 INFOMODE?=	${NONBINMODE}
    907 
    908 LIBDIR?=	/usr/lib
    909 
    910 LINTLIBDIR?=	/usr/libdata/lint
    911 LIBGRP?=	${BINGRP}
    912 LIBOWN?=	${BINOWN}
    913 LIBMODE?=	${NONBINMODE}
    914 
    915 DOCDIR?=	/usr/share/doc
    916 DOCGRP?=	wheel
    917 DOCOWN?=	root
    918 DOCMODE?=	${NONBINMODE}
    919 
    920 NLSDIR?=	/usr/share/nls
    921 NLSGRP?=	wheel
    922 NLSOWN?=	root
    923 NLSMODE?=	${NONBINMODE}
    924 
    925 KMODULEGRP?=	wheel
    926 KMODULEOWN?=	root
    927 KMODULEMODE?=	${NONBINMODE}
    928 
    929 LOCALEDIR?=	/usr/share/locale
    930 LOCALEGRP?=	wheel
    931 LOCALEOWN?=	root
    932 LOCALEMODE?=	${NONBINMODE}
    933 
    934 FIRMWAREDIR?=	/libdata/firmware
    935 FIRMWAREGRP?=	wheel
    936 FIRMWAREOWN?=	root
    937 FIRMWAREMODE?=	${NONBINMODE}
    938 
    939 DEBUGDIR?=	/usr/libdata/debug
    940 DEBUGGRP?=	wheel
    941 DEBUGOWN?=	root
    942 DEBUGMODE?=	${NONBINMODE}
    943 
    944 DTBDIR?=	/boot/dtb
    945 DTBGRP?=	wheel
    946 DTBOWN?=	root
    947 DTBMODE?=	${NONBINMODE}
    948 
    949 MKDIRMODE?=	0755
    950 MKDIRPERM?=	-m ${MKDIRMODE}
    951 
    952 #
    953 # Data-driven table using make variables to control how
    954 # toolchain-dependent targets and shared libraries are built
    955 # for different platforms and object formats.
    956 #
    957 # OBJECT_FMT:		currently either "ELF" or "a.out".
    958 #
    959 # All platforms are ELF.
    960 #
    961 OBJECT_FMT=	ELF
    962 
    963 #
    964 # If this platform's toolchain is missing, we obviously cannot build it.
    965 #
    966 .if ${TOOLCHAIN_MISSING} != "no"
    967 MKBINUTILS:= no
    968 MKGCC:= no
    969 MKGDB:= no
    970 .endif
    971 
    972 #
    973 # If we are using an external toolchain, we can still build the target's
    974 # binutils, but we cannot build GCC's support libraries, since those are
    975 # tightly-coupled to the version of GCC being used.
    976 #
    977 .if defined(EXTERNAL_TOOLCHAIN)
    978 MKGCC:= no
    979 .endif
    980 
    981 MKGDB.or1k=	no
    982 
    983 # No kernel modules for or1k (yet)
    984 MKKMOD.or1k=	no
    985 
    986 # No profiling for or1k (yet)
    987 MKPROFILE.or1k=	no
    988 
    989 #
    990 # The m68000 port is incomplete.
    991 #
    992 .if ${MACHINE_ARCH} == "m68000"
    993 NOPIC=		# defined
    994 MKISCSI=	no
    995 # XXX GCC 4 outputs mcount() calling sequences that try to load values
    996 # from over 64KB away and this fails to assemble.
    997 .if defined(HAVE_GCC)
    998 NOPROFILE=	# defined
    999 .endif
   1000 .endif
   1001 
   1002 #
   1003 # The ia64 port is incomplete.
   1004 #
   1005 MKGDB.ia64=	no
   1006 
   1007 #
   1008 # On VAX using ELF, all objects are PIC, not just shared libraries,
   1009 # so don't build the _pic version. VAX has no native TLS support either,
   1010 # so differences between TLS models are not relevant.
   1011 #
   1012 MKPICLIB.vax=	no
   1013 
   1014 #
   1015 # Location of the file that contains the major and minor numbers of the
   1016 # version of a shared library.  If this file exists a shared library
   1017 # will be built by <bsd.lib.mk>.
   1018 #
   1019 SHLIB_VERSION_FILE?= ${.CURDIR}/shlib_version
   1020 
   1021 #
   1022 # GNU sources and packages sometimes see architecture names differently.
   1023 #
   1024 GNU_ARCH.aarch64eb=aarch64_be
   1025 GNU_ARCH.coldfire=m5407
   1026 GNU_ARCH.earm=arm
   1027 GNU_ARCH.earmeb=armeb
   1028 GNU_ARCH.earmhf=arm
   1029 GNU_ARCH.earmhfeb=armeb
   1030 GNU_ARCH.earmv4=armv4
   1031 GNU_ARCH.earmv4eb=armv4eb
   1032 GNU_ARCH.earmv5=arm
   1033 GNU_ARCH.earmv5eb=armeb
   1034 GNU_ARCH.earmv5hf=arm
   1035 GNU_ARCH.earmv5hfeb=armeb
   1036 GNU_ARCH.earmv6=armv6
   1037 GNU_ARCH.earmv6eb=armv6eb
   1038 GNU_ARCH.earmv6hf=armv6
   1039 GNU_ARCH.earmv6hfeb=armv6eb
   1040 GNU_ARCH.earmv7=armv7
   1041 GNU_ARCH.earmv7eb=armv7eb
   1042 GNU_ARCH.earmv7hf=armv7
   1043 GNU_ARCH.earmv7hfeb=armv7eb
   1044 GNU_ARCH.i386=i486
   1045 GCC_CONFIG_ARCH.i386=i486
   1046 GCC_CONFIG_TUNE.i386=nocona
   1047 GCC_CONFIG_TUNE.x86_64=nocona
   1048 GNU_ARCH.m68000=m68010
   1049 GNU_ARCH.m68ksf=m68k
   1050 GNU_ARCH.mips64eb=mips64
   1051 GNU_ARCH.sh3eb=sh
   1052 GNU_ARCH.sh3el=shle
   1053 MACHINE_GNU_ARCH=${GNU_ARCH.${MACHINE_ARCH}:U${MACHINE_ARCH}}
   1054 
   1055 #
   1056 # In order to identify NetBSD to GNU packages, we sometimes need
   1057 # an "elf" tag for historically a.out platforms.
   1058 #
   1059 .if (${MACHINE_ARCH:Mearm*})
   1060 MACHINE_GNU_PLATFORM?=${MACHINE_GNU_ARCH}--netbsdelf-${MACHINE_ARCH:C/eb//:C/v[4-7]//:S/earm/eabi/}
   1061 .elif (${MACHINE_GNU_ARCH} == "arm" || \
   1062      ${MACHINE_GNU_ARCH} == "armeb" || \
   1063      ${MACHINE_ARCH} == "i386" || \
   1064      ${MACHINE_CPU} == "m68k" || \
   1065      ${MACHINE_GNU_ARCH} == "sh" || \
   1066      ${MACHINE_GNU_ARCH} == "shle" || \
   1067      ${MACHINE_ARCH} == "sparc" || \
   1068      ${MACHINE_ARCH} == "vax")
   1069 MACHINE_GNU_PLATFORM?=${MACHINE_GNU_ARCH}--netbsdelf
   1070 .else
   1071 MACHINE_GNU_PLATFORM?=${MACHINE_GNU_ARCH}--netbsd
   1072 .endif
   1073 
   1074 .if ${MACHINE_ARCH:M*arm*}
   1075 # Flags to pass to CC for using the old APCS ABI on ARM for compat or stand.
   1076 ARM_APCS_FLAGS=	-mabi=apcs-gnu -mfloat-abi=soft -marm
   1077 ARM_APCS_FLAGS+= ${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 8:? -mno-thumb-interwork :}
   1078 ARM_APCS_FLAGS+=${${ACTIVE_CC} == "clang":? -target ${MACHINE_GNU_ARCH}--netbsdelf -B ${TOOLDIR}/${MACHINE_GNU_PLATFORM}/bin :}
   1079 .endif
   1080 
   1081 GENASSYM_CPPFLAGS+=	${${ACTIVE_CC} == "clang":? -no-integrated-as :}
   1082 
   1083 TARGETS+=	all clean cleandir depend dependall includes \
   1084 		install lint obj regress tags html analyze describe \
   1085 		rumpdescribe
   1086 PHONY_NOTMAIN =	all clean cleandir depend dependall distclean includes \
   1087 		install lint obj regress beforedepend afterdepend \
   1088 		beforeinstall afterinstall realinstall realdepend realall \
   1089 		html subdir-all subdir-install subdir-depend analyze describe \
   1090 		rumpdescribe
   1091 .PHONY:		${PHONY_NOTMAIN}
   1092 .NOTMAIN:	${PHONY_NOTMAIN}
   1093 
   1094 .if ${NEED_OWN_INSTALL_TARGET} != "no"
   1095 .if !target(install)
   1096 install:	beforeinstall .WAIT subdir-install realinstall .WAIT afterinstall
   1097 beforeinstall:
   1098 subdir-install:
   1099 realinstall:
   1100 afterinstall:
   1101 .endif
   1102 all:		realall subdir-all
   1103 subdir-all:
   1104 realall:
   1105 depend:		realdepend subdir-depend
   1106 subdir-depend:
   1107 realdepend:
   1108 distclean:	cleandir
   1109 cleandir:	clean
   1110 
   1111 dependall:	.NOTMAIN realdepend .MAKE
   1112 	@cd "${.CURDIR}"; ${MAKE} realall
   1113 .endif
   1114 
   1115 #
   1116 # Define MKxxx variables (which are either yes or no) for users
   1117 # to set in /etc/mk.conf and override in the make environment.
   1118 # These should be tested with `== "no"' or `!= "no"'.
   1119 # The NOxxx variables should only be set by Makefiles.
   1120 #
   1121 # Please keep etc/Makefile and share/man/man5/mk.conf.5 in sync
   1122 # with changes to the MK* variables here.
   1123 #
   1124 
   1125 #
   1126 # Supported NO* options (if defined, MK* will be forced to "no",
   1127 # regardless of user's mk.conf setting).
   1128 #
   1129 # Source makefiles should set NO*, and not MK*, and must do so before
   1130 # including bsd.own.mk.
   1131 # Please keep alphabetically sorted with one entry per line.
   1132 #
   1133 _NOVARS= \
   1134 	NOCOMPAT \
   1135 	NODEBUGLIB \
   1136 	NODOC \
   1137 	NOHTML \
   1138 	NOINFO \
   1139 	NOLIBCSANITIZER \
   1140 	NOLINKLIB \
   1141 	NOLINT \
   1142 	NOMAN \
   1143 	NONLS \
   1144 	NOOBJ \
   1145 	NOPIC \
   1146 	NOPICINSTALL \
   1147 	NOPIE \
   1148 	NOPROFILE \
   1149 	NORELRO \
   1150 	NOSANITIZER \
   1151 	NOSHARE \
   1152 	NOSTATICLIB
   1153 
   1154 .for var in ${_NOVARS}
   1155 .if defined(${var})
   1156 MK${var:S/^NO//}:=	no
   1157 .endif
   1158 .endfor
   1159 
   1160 #
   1161 # MK* options which have variable defaults.
   1162 #
   1163 
   1164 #
   1165 # aarch64eb is not yet supported for MKCOMPAT.
   1166 #
   1167 .if \
   1168     (${MACHINE_ARCH} == "aarch64" && ${HAVE_GCC:U0} == 0) || \
   1169     ${MACHINE_MIPS64} || \
   1170     ${MACHINE_ARCH} == "powerpc64" || \
   1171     ${MACHINE_ARCH} == "riscv64" || \
   1172     ${MACHINE_ARCH} == "sparc64" || \
   1173     ${MACHINE_ARCH} == "x86_64"
   1174 MKCOMPAT?=	yes
   1175 .else
   1176 # Don't let this build where it really isn't supported.
   1177 MKCOMPAT:=	no
   1178 .endif
   1179 
   1180 .if ${MKCOMPAT} == "no"
   1181 MKCOMPATTESTS:=	no
   1182 MKCOMPATX11:=	no
   1183 .endif
   1184 
   1185 .if \
   1186     (${MACHINE} == "evbppc" && ${MACHINE_ARCH} == "powerpc") || \
   1187     ${MACHINE_MIPS64}
   1188 MKCOMPATMODULES?=	yes
   1189 .else
   1190 MKCOMPATMODULES:=	no
   1191 .endif
   1192 
   1193 #
   1194 # These platforms use softfloat by default.
   1195 #
   1196 .if ${MACHINE_MIPS64}
   1197 MKSOFTFLOAT?=	yes
   1198 .endif
   1199 
   1200 #
   1201 # These platforms always use softfloat.
   1202 #
   1203 .if \
   1204     (${MACHINE_CPU} == "arm" && ${MACHINE_ARCH:M*hf*} == "") || \
   1205     ${MACHINE_ARCH} == "coldfire" || \
   1206     ${MACHINE} == "emips" || \
   1207     ${MACHINE_ARCH} == "m68ksf" || \
   1208     ${MACHINE_CPU} == "or1k" || \
   1209     ${MACHINE_CPU} == "sh3"
   1210 MKSOFTFLOAT=	yes
   1211 .endif
   1212 
   1213 .if ${MACHINE} == "emips"
   1214 SOFTFLOAT_BITS=	32
   1215 .endif
   1216 
   1217 MKSOFTFLOAT?=	no
   1218 #
   1219 # Prefer libc's softfloat.c
   1220 #
   1221 .if ${MKSOFTFLOAT} != "no"
   1222 MKLIBCSOFTFLOAT?= yes
   1223 .else
   1224 MKLIBCSOFTFLOAT= no
   1225 .endif
   1226 
   1227 #
   1228 # We want to build zfs only for aarch64{,be}, amd64, riscv64, and sparc64
   1229 # by default for now.
   1230 #
   1231 .if \
   1232     ${MACHINE_ARCH:Maarch64*} || \
   1233     ${MACHINE} == "amd64" || \
   1234     ${MACHINE_ARCH} == "riscv64" || \
   1235     ${MACHINE} == "sparc64"
   1236 MKZFS?=		yes
   1237 .endif
   1238 
   1239 #
   1240 # DTrace works on aarch64, earm*, i386, and x86_64
   1241 #
   1242 .if \
   1243     ${MACHINE_ARCH} == "aarch64" || \
   1244     ${MACHINE_ARCH:Mearm*} || \
   1245     ${MACHINE_ARCH} == "i386" || \
   1246     ${MACHINE_ARCH} == "x86_64"
   1247 MKDTRACE?=	yes
   1248 MKCTF?=		yes
   1249 .endif
   1250 
   1251 #
   1252 # PIE is enabled on many platforms by default.
   1253 #
   1254 # Coverity does not like PIE
   1255 .if !defined(COVERITY_TOP_CONFIG) && ( \
   1256     ${MACHINE_ARCH:Maarch64*} || \
   1257     ${MACHINE_CPU} == "arm" || \
   1258     ${MACHINE_ARCH} == "i386" || \
   1259     ${MACHINE} == "macppc" || \
   1260     ${MACHINE_CPU} == "m68k" || \
   1261     ${MACHINE_CPU} == "mips" || \
   1262     ${MACHINE_CPU} == "sh3" || \
   1263     ${MACHINE} == "sparc64" || \
   1264     ${MACHINE_ARCH} == "x86_64" \
   1265     )
   1266 MKPIE?=		yes
   1267 .else
   1268 MKPIE?=		no
   1269 .endif
   1270 
   1271 #
   1272 # RELRO is enabled on aarch64, amd64, i386, and mip64 by default
   1273 #
   1274 # sync with NORELRO in compat/*/*/bsd.*.mk for the relro-enabled 64-bit
   1275 # platforms with relro-disabled 32-bit compat
   1276 #
   1277 .if \
   1278     ${MACHINE_ARCH:Maarch64*} || \
   1279     ${MACHINE} == "amd64" || \
   1280     ${MACHINE} == "i386" || \
   1281     ${MACHINE_MIPS64}
   1282 MKRELRO?=	partial
   1283 .else
   1284 MKRELRO?=	no
   1285 .endif
   1286 
   1287 .if \
   1288     ${MACHINE_ARCH} == "i386" || \
   1289     ${MACHINE_ARCH} == "x86_64"
   1290 MKSTATICPIE?=	yes
   1291 .else
   1292 MKSTATICPIE?=	no
   1293 .endif
   1294 
   1295 #
   1296 # MK* options which default to "yes".
   1297 # Please keep alphabetically sorted with one entry per line.
   1298 #
   1299 _MKVARS.yes= \
   1300 	MKADOSFS \
   1301 	MKARGON2 \
   1302 	MKATF \
   1303 	MKAUDIO \
   1304 	MKAUTOFS \
   1305 	MKBIND \
   1306 	MKBINUTILS \
   1307 	MKBLUETOOTH \
   1308 	MKBSDDIFF \
   1309 	MKBSDTAR \
   1310 	MKCD9660FS \
   1311 	MKCHFS \
   1312 	MKCLEANSRC \
   1313 	MKCLEANVERIFY \
   1314 	MKCOMPLEX \
   1315 	MKCVS \
   1316 	MKCXX \
   1317 	MKDOC \
   1318 	MKDTC \
   1319 	MKDYNAMICROOT \
   1320 	MKEFS \
   1321 	MKEXT2FS \
   1322 	MKFDESCFS \
   1323 	MKFIDO2 \
   1324 	MKFILECOREFS \
   1325 	MKGCC \
   1326 	MKGDB \
   1327 	MKGROFF \
   1328 	MKHESIOD \
   1329 	MKHFS \
   1330 	MKHTML \
   1331 	MKIEEEFP \
   1332 	MKINET6 \
   1333 	MKINFO \
   1334 	MKIPFILTER \
   1335 	MKIPSEC \
   1336 	MKISCSI \
   1337 	MKKERBEROS \
   1338 	MKKERNFS \
   1339 	MKKMOD \
   1340 	MKLDAP \
   1341 	MKLFS \
   1342 	MKLIBSTDCXX \
   1343 	MKLINKLIB \
   1344 	MKLVM \
   1345 	MKMAKEMANDB \
   1346 	MKMAN \
   1347 	MKMANDOC \
   1348 	MKMDNS \
   1349 	MKMSDOSFS \
   1350 	MKNFS \
   1351 	MKNILFS \
   1352 	MKNLS \
   1353 	MKNPF \
   1354 	MKNTFS \
   1355 	MKNULLFS \
   1356 	MKOBJ \
   1357 	MKOVERLAYFS \
   1358 	MKPAM \
   1359 	MKPF \
   1360 	MKPIC \
   1361 	MKPICLIB \
   1362 	MKPOSTFIX \
   1363 	MKPROCFS \
   1364 	MKPROFILE \
   1365 	MKPTYFS \
   1366 	MKQEMUFWCFG \
   1367 	MKRUMP \
   1368 	MKSHARE \
   1369 	MKSKEY \
   1370 	MKSSH \
   1371 	MKSTATICLIB \
   1372 	MKSTRIPSYM \
   1373 	MKSYSVBFS \
   1374 	MKTMPFS \
   1375 	MKUDF \
   1376 	MKUMAPFS \
   1377 	MKUNBOUND \
   1378 	MKUNIONFS \
   1379 	MKUSB \
   1380 	MKV7FS \
   1381 	MKWLAN \
   1382 	MKX11FONTS \
   1383 	MKYP
   1384 
   1385 #
   1386 # Systems with MACHINE_ARCH == m68000 are extremely limited in terms
   1387 # of available system resources.  Trim down the base set of system
   1388 # features accordingly.
   1389 #
   1390 MKADOSFS.m68000?=	no
   1391 MKAUDIO.m68000?=	no
   1392 MKAUTOFS.m68000?=	no
   1393 MKBIND.m68000?=		no
   1394 MKBLUETOOTH.m68000?=	no
   1395 MKBSDTAR.m68000?=	no
   1396 MKCHFS.m68000?=		no
   1397 MKDTC.m68000?=		no
   1398 MKEFS.m68000?=		no
   1399 MKEXT2FS.m68000?=	no
   1400 MKFDESCFS.m68000?=	no
   1401 MKFIDO2.m68000?=	no
   1402 MKFILECOREFS.m68000?=	no
   1403 MKGROFF.m68000?=	no
   1404 MKHESIOD.m68000?=	no
   1405 MKHFS.m68000?=		no
   1406 MKHTML.m68000?=		no
   1407 MKINET6.m68000?=	no
   1408 MKIPFILTER.m68000?=	no
   1409 MKIPSEC.m68000?=	no
   1410 MKISCSI.m68000?=	no
   1411 MKLDAP.m68000?=		no
   1412 MKLFS.m68000?=		no
   1413 MKLVM.m68000?=		no
   1414 MKMSDOSFS.m68000?=	no
   1415 MKNILFS.m68000?=	no
   1416 MKNPF.m68000?=		no
   1417 MKNTFS.m68000?=		no
   1418 MKNULLFS.m68000?=	no
   1419 MKOVERLAYFS.m68000?=	no
   1420 MKPAM.m68000?=		no
   1421 MKPF.m68000?=		no
   1422 MKPOSTFIX.m68000?=	no
   1423 MKPROCFS.m68000?=	no
   1424 MKQEMUFWCFG.m68000?=	no
   1425 MKRUMP.m68000?=		no
   1426 MKSSH.m68000?=		no
   1427 MKSYSVBFS.m68000?=	no
   1428 MKTMPFS.m68000?=	no
   1429 MKUDF.m68000?=		no
   1430 MKUMAPFS.m68000?=	no
   1431 MKUNBOUND.m68000?=	no
   1432 MKUNIONFS.m68000?=	no
   1433 MKUSB.m68000?=		no
   1434 MKV7FS.m68000?=		no
   1435 MKWLAN.m68000?=		no
   1436 
   1437 .for var in ${_MKVARS.yes}
   1438 ${var}?=	${${var}.${MACHINE_ARCH}:U${${var}.${MACHINE}:Uyes}}
   1439 .endfor
   1440 
   1441 #
   1442 # MKGCCCMDS is only valid if we are building GCC so make it dependent on that.
   1443 #
   1444 _MKVARS.yes += MKGCCCMDS
   1445 MKGCCCMDS?=	${MKGCC}
   1446 
   1447 #
   1448 # Sanitizers, only "address" and "undefined" are supported by gcc
   1449 #
   1450 MKSANITIZER?=	no
   1451 USE_SANITIZER?=	address
   1452 
   1453 #
   1454 # Sanitizers implemented in libc, only "undefined" is supported
   1455 #
   1456 MKLIBCSANITIZER?=	no
   1457 USE_LIBCSANITIZER?=	undefined
   1458 
   1459 #
   1460 # Exceptions to the above:
   1461 #
   1462 
   1463 # RUMP uses -nostdinc which coverity does not like
   1464 # It also does not use many new files, so disable it
   1465 .if defined(COVERITY_TOP_CONFIG)
   1466 MKRUMP=		no
   1467 .endif
   1468 
   1469 #
   1470 # Build a dynamically linked /bin and /sbin, with the necessary shared
   1471 # libraries moved from /usr/lib to /lib and the shared linker moved
   1472 # from /usr/libexec to /lib
   1473 #
   1474 # Note that if the BINDIR is not /bin or /sbin, then we always use the
   1475 # non-DYNAMICROOT behavior (i.e. it is only enabled for programs in /bin
   1476 # and /sbin).  See <bsd.shlib.mk>.
   1477 #
   1478 # For ia64, ld.elf_so not yet implemented
   1479 .if ${MACHINE_ARCH} == "ia64"
   1480 MKDYNAMICROOT=	no
   1481 .endif
   1482 
   1483 .if defined(MKREPRO)
   1484 MKARZERO ?= ${MKREPRO}
   1485 GROFF_FLAGS ?= -dpaper=letter
   1486 ROFF_PAGESIZE ?= -P-pletter
   1487 .endif
   1488 
   1489 #
   1490 # Install the kernel as /netbsd/kernel and the modules in /netbsd/modules
   1491 #
   1492 KERNEL_DIR?=	no
   1493 
   1494 # Only install the general firmware on some systems
   1495 MKFIRMWARE.amd64=		yes
   1496 MKFIRMWARE.cobalt=		yes
   1497 MKFIRMWARE.evbarm=		yes
   1498 MKFIRMWARE.evbmips=		yes
   1499 MKFIRMWARE.evbppc=		yes
   1500 MKFIRMWARE.hpcarm=		yes
   1501 MKFIRMWARE.hppa=		yes
   1502 MKFIRMWARE.i386=		yes
   1503 MKFIRMWARE.mac68k=		yes
   1504 MKFIRMWARE.macppc=		yes
   1505 MKFIRMWARE.riscv=		yes
   1506 MKFIRMWARE.sandpoint=		yes
   1507 MKFIRMWARE.sparc64=		yes
   1508 
   1509 # Only install the GPU firmware on DRM-happy systems.
   1510 MKAMDGPUFIRMWARE.x86_64=	yes
   1511 MKNOUVEAUFIRMWARE.aarch64=	yes
   1512 MKNOUVEAUFIRMWARE.i386=		yes
   1513 MKNOUVEAUFIRMWARE.x86_64=	yes
   1514 MKRADEONFIRMWARE.aarch64=	yes
   1515 MKRADEONFIRMWARE.i386=		yes
   1516 MKRADEONFIRMWARE.x86_64=	yes
   1517 
   1518 # Only install the tegra firmware on evbarm.
   1519 MKTEGRAFIRMWARE.evbarm=		yes
   1520 
   1521 # Only build devicetree (dtb) files on armv5, armv6, armv7, aarch64,
   1522 # and risc-v.
   1523 MKDTB.aarch64=			yes
   1524 MKDTB.aarch64eb=		yes
   1525 MKDTB.earmv5=			yes
   1526 MKDTB.earmv5hf=			yes
   1527 MKDTB.earmv6=			yes
   1528 MKDTB.earmv6eb=			yes
   1529 MKDTB.earmv6hf=			yes
   1530 MKDTB.earmv6hfeb=		yes
   1531 MKDTB.earmv7=			yes
   1532 MKDTB.earmv7eb=			yes
   1533 MKDTB.earmv7hf=			yes
   1534 MKDTB.earmv7hfeb=		yes
   1535 MKDTB.riscv32=			yes
   1536 MKDTB.riscv64=			yes
   1537 
   1538 # During transition from xorg-server 1.10 to 1.20
   1539 # XXX sgimips uses XAA which is removed in 1.20, and EXA is hard
   1540 # XXX to do the same with.
   1541 .if ${MACHINE} == "sgimips"
   1542 HAVE_XORG_SERVER_VER?=110
   1543 .else
   1544 HAVE_XORG_SERVER_VER?=120
   1545 .endif
   1546 
   1547 # Newer Mesa does not build with old X server
   1548 .if ${HAVE_XORG_SERVER_VER} != "120"
   1549 HAVE_MESA_VER?=19
   1550 .endif
   1551 
   1552 HAVE_MESA_VER?=	21
   1553 .if ${HAVE_MESA_VER} == 19
   1554 EXTERNAL_MESALIB_DIR?=	MesaLib.old
   1555 .elif ${HAVE_MESA_VER} == 21
   1556 EXTERNAL_MESALIB_DIR?=	MesaLib
   1557 .endif
   1558 
   1559 # Default to LLVM run-time if x86 or aarch64 and X11 and Mesa 18 or newer
   1560 # XXX This knows that MKX11=no is default below, but would
   1561 # require splitting the below loop in two parts.
   1562 .if ${MKX11:Uno} != "no" && ${HAVE_MESA_VER} >= 19
   1563 MKLLVMRT.aarch64=	yes
   1564 MKLLVMRT.amd64=		yes
   1565 MKLLVMRT.i386=		yes
   1566 .endif
   1567 
   1568 # Just-in-time compiler for bpf, npf acceleration
   1569 MKSLJIT.aarch64=	yes
   1570 MKSLJIT.i386=		yes
   1571 MKSLJIT.sparc=		yes
   1572 MKSLJIT.x86_64=		yes
   1573 #MKSLJIT.mips64eb=	yes	# XXX
   1574 #MKSLJIT.mips64el=	yes	# XXX
   1575 #MKSLJIT.mipseb=	yes	# XXX
   1576 #MKSLJIT.mipsel=	yes	# XXX
   1577 #MKSLJIT.powerpc64=	yes	# XXX
   1578 #MKSLJIT.powerpc=	yes	# XXX
   1579 #MKSLJIT.riscv32=	yes	# not until we update sljit
   1580 #MKSLJIT.riscv64=	yes	# not until we update sljit
   1581 #MKSLJIT.sparc64=	yes	# not suppored in sljit (yet?)
   1582 
   1583 # compat with old names
   1584 MKDEBUGKERNEL?=${MKKDEBUG:Uno}
   1585 MKDEBUGTOOLS?=${MKTOOLSDEBUG:Uno}
   1586 
   1587 #
   1588 # MK* options which default to "no".
   1589 # Note that MKZFS has a different default for some platforms, see above.
   1590 # Please keep alphabetically sorted with one entry per line.
   1591 #
   1592 _MKVARS.no= \
   1593 	MKAMDGPUFIRMWARE \
   1594 	MKARZERO \
   1595 	MKDEBUGKERNEL \
   1596 	MKBSDGREP \
   1597 	MKCATPAGES \
   1598 	MKCOMPATTESTS \
   1599 	MKCOMPATX11 \
   1600 	MKCTF \
   1601 	MKDEBUG \
   1602 	MKDEBUGLIB \
   1603 	MKDEPINCLUDES \
   1604 	MKDTB \
   1605 	MKDTRACE \
   1606 	MKFIRMWARE \
   1607 	MKGROFFHTMLDOC \
   1608 	MKHOSTOBJ \
   1609 	MKKYUA \
   1610 	MKLIBCXX \
   1611 	MKLINT \
   1612 	MKLLVM \
   1613 	MKLLVMRT \
   1614 	MKMANZ \
   1615 	MKNOUVEAUFIRMWARE \
   1616 	MKNSD \
   1617 	MKOBJDIRS \
   1618 	MKPCC \
   1619 	MKPICINSTALL \
   1620 	MKPIGZGZIP \
   1621 	MKRADEONFIRMWARE \
   1622 	MKREPRO \
   1623 	MKSLJIT \
   1624 	MKSOFTFLOAT \
   1625 	MKSTRIPIDENT \
   1626 	MKTEGRAFIRMWARE \
   1627 	MKTPM \
   1628 	MKUNPRIVED \
   1629 	MKUPDATE \
   1630 	MKX11 \
   1631 	MKX11MOTIF \
   1632 	MKXORG_SERVER \
   1633 	MKZFS
   1634 
   1635 .for var in ${_MKVARS.no}
   1636 ${var}?=	${${var}.${MACHINE_ARCH}:U${${var}.${MACHINE}:Uno}}
   1637 .endfor
   1638 
   1639 #
   1640 # Which platforms build the xorg-server drivers (as opposed
   1641 # to just Xnest and Xvfb.)
   1642 #
   1643 .if \
   1644     ${MACHINE} == "alpha"	|| \
   1645     ${MACHINE} == "amd64"	|| \
   1646     ${MACHINE} == "amiga"	|| \
   1647     ${MACHINE} == "bebox"	|| \
   1648     ${MACHINE} == "cats"	|| \
   1649     ${MACHINE} == "dreamcast"	|| \
   1650     ${MACHINE} == "evbarm"	|| \
   1651     ${MACHINE} == "evbmips"	|| \
   1652     ${MACHINE} == "evbppc"	|| \
   1653     ${MACHINE} == "ews4800mips"	|| \
   1654     ${MACHINE} == "hp300"	|| \
   1655     ${MACHINE} == "hpcarm"	|| \
   1656     ${MACHINE} == "hpcmips"	|| \
   1657     ${MACHINE} == "hpcsh"	|| \
   1658     ${MACHINE} == "hppa"	|| \
   1659     ${MACHINE} == "i386"	|| \
   1660     ${MACHINE} == "ibmnws"	|| \
   1661     ${MACHINE} == "iyonix"	|| \
   1662     ${MACHINE} == "luna68k"	|| \
   1663     ${MACHINE} == "mac68k"	|| \
   1664     ${MACHINE} == "macppc"	|| \
   1665     ${MACHINE} == "netwinder"	|| \
   1666     ${MACHINE} == "newsmips"	|| \
   1667     ${MACHINE} == "ofppc"	|| \
   1668     ${MACHINE} == "pmax"	|| \
   1669     ${MACHINE} == "prep"	|| \
   1670     ${MACHINE} == "sgimips"	|| \
   1671     ${MACHINE} == "shark"	|| \
   1672     ${MACHINE} == "sparc"	|| \
   1673     ${MACHINE} == "sparc64"	|| \
   1674     ${MACHINE} == "vax"		|| \
   1675     ${MACHINE} == "zaurus"
   1676 MKXORG_SERVER=yes
   1677 .endif
   1678 
   1679 #
   1680 # Force some options off if their dependencies are off.
   1681 #
   1682 
   1683 .if ${MKCXX} == "no"
   1684 MKATF:=		no
   1685 MKGCCCMDS:=	no
   1686 MKGDB:=		no
   1687 MKGROFF:=	no
   1688 MKKYUA:=	no
   1689 .endif
   1690 
   1691 .if ${MKMAN} == "no"
   1692 MKCATPAGES:=	no
   1693 MKHTML:=	no
   1694 .endif
   1695 
   1696 _MANINSTALL=	maninstall
   1697 .if ${MKCATPAGES} != "no"
   1698 _MANINSTALL+=	catinstall
   1699 .endif
   1700 .if ${MKHTML} != "no"
   1701 _MANINSTALL+=	htmlinstall
   1702 .endif
   1703 
   1704 .if ${MKLINKLIB} == "no"
   1705 MKLINT:=	no
   1706 MKPICINSTALL:=	no
   1707 MKPROFILE:=	no
   1708 .endif
   1709 
   1710 .if ${MKPIC} == "no"
   1711 MKPICLIB:=	no
   1712 .endif
   1713 
   1714 .if ${MKOBJ} == "no"
   1715 MKOBJDIRS:=	no
   1716 .endif
   1717 
   1718 .if ${MKSHARE} == "no"
   1719 MKCATPAGES:=	no
   1720 MKDOC:=		no
   1721 MKHTML:=	no
   1722 MKINFO:=	no
   1723 MKMAN:=		no
   1724 MKNLS:=		no
   1725 .endif
   1726 
   1727 .if ${MKUSB} == "no"
   1728 MKFIDO2:=	no
   1729 .endif
   1730 
   1731 .if ${MACHINE_ARCH:Mearm*}
   1732 _NEEDS_LIBCXX.${MACHINE_ARCH}=	yes
   1733 .endif
   1734 _NEEDS_LIBCXX.aarch64=		yes
   1735 _NEEDS_LIBCXX.aarch64eb=	yes
   1736 _NEEDS_LIBCXX.i386=		yes
   1737 _NEEDS_LIBCXX.powerpc=		yes
   1738 _NEEDS_LIBCXX.powerpc64=	yes
   1739 _NEEDS_LIBCXX.sparc=		yes
   1740 _NEEDS_LIBCXX.sparc64=		yes
   1741 _NEEDS_LIBCXX.x86_64=		yes
   1742 
   1743 .if ${MKLLVM} == "yes" && ${_NEEDS_LIBCXX.${MACHINE_ARCH}:Uno} == "yes"
   1744 MKLIBCXX:=	yes
   1745 .endif
   1746 
   1747 #
   1748 # Disable MKSTRIPSYM if MKDEBUG is enabled.
   1749 #
   1750 .if ${MKDEBUG} != "no"
   1751 MKSTRIPSYM:=	no
   1752 .endif
   1753 
   1754 #
   1755 # install(1) parameters.
   1756 #
   1757 COPY?=		-c
   1758 .if ${MKUPDATE} == "no"
   1759 PRESERVE?=
   1760 .else
   1761 PRESERVE?=	-p
   1762 .endif
   1763 RENAME?=	-r
   1764 HRDLINK?=	-l h
   1765 SYMLINK?=	-l s
   1766 
   1767 METALOG?=	${DESTDIR}/METALOG
   1768 METALOG.add?=	${TOOL_CAT} -l >> ${METALOG}
   1769 .if (${_SRC_TOP_} != "")	# only set INSTPRIV if inside ${NETBSDSRCDIR}
   1770 .if ${MKUNPRIVED} != "no"
   1771 INSTPRIV.unpriv=-U -M ${METALOG} -D ${DESTDIR} -h sha256
   1772 .else
   1773 INSTPRIV.unpriv=
   1774 .endif
   1775 INSTPRIV?=	${INSTPRIV.unpriv} -N ${NETBSDSRCDIR}/etc
   1776 .endif
   1777 STRIPFLAG?=
   1778 
   1779 INSTALL_DIR?=		${INSTALL} ${INSTPRIV} -d
   1780 INSTALL_FILE?=		${INSTALL} ${INSTPRIV} ${COPY} ${PRESERVE} ${RENAME}
   1781 INSTALL_LINK?=		${INSTALL} ${INSTPRIV} ${HRDLINK} ${RENAME}
   1782 INSTALL_SYMLINK?=	${INSTALL} ${INSTPRIV} ${SYMLINK} ${RENAME}
   1783 
   1784 # for crunchide & ldd, define the OBJECT_FMTS used by a MACHINE_ARCH
   1785 #
   1786 OBJECT_FMTS=
   1787 .if	${MACHINE_ARCH} != "alpha" && ${MACHINE_ARCH} != "ia64"
   1788 OBJECT_FMTS+=	elf32
   1789 .endif
   1790 .if	${MACHINE_ARCH} == "alpha" || ${MACHINE_ARCH:M*64*} != ""
   1791 . if !(${MKCOMPAT:Uyes} == "no" && ${MACHINE_ARCH:Mmips64*} != "")
   1792 OBJECT_FMTS+=	elf64
   1793 . endif
   1794 .endif
   1795 
   1796 #
   1797 # Set defaults for the USE_xxx variables.
   1798 #
   1799 
   1800 #
   1801 # USE_* options which default to "no" and will be forced to "no" if their
   1802 # corresponding MK* variable is set to "no".
   1803 #
   1804 .for var in USE_SKEY
   1805 .if (${${var:S/USE_/MK/}} == "no")
   1806 ${var}:= no
   1807 .else
   1808 ${var}?= no
   1809 .endif
   1810 .endfor
   1811 
   1812 #
   1813 # USE_* options which default to "yes" unless their corresponding MK*
   1814 # variable is set to "no".
   1815 #
   1816 .for var in USE_HESIOD USE_INET6 USE_KERBEROS USE_LDAP USE_PAM USE_YP
   1817 .if (${${var:S/USE_/MK/}} == "no")
   1818 ${var}:= no
   1819 .else
   1820 ${var}?= yes
   1821 .endif
   1822 .endfor
   1823 
   1824 #
   1825 # USE_* options which default to "yes".
   1826 #
   1827 .for var in USE_JEMALLOC
   1828 ${var}?= yes
   1829 .endfor
   1830 
   1831 #
   1832 # USE_* options which default to "no".
   1833 #
   1834 # For now, disable pigz as compressor by default
   1835 .for var in USE_PIGZGZIP
   1836 ${var}?= no
   1837 .endfor
   1838 
   1839 # Default to USE_XZ_SETS on some 64bit architectures where decompressor
   1840 # memory will likely not be in short supply.
   1841 # Since pigz can not create .xz format files currently, disable .xz
   1842 # format if USE_PIGZGZIP is enabled.
   1843 .if ${USE_PIGZGZIP} == "no" && ( \
   1844     ${MACHINE_ARCH:Maarch64*} || \
   1845     ${MACHINE} == "amd64" \
   1846     )
   1847 USE_XZ_SETS?= yes
   1848 .else
   1849 USE_XZ_SETS?= no
   1850 .endif
   1851 
   1852 #
   1853 # TOOL_GZIP and friends.  These might refer to TOOL_PIGZ or to the host gzip.
   1854 #
   1855 .if ${USE_PIGZGZIP} != "no"
   1856 TOOL_GZIP=		${TOOL_PIGZ}
   1857 GZIP_N_FLAG?=		-nT
   1858 .else
   1859 .if ${USETOOLS} == "yes"
   1860 TOOL_GZIP=		${TOOLDIR}/bin/${_TOOL_PREFIX}gzip
   1861 .else
   1862 TOOL_GZIP=		gzip
   1863 .endif
   1864 GZIP_N_FLAG?=		-n
   1865 .endif
   1866 TOOL_GZIP_N=		${TOOL_GZIP} ${GZIP_N_FLAG}
   1867 
   1868 #
   1869 # Where X11 sources are and where it is installed to.
   1870 #
   1871 .if !defined(X11SRCDIR)
   1872 .if exists(${NETBSDSRCDIR}/../xsrc)
   1873 X11SRCDIR!=		cd "${NETBSDSRCDIR}/../xsrc" && pwd
   1874 .else
   1875 X11SRCDIR=		/usr/xsrc
   1876 .endif
   1877 .endif # !defined(X11SRCDIR)
   1878 
   1879 X11SRCDIR.local?=	${X11SRCDIR}/local
   1880 X11ROOTDIR?=		/usr/X11R7
   1881 X11BINDIR?=		${X11ROOTDIR}/bin
   1882 X11ETCDIR?=		/etc/X11
   1883 X11FONTDIR?=		${X11ROOTDIR}/lib/X11/fonts
   1884 X11INCDIR?=		${X11ROOTDIR}/include
   1885 X11LIBDIR?=		${X11ROOTDIR}/lib/X11
   1886 X11MANDIR?=		${X11ROOTDIR}/man
   1887 X11SHAREDIR?=		${X11ROOTDIR}/share
   1888 X11USRLIBDIR?=		${X11ROOTDIR}/lib${MLIBDIR:D/${MLIBDIR}}
   1889 
   1890 #
   1891 # New modular-xorg based builds
   1892 #
   1893 X11SRCDIRMIT?=		${X11SRCDIR}/external/mit
   1894 .for _lib in \
   1895 	FS ICE SM X11 XScrnSaver XTrap Xau Xcomposite Xcursor Xdamage \
   1896 	Xdmcp Xevie Xext Xfixes Xfont Xfont2 Xft Xi Xinerama Xmu Xpresent Xpm \
   1897 	Xrandr Xrender Xres Xt Xtst Xv XvMC Xxf86dga Xxf86misc Xxf86vm drm \
   1898 	epoxy fontenc vdpau xkbfile xkbui Xaw pciaccess xcb xshmfence \
   1899 	pthread-stubs xcvt
   1900 X11SRCDIR.${_lib}?=		${X11SRCDIRMIT}/lib${_lib}/dist
   1901 .endfor
   1902 
   1903 .for _proto in \
   1904 	xcb- xorg
   1905 X11SRCDIR.${_proto}proto?=		${X11SRCDIRMIT}/${_proto}proto/dist
   1906 .endfor
   1907 
   1908 # Build glamor extension?
   1909 
   1910 .if ${HAVE_XORG_SERVER_VER} == "120"
   1911 XORG_SERVER_SUBDIR?=xorg-server
   1912 . if \
   1913     ${MACHINE} == "amd64" || \
   1914     ${MACHINE} == "evbarm" || \
   1915     ${MACHINE} == "evbppc" || \
   1916     ${MACHINE} == "i386"
   1917 HAVE_XORG_GLAMOR?=	yes
   1918 . endif
   1919 HAVE_XORG_EGL?=		yes
   1920 .else
   1921 XORG_SERVER_SUBDIR?=xorg-server.old
   1922 .endif
   1923 
   1924 X11SRCDIR.xorg-server?=		${X11SRCDIRMIT}/${XORG_SERVER_SUBDIR}/dist
   1925 HAVE_XORG_GLAMOR?=	no
   1926 HAVE_XORG_EGL?=		no
   1927 
   1928 .for _dir in \
   1929 	xtrans fontconfig freetype evieext mkfontscale bdftopcf \
   1930 	xorg-cf-files imake xbiff xkeyboard-config \
   1931 	xcompmgr xbitmaps appres xeyes xev xedit sessreg pixman \
   1932 	brotli \
   1933 	beforelight bitmap editres makedepend fonttosfnt fslsfonts fstobdf \
   1934 	glu glw mesa-demos MesaGLUT MesaLib MesaLib.old MesaLib7 \
   1935 	ico iceauth listres lndir \
   1936 	luit xproxymanagementprotocol mkfontdir oclock proxymngr rgb \
   1937 	rstart setxkbmap showfont smproxy transset twm viewres \
   1938 	util-macros \
   1939 	x11perf xauth xcalc xclipboard \
   1940 	xclock xcmsdb xconsole xditview xdpyinfo xdriinfo xdm \
   1941 	xfd xf86dga xfindproxy xfontsel xgamma xgc xhost xinit \
   1942 	xkill xload xlogo xlsatoms xlsclients xlsfonts xmag xmessage \
   1943 	xmh xmodmap xmore xman xprop xrandr xrdb xrefresh xset \
   1944 	xsetmode xsetpointer xsetroot xsm xstdcmap xvidtune xvinfo \
   1945 	xwininfo xwud xkbprint xkbevd \
   1946 	xterm xwd xfs xfsinfo xtrap xkbutils xkbcomp \
   1947 	xinput xcb-util xorg-docs \
   1948 	font-adobe-100dpi font-adobe-75dpi font-adobe-utopia-100dpi \
   1949 	font-adobe-utopia-75dpi font-adobe-utopia-type1 \
   1950 	font-alias \
   1951 	font-bh-100dpi font-bh-75dpi font-bh-lucidatypewriter-100dpi \
   1952 	font-bh-lucidatypewriter-75dpi font-bh-ttf font-bh-type1 \
   1953 	font-bitstream-100dpi font-bitstream-75dpi font-bitstream-type1 \
   1954 	font-cursor-misc font-daewoo-misc font-dec-misc font-ibm-type1 \
   1955 	font-isas-misc font-jis-misc font-misc-misc font-mutt-misc \
   1956 	font-sony-misc font-util ttf-bitstream-vera encodings \
   1957 	font-arabic-misc font-micro-misc font-schumacher-misc \
   1958 	font-sun-misc font-cronyx-cyrillic font-misc-cyrillic \
   1959 	font-screen-cyrillic font-winitzki-cyrillic font-xfree86-type1
   1960 X11SRCDIR.${_dir}?=		${X11SRCDIRMIT}/${_dir}/dist
   1961 .endfor
   1962 
   1963 # X11SRCDIR.Mesa points to the currently used Mesa sources
   1964 X11SRCDIR.Mesa?=		${X11SRCDIRMIT}/${EXTERNAL_MESALIB_DIR}/dist
   1965 
   1966 .for _i in \
   1967 	elographics keyboard mouse synaptics vmmouse void ws
   1968 X11SRCDIR.xf86-input-${_i}?=	${X11SRCDIRMIT}/xf86-input-${_i}/dist
   1969 .endfor
   1970 
   1971 # xf86-video-modesetting move into the server build.
   1972 EXTRA_DRIVERS=
   1973 .if ${HAVE_XORG_SERVER_VER} == "120"
   1974 X11SRCDIR.xf86-video-modesetting=${X11SRCDIR.xorg-server}/hw/xfree86/drivers/modesetting
   1975 .else
   1976 EXTRA_DRIVERS=	modesetting
   1977 .endif
   1978 
   1979 .for _v in \
   1980 	ag10e amdgpu apm ark ast ati ati-kms chips cirrus crime \
   1981 	geode glint i128 i740 igs imstt intel intel-old intel-2014 \
   1982 	${EXTRA_DRIVERS} mach64 mga mgx \
   1983 	neomagic newport ngle nouveau nsc nv openchrome pnozz \
   1984 	r128 rendition \
   1985 	s3 s3virge savage siliconmotion sis suncg14 \
   1986 	suncg6 sunffb sunleo suntcx \
   1987 	tdfx tga trident tseng vboxvideo vesa vga vmware wsfb xgi
   1988 X11SRCDIR.xf86-video-${_v}?=	${X11SRCDIRMIT}/xf86-video-${_v}/dist
   1989 .endfor
   1990 
   1991 
   1992 X11DRI?=			yes
   1993 X11LOADABLE?=			yes
   1994 
   1995 
   1996 #
   1997 # MAKEDIRTARGET dir target [extra make(1) params]
   1998 #	run "cd $${dir} && ${MAKEDIRTARGETENV} ${MAKE} [params] $${target}", with a pretty message
   1999 #
   2000 MAKEDIRTARGETENV?=
   2001 MAKEDIRTARGET=\
   2002 	@_makedirtarget() { \
   2003 		dir="$$1"; shift; \
   2004 		target="$$1"; shift; \
   2005 		case "$${dir}" in \
   2006 		/*)	this="$${dir}/"; \
   2007 			real="$${dir}" ;; \
   2008 		.)	this="${_THISDIR_}"; \
   2009 			real="${.CURDIR}" ;; \
   2010 		*)	this="${_THISDIR_}$${dir}/"; \
   2011 			real="${.CURDIR}/$${dir}" ;; \
   2012 		esac; \
   2013 		show=$${this:-.}; \
   2014 		echo "$${target} ===> $${show%/}$${1:+	(with: $$@)}"; \
   2015 		cd "$${real}" \
   2016 		&& ${MAKEDIRTARGETENV} ${MAKE} _THISDIR_="$${this}" "$$@" $${target}; \
   2017 	}; \
   2018 	_makedirtarget
   2019 
   2020 #
   2021 # MAKEVERBOSE support.  Levels are:
   2022 #	0	Minimal output ("quiet")
   2023 #	1	Describe what is occurring
   2024 #	2	Describe what is occurring and echo the actual command
   2025 #	3	Ignore the effect of the "@" prefix in make commands
   2026 #	4	Trace shell commands using the shell's -x flag
   2027 #
   2028 MAKEVERBOSE?=		2
   2029 
   2030 .if ${MAKEVERBOSE} == 0
   2031 _MKMSG?=	@\#
   2032 _MKSHMSG?=	: echo
   2033 _MKSHECHO?=	: echo
   2034 .SILENT:
   2035 .elif ${MAKEVERBOSE} == 1
   2036 _MKMSG?=	@echo '   '
   2037 _MKSHMSG?=	echo '   '
   2038 _MKSHECHO?=	: echo
   2039 .SILENT:
   2040 .else	# MAKEVERBOSE >= 2
   2041 _MKMSG?=	@echo '\#  '
   2042 _MKSHMSG?=	echo '\#  '
   2043 _MKSHECHO?=	echo
   2044 .SILENT: __makeverbose_dummy_target__
   2045 .endif	# MAKEVERBOSE >= 2
   2046 .if ${MAKEVERBOSE} >= 3
   2047 .MAKEFLAGS:	-dl
   2048 .endif	# ${MAKEVERBOSE} >= 3
   2049 .if ${MAKEVERBOSE} >= 4
   2050 .MAKEFLAGS:	-dx
   2051 .endif	# ${MAKEVERBOSE} >= 4
   2052 
   2053 _MKMSG_BUILD?=		${_MKMSG} "  build "
   2054 _MKMSG_COMPILE?=	${_MKMSG} "compile "
   2055 _MKMSG_CREATE?=		${_MKMSG} " create "
   2056 _MKMSG_EXECUTE?=	${_MKMSG} "execute "
   2057 _MKMSG_FORMAT?=		${_MKMSG} " format "
   2058 _MKMSG_INSTALL?=	${_MKMSG} "install "
   2059 _MKMSG_LEX?=		${_MKMSG} "    lex "
   2060 _MKMSG_LINK?=		${_MKMSG} "   link "
   2061 _MKMSG_REGEN?=		${_MKMSG} "  regen "
   2062 _MKMSG_REMOVE?=		${_MKMSG} " remove "
   2063 _MKMSG_YACC?=		${_MKMSG} "   yacc "
   2064 
   2065 _MKSHMSG_CREATE?=	${_MKSHMSG} " create "
   2066 _MKSHMSG_FORMAT?=	${_MKSHMSG} " format "
   2067 _MKSHMSG_INSTALL?=	${_MKSHMSG} "install "
   2068 
   2069 _MKTARGET_BUILD?=	${_MKMSG_BUILD} ${.CURDIR:T}/${.TARGET}
   2070 _MKTARGET_COMPILE?=	${_MKMSG_COMPILE} ${.CURDIR:T}/${.TARGET}
   2071 _MKTARGET_CREATE?=	${_MKMSG_CREATE} ${.CURDIR:T}/${.TARGET}
   2072 _MKTARGET_FORMAT?=	${_MKMSG_FORMAT} ${.CURDIR:T}/${.TARGET}
   2073 _MKTARGET_INSTALL?=	${_MKMSG_INSTALL} ${.TARGET}
   2074 _MKTARGET_LEX?=		${_MKMSG_LEX} ${.CURDIR:T}/${.TARGET}
   2075 _MKTARGET_LINK?=	${_MKMSG_LINK} ${.CURDIR:T}/${.TARGET}
   2076 _MKTARGET_REMOVE?=	${_MKMSG_REMOVE} ${.TARGET}
   2077 _MKTARGET_YACC?=	${_MKMSG_YACC} ${.CURDIR:T}/${.TARGET}
   2078 
   2079 .if ${MKMANDOC} == "yes"
   2080 TARGETS+=	lintmanpages
   2081 .endif
   2082 
   2083 TESTSBASE=	/usr/tests${MLIBDIR:D/${MLIBDIR}}
   2084 
   2085 # Override with tools versions if needed
   2086 .if ${MKCTF:Uno} != "no" && !defined(NOCTF) && \
   2087     (exists(${TOOL_CTFCONVERT}) || exists(/usr/bin/${TOOL_CTFCONVERT}))
   2088 CTFCONVERT=	${TOOL_CTFCONVERT}
   2089 CTFMERGE=	${TOOL_CTFMERGE}
   2090 .endif
   2091 
   2092 .endif	# !defined(_BSD_OWN_MK_)
   2093