1*2026b728Smrg$NetBSD: README,v 1.9 2024/02/04 05:43:05 mrg Exp $ 228d618d6Smrg 328d618d6Smrg 43ad6dcd1SmrgBuilding multi-ABI libraries for NetBSD platforms. 528d618d6Smrg 628d618d6Smrg 73ad6dcd1Smrgsrc/compat has a framework to (re)build the libraries shipped with 83ad6dcd1SmrgNetBSD for a different ABI than the default for that platform. This 96066e382Ssnjallows 32-bit libraries for the amd64 and sparc64 ports, and enables 103ad6dcd1Smrgthe mips64 port to support all three of old-style 32-bit ("o32"), the 113ad6dcd1Smrgnew 32-bit (default, "n32", 64-bit CPU required) or the 64-bit ABI. 123ad6dcd1Smrg 133ad6dcd1Smrg 14df0710a4SmrgThe basic premise is to re-set $MAKEOBJDIR to fresh subdirectory 153ad6dcd1Smrgunderneath src/compat and rebuild the libraries with a different set 163ad6dcd1Smrgof options. Each platform wanting support should create their port 173ad6dcd1Smrgsubdirectory directly in src/compat, and then one subdirectory in here 18cbdb6a1fSwizfor each ABI required, e.g., src/compat/amd64/i386 is where we build 193ad6dcd1Smrgthe 32-bit compat libraries for the amd64 port. In each of these 20cbdb6a1fSwizsubdirectories, a small Makefile and makefile fragment should exist. The 213ad6dcd1SmrgMakefile should set BSD_MK_COMPAT_FILE to equal the fragment, and then 22cbdb6a1fSwizinclude "../../compatsubdir.mk". E.g., amd64/i386/Makefile has: 233ad6dcd1Smrg 243ad6dcd1Smrg BSD_MK_COMPAT_FILE=${.CURDIR}/bsd.i386.mk 253ad6dcd1Smrg 264f6d9f58Smrg .include "../../compatsubdir.mk" 273ad6dcd1Smrg 283ad6dcd1SmrgIn the makefile fragment any changes to ABI flags are passed here 293ad6dcd1Smrgand the MLIBDIR variable must be set to the subdirectory in /usr/lib 303ad6dcd1Smrgwhere libraries for the ABI will be installed. There are a couple of 316066e382Ssnjhelper Makefiles around. amd64/i386/bsd.i386.mk looks like: 323ad6dcd1Smrg 333ad6dcd1Smrg LD+= -m elf_i386 343ad6dcd1Smrg MLIBDIR= i386 353ad6dcd1Smrg LIBC_MACHINE_ARCH= ${MLIBDIR} 363ad6dcd1Smrg COMMON_MACHINE_ARCH= ${MLIBDIR} 373ad6dcd1Smrg KVM_MACHINE_ARCH= ${MLIBDIR} 383ad6dcd1Smrg PTHREAD_MACHINE_ARCH= ${MLIBDIR} 393ad6dcd1Smrg BFD_MACHINE_ARCH= ${MLIBDIR} 403ad6dcd1Smrg CSU_MACHINE_ARCH= ${MLIBDIR} 413ad6dcd1Smrg CRYPTO_MACHINE_CPU= ${MLIBDIR} 423ad6dcd1Smrg LDELFSO_MACHINE_CPU= ${MLIBDIR} 433ad6dcd1Smrg 444f6d9f58Smrg .include "${NETBSDSRCDIR}/compat/m32.mk" 453ad6dcd1Smrg 464f6d9f58Smrgand the referenced m32.mk looks like: 473ad6dcd1Smrg 483ad6dcd1Smrg COPTS+= -m32 493ad6dcd1Smrg CPUFLAGS+= -m32 503ad6dcd1Smrg LDADD+= -m32 513ad6dcd1Smrg LDFLAGS+= -m32 523ad6dcd1Smrg MKDEPFLAGS+= -m32 533ad6dcd1Smrg 543ad6dcd1Smrg .include "Makefile.compat" 553ad6dcd1Smrg 563ad6dcd1Smrg 574f6d9f58Smrgcompatsubdir.mk holds the list of subdirectories (the libraries and 583ad6dcd1Smrgld.elf_so) to build with this ABI. 593ad6dcd1Smrg 604f6d9f58Smrgarchdirs.mk holds the list of subdirectories for each port. 613ad6dcd1Smrg 623ad6dcd1SmrgMakefile.compat has the basic framework to force the right paths for 63cbdb6a1fSwizlibrary and ld.elf_so linkage. It contains a hack to create subdirectories 643ad6dcd1Smrgin the build that should be fixed. 653ad6dcd1Smrg 663ad6dcd1Smrgdirshack/Makefile is a hack to get objdirs created timely, and should 673ad6dcd1Smrgbe fixed in a better way. 6828d618d6Smrg 6928d618d6Smrg 7028d618d6Smrg 71*2026b728Smrgmrg@eterna23.net 723ad6dcd1Smrgdecember 2009 73