11.9Smrg$NetBSD: README,v 1.9 2024/02/04 05:43:05 mrg Exp $ 21.1Smrg 31.1Smrg 41.8SwizBuilding multi-ABI libraries for NetBSD platforms. 51.1Smrg 61.1Smrg 71.4Smrgsrc/compat has a framework to (re)build the libraries shipped with 81.4SmrgNetBSD for a different ABI than the default for that platform. This 91.5Ssnjallows 32-bit libraries for the amd64 and sparc64 ports, and enables 101.4Smrgthe mips64 port to support all three of old-style 32-bit ("o32"), the 111.4Smrgnew 32-bit (default, "n32", 64-bit CPU required) or the 64-bit ABI. 121.1Smrg 131.1Smrg 141.7SmrgThe basic premise is to re-set $MAKEOBJDIR to fresh subdirectory 151.4Smrgunderneath src/compat and rebuild the libraries with a different set 161.4Smrgof options. Each platform wanting support should create their port 171.4Smrgsubdirectory directly in src/compat, and then one subdirectory in here 181.8Swizfor each ABI required, e.g., src/compat/amd64/i386 is where we build 191.5Ssnjthe 32-bit compat libraries for the amd64 port. In each of these 201.8Swizsubdirectories, a small Makefile and makefile fragment should exist. The 211.4SmrgMakefile should set BSD_MK_COMPAT_FILE to equal the fragment, and then 221.8Swizinclude "../../compatsubdir.mk". E.g., amd64/i386/Makefile has: 231.1Smrg 241.4Smrg BSD_MK_COMPAT_FILE=${.CURDIR}/bsd.i386.mk 251.1Smrg 261.6Smrg .include "../../compatsubdir.mk" 271.1Smrg 281.4SmrgIn the makefile fragment any changes to ABI flags are passed here 291.4Smrgand the MLIBDIR variable must be set to the subdirectory in /usr/lib 301.4Smrgwhere libraries for the ABI will be installed. There are a couple of 311.5Ssnjhelper Makefiles around. amd64/i386/bsd.i386.mk looks like: 321.1Smrg 331.4Smrg LD+= -m elf_i386 341.4Smrg MLIBDIR= i386 351.4Smrg LIBC_MACHINE_ARCH= ${MLIBDIR} 361.4Smrg COMMON_MACHINE_ARCH= ${MLIBDIR} 371.4Smrg KVM_MACHINE_ARCH= ${MLIBDIR} 381.4Smrg PTHREAD_MACHINE_ARCH= ${MLIBDIR} 391.4Smrg BFD_MACHINE_ARCH= ${MLIBDIR} 401.4Smrg CSU_MACHINE_ARCH= ${MLIBDIR} 411.4Smrg CRYPTO_MACHINE_CPU= ${MLIBDIR} 421.4Smrg LDELFSO_MACHINE_CPU= ${MLIBDIR} 431.1Smrg 441.6Smrg .include "${NETBSDSRCDIR}/compat/m32.mk" 451.4Smrg 461.6Smrgand the referenced m32.mk looks like: 471.4Smrg 481.4Smrg COPTS+= -m32 491.4Smrg CPUFLAGS+= -m32 501.4Smrg LDADD+= -m32 511.4Smrg LDFLAGS+= -m32 521.4Smrg MKDEPFLAGS+= -m32 531.4Smrg 541.4Smrg .include "Makefile.compat" 551.4Smrg 561.4Smrg 571.6Smrgcompatsubdir.mk holds the list of subdirectories (the libraries and 581.4Smrgld.elf_so) to build with this ABI. 591.4Smrg 601.6Smrgarchdirs.mk holds the list of subdirectories for each port. 611.4Smrg 621.4SmrgMakefile.compat has the basic framework to force the right paths for 631.8Swizlibrary and ld.elf_so linkage. It contains a hack to create subdirectories 641.4Smrgin the build that should be fixed. 651.4Smrg 661.4Smrgdirshack/Makefile is a hack to get objdirs created timely, and should 671.4Smrgbe fixed in a better way. 681.4Smrg 691.4Smrg 701.4Smrg 711.9Smrgmrg@eterna23.net 721.4Smrgdecember 2009 73