summaryrefslogtreecommitdiff
path: root/Configure
blob: 1e9dc7dcf5056e4e41ed9e47b63a87c7e76ba457 (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
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
#!/bin/sh

echo This script will ask you several questions related to the configuration
echo of your system. To choose the default answer \(the one printed between
echo the brackets\), simply press Enter.
echo
echo "Checking echo to see how to suppress newlines..."

if (echo "hi\c"; echo " ") | grep c >/dev/null 2>&1 ; then
  echo "...using -n."; n=-n; c=
else
  cat <<EOM
...using \c
EOM
  n=; c='\c'
fi
echo $n ..."The star should be here-->$c"; echo '*'

if test -r ./config.in; then . ./config.in; fi

# TODO : gestion du echo -n...

# On determine OS et on met en place les flags bizarres.
syst=`uname -a | awk '{print $1$3}'`

case $syst in 
    FreeBSD*)
      ostype=freebsd
      defC=/usr/bin/gcc
      make=/usr/bin/make
      ldlibs="-lm"
      ;;
    CYGWIN*)
      ostype="cygwin"
      defC="gcc"
      make="make"
      ldlibs="-lm"
      ;;
    SunOS5*)
        ostype=solaris	
	defC=/usr/local/bin/gcc
	machtype=sparc
	make=/usr/ccs/bin/make	
	ldlibs="-lm"
	;;
    Linux*)
	fpucw=`grep __setfpucw /usr/include/fpu_control.h`
	if test -z "$fpucw"; then special="-DLIBC211"; fi;  # for __setfpucw
        ostype=linux
	defC=/usr/bin/gcc
	make=/usr/bin/make
	machtype=`uname -a | awk '{print $11}'`
	if [ "$machtype" = "alpha" ]; 
	then special="-mfp-rounding-mode=d -mieee-with-inexact";
	fi; 
	ldlibs="-lm"
	;;
    OSF*)
        special="-D__STDC__ $special -mfp-rounding-mode=d -mieee-with-inexact -ffloat-store";
        ostype=alpha
	defC=/usr/local/bin/gcc
	make=/usr/local/gnu/bin/make # pour $LDLIBS des tests
	machtype=dec
	ldlibs="-lm"
	;;
    SunOS4*)
        ostype=sunos
	machtype=sparc
	defC=/usr/local/gnu/bin/gcc 
	make=/usr/local/gnu/bin/make
	ldlibs="-lm"	
	;;
    IRIX64*)
	ostype=IRIX64
	machtype=sgi
	defC=/usr/local/gnu/bin/gcc
	make=/usr/local/gnu/bin/make
	ldlibs="-lm"
	;;
    HP-UX*)
	ostype=HPUX
	machtype=HP
	defC=/usr/local/gnu/bin/gcc
	make=/usr/local/gnu/bin/make
	special="-Dhpux"
	ldpath="-L/lib/pa1.1"
	ldlibs="-lM"	
	;;	
    AIX*)
	ostype=AIX
	machtype=IBM
	defC=/usr/local/bin/gcc
	make=/usr/local/bin/make
	ldlibs="-lm"
	;;
    *)
	ostype=unknown
	make=/usr/local/gnu/bin/make
	machtype=default;;	
	# we should try to look for gcc there 
esac

echo You seem to be using a $machtype running $ostype.
echo

if [ "$ostype" = "IRIX64" ]; 
	then
	echo On this architecture you need to decide whether your program
	echo will be compiled as a 32-bit or a 64-bit executable. 
	echo
		while :; do
		echo $n "32/64 bits mode [32] ? $c"
		read ans
		case "$ans" in
		   '' | 32*)
		   special="-mabi=n32 $special"
		   break
		   ;;
		   64*) 
		   special="-mabi=64 $special"
		   break;;
		   *) 
		   echo Invalid choice
		   ;;
		esac
		done; 
fi

while :; do
    echo $n "Which C compiler are you going to use [$defC] ? $c"
    read ans
    case "$ans" in 
	'')
	ans="$defC"
	break
	;;
	*)
	if test -x "$ans"; then break; fi
	echo $n "*** $ans: file does not exist or execution permission denied"
    esac
done
defC=$ans

echo Using compiler $defC
echo
echo I now need to know where to find the GMP distribution. I do not actually
echo need the full distribution, but only the following include files : 
echo gmp.h, gmp-impl.h, gmp-mparam.h, longlong.h, stack-alloc.h

while :; do
    echo $n "Where should I look for these files [$inc] ? $c"
    read ans
    case "$ans" in 
	'')
	ans=$inc
	;;
	*) 
	;;
    esac
    if test -r "$ans"/gmp.h -a -r "$ans"/gmp-impl.h -a -r "$ans"/gmp-mparam.h -a -r "$ans"/longlong.h -a -r "$ans"/stack-alloc.h; 
    then incflags="-I$ans" 
	 break; 
    fi; 
    # ad hoc installation 
    
    if test -r "$ans"/gmp.h -a \
	    -r "$ans"/gmp-impl.h -a \
	    -r "$ans"/mpn/gmp-mparam.h -a \
	    -r "$ans"/longlong.h -a \
	    -r stack-alloc.h; 
    then 
    incflags="-I$ans -I$ans/mpn " 
    break; 
    fi; # gmp distrib 

    echo I could not find some of the files at that place, or could not read
    echo some of them. Please try again.
    echo 
done
inc=$ans

echo
echo If you wish to compile a program with the mpfr library, you will need
echo the gmp library. In particular, in order to compile the tests, you will
echo need it. Could you tell me where to find it ? 
echo $n "(You can lie, I won't check) path for the libgmp.a file [$lib] ? $c"
read ans

if test -z "$ans"; then ans=$lib; fi; 
if test -d "$ans" -a -r "$ans/libgmp.a"; then lib="$ans/libgmp.a"; fi; 
olib=$ans


echo
echo Unless you know what you are doing, you should not answer anything
echo to the following question.
echo $n "Flags for floating point rounding modes [$contrspecial] ? $c"
read ans
case "$ans" in 
	'')
	ans="$contrspecial"
	;;
	*) 
	;;
esac
contrspecial=$ans

if test -z "$cflags"; then cflags="-ansi -Wall -g -O2"; fi; 

echo
echo $n "What supplementary (optimization/debugging) flags are you willing to use [$cflags] ? $c"
read ans
case "$ans" in 
	'')
	ans="$cflags"
	;;
	*) 
	;;
esac
cflags=$ans

echo
echo Now dumping the Makefile. 

cat > config.in<<EOF
inc=$inc
lib=$olib
cflags="$cflags"
contrspecial="$contrspecial"
EOF

cat > Makefile <<EOF
#
# Makefile automatically generated by Configure. Do not edit !!
#
CC=$defC
CFLAGS=\$(TESTFLAGS) $special $incflags $cflags $contrspecial -D$ostype
OBJS=sin_cos.o extract.o exp2.o exp3.o add.o div_2exp.o neg.o set_dfl_prec.o set_str_raw.o agm.o get_str.o print_raw.o set_dfl_rnd.o sqrt.o clear.o init.o rnd_mode.o set_f.o sub.o cmp.o mul.o  round.o set_prec.o cmp_ui.o mul_2exp.o set.o set_si.o div.o mul_ui.o set_d.o pow.o out_str.o pi.o set_z.o add_ulp.o log2.o random.o log.o exp.o div_ui.o zeta.o karasqrt.o print_rnd_mode.o set_q.o random2.o eq.o dump.o set_prc_raw.o urandomb.o ceil.o floor.o trunc.o add_ui.o sqrt_ui.o ui_div.o ui_sub.o reldiff.o sub_ui.o set_str.o inp_str.o mpz_set_fr.o
VERSION=0.0

dft: libmpfr.a

all: libmpfr.a tests

clean:
	-rm libmpfr.a \$(OBJS) mpfr.dvi *~ mpfr.aux mpfr.cp mpfr.cps mpfr.fn mpfr.fns mpfr.ky mpfr.log mpfr.pg mpfr.toc mpfr.tp mpfr.vr mpfr.vrs

libmpfr.a: \$(OBJS)
	ar cr libmpfr.a \$(OBJS)
	ranlib libmpfr.a    

tests: mpfr.h libmpfr.a
	-cd tests; \$(MAKE) "TESTFLAGS=\$(TESTFLAGS)" all

doc: mpfr.texi
	texi2dvi mpfr.texi

dist:
	mkdir mpfr-\$(VERSION)
	tar cf mpfr.tar *.c COPYING.LIB Configure INSTALL mpfr.texi mpfr.h mpfr-impl.h tests/*.c
	cd mpfr-\$(VERSION); mv ../mpfr.tar .; tar xf mpfr.tar; rm mpfr.tar
	tar cf mpfr-\$(VERSION).tar mpfr-\$(VERSION)
	gzip mpfr-\$(VERSION).tar
	rm -r mpfr-\$(VERSION)

add.o: mpfr.h
div_2exp.o: mpfr.h
neg.o: mpfr.h
set_dfl_prec.o: mpfr.h
set_str_raw.o: mpfr.h
agm.o: mpfr.h
get_str.o: mpfr.h
print_raw.o: mpfr.h
set_dfl_rnd.o: mpfr.h
sqrt.o: mpfr.h
clear.o: mpfr.h
init.o: mpfr.h
rnd_mode.o: mpfr.h
set_f.o: mpfr.h
sub.o: mpfr.h
cmp.o: mpfr.h
mul.o: mpfr.h
random.o: mpfr.h
round.o: mpfr.h
set_prec.o: mpfr.h
cmp_ui.o: mpfr.h
mul_2exp.o: mpfr.h
set.o: mpfr.h
set_si.o: mpfr.h
div.o: mpfr.h
mul_ui.o: mpfr.h
set_d.o: mpfr.h
pow.o: mpfr.h
out_str.o: mpfr.h
pi.o: mpfr.h
set_z.o: mpfr.h
add_ulp.o: mpfr.h
log2.o: mpfr.h
log.o: mpfr.h
exp.o: mpfr.h
div_ui.o: mpfr.h
zeta.o: mpfr.h
random2.o: mpfr.h
eq.o: mpfr.h
dump.o: mpfr.h
set_prc_raw.o: mpfr.h
urandomb.o: mpfr.h
sub_ui.o: mpfr.h
ceil.o: mpfr.h trunc.c
	\$(CC) \$(CFLAGS) -DMPFR_CEIL -c trunc.c -o ceil.o
floor.o: mpfr.h trunc.c
	\$(CC) \$(CFLAGS) -DMPFR_FLOOR -c trunc.c -o floor.o
trunc.o: mpfr.h trunc.c
	\$(CC) \$(CFLAGS) -DMPFR_TRUNC -c trunc.c
EOF
cat > tests/Makefile <<EOF
CC=$defC
CFLAGS=$special $incflags -I.. $cflags $ldpath -D$ostype
LDLIBS=$ldflags ../libmpfr.a $lib $ldlibs
TESTS=tadd tcmp2 tget_str tmul_ui tset_f tsqrt tagm tcmp_ui tmul tround tset_si tcmp tdiv tmul_2exp tset_d tset_str tpi tset_z tlog2 tcan_round tlog texp tdiv_ui tzeta tout_str tset_q tadd_ui tsqrt_ui tui_div tui_sub tabs teq trandom ttrunc

tests all: \$(TESTS)
	for i in \$(TESTS); do \
	echo Testing \$\$i; \
	./\$\$i; \
	done

clean:
	-rm \$(TESTS) *~

t%: t%.c ../libmpfr.a 
	\$(CC) \$(CFLAGS) \$(TESTFLAGS) -o \$@ \$@.c \$(LDLIBS)
EOF