README revision 1.2.6.1       1  1.2.6.1  mrg $NetBSD: README,v 1.2.6.1 2009/12/14 06:20:58 mrg Exp $
      2      1.1  mrg 
      3      1.1  mrg 
      4  1.2.6.1  mrg Building multi- ABI libraries for NetBSD platforms.
      5      1.1  mrg 
      6      1.1  mrg 
      7  1.2.6.1  mrg src/compat has a framework to (re)build the libraries shipped with
      8  1.2.6.1  mrg NetBSD for a different ABI than the default for that platform.  This
      9  1.2.6.1  mrg allow 32-bit libraries for the amd64 and sparc64 ports, and enables
     10  1.2.6.1  mrg the mips64 port to support all three of old-style 32-bit ("o32"), the
     11  1.2.6.1  mrg new 32-bit (default, "n32", 64-bit CPU required) or the 64-bit ABI.
     12      1.1  mrg 
     13      1.1  mrg 
     14  1.2.6.1  mrg The basic premise is to re-set $MAKEOBJDIRPREFIX to fresh subdirectory
     15  1.2.6.1  mrg underneath src/compat and rebuild the libraries with a different set
     16  1.2.6.1  mrg of options.  Each platform wanting support should create their port
     17  1.2.6.1  mrg subdirectory directly in src/compat, and then one subdirectory in here
     18  1.2.6.1  mrg for each ABI required.  e.g., src/compat/amd64/i386 is where we build
     19  1.2.6.1  mrg the 32-bit compat libraries for the amd64port.  In each of these
     20  1.2.6.1  mrg subdirs, a small Makefile and makefile fragment should exist.  The
     21  1.2.6.1  mrg Makefile should set BSD_MK_COMPAT_FILE to equal the fragment, and then
     22  1.2.6.1  mrg include "../../Makefile.common".  Eg, amd64/i386/Makefile has:
     23      1.1  mrg 
     24  1.2.6.1  mrg 	#	$NetBSD: README,v 1.2.6.1 2009/12/14 06:20:58 mrg Exp $
     25  1.2.6.1  mrg 
     26  1.2.6.1  mrg 	BSD_MK_COMPAT_FILE=${.CURDIR}/bsd.i386.mk
     27  1.2.6.1  mrg 
     28  1.2.6.1  mrg 	.include "../../Makefile.common"
     29  1.2.6.1  mrg 
     30  1.2.6.1  mrg In the makefile fragment any changes to ABI flags are passed here
     31  1.2.6.1  mrg and the MLIBDIR variable must be set to the subdirectory in /usr/lib
     32  1.2.6.1  mrg where libraries for the ABI will be installed.  There are a couple of
     33  1.2.6.1  mrg helper Makefile's around.  amd64/i386/bsd.i386.mk looks like:
     34  1.2.6.1  mrg 
     35  1.2.6.1  mrg 
     36  1.2.6.1  mrg 	#	$NetBSD: README,v 1.2.6.1 2009/12/14 06:20:58 mrg Exp $
     37  1.2.6.1  mrg 
     38  1.2.6.1  mrg 	LD+=		-m elf_i386
     39  1.2.6.1  mrg 	MLIBDIR=	i386
     40  1.2.6.1  mrg 
     41  1.2.6.1  mrg 	.include "${NETBSDSRCDIR}/compat/Makefile.m32"
     42  1.2.6.1  mrg 
     43  1.2.6.1  mrg and the referenced Makefile.m32 looks like:
     44  1.2.6.1  mrg 
     45  1.2.6.1  mrg 	#	$NetBSD: README,v 1.2.6.1 2009/12/14 06:20:58 mrg Exp $
     46  1.2.6.1  mrg 
     47  1.2.6.1  mrg 	#
     48  1.2.6.1  mrg 	# Makefile fragment to help implement a set of 'cc -m32' libraries.
     49  1.2.6.1  mrg 	#
     50  1.2.6.1  mrg 
     51  1.2.6.1  mrg 	COPTS+=			-m32
     52  1.2.6.1  mrg 	CPUFLAGS+=		-m32
     53  1.2.6.1  mrg 	LDADD+=			-m32
     54  1.2.6.1  mrg 	LDFLAGS+=		-m32
     55  1.2.6.1  mrg 	MKDEPFLAGS+=		-m32
     56  1.2.6.1  mrg 
     57  1.2.6.1  mrg 	.include "Makefile.compat"
     58  1.2.6.1  mrg 
     59  1.2.6.1  mrg 
     60  1.2.6.1  mrg Makefile.common holds the list of subdirectories (the libraries and
     61  1.2.6.1  mrg ld.elf_so) to build with this ABI.
     62  1.2.6.1  mrg 
     63  1.2.6.1  mrg Makefile.md_subdir holds the list of subdirectories for each port.
     64  1.2.6.1  mrg 
     65  1.2.6.1  mrg Makefile.compat has the basic framework to force the right paths for
     66  1.2.6.1  mrg library and ld.elf_so linkage.  It contains a hack to create subdirs
     67  1.2.6.1  mrg in the build that should be fixed.
     68  1.2.6.1  mrg 
     69  1.2.6.1  mrg dirshack/Makefile is a hack to get objdirs created timely, and should
     70  1.2.6.1  mrg be fixed in a better way.
     71      1.1  mrg 
     72      1.1  mrg 
     73      1.1  mrg TODO:
     74  1.2.6.1  mrg 
     75  1.2.6.1  mrg - fix MLIBDIR in ld.elf_so arch-subdirs to be generic since it now is:
     76  1.2.6.1  mrg   .if defined(MLIBDIR)
     77  1.2.6.1  mrg   CPPFLAGS+=    -DRTLD_ARCH_SUBDIR=\"${MLIBDIR}\"
     78  1.2.6.1  mrg   .endif
     79  1.2.6.1  mrg - check this part in ld.elf_so Makefile.  it may be right now:
     80  1.2.6.1  mrg   # XXXX this needs to find the right one some how yet.
     81  1.2.6.1  mrg   CLIBOBJ!=     cd ${NETBSDSRCDIR}/lib/libc && ${PRINTOBJDIR}
     82  1.2.6.1  mrg 
     83  1.2.6.1  mrg 
     84  1.2.6.1  mrg mrg (a] eterna.com.au
     85  1.2.6.1  mrg december 2009
     86