svn commit: r325482 - in head/sys/boot: . efi/boot1 efi/fdt efi/loader i386 i386/boot2 i386/gptboot i386/gptzfsboot i386/libfirewire i386/libi386 i386/loader i386/zfsboot libsa32 ofw/libofw uboot/f...

Warner Losh imp at FreeBSD.org
Mon Nov 6 15:22:07 UTC 2017


Author: imp
Date: Mon Nov  6 15:22:04 2017
New Revision: 325482
URL: https://svnweb.freebsd.org/changeset/base/325482

Log:
  Move machine and other link creation to defs.mk
  
  Steal the code from kmod.mk and use it to automatically create
  links. Modify it a little for the needs of the loader (no need to
  guess the OBJS dependency, and we have 32-on-64 cases to contend
  with). Remove 15 redundant implementations (which were mostly
  different, but kinda the same).
  
  A future commit should factor out this code and that of kmod.mk so we
  have only one copy of it in the tree.
  
  Sposnored by: Netflix

Modified:
  head/sys/boot/defs.mk
  head/sys/boot/efi/boot1/Makefile
  head/sys/boot/efi/fdt/Makefile
  head/sys/boot/efi/loader/Makefile
  head/sys/boot/ficl.mk
  head/sys/boot/i386/Makefile.inc
  head/sys/boot/i386/boot2/Makefile
  head/sys/boot/i386/gptboot/Makefile
  head/sys/boot/i386/gptzfsboot/Makefile
  head/sys/boot/i386/libfirewire/Makefile
  head/sys/boot/i386/libi386/Makefile
  head/sys/boot/i386/loader/Makefile
  head/sys/boot/i386/zfsboot/Makefile
  head/sys/boot/libsa32/Makefile
  head/sys/boot/ofw/libofw/Makefile
  head/sys/boot/uboot/fdt/Makefile
  head/sys/boot/uboot/lib/Makefile
  head/sys/boot/zfs/Makefile

Modified: head/sys/boot/defs.mk
==============================================================================
--- head/sys/boot/defs.mk	Mon Nov  6 15:21:56 2017	(r325481)
+++ head/sys/boot/defs.mk	Mon Nov  6 15:22:04 2017	(r325482)
@@ -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__

Modified: head/sys/boot/efi/boot1/Makefile
==============================================================================
--- head/sys/boot/efi/boot1/Makefile	Mon Nov  6 15:21:56 2017	(r325481)
+++ head/sys/boot/efi/boot1/Makefile	Mon Nov  6 15:22:04 2017	(r325482)
@@ -129,18 +129,3 @@ boot1.efifat: boot1.efi
 CLEANFILES= boot1.efi boot1.efifat
 
 .include <bsd.prog.mk>
-
-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

Modified: head/sys/boot/efi/fdt/Makefile
==============================================================================
--- head/sys/boot/efi/fdt/Makefile	Mon Nov  6 15:21:56 2017	(r325481)
+++ head/sys/boot/efi/fdt/Makefile	Mon Nov  6 15:22:04 2017	(r325482)
@@ -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 <bsd.lib.mk>
-
-beforedepend ${OBJS}: machine

Modified: head/sys/boot/efi/loader/Makefile
==============================================================================
--- head/sys/boot/efi/loader/Makefile	Mon Nov  6 15:21:56 2017	(r325481)
+++ head/sys/boot/efi/loader/Makefile	Mon Nov  6 15:22:04 2017	(r325482)
@@ -133,18 +133,3 @@ DPADD=		${LIBFICL} ${LIBEFI} ${LIBFDT} ${LIBEFI_FDT} $
 LDADD=		${LIBFICL} ${LIBEFI} ${LIBFDT} ${LIBEFI_FDT} ${LIBZFSBOOT} ${LIBSA}
 
 .include <bsd.prog.mk>
-
-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

Modified: head/sys/boot/ficl.mk
==============================================================================
--- head/sys/boot/ficl.mk	Mon Nov  6 15:21:56 2017	(r325481)
+++ head/sys/boot/ficl.mk	Mon Nov  6 15:22:04 2017	(r325482)
@@ -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

Modified: head/sys/boot/i386/Makefile.inc
==============================================================================
--- head/sys/boot/i386/Makefile.inc	Mon Nov  6 15:21:56 2017	(r325481)
+++ head/sys/boot/i386/Makefile.inc	Mon Nov  6 15:22:04 2017	(r325482)
@@ -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"

Modified: head/sys/boot/i386/boot2/Makefile
==============================================================================
--- head/sys/boot/i386/boot2/Makefile	Mon Nov  6 15:21:56 2017	(r325481)
+++ head/sys/boot/i386/boot2/Makefile	Mon Nov  6 15:22:04 2017	(r325482)
@@ -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 <bsd.prog.mk>
 
 # XXX: clang integrated-as doesn't grok .codeNN directives yet

Modified: head/sys/boot/i386/gptboot/Makefile
==============================================================================
--- head/sys/boot/i386/gptboot/Makefile	Mon Nov  6 15:21:56 2017	(r325481)
+++ head/sys/boot/i386/gptboot/Makefile	Mon Nov  6 15:22:04 2017	(r325482)
@@ -76,13 +76,6 @@ gptboot.out: ${BTXCRT} gptboot.o sio.o crc32.o drv.o c
 
 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 <bsd.prog.mk>
 
 # XXX: clang integrated-as doesn't grok .codeNN directives yet

Modified: head/sys/boot/i386/gptzfsboot/Makefile
==============================================================================
--- head/sys/boot/i386/gptzfsboot/Makefile	Mon Nov  6 15:21:56 2017	(r325481)
+++ head/sys/boot/i386/gptzfsboot/Makefile	Mon Nov  6 15:22:04 2017	(r325482)
@@ -88,13 +88,6 @@ gptzfsboot.out: ${BTXCRT} zfsboot.o sio.o gpt.o drv.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 <bsd.prog.mk>
 
 # XXX: clang integrated-as doesn't grok .codeNN directives yet

Modified: head/sys/boot/i386/libfirewire/Makefile
==============================================================================
--- head/sys/boot/i386/libfirewire/Makefile	Mon Nov  6 15:21:56 2017	(r325481)
+++ head/sys/boot/i386/libfirewire/Makefile	Mon Nov  6 15:22:04 2017	(r325482)
@@ -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 <bsd.lib.mk>
-
-.if ${MACHINE_CPUARCH} == "amd64"
-beforedepend ${OBJS}: machine
-.endif
-

Modified: head/sys/boot/i386/libi386/Makefile
==============================================================================
--- head/sys/boot/i386/libi386/Makefile	Mon Nov  6 15:21:56 2017	(r325481)
+++ head/sys/boot/i386/libi386/Makefile	Mon Nov  6 15:22:04 2017	(r325482)
@@ -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 <bsd.lib.mk>
 
 # 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

Modified: head/sys/boot/i386/loader/Makefile
==============================================================================
--- head/sys/boot/i386/loader/Makefile	Mon Nov  6 15:21:56 2017	(r325481)
+++ head/sys/boot/i386/loader/Makefile	Mon Nov  6 15:22:04 2017	(r325482)
@@ -104,12 +104,8 @@ OBJS=	${BTXCRT}
 DPADD=	${LIBFICL32} ${LIBFIREWIRE} ${LIBZFSBOOT} ${LIBI386} ${LIBGELIBOOT} ${LIBSA32}
 LDADD=	${LIBFICL32} ${LIBFIREWIRE} ${LIBZFSBOOT} ${LIBI386} ${LIBGELIBOOT} ${LIBSA32}
 
-.include <bsd.prog.mk>
-
 .if ${MACHINE_CPUARCH} == "amd64"
-beforedepend ${OBJS}: machine
-CLEANFILES+=	machine
 CFLAGS+=	-DLOADER_PREFER_AMD64
-machine: .NOMETA
-	ln -sf ${SYSDIR}/i386/include machine
 .endif
+
+.include <bsd.prog.mk>

Modified: head/sys/boot/i386/zfsboot/Makefile
==============================================================================
--- head/sys/boot/i386/zfsboot/Makefile	Mon Nov  6 15:21:56 2017	(r325481)
+++ head/sys/boot/i386/zfsboot/Makefile	Mon Nov  6 15:22:04 2017	(r325482)
@@ -87,13 +87,6 @@ zfsboot.out: ${BTXCRT} zfsboot.o sio.o drv.o cons.o ut
 
 SRCS=	zfsboot.c
 
-.if ${MACHINE_CPUARCH} == "amd64"
-beforedepend zfsboot.o: machine
-CLEANFILES+=	machine
-machine: .NOMETA
-	ln -sf ${SYSDIR}/i386/include machine
-.endif
-
 .include <bsd.prog.mk>
 
 # XXX: clang integrated-as doesn't grok .codeNN directives yet

Modified: head/sys/boot/libsa32/Makefile
==============================================================================
--- head/sys/boot/libsa32/Makefile	Mon Nov  6 15:21:56 2017	(r325481)
+++ head/sys/boot/libsa32/Makefile	Mon Nov  6 15:22:04 2017	(r325482)
@@ -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

Modified: head/sys/boot/ofw/libofw/Makefile
==============================================================================
--- head/sys/boot/ofw/libofw/Makefile	Mon Nov  6 15:21:56 2017	(r325481)
+++ head/sys/boot/ofw/libofw/Makefile	Mon Nov  6 15:22:04 2017	(r325482)
@@ -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 <bsd.lib.mk>
-
-beforedepend ${OBJS}: machine

Modified: head/sys/boot/uboot/fdt/Makefile
==============================================================================
--- head/sys/boot/uboot/fdt/Makefile	Mon Nov  6 15:21:56 2017	(r325481)
+++ head/sys/boot/uboot/fdt/Makefile	Mon Nov  6 15:22:04 2017	(r325482)
@@ -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 <bsd.stand.mk>
 .include <bsd.lib.mk>
-
-beforedepend ${OBJS}: machine

Modified: head/sys/boot/uboot/lib/Makefile
==============================================================================
--- head/sys/boot/uboot/lib/Makefile	Mon Nov  6 15:21:56 2017	(r325481)
+++ head/sys/boot/uboot/lib/Makefile	Mon Nov  6 15:22:04 2017	(r325482)
@@ -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 <bsd.stand.mk>
 .include <bsd.lib.mk>
-
-beforedepend ${OBJS}: machine

Modified: head/sys/boot/zfs/Makefile
==============================================================================
--- head/sys/boot/zfs/Makefile	Mon Nov  6 15:21:56 2017	(r325481)
+++ head/sys/boot/zfs/Makefile	Mon Nov  6 15:22:04 2017	(r325482)
@@ -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 <bsd.stand.mk>
 .include <bsd.lib.mk>
-
-.if ${MACHINE_CPUARCH} == "amd64" && defined(DO32)
-.if !exists(machine)
-beforedepend ${OBJS}: machine
-.endif
-.endif


More information about the svn-src-head mailing list