OSDN Git Service

ccd073844c9b2928ad22ab86b941dcda1bd04144
[pf3gnuchains/gcc-fork.git] / libgfortran / mk-kinds-h.sh
1 #!/bin/sh
2
3 compile="$1"
4
5 # Possible types must be listed in ascending order
6 possible_integer_kinds="1 2 4 8 16"
7 possible_real_kinds="4 8 10 16"
8
9
10 largest=""
11 smallest=""
12 for k in $possible_integer_kinds; do
13   echo "  integer (kind=$k) :: i" > tmp$$.f90
14   echo "  end" >> tmp$$.f90
15   if $compile -c tmp$$.f90 > /dev/null 2>&1; then
16     s=`expr 8 \* $k`
17     largest="$k"
18
19     if [ $s -eq 128 ]; then
20       prefix="__"
21     else
22       prefix=""
23     fi
24
25     if [ "$smallest" = "" ]; then
26         smallest="$k"
27     fi
28
29     echo "typedef ${prefix}int${s}_t GFC_INTEGER_${k};"
30     echo "typedef ${prefix}uint${s}_t GFC_UINTEGER_${k};"
31     echo "typedef GFC_INTEGER_${k} GFC_LOGICAL_${k};"
32     echo "#define HAVE_GFC_LOGICAL_${k}"
33     echo "#define HAVE_GFC_INTEGER_${k}"
34   fi
35   rm -f tmp$$.*
36 done
37
38 echo "#define GFC_INTEGER_LARGEST GFC_INTEGER_${largest}"
39 echo "#define GFC_UINTEGER_LARGEST GFC_UINTEGER_${largest}"
40 echo "#define GFC_DEFAULT_CHAR ${smallest}"
41 echo ""
42
43
44 largest_ctype=""
45 for k in $possible_real_kinds; do
46   echo "  real (kind=$k) :: x" > tmp$$.f90
47   echo "  end" >> tmp$$.f90
48   if $compile -c tmp$$.f90 > /dev/null 2>&1; then
49     case $k in
50       4) ctype="float" ;;
51       8) ctype="double" ;;
52       10) ctype="long double" ;;
53       16) ctype="long double" ;;
54       *) echo "$0: Unknown type" >&2 ; exit 1 ;;
55     esac
56     largest_ctype="$ctype"
57     echo "typedef ${ctype} GFC_REAL_${k};"
58     echo "typedef complex ${ctype} GFC_COMPLEX_${k};"
59     echo "#define HAVE_GFC_REAL_${k}"
60     echo "#define HAVE_GFC_COMPLEX_${k}"
61   fi
62   rm -f tmp$$.*
63 done
64
65 case $largest_ctype in
66   float) echo "#define GFC_REAL_LARGEST_FORMAT \"\"" ;;
67   double) echo "#define GFC_REAL_LARGEST_FORMAT \"l\"" ;;
68   "long double") echo "#define GFC_REAL_LARGEST_FORMAT \"L\"" ;;
69   *) echo "$0: Unknown type" >&2 ; exit 1 ;;
70 esac
71 echo "#define GFC_REAL_LARGEST $largest_ctype"
72
73 exit 0