merge the new src/compat build into the place it was actually born. this replaces the old src/compat with a method that re-traverses the library directories with a different set of flags, and is capable of building more than one compat ABI.diff -r1.1.8.1 -r1.1.8.2 src/compat/Makefile
(mrg)
--- src/compat/Makefile 2009/09/13 21:21:16 1.1.8.1
+++ src/compat/Makefile 2009/12/14 06:20:58 1.1.8.2
@@ -1,28 +1,22 @@ | @@ -1,28 +1,22 @@ | |||
1 | # $NetBSD: Makefile,v 1.1.8.1 2009/09/13 21:21:16 matt Exp $ | 1 | # $NetBSD: Makefile,v 1.1.8.2 2009/12/14 06:20:58 mrg Exp $ | |
2 | 2 | |||
3 | # Build 32-bit compat versions of: | 3 | # Build 32-bit compat versions of: | |
4 | # src/gnu/lib/libgcc4 into ${DESTDIR}/usr/lib/<32arch> | 4 | # src/gnu/lib/libgcc4 into ${DESTDIR}/usr/lib/<32arch> | |
5 | # src/lib/libc into ${DESTDIR}/usr/lib/<32arch> | 5 | # src/lib/libc into ${DESTDIR}/usr/lib/<32arch> | |
6 | # src/gnu/lib/ into ${DESTDIR}/usr/lib/<32arch> | 6 | # src/gnu/lib/ into ${DESTDIR}/usr/lib/<32arch> | |
7 | # src/lib/ into ${DESTDIR}/usr/lib/<32arch> | 7 | # src/lib/ into ${DESTDIR}/usr/lib/<32arch> | |
8 | # src/libexec/ld.elf_so into ${DESTDIR}/usr/libexec/ld.elf_so-<32arch> | 8 | # src/libexec/ld.elf_so into ${DESTDIR}/usr/libexec/ld.elf_so-<32arch> | |
9 | 9 | |||
10 | .include <bsd.own.mk> | 10 | .include <bsd.own.mk> | |
11 | 11 | |||
12 | .if ${MKCOMPAT} != "no" && \ | 12 | .if ${MKCOMPAT} != "no" | |
13 | (${MACHINE} == "sparc64" || ${MACHINE} == "amd64") || \ | |||
14 | (${MACHINE_ARCH} == "mips64eb" || ${MACHINE_ARCH} == "mips64el") | |||
15 | ||||
16 | .if !make(includes) | 13 | .if !make(includes) | |
17 | SUBDIR= gnu/lib/crtstuff4 .WAIT \ | |||
18 | lib/csu .WAIT \ | |||
19 | gnu/lib/libgcc4 .WAIT \ | |||
20 | lib/libc .WAIT \ | |||
21 | lib/libutil .WAIT \ | |||
22 | lib gnu/lib .WAIT \ | |||
23 | libexec/ld.elf_so | |||
24 | .endif | |||
25 | 14 | |||
15 | .include "Makefile.md_subdir" | |||
16 | ||||
17 | SUBDIR= dirshack .WAIT ${MD_SUBDIR} | |||
18 | ||||
19 | .endif | |||
26 | .endif | 20 | .endif | |
27 | 21 | |||
28 | .include <bsd.subdir.mk> | 22 | .include <bsd.subdir.mk> |
# $NetBSD: Makefile.common,v 1.1.2.1 2009/12/14 06:20:58 mrg Exp $
# Build netbsd libraries.
.include <bsd.own.mk>
.if ${MKCOMPAT} != "no"
.if !make(includes)
# make sure we get an objdir built early enough
.include <bsd.prog.mk>
# XXX make this use MAKEOBJDIR
MAKEDIRTARGETENV= MAKEOBJDIRPREFIX=${.OBJDIR} MKOBJDIRS=yes MKSHARE=no BSD_MK_COMPAT_FILE=${BSD_MK_COMPAT_FILE}
.if defined(BOOTSTRAP_SUBDIRS)
SUBDIR= ${BOOTSTRAP_SUBDIRS}
.else
SUBDIR= ../../../gnu/lib/crtstuff4 .WAIT \
../../../lib/csu .WAIT \
../../../gnu/lib/libgcc4 .WAIT \
../../../lib/libc .WAIT \
../../../lib/libutil .WAIT \
../../../lib ../../../gnu/lib \
../../../libexec/ld.elf_so
.endif
.include <bsd.subdir.mk>
.endif
.endif
# $NetBSD: Makefile.m32,v 1.1.2.1 2009/12/14 06:20:58 mrg Exp $
#
# Makefile fragment to help implement a set of 'cc -m32' libraries.
#
COPTS+= -m32
CPUFLAGS+= -m32
LDADD+= -m32
LDFLAGS+= -m32
MKDEPFLAGS+= -m32
.include "Makefile.compat"
# $NetBSD: Makefile.md_subdir,v 1.1.2.1 2009/12/14 06:20:58 mrg Exp $
# list of subdirs
.if ${MACHINE} == "sparc64"
MD_SUBDIR= sparc64/sparc
.endif
.if ${MACHINE} == "amd64"
MD_SUBDIR= amd64/i386
.endif
.if (${MACHINE_ARCH} == "mips64eb" || ${MACHINE_ARCH} == "mips64el")
MD_SUBDIR= mips64/64 mips64/o32
.endif
--- src/compat/Makefile.compat 2009/09/13 21:21:16 1.3.8.1
+++ src/compat/Makefile.compat 2009/12/14 06:20:58 1.3.8.2
@@ -1,77 +1,50 @@ | @@ -1,77 +1,50 @@ | |||
1 | # $NetBSD: Makefile.compat,v 1.3.8.1 2009/09/13 21:21:16 matt Exp $ | 1 | # $NetBSD: Makefile.compat,v 1.3.8.2 2009/12/14 06:20:58 mrg Exp $ | |
2 | 2 | |||
3 | # XXX ugly | 3 | # | |
4 | .if ${MACHINE} == "sparc64" | 4 | # Makefile fragment to help implement a multilib set of libraries | |
5 | LD+= -m elf32_sparc | 5 | # | |
6 | LDFLAGS+= -m32 | 6 | # expects MLIBDIR to be set to the extra path component | |
7 | LD32DIR= sparc | 7 | # | |
8 | ARCH32DIR= sparc | 8 | ||
9 | COPTS+= -m32 | 9 | .ifndef _COMPAT_OPTIONS_MK_ # { | |
10 | CPUFLAGS+= -m32 | 10 | _COMPAT_OPTIONS_MK_=1 | |
11 | LDADD+= -m32 | 11 | ||
12 | MKDEPFLAGS+= -m32 | 12 | LIBDIR= /usr/lib/${MLIBDIR} | |
13 | 13 | SHLIBDIR= /usr/lib/${MLIBDIR} | ||
14 | .elif ${MACHINE} == "amd64" | 14 | SHLIBINSTALLDIR= /usr/lib/${MLIBDIR} | |
15 | LD+= -m elf_i386 | 15 | ||
16 | LDFLAGS+= -m32 | 16 | _GCC_CRTBEGIN= ${DESTDIR}/usr/lib/${MLIBDIR}/crtbegin.o | |
17 | LD32DIR= i386 | 17 | _GCC_CRTBEGINS= ${DESTDIR}/usr/lib/${MLIBDIR}/crtbeginS.o | |
18 | ARCH32DIR= i386 | 18 | _GCC_CRTEND= ${DESTDIR}/usr/lib/${MLIBDIR}/crtend.o | |
19 | COPTS+= -m32 | 19 | _GCC_CRTENDS= ${DESTDIR}/usr/lib/${MLIBDIR}/crtendS.o | |
20 | CPUFLAGS+= -m32 | 20 | _GCC_CRTDIR= ${DESTDIR}/usr/lib/${MLIBDIR} | |
21 | LDADD+= -m32 | 21 | _GCC_LIBGCCDIR= ${DESTDIR}/usr/lib/${MLIBDIR} | |
22 | MKDEPFLAGS+= -m32 | |||
23 | ||||
24 | .elif ${MACHINE_ARCH} == "mips64eb" || ${MACHINE_ARCH} == "mips64el" | |||
25 | LD+= -m elf64${MACHINE_ARCH:S/mips64e//}tsmip | |||
26 | LDFLAGS+= -mabi=64 | |||
27 | LD32DIR= lib64 | |||
28 | ARCH32DIR= ${MACHINE_ARCH} | |||
29 | COPTS+= -mabi=64 | |||
30 | CPUFLAGS+= -mabi=64 | |||
31 | LDADD+= -mabi=64 | |||
32 | MKDEPFLAGS+= -mabi=64 | |||
33 | ||||
34 | .endif | |||
35 | ||||
36 | LIBDIR= /usr/lib/${LD32DIR} | |||
37 | SHLIBDIR= /usr/lib/${LD32DIR} | |||
38 | SHLIBINSTALLDIR= /usr/lib/${LD32DIR} | |||
39 | ||||
40 | COMMON_MACHINE_ARCH= ${LD32DIR} | |||
41 | LIBC_MACHINE_ARCH= ${LD32DIR} | |||
42 | BFD_MACHINE_ARCH= ${LD32DIR} | |||
43 | CRYPTO_MACHINE_CPU= ${LD32DIR} | |||
44 | KVM_MACHINE_ARCH= ${LD32DIR} | |||
45 | PTHREAD_MACHINE_ARCH= ${LD32DIR} | |||
46 | LDELFSO_MACHINE_CPU= ${LD32DIR} | |||
47 | ||||
48 | _GCC_CRTBEGIN?= ${DESTDIR}/usr/lib/${LD32DIR}/crtbegin.o | |||
49 | _GCC_CRTBEGINS?= ${DESTDIR}/usr/lib/${LD32DIR}/crtbeginS.o | |||
50 | _GCC_CRTEND?= ${DESTDIR}/usr/lib/${LD32DIR}/crtend.o | |||
51 | _GCC_CRTENDS?= ${DESTDIR}/usr/lib/${LD32DIR}/crtendS.o | |||
52 | _GCC_CRTDIR?= ${DESTDIR}/usr/lib/${LD32DIR} | |||
53 | _GCC_LIBGCCDIR?= ${DESTDIR}/usr/lib/${LD32DIR} | |||
54 | 22 | |||
55 | NOSHARE= # defined | 23 | NOSHARE= # defined | |
56 | NONLS= # defined | 24 | NOLINT= # defined | |
25 | NONLS= # defined | |||
26 | NOMAN= # defined | |||
27 | NOINFO= # defined | |||
57 | NOCHECKVER= # defined | 28 | NOCHECKVER= # defined | |
58 | 29 | |||
59 | LIBC_DIR= ${NETBSDSRCDIR}/compat/lib/libc | |||
60 | ||||
61 | # ld.elf_so | 30 | # ld.elf_so | |
62 | SHLINKINSTALLDIR= /usr/libexec | 31 | SHLINKINSTALLDIR= /usr/libexec | |
63 | 32 | |||
64 | # XXX | 33 | # XXX | |
65 | EXTRALIBDIRS= ${DESTDIR}${LIBDIR} ${DESTDIR}${LIBDIR}/i18n ${DESTDIR}${LIBDIR}/security | 34 | EXTRALIBDIRS= ${DESTDIR}${LIBDIR} ${DESTDIR}${LIBDIR}/i18n ${DESTDIR}${LIBDIR}/security | |
66 | .PRECIOUS: ${EXTRALIBDIRS} | 35 | .PRECIOUS: ${EXTRALIBDIRS} | |
67 | install: ${EXTRALIBDIRS} .WAIT | 36 | # XXX this should be "install:" but that doesn't work for some reason | |
37 | obj: ${EXTRALIBDIRS} | |||
68 | ${EXTRALIBDIRS}: .EXEC | 38 | ${EXTRALIBDIRS}: .EXEC | |
39 | @if [ -z "${MLIBDIR}" ]; then echo "BAH"; false; fi | |||
69 | @if [ ! -d ${.TARGET} ] ; then \ | 40 | @if [ ! -d ${.TARGET} ] ; then \ | |
70 | ${_MKSHMSG_CREATE} ${.TARGET}; \ | 41 | ${_MKSHMSG_CREATE} ${.TARGET}; \ | |
71 | ${_MKSHECHO} ${INSTALL_DIR} -o ${BINOWN} -g ${BINGRP} -m 755 \ | 42 | ${_MKSHECHO} ${INSTALL_DIR} -o ${BINOWN} -g ${BINGRP} -m 755 \ | |
72 | ${.TARGET}; \ | 43 | ${.TARGET}; \ | |
73 | ${INSTALL_DIR} -o ${BINOWN} -g ${BINGRP} -m 755 \ | 44 | ${INSTALL_DIR} -o ${BINOWN} -g ${BINGRP} -m 755 \ | |
74 | ${.TARGET}; \ | 45 | ${.TARGET}; \ | |
75 | fi | 46 | fi | |
76 | # Make sure the base dir is created first. | 47 | # Make sure the base dir is created first. | |
77 | ${DESTDIR}${LIBDIR}/i18n ${DESTDIR}${LIBDIR}/security: ${DESTDIR}${LIBDIR} | 48 | ${DESTDIR}${LIBDIR}/i18n ${DESTDIR}${LIBDIR}/security: ${DESTDIR}${LIBDIR} | |
49 | ||||
50 | .endif # _COMPAT_OPTIONS_MK_ } |
--- src/compat/README 2008/10/27 07:22:22 1.2
+++ src/compat/README 2009/12/14 06:20:58 1.2.6.1
@@ -1,43 +1,85 @@ | @@ -1,43 +1,85 @@ | |||
1 | $NetBSD: README,v 1.2 2008/10/27 07:22:22 mrg Exp $ | 1 | $NetBSD: README,v 1.2.6.1 2009/12/14 06:20:58 mrg Exp $ | |
2 | 2 | |||
3 | This directory contains Makefile fragments that will build all of the | |||
4 | NetBSD libraries in 32-bit mode and install them into /usr/lib/<arch> | |||
5 | and also install a /usr/libexec/ld.elf_so-<arch>. | |||
6 | 3 | |||
7 | This is current only supported for the amd64 and sparc64 platforms, | 4 | Building multi- ABI libraries for NetBSD platforms. | |
8 | where <arch> is "i386" or "sparc" respectively. (It could be used to | |||
9 | build MIPS o32 libraries on n32 system, but not both n32 and o32 on | |||
10 | a n64 system. It only supports one extra target.) | |||
11 | 5 | |||
12 | 6 | |||
13 | Most of the makefiles here were built with the "build-makefiles" script. | 7 | src/compat has a framework to (re)build the libraries shipped with | |
14 | The expections are lib/csu/Makefile and ld.elf_so/Makefile. | 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. | |||
15 | 12 | |||
16 | 13 | |||
17 | The method used is the: | 14 | The basic premise is to re-set $MAKEOBJDIRPREFIX to fresh subdirectory | |
18 | - evaluate some local variables | 15 | underneath src/compat and rebuild the libraries with a different set | |
19 | - switch .CURDIR | 16 | of options. Each platform wanting support should create their port | |
20 | - include original Makefile, | 17 | subdirectory directly in src/compat, and then one subdirectory in here | |
21 | - evaluate some variables | 18 | for each ABI required. e.g., src/compat/amd64/i386 is where we build | |
22 | - switch .CURDIR back | 19 | the 32-bit compat libraries for the amd64port. In each of these | |
23 | that is used by crunchgen to build eg, installer media or /rescue. | 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: | |||
24 | 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. | |||
25 | 71 | |||
26 | 72 | |||
27 | TODO: | 73 | TODO: | |
28 | - some yacc issue -- libc, libipsec and libpcap need "make" run | 74 | ||
29 | to generate headers properly, otherwise it complains about | 75 | - fix MLIBDIR in ld.elf_so arch-subdirs to be generic since it now is: | |
30 | no way to get to foo.h. this is currently hacked by putting | 76 | .if defined(MLIBDIR) | |
31 | a rule "foo.h: foo.c" in the (generated) makefiles | 77 | CPPFLAGS+= -DRTLD_ARCH_SUBDIR=\"${MLIBDIR}\" | |
32 | - there's an ugly hack to make libpam build correctly again the | 78 | .endif | |
33 | right libc. ld.elf_so has a similar (but less ugly hack) | 79 | - check this part in ld.elf_so Makefile. it may be right now: | |
34 | - not sure that /usr/lib/{i386,sparc}{,/i18n} are created | 80 | # XXXX this needs to find the right one some how yet. | |
35 | properly yet | 81 | CLIBOBJ!= cd ${NETBSDSRCDIR}/lib/libc && ${PRINTOBJDIR} | |
36 | 82 | |||
37 | Future work | 83 | ||
38 | 84 | mrg@eterna.com.au | ||
39 | Ideally this should be able to handle any number of compat targets. | 85 | december 2009 | |
40 | Perhaps using a "force MAKEOBJDIR, and run-run make" solution will | |||
41 | work, but my initial attempts got me no where. If not, perhaps | |||
42 | build-makefiles could be expanded to be used at run-time in such | |||
43 | a per-compat target obj-dir. |
# $NetBSD: Makefile,v 1.1.2.2 2009/12/14 06:20:58 mrg Exp $
BSD_MK_COMPAT_FILE=${.CURDIR}/bsd.i386.mk
.include "../../Makefile.common"
# $NetBSD: bsd.i386.mk,v 1.1.2.2 2009/12/14 06:20:58 mrg Exp $
LD+= -m elf_i386
MLIBDIR= i386
LIBC_MACHINE_ARCH= ${MLIBDIR}
COMMON_MACHINE_ARCH= ${MLIBDIR}
KVM_MACHINE_ARCH= ${MLIBDIR}
PTHREAD_MACHINE_ARCH= ${MLIBDIR}
BFD_MACHINE_ARCH= ${MLIBDIR}
CSU_MACHINE_ARCH= ${MLIBDIR}
CRYPTO_MACHINE_CPU= ${MLIBDIR}
LDELFSO_MACHINE_CPU= ${MLIBDIR}
.include "${NETBSDSRCDIR}/compat/Makefile.m32"
# $NetBSD: Makefile,v 1.1.2.2 2009/12/14 06:20:58 mrg Exp $
# hacky method to get compat multilib base objdirs created before
# make tries to go create the subdirs used for builds.
# the problem is that make handles objdir creation for subdirs before it
# handles this current directory, so when make cd's into $arch/$libtype
# and from there into the ../../lib dirs, it ends up setting the forced
# MAKEOBJDIRPREFIX to something based upon ${.CURDIR}, since the objdir
# doesn't exist yet.
#
# our solution is simple - from this Makefile we traverse the same list
# of $arch/$libtype's with "BOOTSTRAP_SUBDIR=". then the compat/Makefile
# handles these subdirs as normal, with the base objdir created.
.include <bsd.own.mk>
.if ${MKCOMPAT} != "no"
.if make(obj)
.include "../Makefile.md_subdir"
MAKEDIRTARGETENV= BOOTSTRAP_SUBDIRS=
SUBDIR= ${MD_SUBDIR:C/^/..\//}
.endif # make(obj)
.endif # MKCOMPAT != no
.include <bsd.subdir.mk>
# $NetBSD: Makefile,v 1.1.2.2 2009/12/14 06:21:11 mrg Exp $
BSD_MK_COMPAT_FILE=${.CURDIR}/bsd.64.mk
.include "../../Makefile.common"
# $NetBSD: bsd.64.mk,v 1.1.2.2 2009/12/14 06:21:11 mrg Exp $
LD+= -m elf64_mipsn64
MLIBDIR= 64
COPTS+= -mabi=64
CPUFLAGS+= -mabi=64
LDADD+= -mabi=64
LDFLAGS+= -mabi=64
MKDEPFLAGS+= -mabi=64
.include "${NETBSDSRCDIR}/compat/Makefile.compat"
# $NetBSD: Makefile,v 1.1.2.2 2009/12/14 06:21:11 mrg Exp $
BSD_MK_COMPAT_FILE=${.CURDIR}/bsd.o32.mk
.include "../../Makefile.common"
# $NetBSD: bsd.o32.mk,v 1.1.2.2 2009/12/14 06:21:11 mrg Exp $
LD+= -m elf32_mipso32
MLIBDIR= o32
#.include "${NETBSDSRCDIR}/compat/Makefile.m32"
COPTS+= -mabi=32 -march=mips3
CPUFLAGS+= -mabi=32 -march=mips3
LDADD+= -mabi=32 -march=mips3
LDFLAGS+= -mabi=32 -march=mips3
MKDEPFLAGS+= -mabi=32 -march=mips3
.include "${NETBSDSRCDIR}/compat/Makefile.compat"
# $NetBSD: Makefile,v 1.1.2.2 2009/12/14 06:21:11 mrg Exp $
BSD_MK_COMPAT_FILE=${.CURDIR}/bsd.sparc.mk
.include "../../Makefile.common"
# $NetBSD: bsd.sparc.mk,v 1.1.2.2 2009/12/14 06:21:11 mrg Exp $
LD+= -m elf32_sparc
MLIBDIR= sparc
LIBC_MACHINE_ARCH= ${MLIBDIR}
COMMON_MACHINE_ARCH= ${MLIBDIR}
KVM_MACHINE_ARCH= ${MLIBDIR}
PTHREAD_MACHINE_ARCH= ${MLIBDIR}
BFD_MACHINE_ARCH= ${MLIBDIR}
CSU_MACHINE_ARCH= ${MLIBDIR}
CRYPTO_MACHINE_CPU= ${MLIBDIR}
LDELFSO_MACHINE_CPU= ${MLIBDIR}
.include "${NETBSDSRCDIR}/compat/Makefile.m32"