diff --git a/sys/boot/defs.mk b/sys/boot/defs.mk index 08daae9c2f80..4fbc83966dc6 100644 --- a/sys/boot/defs.mk +++ b/sys/boot/defs.mk @@ -96,4 +96,43 @@ CFLAGS+= -DLOADER_GELI_SUPPORT CFLAGS+= -m32 -mcpu=powerpc .endif +_ILINKS=machine +.if ${MACHINE} != ${MACHINE_CPUARCH} && ${MACHINE} != "arm64" +_ILINKS+=${MACHINE_CPUARCH} +.endif +.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" +_ILINKS+=x86 +.endif +CLEANFILES+=${_ILINKS} + +all: ${PROG} + +beforedepend: ${_ILINKS} +beforebuild: ${_ILINKS} + +# Ensure that the links exist without depending on it when it exists which +# causes all the modules to be rebuilt when the directory pointed to changes. +.for _link in ${_ILINKS} +.if !exists(${.OBJDIR}/${_link}) +${OBJS}: ${_link} +.endif +.endfor + +.NOPATH: ${_ILINKS} + +${_ILINKS}: + @case ${.TARGET} in \ + machine) \ + if [ ${DO32:U0} -eq 0 ]; then \ + path=${SYSDIR}/${MACHINE}/include ; \ + else \ + path=${SYSDIR}/${MACHINE:C/amd64/i386/}/include ; \ + fi ;; \ + *) \ + path=${SYSDIR}/${.TARGET:T}/include ;; \ + esac ; \ + path=`(cd $$path && /bin/pwd)` ; \ + ${ECHO} ${.TARGET:T} "->" $$path ; \ + ln -fhs $$path ${.TARGET:T} + .endif # __BOOT_DEFS_MK__ diff --git a/sys/boot/efi/boot1/Makefile b/sys/boot/efi/boot1/Makefile index c6b27d8ade03..8f5aed50dce4 100644 --- a/sys/boot/efi/boot1/Makefile +++ b/sys/boot/efi/boot1/Makefile @@ -129,18 +129,3 @@ boot1.efifat: boot1.efi CLEANFILES= boot1.efi boot1.efifat .include - -beforedepend ${OBJS}: machine - -CLEANFILES+= machine - -machine: .NOMETA - ln -sf ${SYSDIR}/${MACHINE}/include machine - -.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" -beforedepend ${OBJS}: x86 -CLEANFILES+= x86 - -x86: .NOMETA - ln -sf ${SYSDIR}/x86/include x86 -.endif diff --git a/sys/boot/efi/fdt/Makefile b/sys/boot/efi/fdt/Makefile index 4a5f164a458f..01dbeed05eaf 100644 --- a/sys/boot/efi/fdt/Makefile +++ b/sys/boot/efi/fdt/Makefile @@ -27,11 +27,4 @@ CFLAGS+= -I${FDTSRC} # Pick up the bootstrap header for some interface items CFLAGS+= -I${LDRSRC} -I${SYSDIR} -I. -machine: .NOMETA - ln -sf ${SYSDIR}/${MACHINE}/include machine - -CLEANFILES+= machine - .include - -beforedepend ${OBJS}: machine diff --git a/sys/boot/efi/loader/Makefile b/sys/boot/efi/loader/Makefile index d4eb8d8d55e2..0c560d554ecb 100644 --- a/sys/boot/efi/loader/Makefile +++ b/sys/boot/efi/loader/Makefile @@ -133,18 +133,3 @@ DPADD= ${LIBFICL} ${LIBEFI} ${LIBFDT} ${LIBEFI_FDT} ${LIBZFSBOOT} ${LIBSA} \ LDADD= ${LIBFICL} ${LIBEFI} ${LIBFDT} ${LIBEFI_FDT} ${LIBZFSBOOT} ${LIBSA} .include - -beforedepend ${OBJS}: machine - -CLEANFILES+= machine - -machine: .NOMETA - ln -sf ${SYSDIR}/${MACHINE}/include machine - -.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386" -beforedepend ${OBJS}: x86 -CLEANFILES+= x86 - -x86: .NOMETA - ln -sf ${SYSDIR}/x86/include x86 -.endif diff --git a/sys/boot/ficl.mk b/sys/boot/ficl.mk index 3c74e3495979..b6ac8d9096b0 100644 --- a/sys/boot/ficl.mk +++ b/sys/boot/ficl.mk @@ -29,16 +29,3 @@ CFLAGS+= -m32 -mcpu=powerpc -I. CFLAGS+= -I${FICLSRC} -I${FICLSRC}/${FICL_CPUARCH} -I${LDRSRC} CFLAGS+= -DBOOT_FORTH CFLAGS+= -DBF_DICTSIZE=15000 - -.if ${MACHINE_CPUARCH} == "amd64" && ${DO32:U0} == 1 -.if !exists(machine) -${SRCS:M*.c:R:S/$/.o/g}: machine - -beforedepend ${OBJS}: machine -.endif - -machine: .NOMETA - ln -sf ${SYSDIR}/i386/include machine - -CLEANFILES+= machine -.endif diff --git a/sys/boot/i386/Makefile.inc b/sys/boot/i386/Makefile.inc index da9489ac9707..941a8c49ab9b 100644 --- a/sys/boot/i386/Makefile.inc +++ b/sys/boot/i386/Makefile.inc @@ -30,6 +30,7 @@ ACFLAGS+= -m32 # LD_FLAGS is passed directly to ${LD}, not via ${CC}: LD_FLAGS+= -m elf_i386_fbsd AFLAGS+= --32 +DO32=1 .endif .include "../Makefile.inc" diff --git a/sys/boot/i386/boot2/Makefile b/sys/boot/i386/boot2/Makefile index 506ea37664e4..9f9e5191e133 100644 --- a/sys/boot/i386/boot2/Makefile +++ b/sys/boot/i386/boot2/Makefile @@ -93,13 +93,6 @@ boot2.h: boot1.out ORG1=`printf "%d" ${ORG1}` \ REL1=`printf "%d" ${REL1}` > ${.TARGET} -.if ${MACHINE_CPUARCH} == "amd64" -beforedepend boot2.s: machine -CLEANFILES+= machine -machine: ${SYSDIR}/i386/include .NOMETA - ln -sf ${.ALLSRC} ${.TARGET} -.endif - .include # XXX: clang integrated-as doesn't grok .codeNN directives yet diff --git a/sys/boot/i386/gptboot/Makefile b/sys/boot/i386/gptboot/Makefile index 2b2d2650d43b..9d3048a89c56 100644 --- a/sys/boot/i386/gptboot/Makefile +++ b/sys/boot/i386/gptboot/Makefile @@ -76,13 +76,6 @@ gptboot.out: ${BTXCRT} gptboot.o sio.o crc32.o drv.o cons.o util.o ${OPENCRYPTO_ gptboot.o: ${SASRC}/ufsread.c -.if ${MACHINE_CPUARCH} == "amd64" -beforedepend gptboot.o: machine -CLEANFILES+= machine -machine: .NOMETA - ln -sf ${SYSDIR}/i386/include machine -.endif - .include # XXX: clang integrated-as doesn't grok .codeNN directives yet diff --git a/sys/boot/i386/gptzfsboot/Makefile b/sys/boot/i386/gptzfsboot/Makefile index c2da080e39f6..b9df313dd291 100644 --- a/sys/boot/i386/gptzfsboot/Makefile +++ b/sys/boot/i386/gptzfsboot/Makefile @@ -88,13 +88,6 @@ gptzfsboot.out: ${BTXCRT} zfsboot.o sio.o gpt.o drv.o cons.o util.o \ zfsboot.o: ${ZFSSRC}/zfsimpl.c -.if ${MACHINE_CPUARCH} == "amd64" -beforedepend zfsboot.o: machine -CLEANFILES+= machine -machine: .NOMETA - ln -sf ${SYSDIR}/i386/include machine -.endif - .include # XXX: clang integrated-as doesn't grok .codeNN directives yet diff --git a/sys/boot/i386/libfirewire/Makefile b/sys/boot/i386/libfirewire/Makefile index 758b850a146b..be906ff94636 100644 --- a/sys/boot/i386/libfirewire/Makefile +++ b/sys/boot/i386/libfirewire/Makefile @@ -17,15 +17,4 @@ CFLAGS+= -I${BOOTSRC}/i386/libi386 CFLAGS+= -Wformat -Wall -.if ${MACHINE_CPUARCH} == "amd64" -CLEANFILES+= machine -machine: .NOMETA - ln -sf ${SYSDIR}/i386/include machine -.endif - .include - -.if ${MACHINE_CPUARCH} == "amd64" -beforedepend ${OBJS}: machine -.endif - diff --git a/sys/boot/i386/libi386/Makefile b/sys/boot/i386/libi386/Makefile index e998d6d6b0b1..20ce255fd50b 100644 --- a/sys/boot/i386/libi386/Makefile +++ b/sys/boot/i386/libi386/Makefile @@ -58,18 +58,8 @@ CFLAGS+= -I${BOOTSRC}/ficl -I${BOOTSRC}/ficl/i386 \ # Handle FreeBSD specific %b and %D printf format specifiers CFLAGS+= ${FORMAT_EXTENSIONS} -.if ${MACHINE_CPUARCH} == "amd64" -CLEANFILES+= machine -machine: .NOMETA - ln -sf ${SYSDIR}/i386/include machine -.endif - .include # XXX: clang integrated-as doesn't grok .codeNN directives yet CFLAGS.amd64_tramp.S= ${CLANG_NO_IAS} CFLAGS.multiboot_tramp.S= ${CLANG_NO_IAS} - -.if ${MACHINE_CPUARCH} == "amd64" -beforedepend ${OBJS}: machine -.endif diff --git a/sys/boot/i386/loader/Makefile b/sys/boot/i386/loader/Makefile index 846de0f085fc..e588d7996ba6 100644 --- a/sys/boot/i386/loader/Makefile +++ b/sys/boot/i386/loader/Makefile @@ -104,12 +104,8 @@ OBJS= ${BTXCRT} DPADD= ${LIBFICL32} ${LIBFIREWIRE} ${LIBZFSBOOT} ${LIBI386} ${LIBGELIBOOT} ${LIBSA32} LDADD= ${LIBFICL32} ${LIBFIREWIRE} ${LIBZFSBOOT} ${LIBI386} ${LIBGELIBOOT} ${LIBSA32} -.include - .if ${MACHINE_CPUARCH} == "amd64" -beforedepend ${OBJS}: machine -CLEANFILES+= machine CFLAGS+= -DLOADER_PREFER_AMD64 -machine: .NOMETA - ln -sf ${SYSDIR}/i386/include machine .endif + +.include diff --git a/sys/boot/i386/zfsboot/Makefile b/sys/boot/i386/zfsboot/Makefile index 2a9804a6f854..a83bfa960590 100644 --- a/sys/boot/i386/zfsboot/Makefile +++ b/sys/boot/i386/zfsboot/Makefile @@ -87,13 +87,6 @@ zfsboot.out: ${BTXCRT} zfsboot.o sio.o drv.o cons.o util.o SRCS= zfsboot.c -.if ${MACHINE_CPUARCH} == "amd64" -beforedepend zfsboot.o: machine -CLEANFILES+= machine -machine: .NOMETA - ln -sf ${SYSDIR}/i386/include machine -.endif - .include # XXX: clang integrated-as doesn't grok .codeNN directives yet diff --git a/sys/boot/libsa32/Makefile b/sys/boot/libsa32/Makefile index d4552fbf50b4..862f8868beab 100644 --- a/sys/boot/libsa32/Makefile +++ b/sys/boot/libsa32/Makefile @@ -17,10 +17,3 @@ CFLAGS+= -m32 -I. .PATH: ${SASRC} .include "${SASRC}/Makefile" - -.if ${MACHINE_CPUARCH} == "amd64" -CLEANFILES+= machine -beforedepend ${OBJS}: machine -machine: .NOMETA - ln -fs ${SYSDIR}/i386/include machine -.endif diff --git a/sys/boot/ofw/libofw/Makefile b/sys/boot/ofw/libofw/Makefile index 0af80aafa54f..836e2a821d1a 100644 --- a/sys/boot/ofw/libofw/Makefile +++ b/sys/boot/ofw/libofw/Makefile @@ -25,11 +25,4 @@ SRCS+= ppc64_elf_freebsd.c CFLAGS+= -DDISK_DEBUG .endif -machine: .NOMETA - ln -sf ${SYSDIR}/${MACHINE_CPUARCH}/include machine - -CLEANFILES+= machine - .include - -beforedepend ${OBJS}: machine diff --git a/sys/boot/uboot/fdt/Makefile b/sys/boot/uboot/fdt/Makefile index 1409e3e4696e..87bebca5c0d8 100644 --- a/sys/boot/uboot/fdt/Makefile +++ b/sys/boot/uboot/fdt/Makefile @@ -21,12 +21,5 @@ CFLAGS+= -I${FDTSRC} # Pick up the bootstrap header for some interface items CFLAGS+= -I${LDRSRC} -I${SYSDIR} -I. -machine: .NOMETA - ln -sf ${SYSDIR}/${MACHINE_CPUARCH}/include machine - -CLEANFILES+= machine - .include .include - -beforedepend ${OBJS}: machine diff --git a/sys/boot/uboot/lib/Makefile b/sys/boot/uboot/lib/Makefile index 8fce769c77c8..6b25a415e6cd 100644 --- a/sys/boot/uboot/lib/Makefile +++ b/sys/boot/uboot/lib/Makefile @@ -38,12 +38,5 @@ CFLAGS+= -I${LDRSRC} -I${SYSDIR} -I. CFLAGS+= -DDISK_DEBUG .endif -machine: .NOMETA - ln -sf ${SYSDIR}/${MACHINE_CPUARCH}/include machine - -CLEANFILES+= machine - .include .include - -beforedepend ${OBJS}: machine diff --git a/sys/boot/zfs/Makefile b/sys/boot/zfs/Makefile index d06464354fca..478e168ef368 100644 --- a/sys/boot/zfs/Makefile +++ b/sys/boot/zfs/Makefile @@ -26,17 +26,5 @@ CFLAGS+= -m32 CFLAGS+= -Wformat -Wall -.if ${MACHINE_CPUARCH} == "amd64" && defined(DO32) -CLEANFILES+= machine -machine: .NOMETA - ln -sf ${SYSDIR}/i386/include machine -.endif - .include .include - -.if ${MACHINE_CPUARCH} == "amd64" && defined(DO32) -.if !exists(machine) -beforedepend ${OBJS}: machine -.endif -.endif