From 4203865325c33d752f814850f43d2ecb16c8fa16 Mon Sep 17 00:00:00 2001
From: Sam Thursfield <sam.thursfield@codethink.co.uk>
Date: Fri, 27 Oct 2017 13:49:38 +0000
Subject: Replace use of architecture conditionals with generic project
 conditions

The initial implementation of architecture conditionals has been
removed, as the same behaviours can be implemented using the more
generic mechanism for conditionals that is being introduced for
BuildStream 1.0.

We now have two architecture options: build_arch and arch. They are
documented in project.conf. The first one controls the build sandbox
while the second controls the host and target of the binaries we
produce.
---
 elements/gnu-toolchain/stage1-gcc.bst | 57 ++++++++++++++++++++++-------------
 1 file changed, 36 insertions(+), 21 deletions(-)

(limited to 'elements/gnu-toolchain/stage1-gcc.bst')

diff --git a/elements/gnu-toolchain/stage1-gcc.bst b/elements/gnu-toolchain/stage1-gcc.bst
index 4df5fde7..75c65990 100644
--- a/elements/gnu-toolchain/stage1-gcc.bst
+++ b/elements/gnu-toolchain/stage1-gcc.bst
@@ -1,5 +1,8 @@
 kind: autotools
 
+description:
+  Simple cross compiler which is used to build all of stage2.
+
 sources:
 - kind: git
   url: upstream:gcc-tarball
@@ -12,10 +15,26 @@ depends:
 
 variables:
   prefix: /tools
+  gcc-arch-flags: ''
+
+  (?):
+    # ARM platforms vary a lot even within a single architecture revision,
+    # and require tweaks such as this to produce a useful compiler.
+    # This is a default configuration that has worked for some targets.
+    - arch in ["armv7b", "armv7l"]:
+        gcc-arch-flags: --with-arch=armv7-a
+    - arch in ["armv7blhf", "armv7lhf"]:
+        gcc-arch-flags: >
+                        --with-arch=armv7-a
+                        --with-cpu=cortex-a9
+                        --with-tune=cortex-a9
+                        --with-fpu=vfpv3-d16
+                        --with-float=hard
 
 environment:
   PATH: /tools/bin:/tools/sbin:/usr/bin:/bin:/usr/sbin:/sbin
 
+
 config:
   configure-commands:
   # Workaround from LFS due GCC not detecting stack protection correctly
@@ -42,17 +61,8 @@ config:
   #     without an existing libc, and generally try to keep this build as
   #     simple as possible.
   - |
-    case "%{bst-target-arch}" in
-        armv7lhf) ARCH_FLAGS="--with-arch=armv7-a \
-                              --with-cpu=cortex-a9 \
-                              --with-tune=cortex-a9 \
-                              --with-fpu=vfpv3-d16 \
-                              --with-float=hard" ;;
-        armv7*)   ARCH_FLAGS="--with-arch=armv7-a" ;;
-    esac
 
-    cd o && ../configure                                          \
-              $ARCH_FLAGS                                         \
+    cd o && ../configure %{gcc-arch-flags}                        \
               --build=$(sh ../config.guess)                       \
               --host=$(sh ../config.guess)                        \
               --target=%{target-stage1}                           \
@@ -81,20 +91,25 @@ config:
               --enable-languages=c,c++
 
   build-commands:
-  - |
+  - cd o && make
+
+  install-commands:
+  - cd o && make DESTDIR="%{install-root}" install
+
+  (?):
     # GCC is not passing the correct host/target flags to GMP's configure
     # script, which causes it to not use the machine-dependent code for
     # the platform and use the generic one instead.  However, the generic
     # code results on an undefined reference to `__gmpn_invert_limb' in
     # ARMv7.  Fix the invocation of GMP's configure script so that GMP can
     # use the machine-dependent code.
-    case "%{bst-target-arch}" in
-        armv5*)   sed -i "s/--host=none/--host=armv5/" o/Makefile
-                  sed -i "s/--target=none/--target=armv5/" o/Makefile ;;
-        armv7*)   sed -i "s/--host=none/--host=armv7a/" o/Makefile
-                  sed -i "s/--target=none/--target=armv7a/" o/Makefile ;;
-    esac
-    cd o && make
-
-  install-commands:
-  - cd o && make DESTDIR="%{install-root}" install
+    - arch.startswith("armv5"):
+        build-commands:
+          (<):
+          - sed -i "s/--host=none/--host=armv5/" o/Makefile;
+          - sed -i "s/--target=none/--target=armv5/" o/Makefile
+    - arch.startswith("armv7"):
+        build-commands:
+          (<):
+          - sed -i "s/--host=none/--host=armv7a/" o/Makefile
+          - sed -i "s/--target=none/--target=armv7a/" o/Makefile
-- 
cgit v1.2.1

