From ef52e78eccd59530b011b5aa6aafb291fe2b059f Mon Sep 17 00:00:00 2001
From: Jeremy Soller <jeremy@system76.com>
Date: Sun, 6 Jan 2019 16:20:08 -0700
Subject: [PATCH] Add glium, fix recipes

---
 recipes/glium/recipe.sh    | 24 ++++++++++++++++++++++++
 recipes/glutin/recipe.sh   | 10 ++++------
 recipes/hematite/recipe.sh |  2 +-
 recipes/nasm/recipe.sh     |  5 ++---
 recipes/osdemo/recipe.sh   |  4 ++--
 recipes/pixman/recipe.sh   |  6 +++++-
 6 files changed, 38 insertions(+), 13 deletions(-)
 create mode 100644 recipes/glium/recipe.sh

diff --git a/recipes/glium/recipe.sh b/recipes/glium/recipe.sh
new file mode 100644
index 000000000..1ba951965
--- /dev/null
+++ b/recipes/glium/recipe.sh
@@ -0,0 +1,24 @@
+GIT=https://gitlab.redox-os.org/redox-os/glium.git
+GIT_UPSTREAM=https://github.com/glium/glium.git
+BUILD_DEPENDS=(llvm mesa zlib)
+BRANCH=redox
+CARGOFLAGS="--example teapot"
+
+function recipe_build {
+    sysroot="$(realpath ../sysroot)"
+    cp -p "$ROOT/Xargo.toml" "Xargo.toml"
+    set -x
+    xargo rustc --target "$TARGET" --release ${CARGOFLAGS} \
+        -- \
+        -L "${sysroot}/lib" \
+        -C link-args="$("${PKG_CONFIG}" --libs osmesa) -lglapi -lz -lstdc++ -lc -lgcc"
+    set +x
+    skip=1
+}
+
+function recipe_stage {
+    dest="$(realpath $1)"
+    mkdir -pv "$dest/bin"
+    cp -v "target/${TARGET}/release/examples/teapot" "$dest/bin/glium"
+    skip=1
+}
diff --git a/recipes/glutin/recipe.sh b/recipes/glutin/recipe.sh
index fe95257fb..bd2beb51d 100644
--- a/recipes/glutin/recipe.sh
+++ b/recipes/glutin/recipe.sh
@@ -1,20 +1,18 @@
 GIT=https://gitlab.redox-os.org/redox-os/glutin.git
 GIT_UPSTREAM=https://github.com/tomaka/glutin.git
-BUILD_DEPENDS=(mesa zlib)
+BUILD_DEPENDS=(llvm mesa zlib)
 BRANCH=redox
 CARGOFLAGS="--example window"
 
 function recipe_build {
     sysroot="$(realpath ../sysroot)"
     cp -p "$ROOT/Xargo.toml" "Xargo.toml"
+    set -x
     xargo rustc --target "$TARGET" --release ${CARGOFLAGS} \
         -- \
         -L "${sysroot}/lib" \
-        -l OSMesa \
-        -l glapi \
-        -l z \
-        -l stdc++ \
-        -C link-args="-Wl,--whole-archive -lpthread -Wl,--no-whole-archive"
+        -C link-args="$("${PKG_CONFIG}" --libs osmesa) -lglapi -lz -lstdc++ -lc -lgcc"
+    set +x
     skip=1
 }
 
diff --git a/recipes/hematite/recipe.sh b/recipes/hematite/recipe.sh
index 7dfcbbd6a..14014f56f 100644
--- a/recipes/hematite/recipe.sh
+++ b/recipes/hematite/recipe.sh
@@ -1,6 +1,6 @@
 GIT=https://gitlab.redox-os.org/redox-os/hematite.git
 GIT_UPSTREAM=https://github.com/PistonDevelopers/hematite.git
-BUILD_DEPENDS=(mesa llvm zlib)
+BUILD_DEPENDS=(llvm mesa zlib)
 BRANCH=redox
 
 function recipe_build {
diff --git a/recipes/nasm/recipe.sh b/recipes/nasm/recipe.sh
index 46150a345..de7fa3749 100644
--- a/recipes/nasm/recipe.sh
+++ b/recipes/nasm/recipe.sh
@@ -1,4 +1,4 @@
-VERSION=2.13.01
+VERSION=2.14.02
 TAR=http://www.nasm.us/pub/nasm/releasebuilds/$VERSION/nasm-$VERSION.tar.gz
 
 function recipe_version {
@@ -29,8 +29,7 @@ function recipe_clean {
 
 function recipe_stage {
     dest="$(realpath $1)"
-    make INSTALLROOT="$dest" install
-    rm -rf "$dest"/share
+    make install DESTDIR="$dest"
     find "$dest"/bin -exec ${HOST}-strip {} ';' 2> /dev/null
     skip=1
 }
diff --git a/recipes/osdemo/recipe.sh b/recipes/osdemo/recipe.sh
index f14b722a1..37599034f 100644
--- a/recipes/osdemo/recipe.sh
+++ b/recipes/osdemo/recipe.sh
@@ -1,4 +1,4 @@
-BUILD_DEPENDS=(liborbital mesa mesa_glu zlib)
+BUILD_DEPENDS=(liborbital llvm mesa mesa_glu zlib)
 
 function recipe_version {
     printf "1.0.0"
@@ -19,7 +19,7 @@ function recipe_prepare {
 function recipe_build {
     sysroot="$(realpath ../sysroot)"
     set -x
-    "${CXX}" -I "$sysroot/include" -L "$sysroot/lib" osdemo.c -o osdemo -lorbital -lOSMesa -lGLU -lglapi -lz -Wl,--whole-archive -lpthread -Wl,--no-whole-archive -lm
+    "${CXX}" -O2 -I "$sysroot/include" -L "$sysroot/lib" osdemo.c -o osdemo -lorbital $("${PKG_CONFIG}" --libs glu) -lglapi -lz
     set +x
     skip=1
 }
diff --git a/recipes/pixman/recipe.sh b/recipes/pixman/recipe.sh
index 88274193b..617827dc7 100755
--- a/recipes/pixman/recipe.sh
+++ b/recipes/pixman/recipe.sh
@@ -13,7 +13,11 @@ function recipe_update {
 
 function recipe_build {
 	sysroot="$(realpath ../sysroot)"
-	./configure --host=${HOST} --prefix=/
+	./configure \
+		--host=${HOST} \
+		--prefix=/ \
+		--disable-shared \
+		--enable-static
 	make -j"$(nproc)"
 	skip=1
 }
-- 
GitLab