summaryrefslogtreecommitdiffstats
path: root/Makefile.lib32
blob: e385d53a80f5b56f0c4290d0e947d2b368e2e080 (plain)
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# $FreeBSD$

# Makefile for the 32-bit compat libraries on PowerPC and AMD64.
# could also be for mips, but that doesn't work today.

# 32 bit world
LIB32_OBJTREE=	${OBJTREE}${.CURDIR}/world32
LIB32TMP=	${OBJTREE}${.CURDIR}/lib32

.if ${TARGET_ARCH} == "amd64"
.if empty(TARGET_CPUTYPE)
LIB32CPUFLAGS=	-march=i686 -mmmx -msse -msse2
.else
LIB32CPUFLAGS=	-march=${TARGET_CPUTYPE}
.endif
LIB32WMAKEENV=	MACHINE=i386 MACHINE_ARCH=i386 \
		MACHINE_CPU="i686 mmx sse sse2"
LIB32WMAKEFLAGS=	\
		AS="${XAS} --32" \
		LD="${XLD} -m elf_i386_fbsd -Y P,${LIB32TMP}/usr/lib32" \
		OBJCOPY="${XOBJCOPY}"

.elif ${TARGET_ARCH} == "powerpc64"
.if empty(TARGET_CPUTYPE)
LIB32CPUFLAGS=	-mcpu=powerpc
.else
LIB32CPUFLAGS=	-mcpu=${TARGET_CPUTYPE}
.endif
LIB32WMAKEENV=	MACHINE=powerpc MACHINE_ARCH=powerpc
LIB32WMAKEFLAGS=	\
		LD="${XLD} -m elf32ppc_fbsd" \
		OBJCOPY="${XOBJCOPY}"
.endif


LIB32FLAGS=	-m32 ${LIB32CPUFLAGS} -DCOMPAT_32BIT \
		-isystem ${LIB32TMP}/usr/include/ \
		-L${LIB32TMP}/usr/lib32 \
		-B${LIB32TMP}/usr/lib32
.if ${XCC:N${CCACHE_BIN}:M/*}
LIB32FLAGS+=		--sysroot=${WORLDTMP}
.endif

# Yes, the flags are redundant.
LIB32WMAKEENV+=	MAKEOBJDIRPREFIX=${LIB32_OBJTREE} \
		_LDSCRIPTROOT=${LIB32TMP} \
		INSTALL="sh ${.CURDIR}/tools/install.sh" \
		PATH=${TMPPATH} \
		LIBDIR=/usr/lib32 \
		SHLIBDIR=/usr/lib32 \
		DTRACE="${DTRACE} -32"
LIB32WMAKEFLAGS+= CC="${XCC} ${LIB32FLAGS}" \
		CXX="${XCXX} ${LIB32FLAGS}" \
		DESTDIR=${LIB32TMP} \
		-DCOMPAT_32BIT \
		-DLIBRARIES_ONLY \
		-DNO_CPU_CFLAGS \
		MK_CTF=no \
		-DNO_LINT \
		MK_TESTS=no

LIB32WMAKE=	${LIB32WMAKEENV} ${MAKE} ${LIB32WMAKEFLAGS} \
		MK_MAN=no MK_HTML=no
LIB32IMAKE=	${LIB32WMAKE:NINSTALL=*:NDESTDIR=*:N_LDSCRIPTROOT=*} \
		MK_TOOLCHAIN=no ${IMAKE_INSTALL}

build32: .PHONY
	@echo
	@echo "--------------------------------------------------------------"
	@echo ">>> stage 5.1: building 32 bit shim libraries"
	@echo "--------------------------------------------------------------"
	mkdir -p ${LIB32TMP}/usr/include
	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
	    -p ${LIB32TMP}/usr >/dev/null
	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
	    -p ${LIB32TMP}/usr/include >/dev/null
	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
	    -p ${LIB32TMP}/usr >/dev/null
.if ${MK_DEBUG_FILES} != "no"
	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
	    -p ${LIB32TMP}/usr/lib >/dev/null
	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib32.dist \
	    -p ${LIB32TMP}/usr/lib/debug/usr >/dev/null
.endif
	mkdir -p ${WORLDTMP}
	ln -sf ${.CURDIR}/sys ${WORLDTMP}
.for _t in obj includes
	${_+_}cd ${.CURDIR}/include; ${LIB32WMAKE} DIRPRFX=include/ ${_t}
	${_+_}cd ${.CURDIR}/lib; ${LIB32WMAKE} DIRPRFX=lib/ ${_t}
.if ${MK_CDDL} != "no"
	${_+_}cd ${.CURDIR}/cddl/lib; ${LIB32WMAKE} DIRPRFX=cddl/lib/ ${_t}
.endif
	${_+_}cd ${.CURDIR}/gnu/lib; ${LIB32WMAKE} DIRPRFX=gnu/lib/ ${_t}
.if ${MK_CRYPT} != "no"
	${_+_}cd ${.CURDIR}/secure/lib; ${LIB32WMAKE} DIRPRFX=secure/lib/ ${_t}
.endif
.if ${MK_KERBEROS} != "no"
	${_+_}cd ${.CURDIR}/kerberos5/lib; ${LIB32WMAKE} DIRPRFX=kerberos5/lib ${_t}
.endif
.endfor
.for _dir in usr.bin/lex/lib
	${_+_}cd ${.CURDIR}/${_dir}; ${LIB32WMAKE} DIRPRFX=${_dir}/ obj
.endfor
.for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic
	${_+_}cd ${.CURDIR}/${_dir}; \
	    WORLDTMP=${WORLDTMP} \
	    MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \
	    MAKEOBJDIRPREFIX=${LIB32_OBJTREE} ${MAKE} SSP_CFLAGS= DESTDIR= \
	    DIRPRFX=${_dir}/ -DNO_LINT -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
	    build-tools
.endfor
	${_+_}cd ${.CURDIR}; \
	    ${LIB32WMAKE} -f Makefile.inc1 -DNO_FSCHG libraries
.for _t in obj depend all
	${_+_}cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIB32WMAKE} \
	    -DNO_FSCHG DIRPRFX=libexec/rtld-elf/ ${_t}
	${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32WMAKE} \
	    DIRPRFX=usr.bin/ldd ${_t}
.endfor

distribute32 install32: .MAKE .PHONY
	${_+_}cd ${.CURDIR}/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
.if ${MK_CDDL} != "no"
	${_+_}cd ${.CURDIR}/cddl/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
.endif
	${_+_}cd ${.CURDIR}/gnu/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
.if ${MK_CRYPT} != "no"
	${_+_}cd ${.CURDIR}/secure/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
.endif
.if ${MK_KERBEROS} != "no"
	${_+_}cd ${.CURDIR}/kerberos5/lib; ${LIB32IMAKE} ${.TARGET:S/32$//}
.endif
	${_+_}cd ${.CURDIR}/libexec/rtld-elf; \
	    PROG=ld-elf32.so.1 ${LIB32IMAKE} ${.TARGET:S/32$//}
	${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIB32IMAKE} \
	    ${.TARGET:S/32$//}
OpenPOWER on IntegriCloud