git: a09ea2bbc305 - main - amd64: add an i386 include directory

From: Brooks Davis <brooks_at_FreeBSD.org>
Date: Mon, 13 Jun 2022 17:35:56 UTC
The branch main has been updated by brooks:

URL: https://cgit.FreeBSD.org/src/commit/?id=a09ea2bbc3053d3b2afdb2f7444e5e57a96bb891

commit a09ea2bbc3053d3b2afdb2f7444e5e57a96bb891
Author:     Brooks Davis <brooks@FreeBSD.org>
AuthorDate: 2022-06-13 17:35:38 +0000
Commit:     Brooks Davis <brooks@FreeBSD.org>
CommitDate: 2022-06-13 17:35:38 +0000

    amd64: add an i386 include directory
    
    This directory will hold i386-specific headers that are needed for
    -m32 support on amd64 and where the amd64 and i386 cases have too
    little in common for combining them to make sense.  Files to be
    installed will come in later commits.
    
    With the currently required set of files, this could be done with
    another INCGROUP in include/Makefile, but at least one file that
    might want -m32 support (ieeefp.h) conflicts with a files installed
    in /usr/include.
    
    Reviewed by:    jhb, imp
---
 Makefile.inc1         | 15 +++++++++++++++
 include/Makefile      |  7 +++++++
 include/i386/Makefile |  7 +++++++
 3 files changed, 29 insertions(+)

diff --git a/Makefile.inc1 b/Makefile.inc1
index 5aaa9a414473..20c537512273 100644
--- a/Makefile.inc1
+++ b/Makefile.inc1
@@ -1062,6 +1062,9 @@ _bootstrap-tools:
 	    -p ${WORLDTMP}/usr >/dev/null
 	${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.include.dist \
 	    -p ${WORLDTMP}/usr/include >/dev/null
+.if ${TARGET_ARCH} == "amd64"
+	mkdir -p ${WORLDTMP}/usr/include/i386
+.endif
 	ln -sf ${.CURDIR}/sys ${WORLDTMP}
 .if ${MK_DEBUG_FILES} != "no"
 	${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
@@ -1395,6 +1398,9 @@ distributeworld installworld stageworld: _installcheck_world .PHONY
 	    -p ${DESTDIR}/${DISTDIR}/${dist}/usr >/dev/null
 	${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.include.dist \
 	    -p ${DESTDIR}/${DISTDIR}/${dist}/usr/include >/dev/null
+.if ${TARGET_ARCH} == "amd64"
+	-mkdir  ${DESTDIR}/${DISTDIR}/usr/include/i386
+.endif
 .if ${MK_DEBUG_FILES} != "no"
 	${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
 	    -p ${DESTDIR}/${DISTDIR}/${dist}/usr/lib >/dev/null
@@ -1423,6 +1429,9 @@ distributeworld installworld stageworld: _installcheck_world .PHONY
 	    sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
 	${IMAKEENV} ${DISTR_MTREE} -C -f ${.CURDIR}/etc/mtree/BSD.include.dist | \
 	    sed -e 's#^\./#./${dist}/usr/include/#' >> ${METALOG}
+.if ${TARGET_ARCH} == "amd64"
+	echo "./${dist}/usr/include/i386 type=dir uname=root gname=wheel mode=0755" >> ${METALOG}
+.endif
 .if defined(_LIBCOMPAT)
 	${IMAKEENV} ${DISTR_MTREE} -C -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist | \
 	    sed -e 's#^\./#./${dist}/usr/#' >> ${METALOG}
@@ -2852,6 +2861,9 @@ native-xtools-install: .PHONY
 	    -p ${NXBDESTDIR}/usr >/dev/null
 	${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.include.dist \
 	    -p ${NXBDESTDIR}/usr/include >/dev/null
+.if ${TARGET_ARCH} == "amd64"
+	mkdir -p ${NXBDESTDIR}/usr/include/i386
+.endif
 	${_+_}cd ${.CURDIR}; ${NXBMAKE} \
 	    DESTDIR=${NXBDESTDIR} \
 	    -DNO_ROOT \
@@ -3545,6 +3557,9 @@ _xi-mtree: .PHONY
 	    -p ${XDDESTDIR}/usr >/dev/null
 	${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.include.dist \
 	    -p ${XDDESTDIR}/usr/include >/dev/null
+.if ${TARGET_ARCH} == "amd64"
+	mkdir -p ${XDDESTDIR}/usr/include/i386
+.endif
 .if defined(_LIBCOMPAT)
 	${DESTDIR_MTREE} -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
 	    -p ${XDDESTDIR}/usr >/dev/null
diff --git a/include/Makefile b/include/Makefile
index 42590b900442..8d847a3a8dd2 100644
--- a/include/Makefile
+++ b/include/Makefile
@@ -8,6 +8,9 @@
 PACKAGE=runtime
 CLEANFILES= osreldate.h version
 SUBDIR= arpa protocols rpcsvc rpc xlocale
+.if ${MACHINE_CPUARCH} == "amd64"
+SUBDIR+=	i386
+.endif
 SUBDIR_PARALLEL=
 INCS=	a.out.h ar.h assert.h bitstring.h complex.h cpio.h _ctype.h ctype.h \
 	db.h \
@@ -338,6 +341,10 @@ compat:
 	mtree -deU ${NO_ROOT:D-W} ${MTREE_FOLLOWS_SYMLINKS} \
 	    -f ${SRCTOP}/etc/mtree/BSD.include.dist \
 	    -p ${SDESTDIR}${INCLUDEDIR} > /dev/null
+.if ${MACHINE_CPUARCH} == "amd64"
+	${INSTALL} -d ${TAG_ARGS} -o ${BINOWN} -g ${BINGRP} -m 755 \
+	    ${SDESTDIR}${INCLUDEDIR}/i386
+.endif
 
 copies: .PHONY .META
 	cd ${SDESTDIR}${INCLUDEDIR}; find ${LDIRS} ${LSUBDIRS} ${LSUBSUBDIRS} crypto \
diff --git a/include/i386/Makefile b/include/i386/Makefile
new file mode 100644
index 000000000000..60f70d4756b2
--- /dev/null
+++ b/include/i386/Makefile
@@ -0,0 +1,7 @@
+# i386 headers installed on amd64
+
+.PATH: ${SRCTOP}/sys/i386/include
+INCS=
+INCSDIR=	${INCLUDEDIR}/i386
+
+.include <bsd.prog.mk>