xref: /freebsd/Makefile.libcompat (revision bb52d711d0eab2a612da9553c0e07fdb5249cc5e)
1dba75e9fSBryan Drewery# $FreeBSD$
2dba75e9fSBryan Drewery
3dba75e9fSBryan Drewery.if !targets(__<${_this:T}>__)
4dba75e9fSBryan Drewery__<${_this:T}>__:
5dba75e9fSBryan Drewery
6dba75e9fSBryan Drewery# Makefile for the compatibility libraries.
7dba75e9fSBryan Drewery# - 32-bit compat libraries on PowerPC and AMD64.
8dba75e9fSBryan Drewery#   could also be for mips, but that doesn't work today.
9dba75e9fSBryan Drewery
10dba75e9fSBryan Drewery# -------------------------------------------------------------------
11dba75e9fSBryan Drewery# 32 bit world
12dba75e9fSBryan Drewery.if ${TARGET_ARCH} == "amd64"
13dba75e9fSBryan Drewery.if empty(TARGET_CPUTYPE)
14dba75e9fSBryan DreweryLIB32CPUFLAGS=	-march=i686 -mmmx -msse -msse2
15dba75e9fSBryan Drewery.else
16dba75e9fSBryan DreweryLIB32CPUFLAGS=	-march=${TARGET_CPUTYPE}
17dba75e9fSBryan Drewery.endif
18dba75e9fSBryan DreweryLIB32WMAKEENV=	MACHINE=i386 MACHINE_ARCH=i386 \
19dba75e9fSBryan Drewery		MACHINE_CPU="i686 mmx sse sse2"
20dba75e9fSBryan DreweryLIB32WMAKEFLAGS=	\
21dba75e9fSBryan Drewery		AS="${XAS} --32" \
22dba75e9fSBryan Drewery		LD="${XLD} -m elf_i386_fbsd -Y P,${LIBCOMPATTMP}/usr/lib32" \
23dba75e9fSBryan Drewery		OBJCOPY="${XOBJCOPY}"
24dba75e9fSBryan Drewery
25dba75e9fSBryan Drewery.elif ${TARGET_ARCH} == "powerpc64"
26dba75e9fSBryan Drewery.if empty(TARGET_CPUTYPE)
27dba75e9fSBryan DreweryLIB32CPUFLAGS=	-mcpu=powerpc
28dba75e9fSBryan Drewery.else
29dba75e9fSBryan DreweryLIB32CPUFLAGS=	-mcpu=${TARGET_CPUTYPE}
30dba75e9fSBryan Drewery.endif
31dba75e9fSBryan DreweryLIB32WMAKEENV=	MACHINE=powerpc MACHINE_ARCH=powerpc
32dba75e9fSBryan DreweryLIB32WMAKEFLAGS=	\
33dba75e9fSBryan Drewery		LD="${XLD} -m elf32ppc_fbsd" \
34dba75e9fSBryan Drewery		OBJCOPY="${XOBJCOPY}"
35dba75e9fSBryan Drewery.endif
36dba75e9fSBryan Drewery
37dba75e9fSBryan Drewery
38dba75e9fSBryan DreweryLIB32CFLAGS=	-m32 -DCOMPAT_32BIT
39dba75e9fSBryan DreweryLIB32DTRACE=	${DTRACE} -32
40dba75e9fSBryan DreweryLIB32WMAKEFLAGS+=	-DCOMPAT_32BIT
41dba75e9fSBryan Drewery
42dba75e9fSBryan Drewery# -------------------------------------------------------------------
43*bb52d711SWarner Losh# soft-fp world
44*bb52d711SWarner Losh.if ${TARGET_ARCH} == "armv6"
45*bb52d711SWarner LoshLIBSOFTCFLAGS=        -DCOMPAT_SOFTFP
46*bb52d711SWarner LoshLIBSOFTCPUFLAGS= -mfloat-abi=softfp
47*bb52d711SWarner LoshLIBSOFTWMAKEENV= CPUTYPE=soft MACHINE=arm MACHINE_ARCH=armv6
48*bb52d711SWarner LoshLIBSOFTWMAKEFLAGS=        -DCOMPAT_SOFTFP
49*bb52d711SWarner Losh.endif
50*bb52d711SWarner Losh
51*bb52d711SWarner Losh# -------------------------------------------------------------------
52dba75e9fSBryan Drewery# Generic code for each type.
53dba75e9fSBryan Drewery# Set defaults based on type.
54dba75e9fSBryan Drewerylibcompat=	${LIBCOMPAT:tl}
55*bb52d711SWarner Losh_LIBCOMPAT_MAKEVARS=	_OBJTREE TMP CPUFLAGS CFLAGS WMAKEENV WMAKEFLAGS WMAKE
56dba75e9fSBryan Drewery.for _var in ${_LIBCOMPAT_MAKEVARS}
57dba75e9fSBryan Drewery.if !empty(LIB${LIBCOMPAT}${_var})
58dba75e9fSBryan DreweryLIBCOMPAT${_var}?=	${LIB${LIBCOMPAT}${_var}}
59dba75e9fSBryan Drewery.endif
60dba75e9fSBryan Drewery.endfor
61dba75e9fSBryan Drewery
62dba75e9fSBryan Drewery# Shared flags
63dba75e9fSBryan DreweryLIBCOMPAT_OBJTREE?=	${OBJTREE}${.CURDIR}/world${libcompat}
64dba75e9fSBryan DreweryLIBCOMPATTMP?=		${OBJTREE}${.CURDIR}/lib${libcompat}
65dba75e9fSBryan Drewery
66dba75e9fSBryan DreweryLIBCOMPATCFLAGS+=	${LIBCOMPATCPUFLAGS} \
67dba75e9fSBryan Drewery			-isystem ${LIBCOMPATTMP}/usr/include/ \
68dba75e9fSBryan Drewery			-L${LIBCOMPATTMP}/usr/lib${libcompat} \
69dba75e9fSBryan Drewery			-B${LIBCOMPATTMP}/usr/lib${libcompat}
70dba75e9fSBryan Drewery
71dba75e9fSBryan Drewery# Yes, the flags are redundant.
72dba75e9fSBryan DreweryLIBCOMPATWMAKEENV+= MAKEOBJDIRPREFIX=${LIBCOMPAT_OBJTREE} \
73dba75e9fSBryan Drewery		_LDSCRIPTROOT=${LIBCOMPATTMP} \
74dba75e9fSBryan Drewery		INSTALL="sh ${.CURDIR}/tools/install.sh" \
75dba75e9fSBryan Drewery		PATH=${TMPPATH} \
76dba75e9fSBryan Drewery		LIBDIR=/usr/lib${libcompat} \
77dba75e9fSBryan Drewery		SHLIBDIR=/usr/lib${libcompat} \
78dba75e9fSBryan Drewery		DTRACE="${LIB$COMPATDTRACE:U${DTRACE}}"
79dba75e9fSBryan DreweryLIBCOMPATWMAKEFLAGS+= CC="${XCC} ${LIBCOMPATCFLAGS}" \
80dba75e9fSBryan Drewery		CXX="${XCXX} ${LIBCOMPATCFLAGS}" \
81dba75e9fSBryan Drewery		DESTDIR=${LIBCOMPATTMP} \
82dba75e9fSBryan Drewery		-DLIBRARIES_ONLY \
83dba75e9fSBryan Drewery		-DNO_CPU_CFLAGS \
84dba75e9fSBryan Drewery		MK_CTF=no \
85dba75e9fSBryan Drewery		-DNO_LINT \
86dba75e9fSBryan Drewery		MK_TESTS=no
87dba75e9fSBryan DreweryLIBCOMPATWMAKE+=	${LIBCOMPATWMAKEENV} ${MAKE} ${LIBCOMPATWMAKEFLAGS} \
88dba75e9fSBryan Drewery			MK_MAN=no MK_HTML=no
89dba75e9fSBryan DreweryLIBCOMPATIMAKE+=	${LIBCOMPATWMAKE:NINSTALL=*:NDESTDIR=*:N_LDSCRIPTROOT=*} \
90dba75e9fSBryan Drewery			MK_TOOLCHAIN=no ${IMAKE_INSTALL}
91dba75e9fSBryan Drewery
92dba75e9fSBryan Drewery.if ${XCC:N${CCACHE_BIN}:M/*}
93dba75e9fSBryan DreweryLIBCOMPATCFLAGS+=	--sysroot=${WORLDTMP}
94dba75e9fSBryan Drewery.endif
95dba75e9fSBryan Drewery
96dba75e9fSBryan Drewery_LC_LIBDIRS.yes=		lib gnu/lib
97048ce093SBryan Drewery_LC_LIBDIRS.${MK_CDDL:tl}+=	cddl/lib
98048ce093SBryan Drewery_LC_LIBDIRS.${MK_CRYPT:tl}+=	secure/lib
99048ce093SBryan Drewery_LC_LIBDIRS.${MK_KERBEROS:tl}+=	kerberos5/lib
100dba75e9fSBryan Drewery
101dba75e9fSBryan Drewery# Shared logic
102dba75e9fSBryan Drewerybuild${libcompat}: .PHONY
103dba75e9fSBryan Drewery	@echo
104dba75e9fSBryan Drewery	@echo "--------------------------------------------------------------"
105dba75e9fSBryan Drewery	@echo ">>> stage 5.1: building lib${libcompat} shim libraries"
106dba75e9fSBryan Drewery	@echo "--------------------------------------------------------------"
107dba75e9fSBryan Drewery	mkdir -p ${LIBCOMPATTMP}/usr/include
108dba75e9fSBryan Drewery	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
109dba75e9fSBryan Drewery	    -p ${LIBCOMPATTMP}/usr >/dev/null
110dba75e9fSBryan Drewery	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.include.dist \
111dba75e9fSBryan Drewery	    -p ${LIBCOMPATTMP}/usr/include >/dev/null
112dba75e9fSBryan Drewery	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
113dba75e9fSBryan Drewery	    -p ${LIBCOMPATTMP}/usr >/dev/null
114dba75e9fSBryan Drewery.if ${MK_DEBUG_FILES} != "no"
115dba75e9fSBryan Drewery	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
116dba75e9fSBryan Drewery	    -p ${LIBCOMPATTMP}/usr/lib >/dev/null
117dba75e9fSBryan Drewery	mtree -deU -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
118dba75e9fSBryan Drewery	    -p ${LIBCOMPATTMP}/usr/lib/debug/usr >/dev/null
119dba75e9fSBryan Drewery.endif
120dba75e9fSBryan Drewery	mkdir -p ${WORLDTMP}
121dba75e9fSBryan Drewery	ln -sf ${.CURDIR}/sys ${WORLDTMP}
122dba75e9fSBryan Drewery.for _t in obj includes
123dba75e9fSBryan Drewery	${_+_}cd ${.CURDIR}/include; ${LIBCOMPATWMAKE} DIRPRFX=include/ ${_t}
124dba75e9fSBryan Drewery.for _dir in ${_LC_LIBDIRS.yes}
125dba75e9fSBryan Drewery	${_+_}cd ${.CURDIR}/${_dir}; ${LIBCOMPATWMAKE} DIRPRFX=${_dir}/ ${_t}
126dba75e9fSBryan Drewery.endfor
127dba75e9fSBryan Drewery.endfor
128dba75e9fSBryan Drewery.for _dir in usr.bin/lex/lib
129dba75e9fSBryan Drewery	${_+_}cd ${.CURDIR}/${_dir}; ${LIBCOMPATWMAKE} DIRPRFX=${_dir}/ obj
130dba75e9fSBryan Drewery.endfor
131dba75e9fSBryan Drewery.for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw lib/libmagic
132dba75e9fSBryan Drewery	${_+_}cd ${.CURDIR}/${_dir}; \
133dba75e9fSBryan Drewery	    WORLDTMP=${WORLDTMP} \
134dba75e9fSBryan Drewery	    MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \
135dba75e9fSBryan Drewery	    MAKEOBJDIRPREFIX=${LIBCOMPAT_OBJTREE} ${MAKE} SSP_CFLAGS= DESTDIR= \
136dba75e9fSBryan Drewery	    DIRPRFX=${_dir}/ -DNO_LINT -DNO_CPU_CFLAGS MK_WARNS=no MK_CTF=no \
137dba75e9fSBryan Drewery	    build-tools
138dba75e9fSBryan Drewery.endfor
139dba75e9fSBryan Drewery	${_+_}cd ${.CURDIR}; \
140dba75e9fSBryan Drewery	    ${LIBCOMPATWMAKE} -f Makefile.inc1 -DNO_FSCHG libraries
141dba75e9fSBryan Drewery.if ${libcompat} == "32"
142dba75e9fSBryan Drewery.for _t in obj depend all
143dba75e9fSBryan Drewery	${_+_}cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIBCOMPATWMAKE} \
144dba75e9fSBryan Drewery	    -DNO_FSCHG DIRPRFX=libexec/rtld-elf/ ${_t}
145dba75e9fSBryan Drewery	${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIBCOMPATWMAKE} \
146dba75e9fSBryan Drewery	    DIRPRFX=usr.bin/ldd ${_t}
147dba75e9fSBryan Drewery.endfor
148dba75e9fSBryan Drewery.endif
149dba75e9fSBryan Drewery
150dba75e9fSBryan Drewerydistribute${libcompat} install${libcompat}: .PHONY
151dba75e9fSBryan Drewery.for _dir in ${_LC_LIBDIRS.yes}
152dba75e9fSBryan Drewery	${_+_}cd ${.CURDIR}/${_dir}; ${LIBCOMPATIMAKE} ${.TARGET:S/${libcompat}$//}
153dba75e9fSBryan Drewery.endfor
154dba75e9fSBryan Drewery.if ${libcompat} == "32"
155dba75e9fSBryan Drewery	${_+_}cd ${.CURDIR}/libexec/rtld-elf; \
156dba75e9fSBryan Drewery	    PROG=ld-elf32.so.1 ${LIBCOMPATIMAKE} ${.TARGET:S/32$//}
157dba75e9fSBryan Drewery	${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIBCOMPATIMAKE} \
158dba75e9fSBryan Drewery	    ${.TARGET:S/32$//}
159dba75e9fSBryan Drewery.endif
160dba75e9fSBryan Drewery
161dba75e9fSBryan Drewery.endif
162