Re: Bug#708143: mips64(el) and mipsn32(el) support with multilib

YunQiang Su <[email protected]>
Newsgroups gmane.linux.debian.ports.mips
Message-ID <CAKcpw6XbD=r52+=cKZooDJZYV98nsUbKojTb_nPgd8WfgjRh5A@mail.gmail.com>
Hi, I refresh this patch to 4.8.1-8

On Fri, Jul 12, 2013 at 11:52 PM, YunQiang Su <[email protected]> wrote:
> I refresh this patch with 4.8.1-6
>
> This version patch add multilib support.
>
> Thanks.
>
> --
> YunQiang Su



-- 
YunQiang Su
mips64.diff (application/octet-stream, 26.2 KB)
diff --git a/debian/lib32gfortran3.symbols.mips64 b/debian/lib32gfortran3.symbols.mips64
index 0000000..c1908ee
--- /dev/null
+++ b/debian/lib32gfortran3.symbols.mips64
@@ -0,0 +1,2 @@
+libgfortran.so.3 lib32gfortran3 #MINVER#
+#include "libgfortran3.symbols.common"
diff --git a/debian/lib32gfortran3.symbols.mips64el b/debian/lib32gfortran3.symbols.mips64el
new file mode 100644
index 0000000..c1908ee
--- /dev/null
+++ b/debian/lib32gfortran3.symbols.mips64el
@@ -0,0 +1,2 @@
+libgfortran.so.3 lib32gfortran3 #MINVER#
+#include "libgfortran3.symbols.common"
diff --git a/debian/lib32gfortran3.symbols.mipsn32 b/debian/lib32gfortran3.symbols.mipsn32
new file mode 100644
index 0000000..c1908ee
--- /dev/null
+++ b/debian/lib32gfortran3.symbols.mipsn32
@@ -0,0 +1,2 @@
+libgfortran.so.3 lib32gfortran3 #MINVER#
+#include "libgfortran3.symbols.common"
diff --git a/debian/lib32gfortran3.symbols.mipsn32el b/debian/lib32gfortran3.symbols.mipsn32el
new file mode 100644
index 0000000..c1908ee
--- /dev/null
+++ b/debian/lib32gfortran3.symbols.mipsn32el
@@ -0,0 +1,2 @@
+libgfortran.so.3 lib32gfortran3 #MINVER#
+#include "libgfortran3.symbols.common"
diff --git a/debian/patches/gcc-multiarch.diff b/debian/patches/gcc-multiarch.diff
index efd1982..073e779 100644
--- a/debian/patches/gcc-multiarch.diff
+++ b/debian/patches/gcc-multiarch.diff
@@ -2,50 +2,39 @@
 # DP: - Add MULTIARCH_DIRNAME definitions for multilib configurations,
 # DP:   which are used for the non-multilib builds.
 
-2013-06-12  Matthias Klose  <[email protected]>
-
-	* config/i386/t-linux64: Set MULTIARCH_DIRNAME.
-	* config/i386/t-kfreebsd: Set MULTIARCH_DIRNAME.
-	* config.gcc (i[34567]86-*-linux* | x86_64-*-linux*): Prepend
-	i386/t-linux to $tmake_file.
-	* config/mips/t-linux64: Set MULTIARCH_DIRNAME.
-	* config/rs6000/t-linux64: Set MULTIARCH_DIRNAME.
-	* config/s390/t-linux64: Set MULTIARCH_DIRNAME.
-	* config/sparc/t-linux64: Set MULTIARCH_DIRNAME.
-
-Index: b/src/gcc/config/sh/t-linux
+Index: gcc-4.8/src/gcc/config/sh/t-linux
 ===================================================================
---- a/src/gcc/config/sh/t-linux
-+++ b/src/gcc/config/sh/t-linux
+--- gcc-4.8.orig/src/gcc/config/sh/t-linux	2013-06-13 18:10:03.963383948 +0800
++++ gcc-4.8/src/gcc/config/sh/t-linux	2013-06-13 18:10:03.947383947 +0800
 @@ -1,2 +1,4 @@
  MULTILIB_DIRNAMES= 
  MULTILIB_MATCHES = 
 +
 +MULTILIB_OSDIRNAMES = sh4-linux-gnu:sh4-linux-gnu sh4_nofpu-linux-gnu:sh4-linux-gnu
-Index: b/src/gcc/config/sparc/t-linux64
+Index: gcc-4.8/src/gcc/config/sparc/t-linux64
 ===================================================================
---- a/src/gcc/config/sparc/t-linux64
-+++ b/src/gcc/config/sparc/t-linux64
+--- gcc-4.8.orig/src/gcc/config/sparc/t-linux64	2013-06-13 18:10:03.963383948 +0800
++++ gcc-4.8/src/gcc/config/sparc/t-linux64	2013-06-13 18:10:03.947383947 +0800
 @@ -27,3 +27,5 @@
  MULTILIB_DIRNAMES = 64 32
  MULTILIB_OSDIRNAMES = ../lib64$(call if_multiarch,:sparc64-linux-gnu)
  MULTILIB_OSDIRNAMES += $(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:sparc-linux-gnu)
 +
 +MULTIARCH_DIRNAME = $(call if_multiarch,sparc$(if $(findstring 64,$(target)),64)-linux-gnu)
-Index: b/src/gcc/config/s390/t-linux64
+Index: gcc-4.8/src/gcc/config/s390/t-linux64
 ===================================================================
---- a/src/gcc/config/s390/t-linux64
-+++ b/src/gcc/config/s390/t-linux64
+--- gcc-4.8.orig/src/gcc/config/s390/t-linux64	2013-06-13 18:10:03.963383948 +0800
++++ gcc-4.8/src/gcc/config/s390/t-linux64	2013-06-13 18:10:03.951383947 +0800
 @@ -9,3 +9,5 @@
  MULTILIB_DIRNAMES = 64 32
  MULTILIB_OSDIRNAMES = ../lib64$(call if_multiarch,:s390x-linux-gnu)
  MULTILIB_OSDIRNAMES += $(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:s390-linux-gnu)
 +
 +MULTIARCH_DIRNAME = $(call if_multiarch,s390$(if $(findstring s390x,$(target)),x)-linux-gnu)
-Index: b/src/gcc/config/rs6000/t-linux
+Index: gcc-4.8/src/gcc/config/rs6000/t-linux
 ===================================================================
---- a/src/gcc/config/rs6000/t-linux
-+++ b/src/gcc/config/rs6000/t-linux
+--- gcc-4.8.orig/src/gcc/config/rs6000/t-linux	2013-06-13 18:10:03.963383948 +0800
++++ gcc-4.8/src/gcc/config/rs6000/t-linux	2013-06-13 18:10:03.951383947 +0800
 @@ -2,7 +2,7 @@
  # or soft-float.
  ifeq (,$(filter $(with_cpu),$(SOFT_FLOAT_CPUS))$(findstring soft,$(with_float)))
@@ -55,20 +44,20 @@ Index: b/src/gcc/config/rs6000/t-linux
  else
  MULTIARCH_DIRNAME = powerpc-linux-gnu
  endif
-Index: b/src/gcc/config/rs6000/t-linux64
+Index: gcc-4.8/src/gcc/config/rs6000/t-linux64
 ===================================================================
---- a/src/gcc/config/rs6000/t-linux64
-+++ b/src/gcc/config/rs6000/t-linux64
+--- gcc-4.8.orig/src/gcc/config/rs6000/t-linux64	2013-06-13 18:10:03.963383948 +0800
++++ gcc-4.8/src/gcc/config/rs6000/t-linux64	2013-06-13 18:10:03.951383947 +0800
 @@ -30,3 +30,5 @@
  MULTILIB_EXTRA_OPTS     = fPIC
  MULTILIB_OSDIRNAMES	= ../lib64$(call if_multiarch,:powerpc64-linux-gnu)
  MULTILIB_OSDIRNAMES    += $(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:powerpc-linux-gnu)
 +
 +MULTIARCH_DIRNAME = $(call if_multiarch,powerpc$(if $(findstring 64,$(target)),64)-linux-gnu)
-Index: b/src/gcc/config/i386/t-linux64
+Index: gcc-4.8/src/gcc/config/i386/t-linux64
 ===================================================================
---- a/src/gcc/config/i386/t-linux64
-+++ b/src/gcc/config/i386/t-linux64
+--- gcc-4.8.orig/src/gcc/config/i386/t-linux64	2013-06-13 18:10:03.963383948 +0800
++++ gcc-4.8/src/gcc/config/i386/t-linux64	2013-06-13 18:10:03.951383947 +0800
 @@ -36,3 +36,13 @@
  MULTILIB_OSDIRNAMES = m64=../lib64$(call if_multiarch,:x86_64-linux-gnu)
  MULTILIB_OSDIRNAMES+= m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:i386-linux-gnu)
@@ -83,10 +72,10 @@ Index: b/src/gcc/config/i386/t-linux64
 +else
 +  MULTIARCH_DIRNAME = $(call if_multiarch,i386-linux-gnu)
 +endif
-Index: b/src/gcc/config/i386/t-kfreebsd
+Index: gcc-4.8/src/gcc/config/i386/t-kfreebsd
 ===================================================================
---- a/src/gcc/config/i386/t-kfreebsd
-+++ b/src/gcc/config/i386/t-kfreebsd
+--- gcc-4.8.orig/src/gcc/config/i386/t-kfreebsd	2013-06-13 18:10:03.963383948 +0800
++++ gcc-4.8/src/gcc/config/i386/t-kfreebsd	2013-06-13 18:10:03.951383947 +0800
 @@ -1,5 +1,9 @@
 -MULTIARCH_DIRNAME = $(call if_multiarch,i386-kfreebsd-gnu)
 +ifeq (,$(MULTIARCH_DIRNAME))
@@ -98,29 +87,24 @@ Index: b/src/gcc/config/i386/t-kfreebsd
  MULTILIB_OSDIRNAMES := $(filter-out mx32=%,$(subst linux,$(KFREEBSD_OS),$(MULTILIB_OSDIRNAMES)))
 +
 +MULTIARCH_DIRNAME := $(subst linux,$(KFREEBSD_OS),$(MULTIARCH_DIRNAME))
-Index: b/src/gcc/config/mips/t-linux64
-===================================================================
---- a/src/gcc/config/mips/t-linux64
-+++ b/src/gcc/config/mips/t-linux64
-@@ -24,3 +24,13 @@
- 	../lib32$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \
- 	../lib$(call if_multiarch,:mips$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \
- 	../lib64$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
-+
-+ifneq (,$(findstring abin32,$(target)))
-+MULTIARCH_DIRNAME = $(call if_multiarch,mips64$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT))
-+else
-+ifneq (,$(findstring abi64,$(target)))
-+MULTIARCH_DIRNAME = $(call if_multiarch,mips64$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
-+else
-+MULTIARCH_DIRNAME = $(call if_multiarch,mips$(MIPS_EL)-linux-gnu$(MIPS_SOFT))
-+endif
-+endif
-Index: b/src/gcc/config.gcc
+Index: gcc-4.8/src/gcc/config.gcc
 ===================================================================
---- a/src/gcc/config.gcc
-+++ b/src/gcc/config.gcc
-@@ -3707,7 +3707,7 @@
+--- gcc-4.8.orig/src/gcc/config.gcc	2013-06-13 18:10:03.963383948 +0800
++++ gcc-4.8/src/gcc/config.gcc	2013-06-13 18:10:03.955383948 +0800
+@@ -1797,8 +1797,11 @@
+ mips64*-*-linux* | mipsisa64*-*-linux*)
+ 	tm_file="dbxelf.h elfos.h gnu-user.h linux.h glibc-stdint.h ${tm_file} mips/gnu-user.h mips/gnu-user64.h mips/linux64.h mips/linux-common.h"
+ 	tmake_file="${tmake_file} mips/t-linux64"
+-	tm_defines="${tm_defines} MIPS_ABI_DEFAULT=ABI_N32"
++	tm_defines="${tm_defines} MIPS_ABI_DEFAULT=ABI_64"
+ 	case ${target} in
++		*gnuabin32*)
++			tm_defines=$(echo ${tm_defines}| sed 's/MIPS_ABI_DEFAULT=ABI_64/MIPS_ABI_DEFAULT=ABI_N32/g')
++			;;
+ 		mips64el-st-linux-gnu)
+ 			tm_file="${tm_file} mips/st.h"
+ 			tmake_file="${tmake_file} mips/t-st"
+@@ -3703,7 +3706,7 @@
  	i[34567]86-*-darwin* | x86_64-*-darwin*)
  		;;
  	i[34567]86-*-linux* | x86_64-*-linux*)
@@ -129,10 +113,10 @@ Index: b/src/gcc/config.gcc
  		;;
  	i[34567]86-*-kfreebsd*-gnu | x86_64-*-kfreebsd*-gnu)
  		tmake_file="$tmake_file i386/t-kfreebsd"
-Index: b/src/gcc/java/jvspec.c
+Index: gcc-4.8/src/gcc/java/jvspec.c
 ===================================================================
---- a/src/gcc/java/jvspec.c
-+++ b/src/gcc/java/jvspec.c
+--- gcc-4.8.orig/src/gcc/java/jvspec.c	2013-06-13 18:10:03.963383948 +0800
++++ gcc-4.8/src/gcc/java/jvspec.c	2013-06-13 18:10:03.955383948 +0800
 @@ -59,7 +59,7 @@
    "jvgenmain %{findirect-dispatch} %{D*} %b %m.i |\n\
     cc1 %m.i %1 \
diff --git a/debian/patches/gcc-multilib-multiarch.diff b/debian/patches/gcc-multilib-multiarch.diff
index d5c8d87..8a8e102 100644
--- a/debian/patches/gcc-multilib-multiarch.diff
+++ b/debian/patches/gcc-multilib-multiarch.diff
@@ -1,9 +1,9 @@
 # DP: Don't auto-detect multilib osdirnames.
 
-Index: b/src/gcc/config/sparc/t-linux64
+Index: gcc-4.8/src/gcc/config/sparc/t-linux64
 ===================================================================
---- a/src/gcc/config/sparc/t-linux64
-+++ b/src/gcc/config/sparc/t-linux64
+--- gcc-4.8.orig/src/gcc/config/sparc/t-linux64	2013-06-25 23:30:09.396115210 +0800
++++ gcc-4.8/src/gcc/config/sparc/t-linux64	2013-06-25 23:30:09.388115209 +0800
 @@ -25,7 +25,12 @@
  
  MULTILIB_OPTIONS = m64/m32
@@ -18,10 +18,10 @@ Index: b/src/gcc/config/sparc/t-linux64
 +endif
  
  MULTIARCH_DIRNAME = $(call if_multiarch,sparc$(if $(findstring 64,$(target)),64)-linux-gnu)
-Index: b/src/gcc/config/s390/t-linux64
+Index: gcc-4.8/src/gcc/config/s390/t-linux64
 ===================================================================
---- a/src/gcc/config/s390/t-linux64
-+++ b/src/gcc/config/s390/t-linux64
+--- gcc-4.8.orig/src/gcc/config/s390/t-linux64	2013-06-25 23:30:09.396115210 +0800
++++ gcc-4.8/src/gcc/config/s390/t-linux64	2013-06-25 23:30:09.388115209 +0800
 @@ -7,7 +7,12 @@
  
  MULTILIB_OPTIONS = m64/m31
@@ -36,10 +36,10 @@ Index: b/src/gcc/config/s390/t-linux64
 +endif
  
  MULTIARCH_DIRNAME = $(call if_multiarch,s390$(if $(findstring s390x,$(target)),x)-linux-gnu)
-Index: b/src/gcc/config/rs6000/t-linux64
+Index: gcc-4.8/src/gcc/config/rs6000/t-linux64
 ===================================================================
---- a/src/gcc/config/rs6000/t-linux64
-+++ b/src/gcc/config/rs6000/t-linux64
+--- gcc-4.8.orig/src/gcc/config/rs6000/t-linux64	2013-06-25 23:30:09.396115210 +0800
++++ gcc-4.8/src/gcc/config/rs6000/t-linux64	2013-06-25 23:30:09.388115209 +0800
 @@ -28,7 +28,12 @@
  MULTILIB_OPTIONS        = m64/m32
  MULTILIB_DIRNAMES       = 64 32
@@ -54,10 +54,10 @@ Index: b/src/gcc/config/rs6000/t-linux64
 +endif
  
  MULTIARCH_DIRNAME = $(call if_multiarch,powerpc$(if $(findstring 64,$(target)),64)-linux-gnu)
-Index: b/src/gcc/config/i386/t-linux64
+Index: gcc-4.8/src/gcc/config/i386/t-linux64
 ===================================================================
---- a/src/gcc/config/i386/t-linux64
-+++ b/src/gcc/config/i386/t-linux64
+--- gcc-4.8.orig/src/gcc/config/i386/t-linux64	2013-06-25 23:30:09.396115210 +0800
++++ gcc-4.8/src/gcc/config/i386/t-linux64	2013-06-25 23:30:09.388115209 +0800
 @@ -33,9 +33,19 @@
  comma=,
  MULTILIB_OPTIONS    = $(subst $(comma),/,$(TM_MULTILIB_CONFIG))
@@ -79,3 +79,35 @@ Index: b/src/gcc/config/i386/t-linux64
  
  ifneq (,$(findstring x86_64,$(target)))
    ifneq (,$(findstring biarchx32.h,$(tm_include_list)))
+Index: gcc-4.8/src/gcc/config/mips/t-linux64
+===================================================================
+--- gcc-4.8.orig/src/gcc/config/mips/t-linux64	2013-06-25 23:30:09.396115210 +0800
++++ gcc-4.8/src/gcc/config/mips/t-linux64	2013-06-25 23:41:41.304134509 +0800
+@@ -20,7 +20,27 @@
+ MULTILIB_DIRNAMES = n32 32 64
+ MIPS_EL = $(if $(filter %el, $(firstword $(subst -, ,$(target)))),el)
+ MIPS_SOFT = $(if $(strip $(filter MASK_SOFT_FLOAT_ABI, $(target_cpu_default)) $(filter soft, $(with_float))),soft)
++
++ifneq (,$(findstring gnuabi64,$(target)))
++MULTILIB_OSDIRNAMES = \
++	../lib32$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \
++	../libo32$(call if_multiarch,:mips$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \
++	../lib$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
++else ifneq (,$(findstring gnuabin32,$(target)))
++	../lib$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \
++	../libo32$(call if_multiarch,:mips$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \
++	../lib64$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
++else
+ MULTILIB_OSDIRNAMES = \
+ 	../lib32$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \
+ 	../lib$(call if_multiarch,:mips$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \
+ 	../lib64$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
++endif
++
++ifneq (,$(findstring gnuabi64,$(target)))
++  MULTIARCH_DIRNAME = $(call if_multiarch,mips64$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
++else ifneq (,$(findstring gnuabin32,$(target)))
++  MULTIARCH_DIRNAME = $(call if_multiarch,mips64$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT))
++else
++  MULTIARCH_DIRNAME = $(call if_multiarch,mips$(MIPS_EL)-linux-gnu$(MIPS_SOFT))
++endif
diff --git a/debian/rules.conf b/debian/rules.conf
index d03bbeb..59c5be1 100644
--- a/debian/rules.conf
+++ b/debian/rules.conf
@@ -267,6 +267,8 @@ LIBC_BIARCH_DEV_DEP :=
 ifneq (,$(findstring yes,$(biarch64) $(biarch32) $(biarchn32) $(biarchx32)$(biarchhf)$(biarchsf)))
   LIBC_BIARCH_DEP := $${shlibs:Depends}
   LIBC_BIARCH_DEV_DEP := $(LIBC_DEV_DEP)-$(biarch_deb_arch)$(LS)$(AQ) (>= $(libc_ver))
+  # x86_64, x32, i386
+  ifneq (,$(findstring $(DEB_TARGET_ARCH),x86_64 x32 i386))
   ifeq ($(biarch64)$(biarch32),yesyes)
     LIBC_BIARCH_DEV_DEP := $(LIBC_DEV_DEP)-amd64$(LS)$(AQ) (>= $(libc_ver)), $(LIBC_DEV_DEP)-i386$(LS)$(AQ) (>= $(libc_ver))
   endif
@@ -276,15 +278,22 @@ ifneq (,$(findstring yes,$(biarch64) $(biarch32) $(biarchn32) $(biarchx32)$(biar
   ifeq ($(biarch32)$(biarchx32),yesyes)
     LIBC_BIARCH_DEV_DEP := $(LIBC_DEV_DEP)-i386$(LS)$(AQ) (>= $(libc_ver)), $(LIBC_DEV_DEP)-x32$(LS)$(AQ) (>= $(libc_ver))
   endif
-  ifeq ($(biarchn32),yes)
-    ifneq (,$(findstring $(DEB_TARGET_ARCH),mips mipsel))
-      triarch :=
-      ifeq ($(biarch64),yes)
-        triarch := $(COMMA)$(SPACE)
-      endif
-      LIBC_BIARCH_DEV_DEP += $(triarch)libc6-dev-mipsn32$(LS)$(AQ) (>= $(libc_ver))
-    endif
   endif
+  # mips*
+  ifneq (,$(findstring $(DEB_TARGET_ARCH),mips mipsel mipsn32 mipsn32el mips64 mips64el))
+  ifeq ($(biarchn32)$(biarch32),yesyes)
+      LIBC_BIARCH_DEV_DEP := libc6-dev-mips32$(LS)$(AQ) (>= $(libc_ver)), libc6-dev-mipsn32$(LS)$(AQ) (>= $(libc_ver))
+  endif
+  ifeq ($(biarch64)$(biarch32),yesyes)
+      triarch := $(COMMA)$(SPACE)
+      LIBC_BIARCH_DEV_DEP := libc6-dev-mips32$(LS)$(AQ) (>= $(libc_ver)), libc6-dev-mips64$(LS)$(AQ) (>= $(libc_ver))
+  endif
+  ifeq ($(biarchn32)$(biarch64),yesyes)
+      triarch := $(COMMA)$(SPACE)
+      LIBC_BIARCH_DEV_DEP := libc6-dev-mips64$(LS)$(AQ) (>= $(libc_ver)), libc6-dev-mipsn32$(LS)$(AQ) (>= $(libc_ver))
+  endif
+  endif
+
   ifeq ($(biarchhf),yes)
     LIBC_BIARCH_DEP := $(LIBC_DEP)-$(biarch_deb_arch)$(LS)$(AQ) (>= $(libc_ver))
     LIBC_BIARCH_DEP += | $(LIBC_DEP)-$(biarch_deb_arch)$(LS)$(AQ)
@@ -590,7 +599,6 @@ ctrl_flags += \
 
 ifeq ($(DEB_CROSS),yes)
   ctrl_flags += \
-	-DTARGET=$(DEB_TARGET_ARCH) \
 	-DLIBUNWIND_BUILD_DEP="$(LIBUNWIND_BUILD_DEP)" \
 	-DLIBATOMIC_OPS_BUILD_DEP="$(LIBATOMIC_OPS_BUILD_DEP)"
   ifeq ($(with_deps_on_target_arch_pkgs),yes)
@@ -610,6 +618,9 @@ endif
 ifeq ($(with_multiarch_lib),yes)
   ctrl_flags += \
 	-DMULTIARCH=yes
+else
+  ctrl_flags += \
+	-DTARGET=$(DEB_TARGET_ARCH)
 endif
 
 control: control-file readme-bugs-file parameters-file symbols-files copyright-file substvars-file versioned-files check-versions
diff --git a/debian/rules.d/binary-go.mk b/debian/rules.d/binary-go.mk
index 6f3da92..ed6a4c5 100644
--- a/debian/rules.d/binary-go.mk
+++ b/debian/rules.d/binary-go.mk
@@ -168,13 +168,12 @@ $(binary_stamp)-gccgo: $(install_stamp)
 		$(d)/$(gcc_lib_dir)/64/; \
 	fi
 	if [ -f $(d)/$(usr_lib32)/libgobegin.a ]; then \
-	  if [ -d $(d)/$(gcc_lib_dir)/32 ]; then \
 	    mv $(d)/$(usr_lib32)/libgobegin.a \
 		$(d)/$(gcc_lib_dir)/32/; \
-	  else \
-	    mv $(d)/$(usr_lib32)/libgobegin.a \
+	fi
+	if [ -f $(d)/$(usr_libn32)/libgobegin.a ]; then \
+	    mv $(d)/$(usr_libn32)/libgobegin.a \
 		$(d)/$(gcc_lib_dir)/n32/; \
-	  fi; \
 	fi
 	if [ -f $(d)/$(usr_libx32)/libgobegin.a ]; then \
 	    mv $(d)/$(usr_libx32)/libgobegin.a \
diff --git a/debian/rules.d/binary-libstdcxx.mk b/debian/rules.d/binary-libstdcxx.mk
index f910a6a..95a3c36 100644
--- a/debian/rules.d/binary-libstdcxx.mk
+++ b/debian/rules.d/binary-libstdcxx.mk
@@ -236,7 +236,8 @@ define __do_libstdcxx_dbg
 	)
 
 	$(if $(filter yes,$(with_debug)),
-		mv $(d)/$(usr_lib$(2))/debug $(d_d)/$(usr_lib$(2))/.;
+		mkdir -p $(d_d)/$(usr_lib$(2))/debug;
+		mv $(d)/$(usr_lib$(2))/debug/libstdc++* $(d_d)/$(usr_lib$(2))/debug;
 		rm -f $(d_d)/$(usr_lib$(2))/debug/libstdc++_pic.a
 	)
 
diff --git a/debian/rules.defs b/debian/rules.defs
index 7081a36..ff7d653 100644
--- a/debian/rules.defs
+++ b/debian/rules.defs
@@ -371,6 +371,10 @@ multiarch_xarch_map = \
 	s390x=s390-linux-gnu \
 	mips=mips64-linux-gnuabin32,mips64-linux-gnuabi64 \
 	mipsel=mips64el-linux-gnuabin32,mips64el-linux-gnuabi64 \
+	mipsn32=mips-linux-gnu,mips64-linux-gnuabi64 \
+	mipsn32el=mipsel-linux-gnu,mips64el-linux-gnuabi64 \
+	mips64=mips-linux-gnu,mips64-linux-gnuabin32 \
+	mips64el=mipsel-linux-gnu,mips64el-linux-gnuabin32 \
 	x32=x86_64-linux-gnu,i386-linux-gnu \
 	kfreebsd-amd64=i386-kfreebsd-gnu
 xarch_multiarch_names = $(subst $(COMMA),$(SPACE),$(patsubst $(DEB_TARGET_ARCH)=%,%, \
@@ -394,6 +398,14 @@ multilib_multiarch_map = \
 	mips/64=mips64-linux-gnuabi64 \
 	mipsel/n32=mips64el-linux-gnuabin32 \
 	mipsel/64=mips64el-linux-gnuabi64 \
+	mipsn32/32=mips-linux-gnu \
+	mipsn32/64=mips64-linux-gnuabi64 \
+	mipsn32el/32=mipsel-linux-gnu \
+	mipsn32el/64=mips64el-linux-gnuabi64 \
+	mips64/32=mips-linux-gnu \
+	mips64/n32=mips64-linux-gnuabin32 \
+	mips64el/32=mipsel-linux-gnu \
+	mips64el/n32=mips64el-linux-gnuabin32 \
 	x32/32=i386-linux-gnu \
 	x32/64=x86_64-linux-gnu \
 	kfreebsd-amd64/32=i386-kfreebsd-gnu
@@ -622,7 +634,7 @@ with_java_plugin := no
 
 ifeq ($(with_java),yes)
   # use the same names as OpenJDK
-  java_cpu_map = armel=arm armhf=arm hppa=parisc i686=i386 i586=i386 i486=i386 mipsel=mips powerpc=ppc sh4=sh
+  java_cpu_map = armel=arm armhf=arm hppa=parisc i686=i386 i586=i386 i486=i386 mipsel=mips mips64=mips mips64el=mips mipsn32=mips mipsn32el=mips powerpc=ppc sh4=sh
   java_cpu = $(patsubst $(DEB_TARGET_ARCH_CPU)=%,%, \
                          $(filter $(DEB_TARGET_ARCH_CPU)=%,$(java_cpu_map)))
   ifeq (,$(java_cpu))
@@ -778,7 +790,7 @@ ifeq ($(with_d),yes)
     with_libphobos := yes
   endif
 
-  libphobos_no_cpus := alpha avr arm arm64 hppa ia64 m68k mips mipsel powerpc powerpcspe ppc64 s390 s390x sh4 sparc sparc64
+  libphobos_no_cpus := alpha avr arm arm64 hppa ia64 m68k mips mipsel mips64 mips64el mipsn32 mipsn32el powerpc powerpcspe ppc64 s390 s390x sh4 sparc sparc64
   libphobos_no_systems := gnu kfreebsd-gnu
   ifneq (,$(findstring $(DEB_TARGET_ARCH_CPU),$(libphobos_no_cpus)))
     with_libphobos := disabled for cpu $(DEB_TARGET_ARCH_CPU)
@@ -1146,6 +1158,9 @@ endif
 with_check := yes
 # if you don't want to run the gcc testsuite, uncomment the next line
 #with_check := disabled by hand
+ifneq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
+  with_check := disabled by DEB_BUILD_OPTIONS
+endif
 ifeq ($(with_base_only),yes)
   with_check := no
 endif
@@ -1198,7 +1213,8 @@ export debian_extra_langs
 
 # multilib
 biarch_map := i686=x86_64 powerpc=powerpc64 sparc=sparc64 sparc64=sparc s390=s390x s390x=s390 \
-		x86_64=i686 powerpc64=powerpc mips=mips64 mipsel=mips64el
+		x86_64=i686 powerpc64=powerpc mips=mips64 mipsel=mips64el \
+		mips64=mips mips64el=mipsel mipsn32=mips mipsn32el=mipsel
 ifeq (,$(filter $(distrelease),lenny etch squeeze wheezy sid dapper hardy jaunty karmic lucid))
   biarch_map := $(subst i686=,i486=,$(biarch_map))
 endif
@@ -1319,9 +1335,9 @@ define gen_biarch
     export TARGET64_MACHINE
   endif
 endef
-biarch32archs := /amd64/ppc64/kfreebsd-amd64/s390x/sparc64/x32/
-biarch64archs := /i386/powerpc/sparc/s390/mips/mipsel/x32/
-biarchn32archs := /mips/mipsel/
+biarch32archs := /amd64/ppc64/kfreebsd-amd64/s390x/sparc64/x32/mipsn32/mipsn32el/mips64/mips64el/
+biarch64archs := /i386/powerpc/sparc/s390/mips/mipsel/mipsn32/mipsn32el/x32/
+biarchn32archs := /mips/mipsel/mips64/mips64el/
 ifeq ($(distribution),Ubuntu)
   ifeq (,$(filter $(distrelease),dapper hardy jaunty karmic lucid maverick natty))
     biarchhfarchs := /armel/
@@ -1670,7 +1686,7 @@ shlibdirs_to_search = -l$(subst $(SPACE),:,$(foreach d,$(_shlibdirs),$(d)))
 
 # native ... 
 
-ifneq (,$(filter $(DEB_TARGET_ARCH), mips mipsel))
+ifneq (,$(filter $(DEB_TARGET_ARCH), mips mipsel mips64 mips64el mipsn32 mipsn32el))
   ifneq ($(with_deps_on_target_arch_pkgs),yes)
     define cross_mangle_control
 	$(if $(findstring 64,$(1)),sed -i -r '/^(Dep|Rec|Sug)/s/[a-z0-9-]+32[^$(COMMA)]+($(COMMA) *|$$)//g;/^(Dep|Rec|Sug)/s/$(p_lgcc)/$(p_l64gcc)/;/^(Dep|Rec|Sug)/s/ *$(COMMA) *$$//' debian/$(1)/DEBIAN/control,@:)
diff --git a/debian/rules2 b/debian/rules2
index b48478b..6023a7c 100644
--- a/debian/rules2
+++ b/debian/rules2
@@ -524,6 +524,51 @@ ifneq (,$(findstring mipsel-linux,$(DEB_TARGET_GNU_TYPE)))
   endif
 endif
 
+#FIXME: howto for mipsn32?
+ifneq (,$(findstring mips64el-linux-gnuabin32,$(DEB_TARGET_GNU_TYPE)))
+  CONFARGS += --with-mips-plt
+  ifeq ($(multilib),yes)
+    ifeq ($(biarchn32)-$(biarch32),yes-yes)
+      CONFARGS += --enable-targets=all
+      CONFARGS += --with-arch-64=mips64r2 --with-tune-64=loongson3a
+      CONFARGS += --with-arch-32=mips32 --with-tune-32=mips32r2
+    endif
+  endif
+endif
+
+ifneq (,$(findstring mips64-linux-gnuabin32,$(DEB_TARGET_GNU_TYPE)))
+  CONFARGS += --with-mips-plt
+  ifeq ($(multilib),yes)
+    ifeq ($(biarchn32)-$(biarch32),yes-yes)
+      CONFARGS += --enable-targets=all
+      CONFARGS += --with-arch-64=mips64r2 --with-tune-64=octeon+
+      CONFARGS += --with-arch-32=mips32 --with-tune-32=mips32r2
+    endif
+  endif
+endif
+
+ifneq (,$(findstring mips64el-linux-gnuabi64,$(DEB_TARGET_GNU_TYPE)))
+  CONFARGS += --with-mips-plt
+  CONFARGS += --with-arch-64=mips64r2 --with-tune-64=loongson3a
+  ifeq ($(multilib),yes)
+    ifeq ($(biarchn32)-$(biarch32),yes-yes)
+      CONFARGS += --enable-targets=all
+      CONFARGS += --with-arch-32=mips2 --with-tune-32=mips32
+    endif
+  endif
+endif
+
+ifneq (,$(findstring mips64-linux-gnuabi64,$(DEB_TARGET_GNU_TYPE)))
+  CONFARGS += --with-mips-plt
+  CONFARGS += --with-arch-64=mips64r2 --with-tune-64=octeon+
+  ifeq ($(multilib),yes)
+    ifeq ($(biarchn32)-$(biarch32),yes-yes)
+      CONFARGS += --enable-targets=all
+      CONFARGS += --with-arch-32=mips2 --with-tune-32=mips32
+    endif
+  endif
+endif
+
 ifneq (,$(findstring s390-linux,$(DEB_TARGET_GNU_TYPE)))
   ifeq ($(multilib),yes)
     ifeq ($(biarch64),yes)
@@ -750,10 +795,18 @@ ifneq ($(single_package),yes)
   endif
 endif
 
-gcc_lib_dir	= $(PF)/$(configured_libdir)/$(gcc_subdir_name)/$(TARGET_ALIAS)/$(versiondir)
+#FIXME: hardcode $(PF)/lib/gcc, is it a problem?
+gcc_lib_dir	= $(PF)/lib/$(gcc_subdir_name)/$(TARGET_ALIAS)/$(versiondir)
+gcc_lexec_dir	= $(PF)/lib/$(gcc_subdir_name)/$(TARGET_ALIAS)/$(versiondir)
+ifeq ($(single_package),yes)
 gcc_lexec_dir	= $(libexecdir)/$(gcc_subdir_name)/$(TARGET_ALIAS)/$(versiondir)
+endif
 
-lib32		= $(PF)/lib32
+lib32loc 	= lib32
+ifneq (,$(findstring mips,$(DEB_TARGET_GNU_TYPE)))
+lib32loc	= lib
+endif
+lib32		= $(PF)/$(lib32loc)
 lib64		= lib64
 libn32		= lib32
 libx32		= libx32
@@ -777,7 +830,7 @@ ifeq ($(DEB_CROSS),yes)
 else
   usr_lib = $(PFL)/$(libdir)
 endif
-usr_lib32 = $(PFL)/lib32
+usr_lib32 = $(PFL)/$(lib32loc)
 usr_libn32 = $(PFL)/lib32
 usr_libx32 = $(PFL)/libx32
 usr_lib64 = $(PFL)/lib64
@@ -799,7 +852,7 @@ gcc_lib_dirsf = $(gcc_lib_dir)/$(biarchsfsubdir)
 
 libgcc_dir = $(RPF)/$(libdir)
 # yes, really; lib32gcc_s ends up in usr
-libgcc_dir32 = $(PFL)/lib32
+libgcc_dir32 = $(PFL)/$(lib32loc)
 libgcc_dirn32 = $(RPF)/lib32
 # libx32gcc_s also ends up in usr
 libgcc_dirx32 = $(PFL)/libx32
@@ -888,6 +941,8 @@ endif
 	@echo "Install prefix: /$(PF)"
 ifeq ($(biarchn32)-$(biarch64),yes-yes)
 	@echo "Will build the triarch compilers (o32/n32/64, defaulting to o32)"
+else ifeq ($(biarchn32)-$(biarch32),yes-yes)
+	@echo "Will build the triarch compilers (o32/n32/64, defaulting to 64)"
 else ifeq ($(biarch64)-$(biarch32),yes-yes)
 	@echo "Will build the triarch compilers (x32/64/32, defaulting to x32)"
 else ifeq ($(biarch64)-$(biarchx32),yes-yes)
@@ -1862,7 +1917,7 @@ ifeq ($(with_hppa64),yes)
 	    esac; \
 	  done
 endif
-
+	
 	: # Work around PR lto/41569
 	ln -sf gcc $(builddir)/prev-gcc
 	ln -sf $(DEB_TARGET_GNU_TYPE) $(builddir)/prev-$(DEB_TARGET_GNU_TYPE)
@@ -1895,13 +1950,6 @@ endif
 	    esac; \
 	  done
 
-ifneq ($(configured_libdir),$(libdir))
-	for i in debug go pkgconfig '*.so' '*.so.*' '*.a' '*.la' '*.py' '*.spec'; do \
-	  mv $(d)/$(PF)/$(configured_libdir)/$$i \
-		$(d)/$(PF)/$(libdir)/. || true; \
-	done
-endif
-
 # FIXME: libjava/classpath not correctly patched
 ifeq ($(with_java),yes)
 	-if [ -d $(d)/$(PF)/lib/gcj-$(GCC_VERSION)-$(GCJ_SONAME) ]; then \
@@ -1948,7 +1996,7 @@ $(install_stamp): $(build_stamp)
 	rm -rf $(d)
 	mkdir -p $(d)/$(libdir) $(d)/$(PF) $(d)/$(PF)/$(libdir)/debug
 ifeq ($(biarch32),yes)
-	mkdir -p $(d)/$(PF)/lib32/debug
+	mkdir -p $(d)/$(PF)/$(lib32loc)/debug
 endif
 ifeq ($(biarch64),yes)
 	mkdir -p $(d)/$(PF)/lib64/debug
@@ -1994,6 +2042,8 @@ ifneq ($(configured_libdir),$(libdir))
 	for i in debug go pkgconfig '*.so' '*.so.*' '*.a' '*.la' '*.o' '*.py' '*.spec'; do \
 	  mv $(d)/$(PF)/$(configured_libdir)/$$i \
 		$(d)/$(PF)/$(libdir)/. || true; \
+	  mv $(d)/$(PF)/libo32/$$i \
+		$(d)/$(PF)/lib/. || true; \
 	done
 endif
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.