aboutsummaryrefslogtreecommitdiffstats
path: root/share/mk/bsd.compat.mk
blob: 043eb33d4421be98c752d97efe7df30fa24fc24b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
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