File: configure

package info (click to toggle)
yorick 1.5.08-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 7,508 kB
  • ctags: 7,937
  • sloc: ansic: 75,604; cpp: 1,282; lisp: 1,217; sh: 1,026; makefile: 616; fortran: 19
file content (193 lines) | stat: -rwxr-xr-x 5,600 bytes parent folder | download
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#! /bin/sh

# debug=yes to keep all cfg.* stdout and stderr files
# (most recent warnings always kept, usually don't need debug)
debug=no

echo ""
echo "=============== begin top level configuration ==============="
echo ""

while test -n "$1"; do
  if test -d "$1"; then
    if test -n "$pkgdirs"; then
      pkgdirs="$pkgdirs $1"
    else
      pkgdirs="$1"
    fi
  else
    echo "**** ERROR **** no such directory ($1) to configure"
    echo "rerun ./configure with proper execute line"
  fi
  shift
done

if test -z "$CC" && make echocc >/dev/null 2>&1; then
  CC=`cat cfg.tmp`
  if test -z "$CC"; then CC=cc; fi
fi
if test -z "$RANLIB" && make echorl >/dev/null 2>&1; then
  RANLIB=`cat cfg.tmp`
fi
if test -z "$AR" && make echoar >/dev/null 2>&1; then
  AR=`cat cfg.tmp`
  if test -z "$AR"; then AR=ar; fi
fi
rm -f cfg.*
curdate=`date`
cursystem=`uname -a`
cat >Make.cfg <<EOF
# Make.cfg built by configure script on $curdate
# $cursystem
SHELL=/bin/sh
EOF

#------------------------------------------------------------------------
# test that the compiler can handle several ANSI C features
cat >cfg.c <<EOF
#undef _POSIX_SOURCE
#define _POSIX_SOURCE 1
/* check whether compiler has necessary ANSI C (non K&R) features */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct junk { int x; double y; } glbl= { 1, -2.0 };
extern int oops(struct junk *dummy);      /* prototype */
extern volatile int vol;
volatile int vol= 0;                      /* volatile qualifier */
int oops(struct junk *dummy) {            /* ANSI function definition */
  struct junk loc1= *dummy;               /* struct assign */
  struct junk loc2= { -3, 4.0 };          /* aggregate automatic init */
  void *vtest= &glbl;                     /* implicit void pointer cast */
  printf("%p %d %g\n", vtest, loc1.x, loc2.y);
  return 0;
}
int main(int argc, char *argv[])
{
  size_t l= strlen("four");               /* size_t typedef */
  struct junk *locl= malloc(sizeof(struct junk)); /* void * cast */
  *locl= glbl;                            /* struct assignment */
  return oops(l>3? locl : &glbl);
}
EOF
if $CC $CFLAGS -o cfg cfg.c $LDFLAGS >cfg.00a 2>&1; then
  :
elif $CC -Aa $CFLAGS -o cfg cfg.c $LDFLAGS >cfg.00b 2>&1; then
  CC="$CC -Aa"
  if test $debug = no; then rm -f cfg.00a; fi
elif gcc $CFLAGS -o cfg cfg.c $LDFLAGS >cfg.00b 2>&1; then
  CC=gcc
  if test $debug = no; then rm -f cfg.00b; fi
else
  rm -f cfg cfg.c
  echo "$CC is not an ANSI C compiler; rerun ./configure with CC env variable"
  exit 1
fi
if $CC $CFLAGS -c cfg.c >cfg.00c 2>&1; then
  echo "$CC is an ANSI C compiler.  Good."
else
  echo "$CC loads but won't compile?  check cfg.00[abc] file messages"
  exit 1
fi

COPTS="$CFLAGS"
LOPTS="$LDFLAGS"
if test -z "$COPTS"; then
  if test -z "$LOPTS"; then  # default compiler flag is -O
    COPTS=-O
    LOPTS=-O
  fi
fi

echo "CC=$CC" >>Make.cfg
echo "COPTIONS=$COPTS" >>Make.cfg
echo "LDOPTIONS=$LOPTS" >>Make.cfg

echo 'GCCOPTS=-g -O2 -ansi -pedantic -Wall $(GCCPROTO)' >>Make.cfg
echo 'GCCPROTO=-Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations' >>Make.cfg

#------------------------------------------------------------------------
# check whether ranlib exists and is necessary
if ar cr cfg.a cfg.o >cfg.00d 2>&1; then
  if ${RANLIB:-ranlib} cfg.a >cfg.00e 2>&1; then
    if test -s cfg.00e && grep "already did it" cfg.00e >/dev/null 2>&1; then
      RANLIB=:
    else
      RANLIB=${RANLIB:-ranlib}
    fi
  else
    RANLIB=:
  fi
else
  echo "ar utility broken?  check messages in file cfg.00d"
  exit 1
fi
rm -f cfg cfg.c cfg.o cfg.a cfg.00d cfg.00e

echo "RANLIB=$RANLIB" >>Make.cfg
echo "AR=$AR" >>Make.cfg

#------------------------------------------------------------------------
# check alternate libm for Alpha Linux (see play/unix/README.fpu)

if test -z "$MATHLIB" && make echoml >/dev/null 2>&1; then
  MATHLIB=`cat cfg.tmp`
  rm -f cfg.tmp
  if test -z "$MATHLIB"; then MATHLIB="-lm"; fi
  cat >cfg.c <<EOF
/* check whether libm is broken */
#include <math.h>
int main(int argc, char *argv[])
{
  return exp(-720.) > 1.0;  /* typically an IEEE denormal */
}
EOF
  if $CC $CFLAGS -o cfg cfg.c $LDFLAGS $MATHLIB >cfg.00f 2>&1; then
    if ./cfg >cfg.00g 2>&1; then
      :
    else
      if $CC $CFLAGS -o cfg cfg.c $LDFLAGS -lcpml >cfg.00h 2>&1; then
        MATHLIB="-lcpml"
        echo "WARNING - using -lcpml instead of -lm"
      else
        rm -f cfg.00h
        echo "WARNING - libm broken? see play/unix/README.fpu"
        echo "  if on Alpha Linux, rerun ./configure with CC='gcc -mieee'"
      fi
    fi
    rm -f cfg cfg.c cfg.00g
  else
    echo "math library missing; rerun ./configure with MATHLIB env variable"
    exit 1
  fi
else
  rm -f cfg.tmp
fi
echo "MATHLIB=$MATHLIB" >>Make.cfg

#----------------------------------------------------------------------
# clean up, issue warning if compiler gave fishy output
rm -f cfg cfg.c cfg.o
for f in cfg.[0-9]*; do
  if grep ... $f >/dev/null 2>&1; then   # or use test -s $f ?
    echo "WARNING - check compiler message in $f"
  else # remove empty files
    rm -f $f
  fi
done

#----------------------------------------------------------------------
# set up installation directories

#----------------------------------------------------------------------
# set up optional packages

#----------------------------------------------------------------------
# configure subdirectories

make pkgconfig "PKGDIRS=$pkgdirs"

echo ""
echo "================ all configuration completed ================"
exit 0
#----------------------------------------------------------------------