From bbcf7edd982ca9295a6a169a15b5bd849e9a6456 Mon Sep 17 00:00:00 2001 From: Brooks Davis Date: Tue, 15 Oct 2019 21:08:49 +0000 Subject: [PATCH] Move the per-ARCH definitions to bsd.compat.mk. This is the first step if refactoring the definitions to allow programs to be selectively linked against libcompat libraries. Reviewed by: bdrewery Sponsored by: DARPA, AFRL --- Makefile.libcompat | 96 +------------------------------------ share/mk/bsd.compat.mk | 106 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 107 insertions(+), 95 deletions(-) create mode 100644 share/mk/bsd.compat.mk diff --git a/Makefile.libcompat b/Makefile.libcompat index acd7dcaba101..2616ddd2b21a 100644 --- a/Makefile.libcompat +++ b/Makefile.libcompat @@ -6,101 +6,7 @@ __<${_this:T}>__: # Makefile for the compatibility libraries. # - 32-bit compat libraries on MIPS, PowerPC, and AMD64. -# ------------------------------------------------------------------- -# 32 bit world -.if ${TARGET_ARCH} == "amd64" -.if empty(TARGET_CPUTYPE) -LIB32CPUFLAGS= -march=i686 -mmmx -msse -msse2 -.else -LIB32CPUFLAGS= -march=${TARGET_CPUTYPE} -.endif -.if ${WANT_COMPILER_TYPE} == gcc || \ - (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc) -.else -LIB32CPUFLAGS+= -target x86_64-unknown-freebsd13.0 -.endif -LIB32CPUFLAGS+= -m32 -LIB32WMAKEENV= MACHINE=i386 MACHINE_ARCH=i386 \ - MACHINE_CPU="i686 mmx sse sse2" -LIB32WMAKEFLAGS= \ - AS="${XAS} --32" \ - LD="${XLD} -m elf_i386_fbsd -L${LIBCOMPATTMP}/usr/lib32" - -.elif ${TARGET_ARCH} == "powerpc64" -.if empty(TARGET_CPUTYPE) -LIB32CPUFLAGS= -mcpu=powerpc -.else -LIB32CPUFLAGS= -mcpu=${TARGET_CPUTYPE} -.endif -LIB32CPUFLAGS+= -m32 -LIB32WMAKEENV= MACHINE=powerpc MACHINE_ARCH=powerpc -LIB32WMAKEFLAGS= \ - LD="${XLD} -m elf32ppc_fbsd" - -.elif ${TARGET_ARCH:Mmips64*} != "" -.if ${WANT_COMPILER_TYPE} == gcc || \ - (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc) -.if empty(TARGET_CPUTYPE) -LIB32CPUFLAGS= -march=mips3 -.else -LIB32CPUFLAGS= -march=${TARGET_CPUTYPE} -.endif -.else -.if ${TARGET_ARCH:Mmips64el*} != "" -LIB32CPUFLAGS= -target mipsel-unknown-freebsd13.0 -.else -LIB32CPUFLAGS= -target mips-unknown-freebsd13.0 -.endif -.endif -LIB32CPUFLAGS+= -mabi=32 -LIB32WMAKEENV= MACHINE=mips MACHINE_ARCH=mips -.if ${TARGET_ARCH:Mmips64el*} != "" -LIB32WMAKEFLAGS= LD="${XLD} -m elf32ltsmip_fbsd" -.else -LIB32WMAKEFLAGS= LD="${XLD} -m elf32btsmip_fbsd" -.endif -.endif - -LIB32WMAKEFLAGS+= NM="${XNM}" -LIB32WMAKEFLAGS+= OBJCOPY="${XOBJCOPY}" - -LIB32CFLAGS= -DCOMPAT_32BIT -LIB32DTRACE= ${DTRACE} -32 -LIB32WMAKEFLAGS+= -DCOMPAT_32BIT - -# ------------------------------------------------------------------- -# soft-fp world -.if ${TARGET_ARCH:Marmv[67]*} != "" -LIBSOFTCFLAGS= -DCOMPAT_SOFTFP -LIBSOFTCPUFLAGS= -mfloat-abi=softfp -LIBSOFTWMAKEENV= CPUTYPE=soft MACHINE=arm MACHINE_ARCH=${TARGET_ARCH} -LIBSOFTWMAKEFLAGS= -DCOMPAT_SOFTFP -.endif - -# ------------------------------------------------------------------- -# Generic code for each type. -# Set defaults based on type. -libcompat= ${LIBCOMPAT:tl} -_LIBCOMPAT_MAKEVARS= _OBJTOP TMP CPUFLAGS CFLAGS CXXFLAGS WMAKEENV \ - WMAKEFLAGS WMAKE -.for _var in ${_LIBCOMPAT_MAKEVARS} -.if !empty(LIB${LIBCOMPAT}${_var}) -LIBCOMPAT${_var}?= ${LIB${LIBCOMPAT}${_var}} -.endif -.endfor - -# Shared flags -LIBCOMPAT_OBJTOP?= ${OBJTOP}/obj-lib${libcompat} -LIBCOMPATTMP?= ${LIBCOMPAT_OBJTOP}/tmp - -LIBCOMPATCFLAGS+= ${LIBCOMPATCPUFLAGS} \ - -L${LIBCOMPATTMP}/usr/lib${libcompat} \ - --sysroot=${LIBCOMPATTMP} \ - ${BFLAGS} - -# -B is needed to find /usr/lib32/crti.o for GCC and /usr/libsoft/crti.o for -# Clang/GCC. -LIBCOMPATCFLAGS+= -B${LIBCOMPATTMP}/usr/lib${libcompat} +.include # Yes, the flags are redundant. LIBCOMPATWMAKEENV+= \ diff --git a/share/mk/bsd.compat.mk b/share/mk/bsd.compat.mk new file mode 100644 index 000000000000..043eb33d4421 --- /dev/null +++ b/share/mk/bsd.compat.mk @@ -0,0 +1,106 @@ +# $FreeBSD$ + +.if !targets(__<${_this:T}>__) +__<${_this:T}>__: + +# Makefile for the compatibility libraries. +# - 32-bit compat libraries on MIPS, PowerPC, and AMD64. + +# ------------------------------------------------------------------- +# 32 bit world +.if ${TARGET_ARCH} == "amd64" +.if empty(TARGET_CPUTYPE) +LIB32CPUFLAGS= -march=i686 -mmmx -msse -msse2 +.else +LIB32CPUFLAGS= -march=${TARGET_CPUTYPE} +.endif +.if ${WANT_COMPILER_TYPE} == gcc || \ + (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc) +.else +LIB32CPUFLAGS+= -target x86_64-unknown-freebsd13.0 +.endif +LIB32CPUFLAGS+= -m32 +LIB32WMAKEENV= MACHINE=i386 MACHINE_ARCH=i386 \ + MACHINE_CPU="i686 mmx sse sse2" +LIB32WMAKEFLAGS= \ + AS="${XAS} --32" \ + LD="${XLD} -m elf_i386_fbsd -L${LIBCOMPATTMP}/usr/lib32" + +.elif ${TARGET_ARCH} == "powerpc64" +.if empty(TARGET_CPUTYPE) +LIB32CPUFLAGS= -mcpu=powerpc +.else +LIB32CPUFLAGS= -mcpu=${TARGET_CPUTYPE} +.endif +LIB32CPUFLAGS+= -m32 +LIB32WMAKEENV= MACHINE=powerpc MACHINE_ARCH=powerpc +LIB32WMAKEFLAGS= \ + LD="${XLD} -m elf32ppc_fbsd" + +.elif ${TARGET_ARCH:Mmips64*} != "" +.if ${WANT_COMPILER_TYPE} == gcc || \ + (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc) +.if empty(TARGET_CPUTYPE) +LIB32CPUFLAGS= -march=mips3 +.else +LIB32CPUFLAGS= -march=${TARGET_CPUTYPE} +.endif +.else +.if ${TARGET_ARCH:Mmips64el*} != "" +LIB32CPUFLAGS= -target mipsel-unknown-freebsd13.0 +.else +LIB32CPUFLAGS= -target mips-unknown-freebsd13.0 +.endif +.endif +LIB32CPUFLAGS+= -mabi=32 +LIB32WMAKEENV= MACHINE=mips MACHINE_ARCH=mips +.if ${TARGET_ARCH:Mmips64el*} != "" +LIB32WMAKEFLAGS= LD="${XLD} -m elf32ltsmip_fbsd" +.else +LIB32WMAKEFLAGS= LD="${XLD} -m elf32btsmip_fbsd" +.endif +.endif + +LIB32WMAKEFLAGS+= NM="${XNM}" +LIB32WMAKEFLAGS+= OBJCOPY="${XOBJCOPY}" + +LIB32CFLAGS= -DCOMPAT_32BIT +LIB32DTRACE= ${DTRACE} -32 +LIB32WMAKEFLAGS+= -DCOMPAT_32BIT + +# ------------------------------------------------------------------- +# soft-fp world +.if ${TARGET_ARCH:Marmv[67]*} != "" +LIBSOFTCFLAGS= -DCOMPAT_SOFTFP +LIBSOFTCPUFLAGS= -mfloat-abi=softfp +LIBSOFTWMAKEENV= CPUTYPE=soft MACHINE=arm MACHINE_ARCH=${TARGET_ARCH} +LIBSOFTWMAKEFLAGS= -DCOMPAT_SOFTFP +.endif + + +# ------------------------------------------------------------------- +# Generic code for each type. +# Set defaults based on type. +libcompat= ${LIBCOMPAT:tl} +_LIBCOMPAT_MAKEVARS= _OBJTOP TMP CPUFLAGS CFLAGS CXXFLAGS WMAKEENV \ + WMAKEFLAGS WMAKE +.for _var in ${_LIBCOMPAT_MAKEVARS} +.if !empty(LIB${LIBCOMPAT}${_var}) +LIBCOMPAT${_var}?= ${LIB${LIBCOMPAT}${_var}} +.endif +.endfor + +# Shared flags +LIBCOMPAT_OBJTOP?= ${OBJTOP}/obj-lib${libcompat} +LIBCOMPATTMP?= ${LIBCOMPAT_OBJTOP}/tmp + +LIBCOMPATCFLAGS+= ${LIBCOMPATCPUFLAGS} \ + -L${LIBCOMPATTMP}/usr/lib${libcompat} \ + --sysroot=${LIBCOMPATTMP} \ + ${BFLAGS} + +# -B is needed to find /usr/lib32/crti.o for GCC and /usr/libsoft/crti.o for +# Clang/GCC. +LIBCOMPATCFLAGS+= -B${LIBCOMPATTMP}/usr/lib${libcompat} + +.endif