OK, here's a fix for amd64 and more for apt-build.  However, I don't
really like it, since:

1) Both i386 and amd64 will still break when gcc-3.4 is introduced as
default compiler.
2) As someone suggested, the Debian architecture specific stuff should
probably be resolved at build-time rather than install time.
3) config.c and apt-build should be hacked to allow for blank arguments.
(I'm currently passing along "-g", being the least destructive thing I
could think of for non-recognized archs.)
4) I've most likely broken arm and sparc archs.
5) I've probably broken the po translation files too.
6) Some intelligent parsing of /proc/cpuinfo should probably be done.
One might be able to use "flags" from cpuinfo as well for some
reasonable build options too, with feedback to debconf.
7) It's plain messy.

Thus, if you consider this patch at all, please review it first.


diff -Naur apt-build-0.11.4/apt-build apt-build-0.11.4.fixed/apt-build
--- apt-build-0.11.4/apt-build  2005-01-15 12:58:11.000000000 +0100
+++ apt-build-0.11.4.fixed/apt-build    2005-02-23 11:25:02.705786926 +0100
@@ -42,7 +42,7 @@
 
 
 # Initial
-my $VERSION = "0.11.3";
+my $VERSION = "0.11.4";
 my ($conf, %conf, @builddep, @apt_args);
 
 @apt_args = qw/--yes/;     # and DEFAULT => 1, down in parse_config()
@@ -313,7 +313,7 @@
        # Add optimizations infos
        my $buildoptions;
        $buildoptions = "Build options: ".
-               $conf->Olevel." ".$conf->march." ".$conf->mcpu." 
".$conf->options;
+               $conf->Olevel." ".$conf->march." ".$conf->mtune." 
".$conf->options;
        
        system "debchange --append \"$buildoptions\"";
 
@@ -740,7 +740,7 @@
                "cleanup!",           { DEFAULT => 1 }, # call debian/rules 
clean after build
                "Olevel=s",           {},
                "march=s",            {},
-               "mcpu=s",             {},
+               "mtune=s",            {},
                "options=s",          {},
                "make_options=s",          {},
                "version",            {
diff -Naur apt-build-0.11.4/apt-build.h apt-build-0.11.4.fixed/apt-build.h
--- apt-build-0.11.4/apt-build.h        2005-01-14 20:27:04.000000000 +0100
+++ apt-build-0.11.4.fixed/apt-build.h  2005-02-21 22:08:04.811906450 +0100
@@ -14,7 +14,7 @@
 {
   char *Olevel;
   char *march;
-  char *mcpu;
+  char *mtune;
   char *options;
   char *make_options;
 };
diff -Naur apt-build-0.11.4/config.c apt-build-0.11.4.fixed/config.c
--- apt-build-0.11.4/config.c   2005-01-14 20:27:04.000000000 +0100
+++ apt-build-0.11.4.fixed/config.c     2005-02-23 10:53:35.470653043 +0100
@@ -86,8 +86,8 @@
          if(!strncmp(opt, "march", 5))
                args.march = strdup(buf);
          
-         if(!strncmp(opt, "mcpu", 4))
-               args.mcpu = strdup(buf);
+         if(!strncmp(opt, "mtune", 5))
+               args.mtune = strdup(buf);
        
          if(!strncmp(opt, "options", 7))
                args.options = parse_options(file_content);
@@ -158,7 +158,7 @@
   cmd_line_args[0] = strdup(argv[0]);
   cmd_line_args[1] = args.Olevel;
   cmd_line_args[2] = args.march;
-  cmd_line_args[3] = args.mcpu;
+  cmd_line_args[3] = args.mtune;
 
   /* Copy the rest of the line */
   for(i = 1; i < argc; i++)
diff -Naur apt-build-0.11.4/debian/po/templates.pot 
apt-build-0.11.4.fixed/debian/po/templates.pot
--- apt-build-0.11.4/debian/po/templates.pot    2005-01-14 20:27:04.000000000 
+0100
+++ apt-build-0.11.4.fixed/debian/po/templates.pot      2005-02-23 
11:19:00.164664697 +0100
@@ -16,7 +16,7 @@
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2005-01-12 18:09+0100\n"
+"POT-Creation-Date: 2005-02-23 09:30+0100\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <[EMAIL PROTECTED]>\n"
 "Language-Team: LANGUAGE <[EMAIL PROTECTED]>\n"
@@ -75,13 +75,19 @@
 
 #. Type: select
 #. Description
-#: ../templates:69
+#: ../templates:105
+msgid "What architecture do you which to tune for?"
+msgstr ""
+
+#. Type: select
+#. Description
+#: ../templates:141
 msgid "What is your architecture?"
 msgstr ""
 
 #. Type: select
 #. Description
-#: ../templates:69
+#: ../templates:141
 msgid ""
 "If your architecture is not here, choose one and edit your configuration "
 "file (/etc/apt/apt-build.conf) by hand, and please do a bugreport. (wishlist)"
@@ -89,12 +95,12 @@
 
 #. Type: string
 #. Description
-#: ../templates:76
+#: ../templates:148
 msgid "Options to add to gcc:"
 msgstr ""
 
 #. Type: string
 #. Description
-#: ../templates:80
+#: ../templates:152
 msgid "Options to add to make:"
 msgstr ""
diff -Naur apt-build-0.11.4/debian/postinst 
apt-build-0.11.4.fixed/debian/postinst
--- apt-build-0.11.4/debian/postinst    2005-01-14 20:27:04.000000000 +0100
+++ apt-build-0.11.4.fixed/debian/postinst      2005-02-23 11:24:52.751568453 
+0100
@@ -7,10 +7,17 @@
 
 find_arch()
 {
-    case "`uname -m`" in
-       i[3-9]86|x86|x86pc|k5|k6|k6-2|k6-3|pentium*|athlon*|i586-i686)
-if [ -r /proc/cpuinfo ]; then
-    case "`grep 'vendor_id' /proc/cpuinfo | cut -d ':' -f 2 | head -n 1`" in
+# Don't use 'uname -m': it may fool you for instance if you're
+# running a 32-bit Debian installation with a 64-bit kernel on
+# an amd64.
+#    case "`uname -m`" in
+#      i[3-9]86|x86|x86pc|k5|k6|k6-2|k6-3|pentium*|athlon*|i586-i686)
+# 
+# FIXME: should this really be "dpkg-architecture -qDEB_BUILD_ARCH"?
+case "`dpkg-architecture -qDEB_HOST_ARCH`" in
+i386|*-i386)
+    if [ -r /proc/cpuinfo ]; then
+       case "`grep 'vendor_id' /proc/cpuinfo | cut -d ':' -f 2 | head -n 1`" in
        *AMD*)
            db_input critical apt-build/arch_amd || true
            db_go
@@ -21,26 +28,96 @@
            db_go
            db_get apt-build/arch_intel
            ;;
-    esac
-fi
-;;
-sparc*)
-db_input critical apt-build/arch_sparc || true
-db_go
-db_get apt-build/arch_sparc
-;;
-alpha)
-db_input critical apt-build/arch_alpha || true
-db_go
-db_get apt-build/arch_alpha
-;;
-arm*)
-db_input critical apt-build/arch_arm || true
-db_go
-db_get apt-build/arch_arm
-;;
+       *)
+           # Exotic stuff
+           db_input critical apt-build/arch_i386 || true
+           db_go
+           db_get apt-build/arch_i386
+           ;;
+       esac
+    else
+       # Generic i386 case for fallback (kernels without /proc/cpuinfo)
+       db_input critical apt-build/arch_i386 || true
+       db_go
+       db_get apt-build/arch_i386
+    fi
+    arch="$RET"
+    tune="$arch"
+    ;;
+amd64|*-amd64)
+    db_input critical apt-build/arch_amd64 || true
+    db_go
+    db_get apt-build/arch_amd64
+    arch="$RET"
+    tune="$arch"
+    ;;
+m68k|*-m68k)
+    db_input critical apt-build/arch_m68k || true
+    db_go
+    db_get apt-build/arch_m68k
+    arch="$RET"
+    tune="unknown"
+    ;;
+powerpc|*-powerpc)
+    db_input critical apt-build/arch_powerpc || true
+    db_go
+    db_get apt-build/arch_powerpc
+    arch="$RET"
+    tune="$arch"
+    ;;
+sparc|*-sparc|sparc64|*-sparc64)
+    db_input critical apt-build/arch_sparc || true
+    db_go
+    db_get apt-build/arch_sparc
+    arch="$RET"
+    tune="$arch"
+    ;;
+alpha|*-alpha)
+    db_input critical apt-build/arch_alpha || true
+    db_go
+    db_get apt-build/arch_alpha
+    arch="$RET"
+    tune="$arch"
+    ;;
+arm|*-arm)
+    db_input critical apt-build/arch_arm || true
+    db_go
+    db_get apt-build/arch_arm
+    arch="$RET"
+    db_input critical apt-build/tune_arm || true
+    db_go
+    db_get apt-build/tune_arm
+    tune="$RET"
+    ;;
+hppa|*-hppa)
+    db_input critical apt-build/arch_hppa || true
+    db_go
+    db_get apt-build/arch_hppa
+    arch="$RET"
+    db_input critical apt-build/tune_hppa || true
+    db_go
+    db_get apt-build/tune_hppa
+    tune="$RET"
+    ;;
+mips|*-mips|mipsel|*-mipsel)
+    db_input critical apt-build/arch_mips || true
+    db_go
+    db_get apt-build/arch_mips
+    arch="$RET"
+    tune="$arch"
+    ;;
+#
+# ia64 tuning can be set via -mtune-arch (sic) in gcc-3.4
+#
+# s390 and s390x -march/-mtune can be set in gcc-3.4 too
+#
+# In case we're handling an unknown arch, don't spill
+*)
+    RET="unknown"
+    arch="unknown"
+    tune="unknown"
+    ;;
 esac
-arch="$RET"
 }
 
 get_config()
@@ -117,8 +194,50 @@
                ;;
        esac
 
-       echo "march = -march=$arch" >> $CONFFILE
-       echo "mcpu = -mcpu=$arch" >> $CONFFILE
+       # Watch it!  Depending on arch, version of gcc and the phase of
+       # the moon, the semantics of -mcpu/arch/tune and friends might differ.
+       #
+       # arch
+       #
+       if [ "$arch" = "unknown" ]; then
+           # FIXME: apt-build and config.c should be fixed to allow NULL
+           # arguments.  This is an ugly workaround.
+           echo "march = -g" >> $CONFFILE
+       else
+           case "`dpkg-architecture -qDEB_HOST_ARCH`" in
+           m68k|*-m68k)
+               echo "march = -m$arch" >> $CONFFILE
+               ;;
+           sparc|*-sparc|sparc64|*-sparc64|powerpc|*-powerpc|alpha|*-alpha)
+               echo "march = -mcpu=$arch" >> $CONFFILE
+               ;;
+           *)
+               echo "march = -march=$arch" >> $CONFFILE
+               ;;
+           esac
+       fi
+       #
+       # tune
+       #
+       if [ "$tune" = "unknown" ]; then
+           # FIXME: apt-build and config.c should be fixed to allow NULL
+           # arguments.  This is an ugly workaround.
+           echo "mtune = -g" >> $CONFFILE
+       else
+           case "`dpkg-architecture -qDEB_HOST_ARCH`" in
+           # FIXME: i386 and amd64 change from -mcpu to -mtune in gcc-3.4
+           i386|*-i386|amd64|*-amd64)
+               echo "mtune = -mcpu=$tune" >> $CONFFILE
+               ;;
+           hppa|*-hppa)
+               echo "mtune = -mschedule=$tune" >> $CONFFILE
+               ;;
+           *)
+               echo "mtune = -mtune=$tune" >> $CONFFILE
+               ;;
+           esac
+       fi
+       #
        echo "options = \" $options\"" >> $CONFFILE
        echo "make_options = \" $make_options\"" >> $CONFFILE
 
diff -Naur apt-build-0.11.4/debian/templates 
apt-build-0.11.4.fixed/debian/templates
--- apt-build-0.11.4/debian/templates   2005-01-14 20:27:04.000000000 +0100
+++ apt-build-0.11.4.fixed/debian/templates     2005-02-23 11:14:46.916975128 
+0100
@@ -28,7 +28,7 @@
 
 Template: apt-build/arch_intel
 Type: select
-Choices: pentium, pentium-mmx, pentiumpro, pentium2, pentium3, pentium4
+Choices: pentium, pentium-mmx, pentiumpro, pentium2, pentium3, pentium4, 
prescott, nocona
 Default: pentium
 _Description: What is your architecture?
  If your architecture is not here, choose one and edit your configuration
@@ -37,17 +37,35 @@
 
 Template: apt-build/arch_amd
 Type: select
-Choices: k6, k6-2, k6-3, athlon, athlon-tbird, athlon-4, athlon-xp, athlon-mp
+Choices: k6, k6-2, k6-3, athlon, athlon-tbird, athlon-4, athlon-xp, athlon-mp, 
x86-64
 Default: k6
 _Description: What is your architecture?
  If your architecture is not here, choose one and edit your configuration
  file (/etc/apt/apt-build.conf) by hand, and please do a bugreport.
  (wishlist)
 
+Template: apt-build/arch_i386
+Type: select
+Choices: i386, i486, i586, i686, pentium, pentium-mmx, pentiumpro, pentium2, 
pentium3, pentium4, prescott, nocona, k6, k6-2, k6-3, athlon, athlon-tbird, 
athlon-4, athlon-xp, athlon-mp, winchip-c6, winchip2, c3
+Default: i486
+_Description: What is your architecture?
+ If your architecture is not here, choose one and edit your configuration
+ file (/etc/apt/apt-build.conf) by hand, and please do a bugreport.
+ (wishlist)
+
+Template: apt-build/arch_amd64
+Type: select
+Choices: nocona, x86-64
+Default: x86-64
+_Description: What is your architecture?
+ If your architecture is not here, choose one and edit your configuration
+ file (/etc/apt/apt-build.conf) by hand, and please do a bugreport.
+ (wishlist)
+
 Template: apt-build/arch_sparc
 Type: select
-Choices: sparc, sparcv7, sparcv8, sparcv9
-Default: sparc
+Choices: v7, cypress, v8, supersparc, sparclite, hypersparc, sparclite86x, 
f930, f934, sparclet, tsc701, v9, ultrasparc, ultrasparc3
+Default: v7
 _Description: What is your architecture?
  If your architecture is not here, choose one and edit your configuration
  file (/etc/apt/apt-build.conf) by hand, and please do a bugreport.
@@ -62,15 +80,69 @@
  file (/etc/apt/apt-build.conf) by hand, and please do a bugreport.
  (wishlist)
 
+Template: apt-build/tune_arm
+Type: select
+Choices: arm2, arm250, arm3, arm6, arm60, arm600, arm610, arm620, arm7, arm7m, 
arm7d, arm7dm, arm7di, arm7dmi, arm70, arm700, arm700i, arm710, arm710c, 
arm7100, arm7500, arm7500fe, arm7tdmi, arm8, strongarm, strongarm110, 
strongarm1100, arm8, arm810, arm9, arm9e, arm920, arm920t, arm940t, arm9tdmi, 
arm10tdmi, arm1020t, xscale
+Default: arm2
+_Description: What architecture do you which to tune for?
+ If your architecture is not here, choose one and edit your configuration
+ file (/etc/apt/apt-build.conf) by hand, and please do a bugreport.
+ (wishlist)
+
+Template: apt-build/arch_hppa
+Type: select
+Choices: 1.0, 1.1, 2.0
+Default: 1.0
+_Description: What is your architecture?
+ If your architecture is not here, choose one and edit your configuration
+ file (/etc/apt/apt-build.conf) by hand, and please do a bugreport.
+ (wishlist)
+
+Template: apt-build/tune_hppa
+Type: select
+Choices: 700, 7100, 7100LC, 7200, 7300, 8000
+Default: 8000
+_Description: What architecture do you which to tune for?
+ If your architecture is not here, choose one and edit your configuration
+ file (/etc/apt/apt-build.conf) by hand, and please do a bugreport.
+ (wishlist)
+
 Template: apt-build/arch_alpha
 Type: select
-Choices: ev4, ev5, ev56, pca56, ev6, ev67
+Choices: ev4, ev45, ev5, ev56, pca56, ev6, ev67
 Default: ev4
 _Description: What is your architecture?
  If your architecture is not here, choose one and edit your configuration
  file (/etc/apt/apt-build.conf) by hand, and please do a bugreport.
  (wishlist)
 
+Template: apt-build/arch_m68k
+Type: select
+Choices: 68000, 68020, 68030, 68040, 68060, cpu32, 5200
+Default: 68020
+_Description: What is your architecture?
+ If your architecture is not here, choose one and edit your configuration
+ file (/etc/apt/apt-build.conf) by hand, and please do a bugreport.
+ (wishlist)
+
+Template: apt-build/arch_powerpc
+Type: select
+Choices: 403, 505, 601, 602, 603, 603e, 604, 604e, 620, 630, 740, 7400, 7450, 
750, 801, 821, 823, 860, common, power, power2, powerpc, rios, rios1, rsc, 
rios2, rs64a
+Default: common
+_Description: What is your architecture?
+ If your architecture is not here, choose one and edit your configuration
+ file (/etc/apt/apt-build.conf) by hand, and please do a bugreport.
+ (wishlist)
+
+Template: apt-build/arch_mips
+Type: select
+Choices: from-abi, mips1, mips2, mips3, mips4, mips32, mips64, r2000, r3000, 
r3900, r4000, vr4100, vr4300, r4400, r4600, r4650, vr5000, r6000, r8000, 4kc, 
4kp, 5kc, 20kc, orion, sb1
+Default: mips1
+_Description: What is your architecture?
+ If your architecture is not here, choose one and edit your configuration
+ file (/etc/apt/apt-build.conf) by hand, and please do a bugreport.
+ (wishlist)
+
 Template: apt-build/options
 Type: string
 _Description: Options to add to gcc:



-ukh


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to