summaryrefslogtreecommitdiff
path: root/package/skalibs/patches/patch-configure
blob: bfd2916225f813b2ecbb80effe3b42c851081bce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
--- skalibs-2.3.10.0.orig/configure	2016-03-19 16:04:58.000000000 +0100
+++ skalibs-2.3.10.0/configure	2016-09-03 17:23:41.494368249 +0200
@@ -154,10 +154,28 @@ choose () {
 
 trytypesize() {
   echo "Checking size of $3..."
-  $CC_AUTO $CPPFLAGS_AUTO $CFLAGS_AUTO $LDFLAGS_AUTO -o trysizeof$1 src/sysdeps/trysizeof$1.c
-  type_size=$(./trysizeof$1) || fail "$0: unable to determine size of $3"
+  r=false
+  type_size=0
+  while true; do
+    cat<<EOF>trysizeof$1.c
+#include <sys/types.h>
+
+int main(void)
+{
+  static int v = 1 / !!((sizeof($3) == $type_size));
+  return 0;
+}
+EOF
+    if $CC_AUTO $CPPFLAGS_AUTO $CFLAGS_AUTO $LDFLAGS_AUTO -o trysizeof$1 trysizeof$1.c 2>/dev/null; then
+        r=true
+        break
+    fi
+    type_size=$(expr $type_size + 1)
+    test $type_size -le 16 || break
+  done
+  test $r = true || fail "$0: unable to determine size of $3"
   type_bits=$(expr 8 \* $type_size)
-  rm -f trysizeof$1
+  rm -f trysizeof$1 trysizeof$1.c
   echo "sizeof$1: $type_size" >> $sysdeps/sysdeps
   echo "#define ${package_macro_name}_SIZEOF$2 $type_size" >> $sysdeps/sysdeps.h
   echo "#define ${package_macro_name}_$2_BITS $type_bits" >> $sysdeps/sysdeps.h
@@ -451,12 +469,20 @@ EOF
   fi
 
   echo "Checking system endianness..."
-  $CC_AUTO $CPPFLAGS_AUTO $CFLAGS_AUTO -o tryendianness src/sysdeps/tryendianness.c
-  endianness=$(./tryendianness) || fail "$0: unable to determine endianness"
+  if $CC_AUTO $CPPFLAGS_AUTO $CFLAGS_AUTO -o trybigendian src/sysdeps/trybigendian.c 2>/dev/null; then
+      endianness=big
+  else
+      if $CC_AUTO $CPPFLAGS_AUTO $CFLAGS_AUTO -o trylittleendian src/sysdeps/trylittleendian.c 2>/dev/null; then
+          endianness=little
+      else
+          fail "$0: unable to determine endianness"
+      fi
+  fi
+
   echo "endianness: $endianness" >> $sysdeps/sysdeps
   echo "#define ${package_macro_name}_ENDIANNESS \"$endianness\"" >> $sysdeps/sysdeps.h
   echo "  ... $endianness"
-  rm -f tryendianness
+  rm -f trybigendian trylittleendian
 
   trytypesize ushort USHORT "unsigned short"
   trytypesize uint UINT "unsigned int"