From 219464b4d0ee342077259e76d3cf7e2d63202770 Mon Sep 17 00:00:00 2001
From: Ian Douglas Scott <ian@iandouglasscott.com>
Date: Mon, 7 Aug 2017 14:16:43 -0700
Subject: [PATCH] Specify host in config.sh, not specific recipe

---
 config.sh                      | 5 ++++-
 recipes/curl/recipe.sh         | 2 --
 recipes/dash/recipe.sh         | 1 -
 recipes/diffutils/recipe.sh    | 2 --
 recipes/expat/recipe.sh        | 2 --
 recipes/gawk/recipe.sh         | 2 --
 recipes/gcc/recipe.sh          | 3 +--
 recipes/git/recipe.sh          | 2 --
 recipes/gnu-binutils/recipe.sh | 5 ++---
 recipes/gnu-grep/recipe.sh     | 2 --
 recipes/gnu-make/recipe.sh     | 2 --
 recipes/lua/recipe.sh          | 2 --
 recipes/nasm/recipe.sh         | 2 --
 recipes/newlib/recipe.sh       | 6 ++----
 recipes/openssl/recipe.sh      | 4 +---
 recipes/python/recipe.sh       | 3 ---
 recipes/rust/recipe.sh         | 6 ++----
 recipes/sed/recipe.sh          | 2 --
 18 files changed, 12 insertions(+), 41 deletions(-)

diff --git a/config.sh b/config.sh
index b02361061..ad8d6307e 100755
--- a/config.sh
+++ b/config.sh
@@ -2,7 +2,10 @@
 set -e
 
 # Configuration
-export TARGET=x86_64-unknown-redox
+ARCH=x86_64
+export TARGET=$ARCH-unknown-redox
+HOST=$ARCH-elf-redox
+RUST_HOST=$ARCH-unknown-redox
 
 # Automatic variables
 ROOT="$(cd `dirname "$0"` && pwd)"
diff --git a/recipes/curl/recipe.sh b/recipes/curl/recipe.sh
index e3ec67887..cc11e1e63 100644
--- a/recipes/curl/recipe.sh
+++ b/recipes/curl/recipe.sh
@@ -2,8 +2,6 @@ GIT=https://github.com/ids1024/curl.git
 BRANCH=redox
 BUILD_DEPENDS=(openssl)
 
-HOST=x86_64-elf-redox
-
 function recipe_version {
     printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
     skip=1
diff --git a/recipes/dash/recipe.sh b/recipes/dash/recipe.sh
index 26c147b78..83bc86877 100644
--- a/recipes/dash/recipe.sh
+++ b/recipes/dash/recipe.sh
@@ -1,7 +1,6 @@
 GIT=https://github.com/redox-os/dash.git
 BRANCH=redox
 
-HOST=x86_64-elf-redox
 export AR="${HOST}-ar"
 export AS="${HOST}-as"
 export CC="${HOST}-gcc"
diff --git a/recipes/diffutils/recipe.sh b/recipes/diffutils/recipe.sh
index f96a833c6..ea089587f 100644
--- a/recipes/diffutils/recipe.sh
+++ b/recipes/diffutils/recipe.sh
@@ -1,8 +1,6 @@
 VERSION=3.6
 TAR=http://ftp.gnu.org/gnu/diffutils/diffutils-$VERSION.tar.xz
 
-HOST=x86_64-elf-redox
-
 function recipe_version {
     echo "$VERSION"
     skip=1
diff --git a/recipes/expat/recipe.sh b/recipes/expat/recipe.sh
index 672180052..99a07049e 100644
--- a/recipes/expat/recipe.sh
+++ b/recipes/expat/recipe.sh
@@ -1,8 +1,6 @@
 VERSION=2.2.1
 TAR=http://downloads.sourceforge.net/project/expat/expat/$VERSION/expat-$VERSION.tar.bz2
 
-HOST=x86_64-elf-redox
-
 function recipe_version {
     echo "$VERSION"
     skip=1
diff --git a/recipes/gawk/recipe.sh b/recipes/gawk/recipe.sh
index 93a242f8c..0658bdd60 100644
--- a/recipes/gawk/recipe.sh
+++ b/recipes/gawk/recipe.sh
@@ -1,8 +1,6 @@
 GIT=https://github.com/redox-os/gawk
 BRANCH=redox
 
-HOST=x86_64-elf-redox
-
 function recipe_update {
     echo "skipping update"
     skip=1
diff --git a/recipes/gcc/recipe.sh b/recipes/gcc/recipe.sh
index 93c1818b0..760fcf7cf 100644
--- a/recipes/gcc/recipe.sh
+++ b/recipes/gcc/recipe.sh
@@ -1,7 +1,6 @@
 GIT=https://github.com/redox-os/gcc.git
 BRANCH=redox
 
-HOST=x86_64-elf-redox
 export AR="${HOST}-ar"
 export AS="${HOST}-as"
 export CC="${HOST}-gcc"
@@ -52,7 +51,7 @@ function recipe_clean {
 function recipe_stage {
     dest="$(realpath $1)"
     make DESTDIR="$dest" install-gcc install-target-libgcc install-target-libstdc++-v3
-    find "$dest"/{bin,libexec} -exec x86_64-elf-redox-strip {} ';' 2> /dev/null
+    find "$dest"/{bin,libexec} -exec $STRIP {} ';' 2> /dev/null
     ln -s "gcc" "$1/bin/cc"
     skip=1
 }
diff --git a/recipes/git/recipe.sh b/recipes/git/recipe.sh
index 85699f0c8..f9b212c4f 100644
--- a/recipes/git/recipe.sh
+++ b/recipes/git/recipe.sh
@@ -2,8 +2,6 @@ VERSION=2.13.1
 TAR=https://www.kernel.org/pub/software/scm/git/git-$VERSION.tar.xz
 BUILD_DEPENDS=(zlib curl openssl expat)
 
-HOST=x86_64-elf-redox
-
 export AR="${HOST}-ar"
 export AS="${HOST}-as"
 export CC="${HOST}-gcc"
diff --git a/recipes/gnu-binutils/recipe.sh b/recipes/gnu-binutils/recipe.sh
index 8bbe558c9..4475c0c09 100644
--- a/recipes/gnu-binutils/recipe.sh
+++ b/recipes/gnu-binutils/recipe.sh
@@ -1,6 +1,5 @@
 GIT=https://github.com/redox-os/binutils-gdb.git
 
-HOST=x86_64-elf-redox
 export AR="${HOST}-ar"
 export AS="${HOST}-as"
 export CC="${HOST}-gcc"
@@ -24,7 +23,7 @@ function recipe_update {
 }
 
 function recipe_build {
-    ./configure --host=${HOST} --target=${HOST} --prefix=/ --with-sysroot=/usr/x86_64-elf-redox --disable-gdb --disable-nls --disable-werror
+    ./configure --host=${HOST} --target=${HOST} --prefix=/ --with-sysroot=/usr/$HOST --disable-gdb --disable-nls --disable-werror
     make
     skip=1
 }
@@ -42,6 +41,6 @@ function recipe_clean {
 function recipe_stage {
     dest="$(realpath $1)"
     make DESTDIR="$dest" install
-    find "$dest/bin" -exec x86_64-elf-redox-strip {} ';' 2> /dev/null
+    find "$dest/bin" -exec $STRIP {} ';' 2> /dev/null
     skip=1
 }
diff --git a/recipes/gnu-grep/recipe.sh b/recipes/gnu-grep/recipe.sh
index 938b18124..6795cc2a3 100644
--- a/recipes/gnu-grep/recipe.sh
+++ b/recipes/gnu-grep/recipe.sh
@@ -1,8 +1,6 @@
 VERSION=3.1
 TAR=https://ftp.gnu.org/gnu/grep/grep-$VERSION.tar.xz
 
-HOST=x86_64-elf-redox
-
 function recipe_version {
     echo "$VERSION"
     skip=1
diff --git a/recipes/gnu-make/recipe.sh b/recipes/gnu-make/recipe.sh
index 9c0f0c3ea..2d41262f4 100644
--- a/recipes/gnu-make/recipe.sh
+++ b/recipes/gnu-make/recipe.sh
@@ -1,8 +1,6 @@
 VERSION=4.2.1
 TAR=https://ftp.gnu.org/gnu/make/make-$VERSION.tar.gz
 
-HOST=x86_64-elf-redox
-
 export AR="${HOST}-ar"
 export AS="${HOST}-as"
 export CC="${HOST}-gcc"
diff --git a/recipes/lua/recipe.sh b/recipes/lua/recipe.sh
index d976d114c..543b08c8f 100644
--- a/recipes/lua/recipe.sh
+++ b/recipes/lua/recipe.sh
@@ -1,8 +1,6 @@
 VERSION=5.3.1
 TAR=http://www.lua.org/ftp/lua-$VERSION.tar.gz
 
-HOST=x86_64-elf-redox
-
 function recipe_version {
     echo "$VERSION"
     skip=1
diff --git a/recipes/nasm/recipe.sh b/recipes/nasm/recipe.sh
index 0aedbd04b..66c5f9d7f 100644
--- a/recipes/nasm/recipe.sh
+++ b/recipes/nasm/recipe.sh
@@ -1,8 +1,6 @@
 VERSION=2.13.01
 TAR=http://www.nasm.us/pub/nasm/releasebuilds/$VERSION/nasm-$VERSION.tar.gz
 
-HOST=x86_64-elf-redox
-
 function recipe_version {
     echo "$VERSION"
     skip=1
diff --git a/recipes/newlib/recipe.sh b/recipes/newlib/recipe.sh
index 78950b9a6..58387f730 100644
--- a/recipes/newlib/recipe.sh
+++ b/recipes/newlib/recipe.sh
@@ -1,8 +1,6 @@
 GIT=https://github.com/redox-os/newlib.git
 BRANCH=redox
 
-HOST=x86_64-elf-redox
-
 function recipe_version {
     printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
     skip=1
@@ -46,7 +44,7 @@ function recipe_stage {
     dest="$(realpath $1)"
     make DESTDIR="$dest" install
     cd "$dest"
-    mv x86_64-elf-redox/* ./
-    rmdir x86_64-elf-redox
+    mv $HOST/* ./
+    rmdir $HOST
     skip=1
 }
diff --git a/recipes/openssl/recipe.sh b/recipes/openssl/recipe.sh
index 48559cac7..5aef73cb3 100644
--- a/recipes/openssl/recipe.sh
+++ b/recipes/openssl/recipe.sh
@@ -1,8 +1,6 @@
 GIT=https://github.com/ids1024/openssl.git
 BRANCH=redox
 
-HOST=x86_64-elf-redox
-
 function recipe_version {
     printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
     skip=1
@@ -14,7 +12,7 @@ function recipe_update {
 }
 
 function recipe_build {
-    ./Configure no-shared no-dgram redox-x86_64 --prefix="/"
+    ./Configure no-shared no-dgram redox-$ARCH --prefix="/"
     make -j"$(nproc)"
     skip=1
 }
diff --git a/recipes/python/recipe.sh b/recipes/python/recipe.sh
index c0d11da0a..2a8783cfa 100644
--- a/recipes/python/recipe.sh
+++ b/recipes/python/recipe.sh
@@ -1,9 +1,6 @@
 VERSION=3.6.1
 TAR=https://www.python.org/ftp/python/$VERSION/Python-$VERSION.tar.xz
 
-ARCH=x86_64
-HOST=x86_64-elf-redox
-
 export AR="${HOST}-ar"
 export AS="${HOST}-as"
 export CC="${HOST}-gcc"
diff --git a/recipes/rust/recipe.sh b/recipes/rust/recipe.sh
index c2e13f227..e10d07499 100644
--- a/recipes/rust/recipe.sh
+++ b/recipes/rust/recipe.sh
@@ -1,13 +1,11 @@
 GIT=https://github.com/ids1024/rust.git
 BRANCH=compile-redox
 
-ARCH=x86_64
-HOST=x86_64-elf-redox
-RUST_HOST=x86_64-unknown-redox
 LLVM_PREFIX=$PWD/build/llvm-root
-SYSROOT=/usr/x86_64-elf-redox
+SYSROOT=/usr/$HOST
 unset AR AS CC CXX LD NM OBJCOPY OBJDUMP RANLIB READELF STRIP
 
+
 LLVM_CMAKE_ARGS=(-Wno-dev -DCMAKE_CROSSCOMPILING=True -DCMAKE_INSTALL_PREFIX="$LLVM_PREFIX" -DLLVM_DEFAULT_TARGET_TRIPLE=$HOST -DLLVM_TARGET_ARCH=$ARCH -DLLVM_TARGETS_TO_BUILD=X86 -DCMAKE_SYSTEM_NAME=Generic -DPYTHON_EXECUTABLE=/usr/bin/python2 -DUNIX=1 -DLLVM_ENABLE_THREADS=Off -DLLVM_INCLUDE_TESTS=OFF -target=$HOST -DLLVM_TABLEGEN=/usr/bin/llvm-tblgen -I"$SYSROOT/include" -DCMAKE_CXX_FLAGS='--std=gnu++11' -DLLVM_TOOL_LTO_BUILD=Off -DLLVM_TOOL_LLVM_PROFDATA_BUILD=Off -DLLVM_TOOL_LLI_BUILD=Off -DLLVM_TOOL_RDOBJ_BUILD=Off -DLLVM_TOOL_LLVM_COV_BUILD=Off -DLLVM_TOOL_LLVM_XRAY_BUILD=Off -DLLVM_TOOL_LLVM_LTO2_BUILD=Off -DLLVM_TOOL_LLVM_LTO_BUILD=Off -DLLVM_TOOL_LLVM_RTDYLD_BUILD=Off)
 
 function recipe_version {
diff --git a/recipes/sed/recipe.sh b/recipes/sed/recipe.sh
index 7e09799d9..ca77b9102 100644
--- a/recipes/sed/recipe.sh
+++ b/recipes/sed/recipe.sh
@@ -1,8 +1,6 @@
 VERSION=4.4
 TAR=http://ftp.gnu.org/gnu/sed/sed-$VERSION.tar.xz
 
-HOST=x86_64-elf-redox
-
 function recipe_version {
     echo "$VERSION"
     skip=1
-- 
GitLab