pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/graphics/MesaLib Allow MesaLib to be cross-compiled. T...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/1c2c6ed5c74c
branches:  trunk
changeset: 531786:1c2c6ed5c74c
user:      joerg <joerg%pkgsrc.org@localhost>
date:      Mon Aug 06 13:47:38 2007 +0000

description:
Allow MesaLib to be cross-compiled. This is horrible slow, but working
magic.

diffstat:

 graphics/MesaLib/distinfo              |   4 +-
 graphics/MesaLib/files/gen_matypes.awk |  31 ++++++++++
 graphics/MesaLib/files/gen_matypes.sh  |  98 ++++++++++++++++++++++++++++++++++
 graphics/MesaLib/patches/patch-ca      |  18 ++++++
 graphics/MesaLib/patches/patch-cb      |  15 +++++
 5 files changed, 165 insertions(+), 1 deletions(-)

diffs (193 lines):

diff -r 21a3292170da -r 1c2c6ed5c74c graphics/MesaLib/distinfo
--- a/graphics/MesaLib/distinfo Mon Aug 06 13:10:13 2007 +0000
+++ b/graphics/MesaLib/distinfo Mon Aug 06 13:47:38 2007 +0000
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.45 2007/04/13 09:12:02 tnn Exp $
+$NetBSD: distinfo,v 1.46 2007/08/06 13:47:38 joerg Exp $
 
 SHA1 (Mesa-6.4.2/MesaDemos-6.4.2.tar.bz2) = 35b1ff78fc1bd1c303be754ad2ff4252ad6c0258
 RMD160 (Mesa-6.4.2/MesaDemos-6.4.2.tar.bz2) = 82e1dafd39abbe1c0e1de49adcff00dec19c6c1a
@@ -22,3 +22,5 @@
 SHA1 (patch-ak) = 9f3480d08d2b6b7048b018956c57ad6e5d253174
 SHA1 (patch-al) = 8ccbc370bc52882ee72ba76b72a99f163f7b89a7
 SHA1 (patch-am) = a7a40d0d1f371cfa312ae504582ce0521172f85c
+SHA1 (patch-ca) = 5a40dba087b59711778f499b084a2b818b779320
+SHA1 (patch-cb) = 31b4358e171042608a017f4dc98d44f35fcdce70
diff -r 21a3292170da -r 1c2c6ed5c74c graphics/MesaLib/files/gen_matypes.awk
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/graphics/MesaLib/files/gen_matypes.awk    Mon Aug 06 13:47:38 2007 +0000
@@ -0,0 +1,31 @@
+# $NetBSD: gen_matypes.awk,v 1.1 2007/08/06 13:47:39 joerg Exp $
+
+BEGIN {
+       while (getline) {
+               if (/int main/) break;
+       }
+}
+
+/printf/ {
+       printf("printf %s\n", substr($0, 12, length($0) - 14))
+}
+/OFFSET\(/ {
+       split(substr($0,12, length($0) - 14), offsets, ",");
+       printf("offset %s \"%s\" \"%s\"\n", offsets[1], offsets[2], offsets[3]);
+}
+/OFFSET_HEADER/ {
+       printf("offset_header %s\n", substr($0,19, length($0) - 21))
+}
+
+/DEFINE\(/ {
+       split(substr($0,12, length($0) - 14), offsets, ",");
+       printf("define %s \"%s\"\n", offsets[1], offsets[2]);
+}
+/DEFINE_HEADER/ {
+       printf("define_header %s\n", substr($0,19, length($0) - 21))
+}
+
+/SIZEOF\(/ {
+       split(substr($0,12, length($0) - 14), offsets, ",");
+       printf("sizeof %s \"%s\"\n", offsets[1], offsets[2]);
+}
diff -r 21a3292170da -r 1c2c6ed5c74c graphics/MesaLib/files/gen_matypes.sh
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/graphics/MesaLib/files/gen_matypes.sh     Mon Aug 06 13:47:38 2007 +0000
@@ -0,0 +1,98 @@
+#!/bin/sh
+#
+# $NetBSD: gen_matypes.sh,v 1.1 2007/08/06 13:47:39 joerg Exp $
+
+test_condition() {
+       cat > gen_matypes_cross.c << EOF
+#include "main/glheader.h"
+#include "main/mtypes.h"
+#include "tnl/t_context.h"
+
+#undef offsetof
+#define offsetof( type, member ) ((size_t) &((type *)0)->member)
+
+int test_variable[($1) ? 1 : -1];
+EOF
+       ${CC} -c -o /dev/null ${CFLAGS} gen_matypes_cross.c > /dev/null 2>&1
+}
+
+compute_powers(){
+       local cur
+       local i
+       cur=1
+       i=1
+       while [ ${i} -le 16 ]; do
+               power_of_two="${cur} ${power_of_two}"
+               cur=`expr ${cur} + ${cur}`
+               i=`expr ${i} + 1`
+       done
+}
+
+compute_powers
+
+offset() {
+       local got_mismatch
+       local bits
+       local o
+       o=0
+       got_mismatch=0
+       for bits in ${power_of_two}; do
+               if test_condition "offsetof($2, $3) >= $o + $bits"; then
+                       o=`expr $o + $bits`
+               else
+                       got_mismatch=1
+               fi
+       done
+       [ "$got_mismatch" = 0 ] && exit 1
+       printf "#define %s\t%d\n" "$1" $o
+}
+
+offset_header() {
+       printf "\n"
+       printf "\n"
+       printf "/* =============================================================\n"
+       printf " * Offsets for %s\n" "$1"
+       printf " */\n"
+       printf "\n"
+}
+
+define_header() {
+       printf "\n"
+       printf "/*\n"
+       printf " * Flags for %s\n" "$1"
+       printf " */\n"
+       printf "\n"
+}
+
+define() {
+       local bits
+       local v
+       v=0
+       for bits in ${power_of_two}; do
+               if test_condition "$2 >= $v + $bits"; then
+                       v=`expr $v + $bits`
+               fi
+       done
+       printf "#define %s\t0x%x\n" "$1" $v
+}
+
+sizeof() {
+       local got_mismatch
+       local bits
+       local v
+       v=0
+       got_mismatch=0
+       for bits in ${power_of_two}; do
+               if test_condition "sizeof($2) >= $v + $bits"; then
+                       v=`expr $v + $bits`
+               else
+                       got_mismatch=1
+               fi
+       done
+       [ "$got_mismatch" = 0 ] && exit 1
+       printf "#define %s\t0x%x\n" "$1" $v
+}
+
+awk -f gen_matypes.awk < gen_matypes.c > gen_matypes_tmp.sh
+. ./gen_matypes_tmp.sh
+rm gen_matypes_tmp.sh
diff -r 21a3292170da -r 1c2c6ed5c74c graphics/MesaLib/patches/patch-ca
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/graphics/MesaLib/patches/patch-ca Mon Aug 06 13:47:38 2007 +0000
@@ -0,0 +1,18 @@
+$NetBSD: patch-ca,v 1.1 2007/08/06 13:47:39 joerg Exp $
+
+--- src/mesa/x86/Makefile.orig 2007-08-06 05:42:04.000000000 +0200
++++ src/mesa/x86/Makefile
+@@ -24,8 +24,13 @@ gen_matypes: gen_matypes.c
+       $(CC) $(INCLUDE_DIRS) $(CFLAGS) gen_matypes.c -o gen_matypes
+ 
+ # need some special rules here, unfortunately
++.if defined(CROSS_COMPILING)
++matypes.h: ../main/mtypes.h ../tnl/t_context.h gen_matypes.c
++      CFLAGS="${INCLUDE_DIRS} ${CFLAGS}" ./gen_matypes.sh > matypes.h
++.else
+ matypes.h: ../main/mtypes.h ../tnl/t_context.h gen_matypes
+       ./gen_matypes > matypes.h
++.endif
+ 
+ common_x86_asm.o: matypes.h
+ 3dnow_normal.o: matypes.h
diff -r 21a3292170da -r 1c2c6ed5c74c graphics/MesaLib/patches/patch-cb
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/graphics/MesaLib/patches/patch-cb Mon Aug 06 13:47:38 2007 +0000
@@ -0,0 +1,15 @@
+$NetBSD: patch-cb,v 1.1 2007/08/06 13:47:39 joerg Exp $
+
+--- src/mesa/x86-64/Makefile.orig      2007-08-06 05:47:48.000000000 +0200
++++ src/mesa/x86-64/Makefile
+@@ -23,7 +23,8 @@ clean:
+ 
+ 
+ # need some special rules here, unfortunately
+-matypes.h: ../main/mtypes.h ../tnl/t_context.h ../x86/gen_matypes
+-      ../x86/gen_matypes | grep -v '#include "assyntax.h' > matypes.h
++matypes.h: ../main/mtypes.h ../tnl/t_context.h ../x86/matypes.h
++      cd ../x86 && ${MAKE} matypes.h
++      grep -v '#include "assyntax.h' < ../x86/matypes.h > matypes.h
+ 
+ xform4.o: matypes.h



Home | Main Index | Thread Index | Old Index