File: configure.ac

package info (click to toggle)
numerix 0.22-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 4,380 kB
  • ctags: 4,165
  • sloc: asm: 26,210; ansic: 12,168; ml: 4,912; sh: 3,899; pascal: 414; makefile: 179
file content (493 lines) | stat: -rw-r--r-- 15,415 bytes parent folder | download | duplicates (2)
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
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
#  file autoconf.ac: Numerix configuration
#-----------------------------------------------------------------------+
#  Copyright 2005-2006, Michel Quercia (michel.quercia@prepas.org)      |
#                                                                       |
#  This file is part of Numerix. Numerix is free software; you can      |
#  redistribute it and/or modify it under the terms of the GNU Lesser   |
#  General Public License as published by the Free Software Foundation; |
#  either version 2.1 of the License, or (at your option) any later     |
#  version.                                                             |
#                                                                       |
#  The Numerix Library is distributed in the hope that it will be       |
#  useful, but WITHOUT ANY WARRANTY; without even the implied warranty  |
#  of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU  |
#  Lesser General Public License for more details.                      |
#                                                                       |
#  You should have received a copy of the GNU Lesser General Public     |
#  License along with the GNU MP Library; see the file COPYING. If not, |
#  write to the Free Software Foundation, Inc., 59 Temple Place -       |
#  Suite 330, Boston, MA 02111-1307, USA.                               |
#-----------------------------------------------------------------------+
#                                                                       |
#                       Configuration de Numerix                        |
#                                                                       |
#-----------------------------------------------------------------------+

AC_INIT(Numerix, 0.22, michel.quercia@prepas.org)
AC_CONFIG_AUX_DIR(config)

                                # +--------+
                                # |  bits  |
                                # +--------+

AC_CHECK_SIZEOF(long)
case $ac_cv_sizeof_long in
4) machine_word_size=32;;
8) machine_word_size=64;;
*) AC_MSG_ERROR(exotic hardware; cannot handle $ac_cv_sizeof_long byte machine word size);;
esac
AC_SUBST(machine_word_size)

                             # +-------------+
                             # |  long long  |
                             # +-------------+

AC_ARG_ENABLE(longlong,--enable-longlong: use double-long arithmetic,[
case $enableval in
yes) dlong_available=1;;
*)   dlong_available=0;;
esac],[
AC_CHECK_SIZEOF(long long)
dlong_available=`expr $ac_cv_sizeof_long_long = $ac_cv_sizeof_long \* 2`
])
case $dlong_available in
1) longlong=yes; have_long_long="#define have_long_long";;
*) longlong=no;  have_long_long="#undef have_long_long";;
esac
AC_SUBST(have_long_long)

                             # +--------------+
                             # |  processeur  |
                             # +--------------+

AC_ARG_ENABLE(processor,--enable-processor=proc: specify the processor (x86,x86-64,alpha,ppc32,generic,unknown),[
case $enableval in
x86)     cpu=$enableval;;
x86_64)  cpu=$enableval;;
x86-64)  cpu=x86_64;;
alpha)   cpu=$enableval;;
ppc32)   cpu=$enableval;;
generic) cpu=$enableval;;
unknown) cpu=$enableval;;
*)       AC_MSG_WARN(unknown processor $enableval, using processor=generic)
         cpu=generic;;
esac],[cpu=unknown])
AC_ARG_ENABLE(sse2,--enable-sse2: use SSE2 code,[
case $enableval in
yes) sse2=1;;
*)   sse2=0;;
esac],[sse2=unknown])
if test $cpu = unknown; then
AC_CANONICAL_HOST
case $host_cpu in
i*86)    cpu=x86;;
x86_64*) cpu=x86_64;;
alpha*)  cpu=alpha;;
powerpc) case $machine_word_size in
         32) cpu=ppc32;;
         *)  cpu=generic;;
         esac;;
*)       cpu=generic;;
esac
fi
case $cpu in
x86)    if test $sse2 = unknown; then
	  AC_MSG_CHECKING(for SSE2 capability)
          AC_RUN_IFELSE(
		[AC_LANG_PROGRAM([#include <stdio.h>],[
			unsigned long r;
			asm("pushl %%ebx\n\tpushl %%ecx\n\tpushl %%edx\n\txorl %%eax,%%eax\n\tincl %%eax\n\tcpuid\n\tmovl %%edx,%%eax\n\tpopl %%edx\n\tpopl %%ecx\n\tpopl %%ebx": "=a" (r));
			printf("%08x ",r);
			if ((r & 0x4000000) == 0) return(1);])],
		[sse2=1],[sse2=0],[sse2=0]
		)
	  if test $sse2 = 1 ;then answer="-> yes"; else answer="-> no"; fi
	  AC_MSG_RESULT($answer)
	  if test $sse2 = 1; then
	  AC_MSG_CHECKING(for AMD CPU)
          AC_RUN_IFELSE(
		[AC_LANG_PROGRAM([#include <string.h>
			#include <stdio.h>],[
			char r[[13]];
			asm("pushl %%ebx\n\tpushl %%ecx\n\tpushl %%edx\n\tpushl %%eax\n\txorl %%eax,%%eax\n\tcpuid\n\tpopl %%eax\n\tmovl %%ebx,(%%eax)\n\tmovl %%edx,4(%%eax)\n\tmovl %%ecx,8(%%eax)\n\txorl %%ebx,%%ebx\n\tmovl %%ebx,12(%%eax)\n\tpopl %%edx\n\tpopl %%ecx\n\tpopl %%ebx":: "a" (r));
			printf("%s ",r);
			if (strcmp(r,"AuthenticAMD") == 0) return(1);])],
		[sse2=1],[sse2=0],[sse2=1]
		)
	  if test $sse2 = 0 ;then answer="-> SSE2 unselected"; else answer="-> not AMD"; fi
	  AC_MSG_RESULT($answer)
	fi; fi
        if test $sse2 = 1; then processor=x86-sse2; else processor=x86; fi
        slong_available=1;;
x86_64) processor=x86-64;  slong_available=1;;
alpha)  processor=alpha;   slong_available=1;;
ppc32)  processor=ppc32;   slong_available=1;;
*)      processor=generic; slong_available=0;;
esac
AC_SUBST(processor)

                             # +---------------+
                             # |  compilation  |
                             # +---------------+


# C compiler
AC_PROG_CC
AC_ARG_ENABLE(mingw,--enable-mingw: choose the Mingw environment inside Cygwin,[
case $enableval in
yes)     CC="$CC -mno-cygwin";;
*)       ;;
esac])

# build shared libraries ?
AC_ARG_ENABLE(shared,--enable-shared: build shared libraries,[
shared=$enableval],[
shared=no
])
case $shared in
yes) SHARED=1;;
*)   SHARED=0;;
esac
AC_SUBST(SHARED)


# do we need Position Independent Code ?
pic=
if test $shared = yes; then pic=-fpic; fi
if test $cpu = x86_64; then pic=-fpic; fi
AC_SUBST(pic)

AC_CHECK_PROGS(ar,ar)
AC_PROG_RANLIB

AC_ARG_ENABLE(alloca,--enable-alloca: use alloca,[alloca=$enableval],[
AC_FUNC_ALLOCA
if test $ac_cv_working_alloca_h = yes; then
   alloca=$ac_cv_func_alloca_works
else
   alloca=no
fi
])
case $alloca in
yes) use_alloca="#define use_alloca";;
*)   use_alloca="#undef use_alloca";;
esac
AC_SUBST(use_alloca)

                             # +---------------+
                             # |  rpertoires  |
                             # +---------------+

AC_PREFIX_DEFAULT($HOME)
test "$prefix"     = NONE                 && prefix=$HOME
test "$bindir"     = '${exec_prefix}/bin' && bindir=${prefix}/bin
test "$libdir"     = '${exec_prefix}/lib' && libdir=${prefix}/lib
test "$includedir" = '${prefix}/include'  && includedir=${prefix}/include

              # +---------------------------------------------+
              # |  dsactive les langages/modules par dfaut  |
              # +---------------------------------------------+

AC_ARG_ENABLE(all,--disable-all: disable all default modules/languages,[
case $enableval in
yes) default=1;;
*)   default=0;;
esac],[default=1])

AC_ARG_ENABLE(lang,--disable-lang: disable all default languages,[
case $enableval in
yes) default_lang=1;;
*)   default_lang=0;;
esac],[default_lang=$default])

AC_ARG_ENABLE(modules,--disable-modules: disable all default modules,[
case $enableval in
yes) default_mod=1;;
*)   default_mod=0;;
esac],[default_mod=$default])

                              # +------------+
                              # |  langages  |
                              # +------------+

#------------------------------ C

AC_ARG_ENABLE(c,--enable-c: build the C interface,[
case $enableval in
yes) make_c_lib=1;;
*)   make_c_lib=0;;
esac],[
make_c_lib=$default_lang
])
AC_SUBST(make_c_lib)

#------------------------------ Caml

AC_ARG_ENABLE(caml,--enable-caml: build the Camllight interface,[
case $enableval in
yes) make_caml_lib=1
     AC_CHECK_PROGS(camlc,camlc,no)
     if test $camlc = no; then
        AC_MSG_WARN(--enable-caml selected but camlc not found)
     fi;;
*)   make_caml_lib=0;;
esac],[
if test x$default_lang = x1; then
AC_CHECK_PROGS(camlc,camlc,no)
case $camlc in
no) make_caml_lib=0;;
*)  make_caml_lib=1;;
esac
else make_caml_lib=0; fi
])
if test $make_caml_lib = 1; then
  AC_CHECK_PROGS(camllibr,camllibr)
  AC_CHECK_PROGS(camlmktop,camlmktop)
  AC_MSG_CHECKING(for Caml directory)
  caml_libdir=$($camlc -v 2>&1)
  caml_libdir=$(echo $caml_libdir | sed -e 's?.*andard library[[^/]]*\([[^ )]]*\).*?\1?')
  AC_MSG_RESULT($caml_libdir)
fi
AC_SUBST(make_caml_lib)
AC_SUBST(caml_libdir)

#------------------------------ Ocaml

AC_ARG_ENABLE(ocaml,--enable-ocaml: build the Ocaml interface,[
case $enableval in
yes) make_ocaml_lib=1
     AC_CHECK_PROGS(ocamlc,ocamlc.opt ocamlc,no)
     if test $ocamlc = no; then
        AC_MSG_WARN(--enable-ocaml selected but ocamlc not found)
     fi;;
*)   make_ocaml_lib=0;;
esac],[
if test x$default_lang = x1; then
AC_CHECK_PROGS(ocamlc,ocamlc.opt ocamlc,no)
case $ocamlc in
no) make_ocaml_lib=0;;
*)  make_ocaml_lib=1;;
esac
else make_ocaml_lib=0; fi
])
if test $make_ocaml_lib = 1; then
  AC_CHECK_PROGS(ocamlopt,ocamlopt.opt ocamlopt)
  AC_CHECK_PROGS(ocamlmktop,ocamlmktop)
  AC_CHECK_PROGS(ocamlmklib,ocamlmklib)
  AC_MSG_CHECKING(for Ocaml directory)
  ocaml_libdir=$($ocamlc -v 2>&1)
  ocaml_libdir=$(echo $ocaml_libdir | sed -e 's?.*andard library directory: \(.*\).*?\1?')
  AC_MSG_RESULT($ocaml_libdir)
fi
AC_SUBST(make_ocaml_lib)
AC_SUBST(ocaml_libdir)

#------------------------------ Pascal

AC_ARG_ENABLE(pascal,--enable-pascal@<:@=gpc|fpc@:>@: build the Pascal interface,[
case $enableval in
yes)   make_pascal_lib=1;       use_gpc=1; use_fpc=1;;
fpc)   make_pascal_lib=1;       use_gpc=0; use_fpc=1;;
gpc)   make_pascal_lib=1;       use_gpc=1; use_fpc=0;;
*)     make_pascal_lib=0;       use_gpc=0; use_fpc=0;;
esac],[
case $default_lang in
0) make_pascal_lib=0;;
*) make_pascal_lib=unknown; use_gpc=1; use_fpc=1;;
esac
])

pc=none
if test x$make_pascal_lib != x0; then

  if test x$use_gpc = x1; then
     AC_CHECK_PROGS(gpc,gpc,no)
     if test x$gpc = xno; then use_gpc=0; else pc=$gpc; use_fpc=0; fi
  fi

  if test x$use_fpc = x1; then
     AC_CHECK_PROGS(fpc,fpc,no)
     if test x$fpc = xno; then use_fpc=0; else pc=$fpc; use_gpc=0; fi
  fi

  if test x$pc = xnone; then
    if test x$make_pascal_lib = x1; then
      AC_MSG_WARN(--enable-pascal selected but no Pascal compiler found)
    else
      make_pascal_lib=0
    fi
  else
    make_pascal_lib=1
  fi

fi

case $use_gpc$use_fpc in
10) pascal=gpc;;
01) pascal=fpc;;
*)  pascal=none;;
esac

AC_SUBST(make_pascal_lib)
AC_SUBST(pascal)
AC_SUBST(pc)

#------------------------------ assemblage

languages=
if test $make_c_lib      = 1; then languages="$languages C";      fi
if test $make_caml_lib   = 1; then languages="$languages Caml";   fi
if test $make_ocaml_lib  = 1; then languages="$languages Ocaml";  fi
if test $make_pascal_lib = 1; then languages="$languages Pascal($pascal)"; fi
if test -z "$languages"; then languages=" (none)"; fi

                               # +-----------+
                               # |  modules  |
                               # +-----------+

#------------------------------ Clong

AC_ARG_ENABLE(clong,--enable-clong: build the Clong module,[
case $enableval in
yes) use_clong=1;;
*)   use_clong=0;;
esac],[
use_clong=$default_mod
])
AC_SUBST(use_clong)

#------------------------------ Dlong

AC_ARG_ENABLE(dlong,--enable-dlong: build the Dlong module,[
case $enableval in
yes) use_dlong=1;;
*)   use_dlong=0;;
esac],[
if test x$default_mod = x1; then use_dlong=$dlong_available; else use_dlong=0; fi
])
AC_SUBST(use_dlong)

#------------------------------ Slong

AC_ARG_ENABLE(slong,--enable-slong: build the Slong module,[
case $enableval in
yes) use_slong=1;;
*)   use_slong=0;;
esac],[
if test x$default_mod = x1; then
case $slong_available in
1) use_slong=1;;
*) use_slong=0;;
esac
else use_slong=0; fi
])
AC_SUBST(use_slong)

#------------------------------ Gmp

AC_ARG_ENABLE(gmp,--enable-gmp: build the Gmp module,[
case $enableval in
yes) use_gmp=1
     AC_CHECK_LIB(gmp,__gmpz_init,[],[AC_MSG_WARN(--enable-gmp selected but -lgmp fails)]);;
*)   use_gmp=0;;
esac],[
if test x$default_mod = x1; then
AC_CHECK_LIB(gmp,__gmpz_init,[use_gmp=1],[use_gmp=0])
else use_gmp=0; fi
])
AC_SUBST(use_gmp)

#------------------------------ Bignum

AC_ARG_ENABLE(caml_bignum,--enable-caml_bignum: build the Big module for Camllight,[
case $enableval in
yes) use_caml_bignum=1
     AC_CHECK_FILE($caml_libdir/libnums.a,[],[
       AC_MSG_WARN(--enable-caml_bignum selected but libnums.a not found)
     ]);;
*)   use_caml_bignum=0;;
esac],[
if test x$default_mod = x1 -a x$make_caml_lib = x1; then
AC_CHECK_FILE($caml_libdir/libnums.a,[use_caml_bignum=1],[use_caml_bignum=0])
else use_caml_bignum=0; fi
])
AC_SUBST(use_caml_bignum)

AC_ARG_ENABLE(ocaml_bignum,--enable-ocaml_bignum: build the Big module for Ocaml,[
case $enableval in
yes) use_ocaml_bignum=1
     AC_CHECK_FILE($ocaml_libdir/libnums.a,[],[
       AC_MSG_WARN(--enable-ocaml_bignum selected but libnums.a not found)
     ]);;
*)   use_ocaml_bignum=0;;
esac],[
if test x$default_mod = x1 -a x$make_ocaml_lib = x1; then
AC_CHECK_FILE($ocaml_libdir/libnums.a,[use_ocaml_bignum=1],[use_ocaml_bignum=0])
else use_ocaml_bignum=0; fi
])
AC_SUBST(use_ocaml_bignum)

#------------------------------ assemblage

modules=
if test $use_clong        = 1; then modules="$modules Clong";      fi
if test $use_dlong        = 1; then modules="$modules Dlong";      fi
if test $use_slong        = 1; then modules="$modules Slong";      fi
if test $use_gmp          = 1; then modules="$modules Gmp";        fi
if test $use_caml_bignum  = 1; then modules="$modules Big(caml)";  fi
if test $use_ocaml_bignum = 1; then modules="$modules Big(ocaml)"; fi
if test -z "$modules"; then modules=" (none)"; fi

                          # +--------------------+
                          # |  fichiers  crer  |
                          # +--------------------+

AC_CONFIG_FILES(Makefile:config/Makefile)
AC_CONFIG_FILES(kernel/config.h:config/$processor.h)
for i in n c caml ocaml pascal; do
  AC_MSG_NOTICE(creating kernel/$i/makefile)
  PROCESSOR=$processor \
  MAKE_C_LIB=$make_c_lib \
  MAKE_CAML_LIB=$make_caml_lib \
  MAKE_OCAML_LIB=$make_ocaml_lib \
  MAKE_PASCAL_LIB=$make_pascal_lib \
  USE_CLONG=$use_clong \
  USE_DLONG=$use_dlong \
  USE_SLONG=$use_slong \
  USE_GMP=$use_gmp \
  USE_CAML_BIGNUM=$use_caml_bignum \
  USE_OCAML_BIGNUM=$use_ocaml_bignum \
  OCAMLOPT="$ocamlopt" \
  OCAMLMKLIB="$ocamlmklib" \
  PASCAL="$pascal" \
  SHARED="$SHARED" \
  kernel/$i/remake >kernel/$i/makefile
done


                               # +-----------+
                               # |  termin  |
                               # +-----------+

AC_OUTPUT
cat << EOF

Configure summary
-----------------
machine word size           $machine_word_size bits
processor                   $processor
use alloca                  $alloca
use longlong                $longlong
shared libraries            $shared
languages selected         $languages
modules selected           $modules
bin directory               $bindir
lib directory               $libdir
include directory           $includedir

To build Numerix            make lib
To compile the examples     make examples
To test Numerix             make test
To build,compile and test   make all
To install Numerix          make install
EOF