Ticket #9814: buildpackage.sh

File buildpackage.sh, 2.9 KB (added by kallisti5, 7 years ago)

updated Mesa build script for reference.

Line 
1#!/bin/bash
2# Mesa-O-Matic
3# Copyright 2011-2013, Alexander von Gluck IV
4# Released under the terms of the MIT license
5
6# This script creates an optional package containing the
7# the headers and binary code needed by the opengl kit
8# to link libGL.so and the OpenGL add-ons
9
10# This script is run against a *COMPILED* Mesa source tree
11
12echo " Welcome to Mesa-O-Matic!"
13echo "-=-=-=-=-=-=-=-=-=-=-=-=-="
14echo ""
15
16if [[ $DEBUG -eq 1 ]]; then
17 echo "Debugging: enabled"
18else
19 echo "Debugging: disabled"
20fi
21
22#######################################################################
23# END CONFIG DATA, Dragons below!
24#######################################################################
25
26function piraterepack {
27 # Ar. Ye be a hack.
28 # Provided a list of .a's, repack them together
29 PACKTMP=/tmp/repack
30 rm -rf $PACKTMP
31 mkdir $PACKTMP
32 for i in $1
33 do
34 if [[ "$1" = /* ]]
35 then
36 # Absolute path
37 cp $i $PACKTMP/ ;
38 else
39 find . -name "$i" -exec cp "{}" $PACKTMP/ \;
40 fi
41 done
42 cd $PACKTMP
43 find . -name "*.a" -exec ar x "{}" \;
44 rm *.a
45 ar rcs $2 *
46 cd -
47 cp $PACKTMP/$2 ./build/
48 rm -rf $PACKTMP
49}
50
51if [[ $( uname ) != "Haiku" ]]; then
52 echo "*************************************"
53 echo " I need to be run on a Haiku system!!"
54 echo "*************************************"
55 exit 1
56fi
57
58if [[ -z $1 ]]; then
59 echo ""
60 echo "Usage: $0 <mesa version> <compiled mesa location>"
61 echo ""
62 exit 1
63fi
64
65MESA_VER="$1"
66MESA_TOP="$2"
67GCC_VER=`gcc -v 2>&1 | tail -1 | awk '{print $3}' | cut -d. -f1`
68DATESTAMP=`date +"%Y-%m-%d"`
69
70echo "Bundling gcc$GCC_VER build of Mesa $MESA_VER..."
71
72cd $MESA_TOP
73
74#######################################################################
75# Create Mesa optional pacakge
76ZIP_HEADERS=""
77echo "Collecting Mesa headers..."
78for i in $(find . -name "*.h")
79do
80 ZIP_HEADERS="$ZIP_HEADERS $i"
81done
82
83echo "Collecting required Mesa libraries..."
84
85rm -rf lib.haiku
86
87BASE_LIBS="libglapi.a libmesa.a"
88
89if [[ $GCC_VER -ge 4 ]]; then
90BASE_LIBS="$BASE_LIBS libgallium.a libglsl.a"
91
92# Repack the Mesa objects into an easy to digest archives
93# These bundles are linked into OpenGL add-ons
94
95## llvmpipe bundle
96LLVM_LIBS=`llvm-config --libfiles engine bitwriter mcjit`
97piraterepack "$LLVM_LIBS" "swpipe_llvm.a"
98piraterepack "swpipe_llvm.a libsoftpipe.a libllvmpipe.a" \
99 "swpipe_bundle.a"
100BASE_LIBS="$BASE_LIBS swpipe_bundle.a"
101
102## r600 bundle
103## etc bundle
104fi
105
106mkdir -p lib.haiku
107for i in $BASE_LIBS
108do
109 find ./build/ -name "$i" -exec cp -f {} lib.haiku/ \;
110 if [[ $? -ne 0 ]]; then
111 echo "Warning: couldn't locate $i"
112 fi
113done
114
115if [[ $DEBUG -eq 0 ]]; then
116echo "Stripping debug symbols from Mesa libraries..."
117find lib.haiku/* -exec strip --strip-debug {} \; ;
118MESADBG=""
119else
120MESADBG="dbg"
121fi
122
123echo "Creating Mesa OptionalPackage..."
124PLATFORM=$( uname -m )
125ZIP_FILENAME="/boot/home/mesa-${MESA_VER}-x86${MESADBG}-gcc${GCC_VER}-${DATESTAMP}.zip"
126zip -r -9 $ZIP_FILENAME $ZIP_HEADERS ./lib.haiku/*
127
128echo "Great Success! $ZIP_FILENAME created."