You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

243 lines
7.0KB

  1. # $FreeBSD$
  2. .if !targets(__<${_this:T}>__)
  3. __<${_this:T}>__:
  4. # Makefile for the compatibility libraries.
  5. # - 32-bit compat libraries on MIPS, PowerPC, and AMD64.
  6. # -------------------------------------------------------------------
  7. # 32 bit world
  8. .if ${TARGET_ARCH} == "amd64"
  9. .if empty(TARGET_CPUTYPE)
  10. LIB32CPUFLAGS= -march=i686 -mmmx -msse -msse2
  11. .else
  12. LIB32CPUFLAGS= -march=${TARGET_CPUTYPE}
  13. .endif
  14. .if ${WANT_COMPILER_TYPE} == gcc || \
  15. (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc)
  16. .else
  17. LIB32CPUFLAGS+= -target x86_64-unknown-freebsd13.0
  18. .endif
  19. LIB32CPUFLAGS+= -m32
  20. LIB32WMAKEENV= MACHINE=i386 MACHINE_ARCH=i386 \
  21. MACHINE_CPU="i686 mmx sse sse2"
  22. LIB32WMAKEFLAGS= \
  23. AS="${XAS} --32" \
  24. LD="${XLD} -m elf_i386_fbsd -L${LIBCOMPATTMP}/usr/lib32" \
  25. OBJCOPY="${XOBJCOPY}"
  26. .elif ${TARGET_ARCH} == "powerpc64"
  27. .if empty(TARGET_CPUTYPE)
  28. LIB32CPUFLAGS= -mcpu=powerpc
  29. .else
  30. LIB32CPUFLAGS= -mcpu=${TARGET_CPUTYPE}
  31. .endif
  32. LIB32CPUFLAGS+= -m32
  33. LIB32WMAKEENV= MACHINE=powerpc MACHINE_ARCH=powerpc
  34. LIB32WMAKEFLAGS= \
  35. LD="${XLD} -m elf32ppc_fbsd" \
  36. OBJCOPY="${XOBJCOPY}"
  37. .elif ${TARGET_ARCH:Mmips64*} != ""
  38. .if ${WANT_COMPILER_TYPE} == gcc || \
  39. (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == gcc)
  40. .if empty(TARGET_CPUTYPE)
  41. LIB32CPUFLAGS= -march=mips3
  42. .else
  43. LIB32CPUFLAGS= -march=${TARGET_CPUTYPE}
  44. .endif
  45. .else
  46. .if ${TARGET_ARCH:Mmips64el*} != ""
  47. LIB32CPUFLAGS= -target mipsel-unknown-freebsd13.0
  48. .else
  49. LIB32CPUFLAGS= -target mips-unknown-freebsd13.0
  50. .endif
  51. .endif
  52. LIB32CPUFLAGS+= -mabi=32
  53. LIB32WMAKEENV= MACHINE=mips MACHINE_ARCH=mips
  54. .if ${TARGET_ARCH:Mmips64el*} != ""
  55. LIB32WMAKEFLAGS= LD="${XLD} -m elf32ltsmip_fbsd"
  56. .else
  57. LIB32WMAKEFLAGS= LD="${XLD} -m elf32btsmip_fbsd"
  58. .endif
  59. LIB32WMAKEFLAGS+= OBJCOPY="${XOBJCOPY}"
  60. .endif
  61. LIB32WMAKEFLAGS+= NM="${XNM}"
  62. LIB32CFLAGS= -DCOMPAT_32BIT
  63. LIB32DTRACE= ${DTRACE} -32
  64. LIB32WMAKEFLAGS+= -DCOMPAT_32BIT
  65. # -------------------------------------------------------------------
  66. # soft-fp world
  67. .if ${TARGET_ARCH:Marmv[67]*} != ""
  68. LIBSOFTCFLAGS= -DCOMPAT_SOFTFP
  69. LIBSOFTCPUFLAGS= -mfloat-abi=softfp
  70. LIBSOFTWMAKEENV= CPUTYPE=soft MACHINE=arm MACHINE_ARCH=${TARGET_ARCH}
  71. LIBSOFTWMAKEFLAGS= -DCOMPAT_SOFTFP
  72. .endif
  73. # -------------------------------------------------------------------
  74. # Generic code for each type.
  75. # Set defaults based on type.
  76. libcompat= ${LIBCOMPAT:tl}
  77. _LIBCOMPAT_MAKEVARS= _OBJTOP TMP CPUFLAGS CFLAGS CXXFLAGS WMAKEENV \
  78. WMAKEFLAGS WMAKE
  79. .for _var in ${_LIBCOMPAT_MAKEVARS}
  80. .if !empty(LIB${LIBCOMPAT}${_var})
  81. LIBCOMPAT${_var}?= ${LIB${LIBCOMPAT}${_var}}
  82. .endif
  83. .endfor
  84. # Shared flags
  85. LIBCOMPAT_OBJTOP?= ${OBJTOP}/obj-lib${libcompat}
  86. LIBCOMPATTMP?= ${LIBCOMPAT_OBJTOP}/tmp
  87. LIBCOMPATCFLAGS+= ${LIBCOMPATCPUFLAGS} \
  88. -L${LIBCOMPATTMP}/usr/lib${libcompat} \
  89. --sysroot=${LIBCOMPATTMP} \
  90. ${BFLAGS}
  91. # -B is needed to find /usr/lib32/crti.o for GCC and /usr/libsoft/crti.o for
  92. # Clang/GCC.
  93. LIBCOMPATCFLAGS+= -B${LIBCOMPATTMP}/usr/lib${libcompat}
  94. # Yes, the flags are redundant.
  95. LIBCOMPATWMAKEENV+= \
  96. INSTALL="sh ${.CURDIR}/tools/install.sh" \
  97. PATH=${TMPPATH} \
  98. SYSROOT=${LIBCOMPATTMP} \
  99. LIBDIR=/usr/lib${libcompat} \
  100. SHLIBDIR=/usr/lib${libcompat} \
  101. DTRACE="${LIB$COMPATDTRACE:U${DTRACE}}"
  102. .if ${MK_META_MODE} != "no"
  103. # Don't rebuild build-tools targets during normal build.
  104. LIBCOMPATWMAKEENV+= BUILD_TOOLS_META=.NOMETA
  105. .endif
  106. LIBCOMPATWMAKEFLAGS+= CC="${XCC} ${LIBCOMPATCFLAGS}" \
  107. CXX="${XCXX} ${LIBCOMPATCXXFLAGS} ${LIBCOMPATCFLAGS}" \
  108. CPP="${XCPP} ${LIBCOMPATCFLAGS}" \
  109. DESTDIR=${LIBCOMPATTMP} \
  110. -DNO_CPU_CFLAGS \
  111. MK_CTF=no \
  112. -DNO_LINT \
  113. MK_CFI=no \
  114. MK_SAFESTACK=no \
  115. MK_SPECTREV1_FIX=no \
  116. MK_RETPOLINE=no \
  117. MK_TESTS=no
  118. LIBCOMPATWMAKE+= ${LIBCOMPATWMAKEENV} ${MAKE} ${LIBCOMPATWMAKEFLAGS} \
  119. OBJTOP=${LIBCOMPAT_OBJTOP} \
  120. OBJROOT='$${OBJTOP}/' \
  121. MAKEOBJDIRPREFIX= \
  122. MK_MAN=no MK_HTML=no \
  123. MK_RETPOLINE=no
  124. LIBCOMPATIMAKE+= ${LIBCOMPATWMAKE:NINSTALL=*:NDESTDIR=*} \
  125. MK_TOOLCHAIN=no \
  126. MK_RETPOLINE=no \
  127. ${IMAKE_INSTALL} \
  128. -DLIBRARIES_ONLY
  129. _LC_LIBDIRS.yes= lib
  130. _LC_LIBDIRS.yes+= gnu/lib
  131. _LC_LIBDIRS.yes+= usr.bin/lex/lib
  132. _LC_LIBDIRS.${MK_CDDL:tl}+= cddl/lib
  133. _LC_LIBDIRS.${MK_CRYPT:tl}+= secure/lib
  134. _LC_LIBDIRS.${MK_KERBEROS:tl}+= kerberos5/lib
  135. _LC_INCDIRS= \
  136. include \
  137. lib/ncurses/ncursesw \
  138. ${_LC_LIBDIRS.yes}
  139. .if ${MK_FILE} != "no"
  140. _libmagic= lib/libmagic
  141. .endif
  142. .if ${MK_PMC} != "no" && ${TARGET_ARCH} == "amd64"
  143. _jevents= lib/libpmc/pmu-events
  144. .endif
  145. # Shared logic
  146. build${libcompat}: .PHONY
  147. @echo
  148. @echo "--------------------------------------------------------------"
  149. @echo ">>> stage 5.1: building lib${libcompat} shim libraries"
  150. @echo "--------------------------------------------------------------"
  151. .if !defined(NO_CLEAN)
  152. rm -rf ${LIBCOMPATTMP}
  153. .else
  154. ${_+_}@if [ -e "${LIBCOMPATTMP}" ]; then \
  155. echo ">>> Deleting stale files in build${libcompat} tree..."; \
  156. cd ${.CURDIR}; ${WMAKE} -DBATCH_DELETE_OLD_FILES \
  157. DESTDIR=${LIBCOMPATTMP} \
  158. delete-old delete-old-libs >/dev/null; \
  159. fi
  160. .endif # !defined(NO_CLEAN)
  161. mkdir -p ${LIBCOMPATTMP}/usr/include
  162. ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.usr.dist \
  163. -p ${LIBCOMPATTMP}/usr >/dev/null
  164. ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.include.dist \
  165. -p ${LIBCOMPATTMP}/usr/include >/dev/null
  166. ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
  167. -p ${LIBCOMPATTMP}/usr >/dev/null
  168. .if ${MK_DEBUG_FILES} != "no"
  169. ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.debug.dist \
  170. -p ${LIBCOMPATTMP}/usr/lib >/dev/null
  171. ${WORLDTMP_MTREE} -f ${.CURDIR}/etc/mtree/BSD.lib${libcompat}.dist \
  172. -p ${LIBCOMPATTMP}/usr/lib/debug/usr >/dev/null
  173. .endif
  174. mkdir -p ${WORLDTMP}
  175. ln -sf ${.CURDIR}/sys ${WORLDTMP}
  176. .for _t in ${_obj} includes
  177. .for _dir in ${_LC_INCDIRS}
  178. ${_+_}cd ${.CURDIR}/${_dir}; ${LIBCOMPATWMAKE} MK_INCLUDES=yes \
  179. DIRPRFX=${_dir}/ ${_t}
  180. .endfor
  181. .endfor
  182. .for _dir in lib/ncurses/ncurses lib/ncurses/ncursesw ${_libmagic} ${_jevents}
  183. .for _t in ${_obj} build-tools
  184. ${_+_}cd ${.CURDIR}/${_dir}; \
  185. WORLDTMP=${WORLDTMP} \
  186. MAKEFLAGS="-m ${.CURDIR}/tools/build/mk ${.MAKEFLAGS}" \
  187. ${MAKE} SSP_CFLAGS= DESTDIR= \
  188. OBJTOP=${LIBCOMPAT_OBJTOP} \
  189. OBJROOT='$${OBJTOP}/' \
  190. MAKEOBJDIRPREFIX= \
  191. DIRPRFX=${_dir}/ -DNO_LINT -DNO_CPU_CFLAGS \
  192. MK_CTF=no MK_RETPOLINE=no MK_WARNS=no \
  193. ${_t}
  194. .endfor
  195. .endfor
  196. ${_+_}cd ${.CURDIR}; \
  197. ${LIBCOMPATWMAKE} -f Makefile.inc1 -DNO_FSCHG libraries
  198. .if ${libcompat} == "32"
  199. .for _t in ${_obj} all
  200. .if !defined(NO_RTLD)
  201. ${_+_}cd ${.CURDIR}/libexec/rtld-elf; PROG=ld-elf32.so.1 ${LIBCOMPATWMAKE} \
  202. -DNO_FSCHG DIRPRFX=libexec/rtld-elf/ ${_t}
  203. .endif
  204. ${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIBCOMPATWMAKE} \
  205. DIRPRFX=usr.bin/ldd ${_t}
  206. .endfor
  207. .endif
  208. distribute${libcompat} install${libcompat}: .PHONY
  209. .for _dir in ${_LC_LIBDIRS.yes}
  210. ${_+_}cd ${.CURDIR}/${_dir}; ${LIBCOMPATIMAKE} ${.TARGET:S/${libcompat}$//}
  211. .endfor
  212. .if ${libcompat} == "32"
  213. .if !defined(NO_RTLD)
  214. ${_+_}cd ${.CURDIR}/libexec/rtld-elf; \
  215. PROG=ld-elf32.so.1 ${LIBCOMPATIMAKE} ${.TARGET:S/32$//}
  216. .endif
  217. ${_+_}cd ${.CURDIR}/usr.bin/ldd; PROG=ldd32 ${LIBCOMPATIMAKE} \
  218. ${.TARGET:S/32$//}
  219. .endif
  220. .endif