From a4d757787575c47664e95b19a98aa035a3f6f110 Mon Sep 17 00:00:00 2001
From: Sascha Wildner <saw@online.de>
Date: Tue, 4 Sep 2018 08:39:22 +0200
Subject: [PATCH] WIP

---
 Makefile.inc1 | 107 ++++++++++++++++++++++----------------------------
 1 file changed, 48 insertions(+), 59 deletions(-)

diff --git a/Makefile.inc1 b/Makefile.inc1
index 6b95925d60..69619885ed 100644
--- a/Makefile.inc1
+++ b/Makefile.inc1
@@ -916,47 +916,56 @@ bstrap-${_tool}!
 .warning undefined WORLD_ALTCOMPILER
 .endif
 
-# gcc80 is now the default compiler.  See sys.mk for WORLD_ALTCOMPILER default
-# and this file for WORLD_CCVER.
-#
-_gcc47_cross= gnu/usr.bin/cc47
-_gcc47_tools= gnu/usr.bin/cc47/cc_prep gnu/usr.bin/cc47/cc_tools
-
-_gcc50_cross= gnu/usr.bin/cc50
-_gcc50_tools= gnu/usr.bin/cc50/cc_prep gnu/usr.bin/cc50/cc_tools
-
+_gcc_common_cross= lib/libz gnu/usr.bin/gmp gnu/usr.bin/mpfr gnu/usr.bin/mpc
 _gcc80_cross= gnu/usr.bin/cc80
 _gcc80_tools= gnu/usr.bin/cc80/cc_prep gnu/usr.bin/cc80/cc_tools
-
-_gcc_common_cross= lib/libz gnu/usr.bin/gmp gnu/usr.bin/mpfr gnu/usr.bin/mpc
-
 .if !defined(NO_ALTCOMPILER)
 . if defined(WORLD_ALTCOMPILER) && (${WORLD_ALTCOMPILER} == "all" || ${WORLD_ALTCOMPILER:Mgcc47})
+_gcc47_cross= gnu/usr.bin/cc47
+_gcc47_tools= gnu/usr.bin/cc47/cc_prep gnu/usr.bin/cc47/cc_tools
 _altcompiler_cross+= ${_gcc47_cross}
+_altcompiler_tools+= _gcc47_tools
 . endif
-.endif
-
-.if !defined(NO_ALTCOMPILER)
 . if defined(WORLD_ALTCOMPILER) && (${WORLD_ALTCOMPILER} == "all" || ${WORLD_ALTCOMPILER:Mgcc50})
+_gcc50_cross= gnu/usr.bin/cc50
+_gcc50_tools= gnu/usr.bin/cc50/cc_prep gnu/usr.bin/cc50/cc_tools
 _altcompiler_cross+= ${_gcc50_cross}
+_altcompiler_tools+= _gcc50_tools
 . endif
 .endif
-
-#.if !defined(NO_ALTCOMPILER)
-#. if defined(WORLD_ALTCOMPILER) && (${WORLD_ALTCOMPILER} == "all" || ${WORLD_ALTCOMPILER:Mgcc80})
-#_altcompiler_cross+= ${_gcc80_cross}
-_basecompiler_cross+= ${_gcc80_cross}
-#. endif
-#.endif
-
 _custom_cross= libexec/customcc
 _binutils= gnu/usr.bin/${WORLD_BINUTILSVER}
 
+# XXX obsolete
+.if 0
+.for _atools in ${_altcompiler_tools}
+BTOOLSDIRS+=	${${_atools}}
+.endfor
+BTOOLSDIRS+=	${_gcc80_tools}
+.endif
+
 build-tools: build-tools-targets
 	touch ${BTOOLSDEST}/.build_done
 
 build-tools-targets: ${BTOOLSDIRS:S/^/btools-/}
 
+.if 0
+.for _atools in ${_altcompiler_tools}
+.ORDER: ${${_atools}:C/^/btools-/}
+.endfor
+.ORDER: ${_gcc80_tools:S/^/btools-/}
+
+.for _tool in ${BTOOLSDIRS}
+btools-${_tool}!
+	${ECHODIR} "===> ${_tool} (build-tools)"; \
+		cd ${.CURDIR}/${_tool}; \
+		make DIRPRFX=${_tool}/ obj && \
+		make DIRPRFX=${_tool}/ depend && \
+		make DIRPRFX=${_tool}/ all && \
+		make DIRPRFX=${_tool}/ DESTDIR=${BTOOLSDEST} install
+.endfor
+.endif
+
 #
 # cross-tools: Build cross-building tools
 #
@@ -966,7 +975,7 @@ CTOOLSDIRS= usr.bin/objformat
 CTOOLSDIRS+=	${_binutils} \
 		${_gcc_common_cross} \
 		${_altcompiler_cross} \
-		${_basecompiler_cross} ${_custom_cross}
+		${_gcc80_cross} ${_custom_cross}
 
 cross-tools: cross-tools-targets
 	touch ${CTOOLSDEST}/.cross_done
@@ -999,15 +1008,10 @@ hierarchy:
 # .makeenv does not work when bootstrapping from 4.x, so we must be sure
 # to specify the correct CCVER or 'cc' will not exec the correct compiler.
 #
-# NOTE: Allow duplicate build for WORLD_ALTCOMPILER=all for WORLD_CCVER,
-#	It will already be built so it won't cost any extra time.  Please
-#	list all compilers in the ALTCOMPILER sequence, including the base
-#	compile.
-#
 libraries:
 	cd ${.CURDIR}; \
-	    HOST_CCVER=${HOST_CCVER} CCVER=${WORLD_CCVER} \
-		make -f Makefile.inc1 ${_startup_libs_base} -DSYSBUILD -DLIBGCC_ONLY;
+	    HOST_CCVER=${HOST_CCVER} CCVER=gcc80 \
+		make -f Makefile.inc1 _startup_libs80 -DSYSBUILD -DLIBGCC_ONLY;
 .if !defined(NO_ALTCOMPILER)
 . if defined(WORLD_ALTCOMPILER) && (${WORLD_ALTCOMPILER} == "all" || ${WORLD_ALTCOMPILER:Mgcc47})
 	cd ${.CURDIR}; \
@@ -1019,11 +1023,6 @@ libraries:
 	    HOST_CCVER=${HOST_CCVER} CCVER=gcc50 \
 		make -f Makefile.inc1 _startup_libs50 -DSYSBUILD -DLIBGCC_ONLY;
 . endif
-. if defined(WORLD_ALTCOMPILER) && (${WORLD_ALTCOMPILER} == "all" || ${WORLD_ALTCOMPILER:Mgcc80})
-	cd ${.CURDIR}; \
-	    HOST_CCVER=${HOST_CCVER} CCVER=gcc80 \
-		make -f Makefile.inc1 _startup_libs80 -DSYSBUILD -DLIBGCC_ONLY;
-. endif
 .endif
 	cd ${.CURDIR}; \
 	    make -f Makefile.inc1 _startup_libs -DSYSBUILD && \
@@ -1037,48 +1036,35 @@ libraries:
 # shared libraries for ELF.  The target for _startup_libsXX is
 # specifically built using gccXX.
 #
+.if !defined(NO_ALTCOMPILER)
 _startup_libs47=	gnu/usr.bin/cc47/cc_prep \
 			gnu/usr.bin/cc47/cc_tools \
 			gnu/lib/gcc47/csu \
 			gnu/lib/gcc47/libgcc \
 			gnu/lib/gcc47/libgcc_eh \
 			gnu/lib/gcc47/libgcc_pic
-
+. if defined(WORLD_ALTCOMPILER) && (${WORLD_ALTCOMPILER} == "all" || ${WORLD_ALTCOMPILER:Mgcc47})
+_startup_libs_alt+=	_startup_libs47
+. endif
+.endif
 _startup_libs50=	gnu/usr.bin/cc50/cc_prep \
 			gnu/usr.bin/cc50/cc_tools \
 			gnu/lib/gcc50/csu \
 			gnu/lib/gcc50/libgcc \
 			gnu/lib/gcc50/libgcc_eh \
 			gnu/lib/gcc50/libgcc_pic
-
 _startup_libs80=	gnu/usr.bin/cc80/cc_prep \
 			gnu/usr.bin/cc80/cc_tools \
 			gnu/lib/gcc80/csu \
 			gnu/lib/gcc80/libgcc \
 			gnu/lib/gcc80/libgcc_eh \
 			gnu/lib/gcc80/libgcc_pic
-
-# gcc80 is now the default compiler.  See sys.mk for WORLD_ALTCOMPILER default.
-#
-.if !defined(NO_ALTCOMPILER)
-. if defined(WORLD_ALTCOMPILER) && (${WORLD_ALTCOMPILER} == "all" || ${WORLD_ALTCOMPILER:Mgcc47})
-_startup_libs_alt+=	_startup_libs47
-. endif
-.endif
-
 .if !defined(NO_ALTCOMPILER)
 . if defined(WORLD_ALTCOMPILER) && (${WORLD_ALTCOMPILER} == "all" || ${WORLD_ALTCOMPILER:Mgcc50})
-_startup_libs_alt+=	_startup_libs50
+_startup_libs_alt+=     _startup_libs50
 . endif
 .endif
 
-#.if !defined(NO_ALTCOMPILER)
-#. if defined(WORLD_ALTCOMPILER) && (${WORLD_ALTCOMPILER} == "all" || ${WORLD_ALTCOMPILER:Mgcc80})
-#_startup_libs_alt+=     _startup_libs80
-_startup_libs_base+=     _startup_libs80
-#. endif
-#.endif
-
 _startup_libs=		lib/csu lib/libc lib/libc_rtld
 lib/libc__L: lib/csu__L
 
@@ -1115,11 +1101,11 @@ lib/libdevattr__L: lib/libprop__L
 
 _generic_libs+=	usr.bin/flex/lib
 
-.for _alib in ${_startup_libs_alt} ${_startup_libs_base}
+.for _alib in ${_startup_libs_alt}
 __startup_alibs+= ${${_alib}}
 .endfor
 
-.for _lib in ${__startup_alibs} \
+.for _lib in ${__startup_alibs} ${_startup_libs80} \
 		${_startup_libs} ${_prebuild_libs} ${_generic_libs}
 ${_lib}__L: .PHONY
 .if exists(${.CURDIR}/${_lib})
@@ -1138,18 +1124,21 @@ ${_lib}__L: .PHONY
 .endfor
 
 _startup_libs: ${_startup_libs:S/$/__L/}
-.for _alib in ${_startup_libs_alt} ${_startup_libs_base}
+.for _alib in ${_startup_libs_alt}
 ${_alib}: ${${_alib}:C/$/__L/}
 .endfor
+_startup_libs80: ${_startup_libs80:S/$/__L/}
 _prebuild_libs: ${_prebuild_libs:S/$/__L/}
 _generic_libs: ${_generic_libs:S/$/__L/}
 
 # library targets must be ordered because there are inter-library
 # races (e.g. generation of tconfig.h)
 #
-.for _alib in ${_startup_libs_base} ${_startup_libs_alt}
+.for _alib in ${_startup_libs_alt}
 .ORDER: ${${_alib}:C/$/__L/}
 .endfor
+.ORDER: ${_startup_libs80:S/$/__L/}
+#.ORDER: ${_startup_libs:S/$/__L/}
 
 # uncomment if there are missing dependencies
 .if 0
-- 
2.20.1

