Преглед на файлове

finetune multilib support a lot, cleanup eglibc/glibc Makefiles while there

Waldemar Brodkorb преди 12 години
родител
ревизия
14b1dc5940

+ 21 - 47
package/eglibc/Makefile

@@ -3,6 +3,7 @@
 
 include $(TOPDIR)/rules.mk
 include $(TOPDIR)/toolchain/eglibc/Makefile.inc
+include $(TOPDIR)/toolchain/eglibc/Makefile.multilib
 
 PKG_DESCR:=		embedded GNU C library
 PKG_SECTION:=		base
@@ -21,60 +22,32 @@ CONFIG_STYLE:=		manual
 BUILD_STYLE:=		manual
 INSTALL_STYLE:=		manual
 
-EGLIBC_CONFOPTS:=	--build=$(GNU_HOST_NAME) \
-			--host=$(REAL_GNU_TARGET_NAME) \
-			--with-headers=$(STAGING_TARGET_DIR)/usr/include \
-			--disable-nls \
-			--without-cvs \
-			--disable-profile \
-			--disable-debug \
-			--enable-kernel=2.6.0 \
-			--without-gd \
-			--with-__thread \
-			--with-tls \
-			--enable-add-ons
-
-EGLIBC_ENV:=		PATH='${TARGET_PATH}' \
-			GCC_HONOUR_COPTS=s \
-			BUILD_CC=${CC_FOR_BUILD} \
-			CFLAGS="$(TARGET_CFLAGS)" \
-			CC=${REAL_GNU_TARGET_NAME}-gcc \
-			CXX=${REAL_GNU_TARGET_NAME}-g++ \
-			AR=${REAL_GNU_TARGET_NAME}-ar \
-			RANLIB=${REAL_GNU_TARGET_NAME}-ranlib \
-			libc_cv_forced_unwind=yes \
-			libc_cv_c_cleanup=yes \
-			libc_cv_gnu99_inline=yes \
-			libc_cv_slibdir="/lib"
-
 # compile nothing, eglibc is already build in toolchain directory
 do-install:
-ifeq ($(ADK_LOCALES),y)
-	${INSTALL_DIR} $(IDIR_EGLIBC)/usr/bin
-	$(CP) $(STAGING_TARGET_DIR)/usr/bin/locale $(IDIR_EGLIBC)/usr/bin
-endif
-	${INSTALL_DIR} $(IDIR_EGLIBC)/$(ADK_TARGET_LIBC_PATH) $(IDIR_EGLIBC)/etc \
+ifeq ($(ADK_TARGET_WITH_MULTILIB),y)
+	for abi in $(TABI); do \
+		${INSTALL_DIR} $(IDIR_EGLIBC)/lib$${abi/*:/} $(IDIR_EGLIBC)/usr/lib$${abi/*:/} ; \
+		$(CP) $(STAGING_TARGET_DIR)/lib/ld* $(IDIR_EGLIBC)/lib$${abi/*:/} ; \
+		-for file in libc libcrypt libdl libm libresolv libutil libnsl libnss_dns libnss_files; do \
+			$(CP) $(STAGING_TARGET_DIR)-$${abi/*:/}/lib/$$file.so* $(IDIR_EGLIBC)/lib$${abi/*:/}; \
+			$(CP) $(STAGING_TARGET_DIR)-$${abi/*:/}/lib/$$file-$(PKG_VERSION).so $(IDIR_EGLIBC)/lib$${abi/*:/}; \
+		done ; \
+	done
+else
+	${INSTALL_DIR} $(IDIR_EGLIBC)/$(ADK_TARGET_LIBC_PATH) \
 	    $(IDIR_EGLIBC)/usr/lib $(IDIR_EGLIBC)/usr/bin
-ifeq ($(ADK_TOOLCHAIN_GCC_USE_SSP),y)
-	$(CP) $(STAGING_TARGET_DIR)/lib/libssp.so* $(IDIR_EGLIBC)/$(ADK_TARGET_LIBC_PATH)
-endif
 	$(CP) $(STAGING_TARGET_DIR)/lib/ld* $(IDIR_EGLIBC)/$(ADK_TARGET_LIBC_PATH)
 	-for file in libc libcrypt libdl libm libresolv libutil libnsl libnss_dns libnss_files; do \
 		$(CP) $(STAGING_TARGET_DIR)/lib/$$file.so* $(IDIR_EGLIBC)/$(ADK_TARGET_LIBC_PATH); \
 		$(CP) $(STAGING_TARGET_DIR)/lib/$$file-$(PKG_VERSION).so $(IDIR_EGLIBC)/$(ADK_TARGET_LIBC_PATH); \
 	done
-	${INSTALL_DATA} ${STAGING_TARGET_DIR}/etc/gai.conf ${IDIR_EGLIBC}/etc
-	${INSTALL_DATA} ${STAGING_TARGET_DIR}/etc/nscd.conf ${IDIR_EGLIBC}/etc
-	${INSTALL_DATA} ${STAGING_TARGET_DIR}/etc/nsswitch.conf ${IDIR_EGLIBC}/etc
 	$(CP) $(STAGING_TARGET_DIR)/usr/bin/getconf $(IDIR_EGLIBC)/usr/bin
-ifeq ($(ADK_TARGET_MULTILIB_X86_32),y)
-	${INSTALL_DIR} $(IDIR_EGLIBC)/lib32 $(IDIR_EGLIBC)/usr/lib32 
-	$(CP) $(STAGING_TARGET_DIR_32)/lib/ld* $(IDIR_EGLIBC)/lib32
-	-for file in libc libcrypt libdl libm libresolv libutil libnsl libnss_dns libnss_files; do \
-		$(CP) $(STAGING_TARGET_DIR_32)/lib/$$file.so* $(IDIR_EGLIBC)/lib32; \
-		$(CP) $(STAGING_TARGET_DIR_32)/lib/$$file-$(PKG_VERSION).so $(IDIR_EGLIBC)/lib32; \
-	done
+ifeq ($(ADK_LOCALES),y)
+	$(CP) $(STAGING_TARGET_DIR)/usr/bin/locale $(IDIR_EGLIBC)/usr/bin
+endif
 endif
+	${INSTALL_DIR} $(IDIR_EGLIBC)/etc 
+	${INSTALL_DATA} ${STAGING_TARGET_DIR}/etc/{gai,nscd,nsswitch}.conf ${IDIR_EGLIBC}/etc
 
 eglibc-static-install:
 	${INSTALL_DIR} $(IDIR_EGLIBC_STATIC)/usr/lib
@@ -106,13 +79,14 @@ endif
 	(cd $(WRKBUILD); \
 		${EGLIBC_ENV} \
 		$(TOOLCHAIN_BUILD_DIR)/w-$(PKG_NAME)-$(PKG_VERSION)-$(PKG_RELEASE)/$(PKG_NAME)-$(PKG_VERSION)/libc/configure \
+			--host=$(REAL_GNU_TARGET_NAME) \
 			--prefix=$(IDIR_EGLIBC_DEV)/usr \
 			--with-headers=$(IDIR_EGLIBC_DEV)/usr/include \
 			${EGLIBC_CONFOPTS} \
 	);
-	PATH='${TARGET_PATH}' $(MAKE) -C $(WRKBUILD) \
-		install-headers install-bootstrap-headers=yes
-	@touch $(IDIR_EGLIBC_DEV)/usr/include/gnu/stubs.h
+	PATH='${TARGET_PATH}' $(MAKE) -C $(WRKBUILD) install-headers install-bootstrap-headers=yes
+	touch $(IDIR_EGLIBC_DEV)/usr/include/gnu/stubs.h
+	touch $(IDIR_EGLIBC_DEV)/usr/include/gnu/stubs-{32,x32,64}.h
 	@find $(IDIR_EGLIBC_DEV) -name .install -exec rm {} \;
 	@find $(IDIR_EGLIBC_DEV) -name ..install.cmd -exec rm {} \;
 	# conflicts with libiconv

+ 39 - 12
package/glibc/Makefile

@@ -3,16 +3,17 @@
 
 include $(TOPDIR)/rules.mk
 
-TARGET_CFLAGS:=	$(filter-out -fstack-protector,$(TARGET_CFLAGS))
-TARGET_CFLAGS:=	$(filter-out -flto,$(TARGET_CFLAGS))
+TARGET_CFLAGS:=		$(filter-out -fstack-protector,$(TARGET_CFLAGS))
+TARGET_CFLAGS:=		$(filter-out -flto,$(TARGET_CFLAGS))
 
 include $(TOPDIR)/toolchain/glibc/Makefile.inc
+include $(TOPDIR)/toolchain/glibc/Makefile.multilib
 
 PKG_DESCR:=		GNU C library
 PKG_VER:=		2.16
 PKG_SECTION:=		base
 PKG_OPTS:=		noremove
-PKG_SUBPKGS:=		GLIBC GLIBC_DEV
+PKG_SUBPKGS:=		GLIBC GLIBC_DEV GLIBC_STATIC
 
 NO_DISTFILES:=		1
 
@@ -20,9 +21,10 @@ include $(TOPDIR)/mk/package.mk
 
 $(eval $(call PKG_template,GLIBC,glibc,$(PKG_VERSION)-${PKG_RELEASE},${PKG_DEPENDS},${PKG_DESCR},${PKG_SECTION},${PKG_OPTS}))
 $(eval $(call PKG_template,GLIBC_DEV,glibc-dev,$(PKG_VERSION)-${PKG_RELEASE},${PKG_DEPENDS},${PKG_DESCR},${PKG_SECTION},${PKG_OPTS}))
+$(eval $(call PKG_template,GLIBC_STATIC,$(PKG_NAME)-static,$(PKG_VERSION)-${PKG_RELEASE},${PKG_DEPENDS},${PKG_DESCR},${PKG_SECTION},${PKG_OPTS}))
 
-TARGET_CFLAGS:=	$(filter-out -fstack-protector,$(TARGET_CFLAGS))
-TARGET_CFLAGS:=	$(filter-out -flto,$(TARGET_CFLAGS))
+#TARGET_CFLAGS:=	$(filter-out -fstack-protector,$(TARGET_CFLAGS))
+#TARGET_CFLAGS:=	$(filter-out -flto,$(TARGET_CFLAGS))
 XAKE_FLAGS+=		GCC_HONOUR_COPTS=s
 
 CONFIG_STYLE:=		manual
@@ -31,24 +33,48 @@ INSTALL_STYLE:=		manual
 
 # compile nothing, glibc is already build in toolchain directory
 do-install:
-	${INSTALL_DIR} ${IDIR_GLIBC}/$(ADK_TARGET_LIBC_PATH) ${IDIR_GLIBC}/etc
-	${CP} ${STAGING_TARGET_DIR}/etc/gai.conf ${IDIR_GLIBC}/etc
-	${CP} ${STAGING_TARGET_DIR}/etc/nscd.conf ${IDIR_GLIBC}/etc
-	${CP} ${STAGING_TARGET_DIR}/etc/nsswitch.conf ${IDIR_GLIBC}/etc
-ifeq ($(ADK_TOOLCHAIN_GCC_USE_SSP),y)
-	$(CP) $(STAGING_TARGET_DIR)/lib/libssp.so* $(IDIR_GLIBC)/$(ADK_TARGET_LIBC_PATH)
-endif
+ifeq ($(ADK_TARGET_WITH_MULTILIB),y)
+	for abi in $(TABI); do \
+		${INSTALL_DIR} $(IDIR_GLIBC)/lib$${abi/*:/} $(IDIR_GLIBC)/usr/lib$${abi/*:/} ; \
+		$(CP) $(STAGING_TARGET_DIR)/lib/ld* $(IDIR_GLIBC)/lib$${abi/*:/} ; \
+		-for file in libc libcrypt libdl libm libresolv libutil libnsl libnss_dns libnss_files; do \
+			$(CP) $(STAGING_TARGET_DIR)-$${abi/*:/}/lib/$$file.so* $(IDIR_GLIBC)/lib$${abi/*:/}; \
+			$(CP) $(STAGING_TARGET_DIR)-$${abi/*:/}/lib/$$file-$(PKG_VERSION).so $(IDIR_GLIBC)/lib$${abi/*:/}; \
+		done ; \
+	done
+else
+	${INSTALL_DIR} ${IDIR_GLIBC}/$(ADK_TARGET_LIBC_PATH)
 	$(CP) $(STAGING_TARGET_DIR)/lib/ld*.so* $(IDIR_GLIBC)/$(ADK_TARGET_LIBC_PATH)
 	for file in libc libcrypt libdl libm libnsl libresolv libutil libnss_compat libnss_dns libnss_files; do \
 		$(CP) $(STAGING_TARGET_DIR)/lib/$$file.so* $(IDIR_GLIBC)/$(ADK_TARGET_LIBC_PATH); \
 		$(CP) $(STAGING_TARGET_DIR)/lib/$$file-$(PKG_VER).so $(IDIR_GLIBC)/$(ADK_TARGET_LIBC_PATH); \
 	done
+	$(CP) $(STAGING_TARGET_DIR)/usr/bin/getconf $(IDIR_GLIBC)/usr/bin
+ifeq ($(ADK_LOCALES),y)
+	$(CP) $(STAGING_TARGET_DIR)/usr/bin/locale $(IDIR_GLIBC)/usr/bin
+endif
+endif
+	${INSTALL_DIR} ${IDIR_GLIBC}/etc
+	${INSTALL_DATA} ${STAGING_TARGET_DIR}/etc/{gai,nscd,nsswitch}.conf ${IDIR_GLIBC}/etc
+
+glibc-static-install:
+	${INSTALL_DIR} $(IDIR_GLIBC_STATIC)/usr/lib
+	$(CP) $(STAGING_TARGET_DIR)/usr/lib/libc.a $(IDIR_GLIBC_STATIC)/usr/lib
 
 glibc-dev-install:
 	echo $(TARGET_CFLAGS)
 	${INSTALL_DIR} $(IDIR_GLIBC_DEV)/$(ADK_TARGET_LIBC_PATH) $(IDIR_GLIBC_DEV)/usr/lib
 	# install linker script
 	-cp ./files/libc.so.$(CPU_ARCH) $(IDIR_GLIBC_DEV)/usr/lib/libc.so
+ifeq ($(ADK_TARGET_ABI_O32),y)
+	$(SED) "s#@@ELFFORMAT@@#elf32-tradlittlemips#" $(IDIR_GLIBC_DEV)/usr/lib/libc.so
+endif
+ifeq ($(ADK_TARGET_ABI_N32),y)
+	$(SED) "s#@@ELFFORMAT@@#elf32-ntradlittlemips#" $(IDIR_GLIBC_DEV)/usr/lib/libc.so
+endif
+ifeq ($(ADK_TARGET_ABI_N64),y)
+	$(SED) "s#@@ELFFORMAT@@#elf64-tradlittlemips#" $(IDIR_GLIBC_DEV)/usr/lib/libc.so
+endif
 	${CP} ${STAGING_TARGET_DIR}/usr/lib/crt* ${IDIR_GLIBC_DEV}/usr/lib
 	${CP} ${STAGING_TARGET_DIR}/usr/lib/libc_nonshared.a ${IDIR_GLIBC_DEV}/usr/lib
 	-for file in libcrypt libdl libm libresolv libutil; do \
@@ -69,6 +95,7 @@ glibc-dev-install:
 	);
 	$(GLIBC_ENV) $(MAKE) -C $(WRKBUILD) cross-compiling=yes install-headers
 	touch $(IDIR_GLIBC_DEV)/usr/include/gnu/stubs.h
+	touch $(IDIR_GLIBC_DEV)/usr/include/gnu/stubs-{32,x32,64}.h
 	touch $(IDIR_GLIBC_DEV)/usr/include/bits/stdio_lim.h
 	# WORKAROUND: bits/syscall.h is only installed via install-others target
 	$(CP) $(STAGING_TARGET_DIR)/usr/include/bits/syscall.h \

+ 8 - 0
package/libgcc/Makefile

@@ -26,5 +26,13 @@ ifeq ($(ADK_NATIVE),)
 	${INSTALL_DIR} ${IDIR_LIBGCC}/$(ADK_TARGET_LIBC_PATH)
 	${CP} ${STAGING_TARGET_DIR}/lib/libgcc*.so* ${IDIR_LIBGCC}/$(ADK_TARGET_LIBC_PATH)
 endif
+ifeq ($(ADK_TARGET_MULTILIB_X86_32),y)
+	${INSTALL_DIR} ${IDIR_LIBGCC}/lib32
+	${CP} ${STAGING_TARGET_DIR_32}/lib/libgcc*.so* ${IDIR_LIBGCC}/lib32
+endif
+ifeq ($(ADK_TARGET_MULTILIB_X86_X32),y)
+	${INSTALL_DIR} ${IDIR_LIBGCC}/libx32
+	${CP} ${STAGING_TARGET_DIR_X32}/lib/libgcc*.so* ${IDIR_LIBGCC}/libx32
+endif
 
 include ${TOPDIR}/mk/pkg-bottom.mk

+ 2 - 2
package/librt/Makefile

@@ -40,8 +40,8 @@ INSTALL_STYLE:=		manual
 
 librt-install:
 ifeq ($(ADK_NATIVE),)
-	${INSTALL_DIR} ${IDIR_LIBR}/$(ADK_TARGET_LIBC_PATH)
-	${CP} ${STAGING_TARGET_DIR}/lib/librt*.so* ${IDIR_LIBR}/$(ADK_TARGET_LIBC_PATH)
+	${INSTALL_DIR} ${IDIR_LIBRT}/$(ADK_TARGET_LIBC_PATH)
+	${CP} ${STAGING_TARGET_DIR}/lib/librt*.so* ${IDIR_LIBRT}/$(ADK_TARGET_LIBC_PATH)
 endif
 
 include ${TOPDIR}/mk/pkg-bottom.mk

+ 47 - 0
package/libssp/Makefile

@@ -0,0 +1,47 @@
+# This file is part of the OpenADK project. OpenADK is copyrighted
+# material, please see the LICENCE file in the top-level directory.
+
+include ${TOPDIR}/rules.mk
+
+ifeq ($(ADK_TARGET_LIB_GLIBC),y)
+include ${TOPDIR}/toolchain/glibc/Makefile.inc
+endif
+ifeq ($(ADK_TARGET_LIB_EGLIBC),y)
+include ${TOPDIR}/toolchain/eglibc/Makefile.inc
+endif
+ifeq ($(ADK_TARGET_LIB_UCLIBC),y)
+include ${TOPDIR}/toolchain/uClibc/Makefile.inc
+endif
+ifeq ($(ADK_NATIVE),y)
+PKG_VERSION:=		1.0
+PKG_RELEASE:=		1
+endif
+
+PKG_NAME:=		libssp
+PKG_DESCR:=		Stack smashing protection library
+PKG_SECTION:=		libs
+PKG_OPTS:=		noremove
+
+NO_DISTFILES:=		1
+
+PKG_SUBPKGS:=		LIBSSP
+
+ifeq ($(ADK_STATIC),y)
+PKG_OPTS+=		libonly
+endif
+
+include ${TOPDIR}/mk/package.mk
+
+$(eval $(call PKG_template,LIBSSP,libssp,${PKG_VERSION}-${PKG_RELEASE},${PKG_DEPENDS},${PKG_DESCR},${PKG_SECTION},${PKG_OPTS}))
+
+CONFIG_STYLE:=		manual
+BUILD_STYLE:=		manual
+INSTALL_STYLE:=		manual
+
+libssp-install:
+ifeq ($(ADK_NATIVE),)
+	${INSTALL_DIR} ${IDIR_LIBSSP}/$(ADK_TARGET_LIBC_PATH)
+	${CP} ${STAGING_TARGET_DIR}/lib/libssp.so* ${IDIR_LIBSSP}/$(ADK_TARGET_LIBC_PATH)
+endif
+
+include ${TOPDIR}/mk/pkg-bottom.mk

+ 8 - 18
target/config/Config.in

@@ -92,14 +92,17 @@ depends on ADK_TARGET_KERNEL64 && ADK_LINUX_X86_64
 config ADK_TARGET_ABI_64
 	boolean "64 Bit ABI"
 	select ADK_64
+	select ADK_TARGET_MULTILIB_X86_64 if ADK_TARGET_WITH_MULTILIB
 
 config ADK_TARGET_ABI_X32
 	boolean "x32 ABI (new)"
 	select ADK_x32
+	select ADK_TARGET_MULTILIB_X86_X32 if ADK_TARGET_WITH_MULTILIB
 
 config ADK_TARGET_ABI_32
 	boolean "32 Bit ABI"
 	select ADK_32
+	select ADK_TARGET_MULTILIB_X86_32 if ADK_TARGET_WITH_MULTILIB
 
 endchoice
 
@@ -126,32 +129,17 @@ config ADK_TARGET_WITH_MULTILIB
 config ADK_TARGET_MULTILIB_X86_64
 	boolean "64 bit libraries"
 	depends on ADK_LINUX_X86_64 && ADK_TARGET_WITH_MULTILIB
-	default y
+	default y if ADK_64
 	
 config ADK_TARGET_MULTILIB_X86_32
 	boolean "32 bit libraries"
 	depends on ADK_LINUX_X86_64 && ADK_TARGET_WITH_MULTILIB
+	default y if ADK_32
 
 config ADK_TARGET_MULTILIB_X86_X32
 	boolean "x32 bit libraries"
 	depends on ADK_LINUX_X86_64 && ADK_TARGET_WITH_MULTILIB
-
-choice
-prompt "Default Library (compile all applications with this library)"
-config ADK_TARGET_MULTILIB_X86_64_DEF
-	boolean "64 Bit libraries as default"
-	depends on ADK_TARGET_MULTILIB_X86_64
-
-config ADK_TARGET_MULTILIB_X86_32_DEF
-	boolean "32 Bit libraries as default"
-	depends on ADK_TARGET_MULTILIB_X86_32
-
-config ADK_TARGET_MULTILIB_X86_X32_DEF
-	boolean "x32 Bit libraries as default"
-	depends on ADK_TARGET_MULTILIB_X86_X32
-
-endchoice
-endmenu
+	default y if ADK_x32
 
 config ADK_MULTILIB_TARGET
 	string
@@ -178,6 +166,8 @@ config ADK_MULTILIB_TARGET
 			&& ADK_TARGET_MULTILIB_X86_X32
 	
 
+endmenu
+
 # submodel support
 #
 choice

+ 5 - 1
target/x86_64/target.mk

@@ -2,4 +2,8 @@ include $(TOPDIR)/mk/kernel-ver.mk
 ARCH:=			x86
 CPU_ARCH:=		x86_64
 TARGET_OPTIMIZATION:=	-O2 -pipe
-TARGET_CFLAGS_ARCH:=	$(ADK_TARGET_CFLAGS)
+ifeq ($(ADK_TARGET_WITH_MULTILIB),y)
+TARGET_CFLAGS_ARCH:=    $(ADK_TARGET_CFLAGS)
+else
+TARGET_CFLAGS_ARCH:=    $(ADK_TARGET_CFLAGS) $(ADK_TARGET_ABI_CFLAGS)
+endif

+ 101 - 102
toolchain/eglibc/Makefile

@@ -4,53 +4,55 @@
 include $(TOPDIR)/rules.mk
 include ../rules.mk
 include Makefile.inc
+include Makefile.multilib
 include ${TOPDIR}/mk/buildhlp.mk
 
 ifneq ($(ADK_DEBUG),)
 TARGET_CFLAGS+=		-O2
 endif
 # ssp partially supported
-TARGET_CFLAGS:= $(filter-out -fstack-protector,$(TARGET_CFLAGS))
-
-EGLIBC_CONFOPTS:=	--build=$(GNU_HOST_NAME) \
-			--without-cvs \
-			--disable-profile \
-			--disable-debug \
-			--enable-kernel=2.6.0 \
-			--without-gd \
-			--with-__thread \
-			--with-tls \
-			--enable-add-ons \
-			$(NLS)
-
-EGLIBC_ENV:=		PATH='${TARGET_PATH}' \
-			BUILD_CC=${CC_FOR_BUILD} \
-			CFLAGS="$(TARGET_CFLAGS)" \
-			CC=${REAL_GNU_TARGET_NAME}-gcc \
-			CXX=${REAL_GNU_TARGET_NAME}-g++ \
-			AR=${REAL_GNU_TARGET_NAME}-ar \
-			RANLIB=${REAL_GNU_TARGET_NAME}-ranlib \
-			libc_cv_cc_with_libunwind=no \
-			libc_cv_forced_unwind=yes \
-			libc_cv_c_cleanup=yes \
-			libc_cv_gnu99_inline=yes \
-			libc_cv_initfini_array=yes \
-			libc_cv_slibdir="/lib"
+TARGET_CFLAGS:= 	$(filter-out -fstack-protector,$(TARGET_CFLAGS))
 
 ifeq ($(ADK_TARGET_NO_FPU),y)
 EGLIBC_CONFOPTS+=       --without-fp
 endif
 
 EGLIBC_BUILD_DIR_INITIAL:=	${WRKDIR}/$(PKG_NAME)-$(PKG_VERSION)-headers
-EGLIBC_BUILD_DIR_INITIAL32:=	${WRKDIR}/$(PKG_NAME)-$(PKG_VERSION)-headers32
 EGLIBC_BUILD_DIR_FINAL:=	${WRKDIR}/$(PKG_NAME)-$(PKG_VERSION)-final
-EGLIBC_BUILD_DIR_FINAL32:=	${WRKDIR}/$(PKG_NAME)-$(PKG_VERSION)-final32
 
 ifeq ($(ADK_TARGET_WITH_MULTILIB),y)
-$(WRKBUILD)/.headers_configure: $(WRKBUILD)/.headers_configure32
+$(WRKBUILD)/.headers_configure: 
+	for abi in $(TABI); do \
+		mkdir -p $(EGLIBC_BUILD_DIR_INITIAL)-$${abi/*:/}; \
+		(cd ${WRKDIR}/$(PKG_NAME)-$(PKG_VERSION); \
+			ln -sf ../ports ${WRKDIR}/$(PKG_NAME)-$(PKG_VERSION)/libc); \
+		$(CP) ${TOPDIR}/toolchain/eglibc/eglibc.config \
+			$(EGLIBC_BUILD_DIR_INITIAL)-$${abi/*:/}/option-groups.config; \
+		(cd $(EGLIBC_BUILD_DIR_INITIAL)-$${abi/*:/}; \
+			${EGLIBC_ENV} \
+			CC="${REAL_GNU_TARGET_NAME}-gcc -m$${abi/*:/}" \
+			$(WRKBUILD)/libc/configure \
+				--prefix=$(STAGING_TARGET_DIR)-$${abi/*:/}/usr \
+				--with-headers=$(STAGING_TARGET_DIR)-$${abi/*:/}/usr/include \
+				--host=$${abi/:*/} \
+				${EGLIBC_CONFOPTS} \
+		); \
+	done
+	touch $@
+
+$(WRKBUILD)/.headers: $(WRKBUILD)/.headers_configure
+	for abi in $(TABI); do \
+		(cd $(EGLIBC_BUILD_DIR_INITIAL)-$${abi/*:/}; \
+			${EGLIBC_ENV} \
+			CC="${REAL_GNU_TARGET_NAME}-gcc -m$${abi/*:/}" \
+			$(MAKE) install-headers install-bootstrap-headers=yes cross-compiling=yes \
+		); \
+		touch $(STAGING_TARGET_DIR)-$${abi/*:/}/usr/include/gnu/stubs.h; \
+		touch $(STAGING_TARGET_DIR)-$${abi/*:/}/usr/include/gnu/stubs-{32,x32,64}.h; \
+	done
+	touch $@
 else
 $(WRKBUILD)/.headers_configure:
-endif
 	mkdir -p $(EGLIBC_BUILD_DIR_INITIAL)
 	(cd ${WRKDIR}/$(PKG_NAME)-$(PKG_VERSION); \
 		ln -sf ../ports ${WRKDIR}/$(PKG_NAME)-$(PKG_VERSION)/libc);
@@ -58,6 +60,7 @@ endif
 		$(EGLIBC_BUILD_DIR_INITIAL)/option-groups.config
 	(cd $(EGLIBC_BUILD_DIR_INITIAL); \
 		${EGLIBC_ENV} \
+		CC="${REAL_GNU_TARGET_NAME}-gcc $(ADK_TARGET_ABI_CFLAGS)" \
 		$(WRKBUILD)/libc/configure \
 			--prefix=$(STAGING_TARGET_DIR)/usr \
 			--with-headers=$(STAGING_TARGET_DIR)/usr/include \
@@ -68,38 +71,14 @@ endif
 
 $(WRKBUILD)/.headers: $(WRKBUILD)/.headers_configure
 	(cd $(EGLIBC_BUILD_DIR_INITIAL); \
-		PATH='${TARGET_PATH}' \
 		${EGLIBC_ENV} \
+		CC="${REAL_GNU_TARGET_NAME}-gcc $(ADK_TARGET_ABI_CFLAGS)" \
 		$(MAKE) install-headers install-bootstrap-headers=yes cross-compiling=yes \
 	);
 	touch $(STAGING_TARGET_DIR)/usr/include/gnu/stubs.h
-	touch $(STAGING_TARGET_DIR)/usr/include/gnu/stubs-64.h
-	touch $@
-
-$(WRKBUILD)/.headers_configure32:
-	mkdir -p $(EGLIBC_BUILD_DIR_INITIAL32)
-	(cd ${WRKDIR}/$(PKG_NAME)-$(PKG_VERSION); \
-		ln -sf ../ports ${WRKDIR}/$(PKG_NAME)-$(PKG_VERSION)/libc);
-	$(CP) ${TOPDIR}/toolchain/eglibc/eglibc.config \
-		$(EGLIBC_BUILD_DIR_INITIAL32)/option-groups.config
-	(cd $(EGLIBC_BUILD_DIR_INITIAL32); \
-		${EGLIBC_ENV} \
-		CC='${REAL_GNU_TARGET_NAME}-gcc -m32' \
-		$(WRKBUILD)/libc/configure \
-			--prefix=$(STAGING_TARGET_DIR_32)/usr \
-			--with-headers=$(STAGING_TARGET_DIR_32)/usr/include \
-			--host=i486-openadk-linux-gnu \
-			${EGLIBC_CONFOPTS} \
-	);
-	(cd $(EGLIBC_BUILD_DIR_INITIAL32); \
-		PATH='${TARGET_PATH}' \
-		${EGLIBC_ENV} \
-		CC='${REAL_GNU_TARGET_NAME}-gcc -m32' \
-		$(MAKE) install-headers install-bootstrap-headers=yes cross-compiling=yes \
-	);
-	touch $(STAGING_TARGET_DIR_32)/usr/include/gnu/stubs.h
-	touch $(STAGING_TARGET_DIR_32)/usr/include/gnu/stubs-64.h
+	touch $(STAGING_TARGET_DIR)/usr/include/gnu/stubs-{32,x32,64}.h
 	touch $@
+endif
 
 ifeq ($(ADK_TOOLCHAIN_GCC_USE_SSP),y)
 EGLIBC_ENV+=		libc_cv_ssp=yes
@@ -108,15 +87,70 @@ EGLIBC_ENV+=		libc_cv_ssp=no
 endif
 
 ifeq ($(ADK_TARGET_WITH_MULTILIB),y)
-$(WRKBUILD)/.configured: $(WRKBUILD)/.configured32
-else
 $(WRKBUILD)/.configured:
+	for abi in $(TABI); do \
+		mkdir -p $(EGLIBC_BUILD_DIR_FINAL)-$${abi/*:/} ;\
+		$(CP) ${TOPDIR}/toolchain/eglibc/eglibc.config \
+			$(EGLIBC_BUILD_DIR_FINAL)-$${abi/*:/}/option-groups.config ;\
+		(cd $(EGLIBC_BUILD_DIR_FINAL)-$${abi/*:/}; \
+			${EGLIBC_ENV} \
+			CC="${REAL_GNU_TARGET_NAME}-gcc -m$${abi/*:/}" \
+			$(WRKBUILD)/libc/configure \
+				--prefix=/usr \
+				--enable-shared \
+				--enable-stackguard-randomization \
+				--host=$${abi/:*/} \
+				${EGLIBC_CONFOPTS} \
+		); \
+	done
+	touch $@
+
+$(EGLIBC_BUILD_DIR_FINAL)/libc.so:
+$(WRKBUILD)/.compiled: $(WRKBUILD)/.configured
+	for abi in $(TABI); do \
+		${EGLIBC_ENV} $(MAKE) -C $(EGLIBC_BUILD_DIR_FINAL)-$${abi/*:/} cross-compiling=yes all ;\
+	done
+	touch $@
+
+$(WRKBUILD)/.installed: $(EGLIBC_BUILD_DIR_FINAL)/libc.so
+	for abi in $(TABI); do \
+		${EGLIBC_ENV} $(MAKE) -C $(EGLIBC_BUILD_DIR_FINAL)-$${abi/*:/} install_root=$(STAGING_TARGET_DIR)-$${abi/*:/} install ;\
+	done
+ifeq ($(ADK_TARGET_ABI_64),y)
+	${EGLIBC_ENV} $(MAKE) -C $(EGLIBC_BUILD_DIR_FINAL)-64 install_root=$(STAGING_TARGET_DIR) install
+endif
+ifeq ($(ADK_TARGET_ABI_32),y)
+	${EGLIBC_ENV} $(MAKE) -C $(EGLIBC_BUILD_DIR_FINAL)-32 install_root=$(STAGING_TARGET_DIR) install
+endif
+ifeq ($(ADK_TARGET_ABI_X32),y)
+	${EGLIBC_ENV} $(MAKE) -C $(EGLIBC_BUILD_DIR_FINAL)-x32 install_root=$(STAGING_TARGET_DIR) install
 endif
+	touch $(STAGING_TARGET_DIR)/usr/include/gnu/stubs.h
+	touch $(STAGING_TARGET_DIR)/usr/include/gnu/stubs-{32,x32,64}.h
+	# for libgcc build we need C library files, 64 bit default
+	mkdir -p $(STAGING_TARGET_DIR)/lib/$(REAL_GNU_TARGET_NAME)/4.7.2 ; \
+	$(CP) $(STAGING_TARGET_DIR)-64/lib/* $(STAGING_TARGET_DIR)-64/usr/lib/* \
+		$(STAGING_TARGET_DIR)/lib/$(REAL_GNU_TARGET_NAME)/4.7.2/; \
+	rm $(STAGING_TARGET_DIR)/lib/$(REAL_GNU_TARGET_NAME)/4.7.2/libc.so ; \
+	-for abi in $(TABI); do \
+		mkdir -p $(STAGING_TARGET_DIR)/lib/$(REAL_GNU_TARGET_NAME)/4.7.2/$${abi/*:/} ; \
+		$(CP) $(STAGING_TARGET_DIR)-$${abi/*:/}/lib/* $(STAGING_TARGET_DIR)-$${abi/*:/}/usr/lib/* \
+			$(STAGING_TARGET_DIR)/lib/$(REAL_GNU_TARGET_NAME)/4.7.2/$${abi/*:/} ; \
+		rm $(STAGING_TARGET_DIR)/lib/$(REAL_GNU_TARGET_NAME)/4.7.2/$${abi/*:/}/libc.so ; \
+	done
+	${INSTALL_DIR} ${STAGING_TARGET_DIR}/etc
+	${INSTALL_DATA} ${WRKBUILD}/libc/posix/gai.conf ${STAGING_TARGET_DIR}/etc/
+	${INSTALL_DATA} ${WRKBUILD}/libc/nscd/nscd.conf ${STAGING_TARGET_DIR}/etc/
+	${INSTALL_DATA} ${WRKBUILD}/libc/nss/nsswitch.conf ${STAGING_TARGET_DIR}/etc/
+	touch $@
+else
+$(WRKBUILD)/.configured:
 	mkdir -p $(EGLIBC_BUILD_DIR_FINAL)
 	$(CP) ${TOPDIR}/toolchain/eglibc/eglibc.config \
 		$(EGLIBC_BUILD_DIR_FINAL)/option-groups.config
 	(cd $(EGLIBC_BUILD_DIR_FINAL); \
 		${EGLIBC_ENV} \
+		CC="${REAL_GNU_TARGET_NAME}-gcc $(ADK_TARGET_ABI_CFLAGS)" \
 		$(WRKBUILD)/libc/configure \
 			--prefix=/usr \
 			--enable-shared \
@@ -128,55 +162,20 @@ endif
 
 $(EGLIBC_BUILD_DIR_FINAL)/libc.so:
 $(WRKBUILD)/.compiled: $(WRKBUILD)/.configured
-	${EGLIBC_ENV} $(MAKE) -C $(EGLIBC_BUILD_DIR_FINAL) cross-compiling=yes all
+	${EGLIBC_ENV} \
+	CC="${REAL_GNU_TARGET_NAME}-gcc $(ADK_TARGET_ABI_CFLAGS)" \
+		$(MAKE) -C $(EGLIBC_BUILD_DIR_FINAL) cross-compiling=yes all
 	touch $@
 
 $(WRKBUILD)/.installed: $(EGLIBC_BUILD_DIR_FINAL)/libc.so
-	${EGLIBC_ENV} $(MAKE) -C $(EGLIBC_BUILD_DIR_FINAL) install_root=$(STAGING_TARGET_DIR) install
+	${EGLIBC_ENV} \
+	CC="${REAL_GNU_TARGET_NAME}-gcc $(ADK_TARGET_ABI_CFLAGS)" \
+		$(MAKE) -C $(EGLIBC_BUILD_DIR_FINAL) install_root=$(STAGING_TARGET_DIR) install
+	${INSTALL_DIR} ${STAGING_TARGET_DIR}/etc
 	${INSTALL_DATA} ${WRKBUILD}/libc/posix/gai.conf ${STAGING_TARGET_DIR}/etc/
 	${INSTALL_DATA} ${WRKBUILD}/libc/nscd/nscd.conf ${STAGING_TARGET_DIR}/etc/
 	${INSTALL_DATA} ${WRKBUILD}/libc/nss/nsswitch.conf ${STAGING_TARGET_DIR}/etc/
 	touch $@
-
-$(WRKBUILD)/.configured32:
-	mkdir -p $(EGLIBC_BUILD_DIR_FINAL32)
-	$(CP) ${TOPDIR}/toolchain/eglibc/eglibc.config \
-		$(EGLIBC_BUILD_DIR_FINAL32)/option-groups.config
-	(cd $(EGLIBC_BUILD_DIR_FINAL32); \
-		${EGLIBC_ENV} \
-		CC='${REAL_GNU_TARGET_NAME}-gcc -m32' \
-		$(WRKBUILD)/libc/configure \
-			--prefix=/usr \
-			--enable-shared \
-			--enable-stackguard-randomization \
-			--host=i486-openadk-linux-gnu \
-			${EGLIBC_CONFOPTS} \
-	);
-	${EGLIBC_ENV} $(MAKE) -C $(EGLIBC_BUILD_DIR_FINAL32) cross-compiling=yes all
-	${EGLIBC_ENV} $(MAKE) -C $(EGLIBC_BUILD_DIR_FINAL32) install_root=$(STAGING_TARGET_DIR_32) install
-	mkdir -p $(STAGING_TARGET_DIR)/lib/$(REAL_GNU_TARGET_NAME)/4.7.2/32
-	$(CP) $(STAGING_TARGET_DIR_32)/lib/* $(STAGING_TARGET_DIR_32)/usr/lib/* \
-		$(STAGING_TARGET_DIR)/lib/$(REAL_GNU_TARGET_NAME)/4.7.2/32
-	-rm $(STAGING_TARGET_DIR)/lib/$(REAL_GNU_TARGET_NAME)/4.7.2/32/libc.so
-	touch $@
-
-$(WRKBUILD)/.configuredx32:
-	mkdir -p $(EGLIBC_BUILD_DIR_FINALX32)
-	$(CP) ${TOPDIR}/toolchain/eglibc/eglibc.config \
-		$(EGLIBC_BUILD_DIR_FINALX32)/option-groups.config
-	(cd $(EGLIBC_BUILD_DIR_FINALX32); \
-		${EGLIBC_ENV} \
-		CC=${REAL_GNU_TARGET_NAME}-gcc -mx32 \
-		$(WRKBUILD)/libc/configure \
-			--prefix=/usr \
-			--enable-shared \
-			--enable-stackguard-randomization \
-			--host=x86_64-x32-openadk-linux-gnu \
-			${EGLIBC_CONFOPTS} \
-	);
-	${EGLIBC_ENV} $(MAKE) -C $(EGLIBC_BUILD_DIR_FINALX32) cross-compiling=yes all
-	${EGLIBC_ENV} $(MAKE) -C $(EGLIBC_BUILD_DIR_FINALX32) install_root=$(STAGING_TARGET_DIR_X32) install
-	touch $@
-
+endif
 
 include ${TOPDIR}/mk/toolchain.mk

+ 26 - 0
toolchain/eglibc/Makefile.inc

@@ -6,3 +6,29 @@ PKG_VERSION:=		2.16
 PKG_RELEASE:=		1
 PKG_MD5SUM:=		97b0956c312e747dcead4c9459ac2aa5
 PKG_SITES:=		http://openadk.org/distfiles/
+EGLIBC_CONFOPTS:=	--build=$(GNU_HOST_NAME) \
+			--without-cvs \
+			--disable-profile \
+			--disable-debug \
+			--enable-kernel=2.6.0 \
+			--without-gd \
+			--with-__thread \
+			--with-tls \
+			--enable-add-ons \
+			$(NLS)
+
+EGLIBC_ENV:=		PATH='${TARGET_PATH}' \
+			BUILD_CC=${CC_FOR_BUILD} \
+			GCC_HONOUR_COPTS=s \
+			CFLAGS="$(TARGET_CFLAGS)" \
+			CC=${REAL_GNU_TARGET_NAME}-gcc \
+			CXX=${REAL_GNU_TARGET_NAME}-g++ \
+			AR=${REAL_GNU_TARGET_NAME}-ar \
+			RANLIB=${REAL_GNU_TARGET_NAME}-ranlib \
+			libc_cv_cc_with_libunwind=no \
+			libc_cv_forced_unwind=yes \
+			libc_cv_c_cleanup=yes \
+			libc_cv_gnu99_inline=yes \
+			libc_cv_initfini_array=yes \
+			libc_cv_slibdir="/lib"
+

+ 13 - 0
toolchain/eglibc/Makefile.multilib

@@ -0,0 +1,13 @@
+# multilib support
+ifeq ($(ADK_TARGET_WITH_MULTILIB),y)
+TABI:=
+ifeq ($(ADK_TARGET_MULTILIB_X86_X32),y)
+TABI+=x86_64-openadk-linux-gnu:x32
+endif
+ifeq ($(ADK_TARGET_MULTILIB_X86_32),y)
+TABI+=i486-openadk-linux-gnu:32
+endif
+ifeq ($(ADK_TARGET_MULTILIB_X86_64),y)
+TABI+=x86_64-openadk-linux-gnu:64
+endif
+endif

+ 90 - 5
toolchain/glibc/Makefile

@@ -15,6 +15,7 @@ TARGET_CFLAGS:=	$(filter-out -fstack-protector,$(TARGET_CFLAGS))
 #TARGET_CFLAGS:=	$(filter-out -flto,$(TARGET_CFLAGS))
 
 include Makefile.inc
+include Makefile.multilib
 include ${TOPDIR}/mk/buildhlp.mk
 
 ifeq ($(ADK_TARGET_NO_FPU),y)
@@ -29,6 +30,36 @@ endif
 GLIBC_BUILD_DIR_INITIAL:=	${WRKDIR}/$(PKG_NAME)-$(PKG_VERSION)-headers
 GLIBC_BUILD_DIR_FINAL:=		${WRKDIR}/$(PKG_NAME)-$(PKG_VERSION)-final
 
+ifeq ($(ADK_TARGET_WITH_MULTILIB),y)
+$(WRKBUILD)/.headers_configure: 
+	for abi in $(TABI); do \
+		mkdir -p $(GLIBC_BUILD_DIR_INITIAL)-$${abi/*:/}; \
+		(cd ${WRKDIR}/$(PKG_NAME)-$(PKG_VERSION); \
+			ln -sf ../../w-glibc-ports-$(PKG_VERSION)-1/glibc-ports-$(PKG_VERSION)/ ports); \
+		(cd $(GLIBC_BUILD_DIR_INITIAL)-$${abi/*:/}; \
+			${GLIBC_ENV} \
+			CC="${REAL_GNU_TARGET_NAME}-gcc -m$${abi/*:/}" \
+			$(WRKBUILD)/libc/configure \
+				--prefix=$(STAGING_TARGET_DIR)-$${abi/*:/}/usr \
+				--with-sysroot=$(STAGING_TARGET_DIR)-$${abi/*:/} \
+				--host=$${abi/:*/} \
+				${GLIBC_CONFOPTS} \
+		); \
+	done
+	touch $@
+
+$(WRKBUILD)/.headers: $(WRKBUILD)/.headers_configure
+	for abi in $(TABI); do \
+		(cd $(GLIBC_BUILD_DIR_INITIAL)-$${abi/*:/}; \
+			${GLIBC_ENV} \
+			CC="${REAL_GNU_TARGET_NAME}-gcc -m$${abi/*:/}" \
+			$(MAKE) ${GLIBC_MAKEOPTS} install-headers \
+		); \
+	done
+	touch $(STAGING_TARGET_DIR)/usr/include/gnu/stubs.h
+	touch $(STAGING_TARGET_DIR)/usr/include/gnu/stubs-{32,x32,64}.h
+	touch $@
+else
 $(WRKBUILD)/.headers_configure:
 	mkdir -p $(GLIBC_BUILD_DIR_INITIAL)
 	(cd ${WRKDIR}/$(PKG_NAME)-$(PKG_VERSION); \
@@ -45,12 +76,67 @@ $(WRKBUILD)/.headers_configure:
 $(WRKBUILD)/.headers: $(WRKBUILD)/.headers_configure
 	(cd $(GLIBC_BUILD_DIR_INITIAL); \
 		${GLIBC_ENV} \
-		$(MAKE) ${GLIBC_MAKEOPTS} \
-		install-headers \
+		$(MAKE) ${GLIBC_MAKEOPTS} install-headers \
 	);
 	touch $(STAGING_TARGET_DIR)/usr/include/gnu/stubs.h
+	touch $(STAGING_TARGET_DIR)/usr/include/gnu/stubs-{32,x32,64}.h
+	touch $@
+endif
+
+ifeq ($(ADK_TARGET_WITH_MULTILIB),y)
+$(WRKBUILD)/.configured:
+	for abi in $(TABI); do \
+		mkdir -p $(GLIBC_BUILD_DIR_FINAL)-$${abi/*:/} ;\
+		(cd $(GLIBC_BUILD_DIR_FINAL)-$${abi/*:/}; \
+			${GLIBC_ENV} \
+			CC="${REAL_GNU_TARGET_NAME}-gcc -m$${abi/*:/}" \
+			$(WRKBUILD)/libc/configure \
+				--prefix=/usr \
+				--enable-shared \
+				--enable-stackguard-randomization \
+				--host=$${abi/:*/} \
+				${GLIBC_CONFOPTS} \
+		); \
+	done
 	touch $@
 
+$(GLIBC_BUILD_DIR_FINAL)/libc.so:
+$(WRKBUILD)/.compiled: $(WRKBUILD)/.configured
+	for abi in $(TABI); do \
+		${GLIBC_ENV} $(MAKE) ${GLIBC_MAKEOPTS} -C $(GLIBC_BUILD_DIR_FINAL)-$${abi/*:/} all ;\
+	done
+	touch $@
+
+$(WRKBUILD)/.installed: $(GLIBC_BUILD_DIR_FINAL)/libc.so
+	for abi in $(TABI); do \
+		${GLIBC_ENV} $(MAKE) -C $(GLIBC_BUILD_DIR_FINAL)-$${abi/*:/} install_root=$(STAGING_TARGET_DIR)-$${abi/*:/} install ;\
+	done
+ifeq ($(ADK_TARGET_ABI_64),y)
+	${GLIBC_ENV} $(MAKE) -C $(GLIBC_BUILD_DIR_FINAL)-64 install_root=$(STAGING_TARGET_DIR) install
+endif
+ifeq ($(ADK_TARGET_ABI_32),y)
+	${GLIBC_ENV} $(MAKE) -C $(GLIBC_BUILD_DIR_FINAL)-32 install_root=$(STAGING_TARGET_DIR) install
+endif
+ifeq ($(ADK_TARGET_ABI_X32),y)
+	${GLIBC_ENV} $(MAKE) -C $(GLIBC_BUILD_DIR_FINAL)-x32 install_root=$(STAGING_TARGET_DIR) install
+endif
+	# for libgcc build we need C library files, 64 bit default
+	mkdir -p $(STAGING_TARGET_DIR)/lib/$(REAL_GNU_TARGET_NAME)/4.7.2 ; \
+	$(CP) $(STAGING_TARGET_DIR)-64/lib/* $(STAGING_TARGET_DIR)-64/usr/lib/* \
+		$(STAGING_TARGET_DIR)/lib/$(REAL_GNU_TARGET_NAME)/4.7.2/; \
+	rm $(STAGING_TARGET_DIR)/lib/$(REAL_GNU_TARGET_NAME)/4.7.2/libc.so ; \
+	-for abi in $(TABI); do \
+		mkdir -p $(STAGING_TARGET_DIR)/lib/$(REAL_GNU_TARGET_NAME)/4.7.2/$${abi/*:/} ; \
+		$(CP) $(STAGING_TARGET_DIR)-$${abi/*:/}/lib/* $(STAGING_TARGET_DIR)-$${abi/*:/}/usr/lib/* \
+			$(STAGING_TARGET_DIR)/lib/$(REAL_GNU_TARGET_NAME)/4.7.2/$${abi/*:/} ; \
+		rm $(STAGING_TARGET_DIR)/lib/$(REAL_GNU_TARGET_NAME)/4.7.2/$${abi/*:/}/libc.so ; \
+	done
+	mkdir -p ${STAGING_TARGET_DIR}/etc
+	${INSTALL_DATA} ${WRKBUILD}/libc/posix/gai.conf ${STAGING_TARGET_DIR}/etc/
+	${INSTALL_DATA} ${WRKBUILD}/libc/nscd/nscd.conf ${STAGING_TARGET_DIR}/etc/
+	${INSTALL_DATA} ${WRKBUILD}/libc/nss/nsswitch.conf ${STAGING_TARGET_DIR}/etc/
+	touch $@
+else
 $(WRKBUILD)/.configured:
 	mkdir -p $(GLIBC_BUILD_DIR_FINAL)
 	(cd $(GLIBC_BUILD_DIR_FINAL); \
@@ -68,13 +154,12 @@ $(WRKBUILD)/.compiled:
 	touch $@
 
 $(WRKBUILD)/.installed:
-	${GLIBC_ENV} $(MAKE) -C $(GLIBC_BUILD_DIR_FINAL) \
-		install_root=$(STAGING_TARGET_DIR) install
+	${GLIBC_ENV} $(MAKE) -C $(GLIBC_BUILD_DIR_FINAL) install_root=$(STAGING_TARGET_DIR) install
 	mkdir -p ${STAGING_TARGET_DIR}/etc
 	${INSTALL_DATA} ${WRKBUILD}/posix/gai.conf ${STAGING_TARGET_DIR}/etc
 	${INSTALL_DATA} ${WRKBUILD}/nscd/nscd.conf ${STAGING_TARGET_DIR}/etc
 	${INSTALL_DATA} ${WRKBUILD}/nss/nsswitch.conf ${STAGING_TARGET_DIR}/etc
-	touch $(STAGING_TARGET_DIR)/usr/include/gnu/stubs.h
 	touch $@
+endif
 
 include ${TOPDIR}/mk/toolchain.mk

+ 13 - 0
toolchain/glibc/Makefile.multilib

@@ -0,0 +1,13 @@
+# multilib support
+ifeq ($(ADK_TARGET_WITH_MULTILIB),y)
+TABI:=
+ifeq ($(ADK_TARGET_MULTILIB_X86_X32),y)
+TABI+=x86_64-openadk-linux-gnu:x32
+endif
+ifeq ($(ADK_TARGET_MULTILIB_X86_32),y)
+TABI+=i486-openadk-linux-gnu:32
+endif
+ifeq ($(ADK_TARGET_MULTILIB_X86_64),y)
+TABI+=x86_64-openadk-linux-gnu:64
+endif
+endif

+ 9 - 1
toolchain/kernel-headers/Makefile

@@ -10,9 +10,17 @@ $(WRKBUILD)/.headers:
 	$(MAKE) -C $(WRKBUILD) HOSTCC=$(CC_FOR_BUILD) ARCH=$(ARCH) V=1 \
 		INSTALL_HDR_PATH=$(STAGING_DIR)/usr \
 		headers_install
+ifeq ($(ADK_TARGET_WITH_MULTILIB),y)
 	$(MAKE) -C $(WRKBUILD) HOSTCC=$(CC_FOR_BUILD) ARCH=x86 V=1 \
-		INSTALL_HDR_PATH=$(STAGING_TARGET_DIR_32)/usr \
+		INSTALL_HDR_PATH=$(STAGING_TARGET_DIR)-32/usr \
 		headers_install
+	$(MAKE) -C $(WRKBUILD) HOSTCC=$(CC_FOR_BUILD) ARCH=x86 V=1 \
+		INSTALL_HDR_PATH=$(STAGING_TARGET_DIR)-x32/usr \
+		headers_install
+	$(MAKE) -C $(WRKBUILD) HOSTCC=$(CC_FOR_BUILD) ARCH=x86 V=1 \
+		INSTALL_HDR_PATH=$(STAGING_TARGET_DIR)-64/usr \
+		headers_install
+endif
 	$(MAKE) -C $(WRKBUILD) HOSTCC=$(CC_FOR_BUILD) ARCH=$(ARCH) V=1 \
 		INSTALL_HDR_PATH=$(LINUX_HEADER_DIR) \
 		headers_install