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