1#                                               -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3
4AC_INIT([Poly/ML],[5.8.2],[polyml AT polyml DOT org],[polyml])
5AM_INIT_AUTOMAKE
6AC_PREREQ(2.69)
7# libtoolize recommends this line.
8AC_CONFIG_MACRO_DIR([m4])
9
10ac_debug_mode="no"
11
12AC_ARG_ENABLE([debug],
13   [  --enable-debug          Compiles without optimisation for debugging ],
14   [ac_debug_mode="yes"])
15
16if test "$ac_debug_mode" != "yes"; then
17    # Default to maximum optimisation. -O2 is not good enough.
18        # Set CCASFLAGS to empty so that it doesn't get set to CFLAGS.
19        #   The -g option on assembler causes problems on Sparc/Solaris 10.
20        # test X || Y  is equivalent to  if !X then Y
21        test "${CFLAGS+set}" = set || CFLAGS="-O3"
22        test "${CXXFLAGS+set}" = set || CXXFLAGS="-O3"
23        test "${CCASFLAGS+set}" = set || CCASFLAGS=""
24else
25        test "${CFLAGS+set}" = set || CFLAGS="-g"
26        test "${CXXFLAGS+set}" = set || CXXFLAGS="-g"
27        test "${CCASFLAGS+set}" = set || CCASFLAGS=""
28fi
29
30AC_CANONICAL_HOST
31
32# If the compiler defines _WIN32 we're building for native Windows otherwise we're
33# building for something else.
34AC_CHECK_DECL([_WIN32], [poly_native_windows=yes], [poly_native_windows=no])
35
36# If we are building on cygwin or mingw we need to give the -no-defined flag to
37# build a DLL.  We also have to use Windows calling conventions rather than
38# SysV on 64-bit.
39poly_use_windowscc=no
40poly_need_macosopt=no
41case "${host_os}" in
42    darwin*)
43        AC_SUBST([OSFLAG], [-DMACOSX])
44        poly_need_macosopt=yes
45        ;;
46    sunos* | solaris*)
47        AC_SUBST([OSFLAG], [-DSOLARIS])
48        ;;
49    *mingw* | *cygwin*)
50        poly_no_undefined=yes
51        poly_use_windowscc=yes
52        ;;
53esac
54
55# libpolyml can be a DLL but libpolymain can't.
56# Enable shared libraries by default.  It complicates installation a bit if the
57# the library is installed to a non-standard location but simplifies polyc.
58LT_INIT([win32-dll])
59AM_MAINTAINER_MODE
60
61
62# Check we're in the right directory
63AC_CONFIG_SRCDIR([polyexports.h])
64AC_CONFIG_HEADER([config.h])
65
66
67# Checks for programs.
68AC_PROG_CXX
69# The following check was supposed to check that there was actually a
70# C++ compiler but doesn't work properly if CXX is set by the user.
71#AC_CHECK_PROG(check_cpp, $CXX, "yes", "no")
72#if test "$check_cpp" != "yes"; then
73#    AC_MSG_ERROR([No C++ compiler found.  Unable to build Poly/ML.])
74#fi
75
76AC_PROG_CC
77AC_PROG_MAKE_SET
78AC_PROG_CPP
79
80AM_PROG_AS
81
82# Activate large file mode if needed
83AC_SYS_LARGEFILE
84
85# Checks for libraries.
86AC_CHECK_LIB(gcc, main)
87AC_CHECK_LIB(gcc_s, main)
88AC_CHECK_LIB(stdc++, main)
89
90# These can sometimes be in the standard libraries
91AC_SEARCH_LIBS([dlopen], [dl dld])
92AC_SEARCH_LIBS([floor], [m])
93
94## External names on Win64.  They have no leading underscores as per
95## the X64 ABI published by MS.  Earlier versions of GCC (anything
96## prior to 4.5.0) were faulty.
97LT_SYS_SYMBOL_USCORE
98if test x$sys_symbol_underscore = xyes; then
99    AC_DEFINE(SYMBOLS_REQUIRE_UNDERSCORE, [1], [Defined if external symbols are prefixed by underscores])
100fi
101
102# Check for headers
103
104AC_FUNC_ALLOCA
105AC_HEADER_DIRENT
106AC_HEADER_STDC
107AC_HEADER_SYS_WAIT
108AC_CHECK_HEADERS([stdio.h time.h fcntl.h float.h limits.h locale.h malloc.h netdb.h netinet/in.h stddef.h])
109AC_CHECK_HEADERS([stdlib.h string.h sys/file.h sys/ioctl.h sys/param.h sys/socket.h sys/systeminfo.h])
110AC_CHECK_HEADERS([sys/time.h unistd.h values.h dlfcn.h signal.h ucontext.h])
111AC_CHECK_HEADERS([assert.h ctype.h direct.h errno.h excpt.h fenv.h fpu_control.h grp.h])
112AC_CHECK_HEADERS([ieeefp.h io.h math.h memory.h netinet/tcp.h arpa/inet.h poll.h pwd.h siginfo.h])
113AC_CHECK_HEADERS([stdarg.h sys/errno.h sys/filio.h sys/mman.h sys/resource.h])
114AC_CHECK_HEADERS([sys/sockio.h sys/stat.h termios.h sys/times.h])
115AC_CHECK_HEADERS([sys/types.h sys/uio.h sys/un.h sys/utsname.h sys/select.h sys/sysctl.h])
116AC_CHECK_HEADERS([sys/elf_SPARC.h sys/elf_386.h sys/elf_amd64.h asm/elf.h machine/reloc.h])
117AC_CHECK_HEADERS([windows.h tchar.h semaphore.h])
118AC_CHECK_HEADERS([stdint.h inttypes.h])
119
120# Only check for the X headers if the user said --with-x.
121if test "${with_x+set}" = set; then
122    AC_CHECK_HEADERS([X11/Xlib.h Xm/Xm.h])
123fi
124
125PKG_PROG_PKG_CONFIG
126
127# Check for GMP
128AC_ARG_WITH([gmp],
129            [AS_HELP_STRING([--with-gmp],
130              [use the GMP library for arbitrary precision arithmetic @<:@default=check@:>@])],
131            [],
132            [with_gmp=check])
133
134# If we want GMP check that the library and headers are installed.
135if test "x$with_gmp" != "xno"; then
136    AC_CHECK_LIB([gmp], [__gmpn_tdiv_qr],
137        [AC_DEFINE([HAVE_LIBGMP], [1],
138              [Define to 1 if you have libgmp])
139         [LIBS="-lgmp $LIBS"]
140         AC_CHECK_HEADER([gmp.h],
141             [AC_DEFINE([HAVE_GMP_H], [1],
142                  [Define to 1 if you have the gmp.h header file])],
143             [if test "x$with_gmp" != "xcheck"; then
144                  AC_MSG_FAILURE(
145                      [--with-gmp was given, but gmp.h header file is not installed])
146              fi
147             ])
148        ],
149        [if test "x$with_gmp" != "xcheck"; then
150            AC_MSG_FAILURE(
151                [--with-gmp was given, but gmp library (version 4 or later) is not installed])
152         fi
153        ])
154fi
155
156# Special configuration for Windows or Unix.
157poly_windows_enablegui=false
158
159if test "x$poly_native_windows" = xyes; then
160    # The next two are only used with mingw.  We mustn't include ws2_32 in Cygwin64 because
161    # the "select" function gets used instead of Cygwin's own.
162    AC_CHECK_LIB(ws2_32, main)
163    AC_CHECK_LIB(gdi32, main)
164
165    CFLAGS="$CFLAGS -mthreads"
166    CXXFLAGS="$CXXFLAGS -mthreads"
167    AC_SUBST([OSFLAG], ["-DUNICODE -D_UNICODE -D_WIN32_WINNT=0x600"])
168    AC_CHECK_TOOL(WINDRES, windres)
169
170    # Enable/Disable the GUI in Windows.
171    AC_ARG_ENABLE([windows-gui],
172        [AS_HELP_STRING([--enable-windows-gui],
173            [create a GUI in Windows. If this is disabled use a Windows console. @<:@default=yes@:>@])],
174        [case "${enableval}" in
175            yes) poly_windows_enablegui=true ;;
176            no)  poly_windows_enablegui=false ;;
177            *) AC_MSG_ERROR([bad value ${enableval} for --enable-windows-gui]) ;;
178        esac],
179        [poly_windows_enablegui=true])
180
181else
182    # Unix or similar e.g. Cygwin.  We need pthreads.
183    # On Android pthread_create is in the standard library
184    AC_SEARCH_LIBS([pthread_create], [pthread],
185        [AC_DEFINE([HAVE_LIBPTHREAD], [1],
186              [Define to 1 if you have the `pthread' library (-lpthread).])
187         AC_CHECK_HEADER([pthread.h],
188             [AC_DEFINE([HAVE_PTHREAD_H], [1],
189                  [Define to 1 if you have the <pthread.h> header file.])],
190             [
191                  AC_MSG_FAILURE([pthread.h header file is not installed])
192             ])
193        ],
194        [
195            AC_MSG_FAILURE([pthread library is not installed])
196        ])
197
198    # Solaris needs -lsocket, -lnsl and -lrt
199    AC_SEARCH_LIBS([gethostbyname], [nsl])
200    AC_SEARCH_LIBS([getsockopt], [socket])
201    AC_SEARCH_LIBS([sem_wait], [rt])
202
203    # Check for X and Motif headers and libraries
204    AC_PATH_X
205
206    if test "x${with_x}" = "xyes"; then
207
208        AC_DEFINE([WITH_XWINDOWS], [1], [Define if the X-Windows interface should be built])
209
210        if test "$x_includes" != "" ; then
211        if test  "$x_includes" != "NONE" ; then
212            CFLAGS="$CFLAGS -I$x_includes"
213            CXXFLAGS="$CXXFLAGS -I$x_includes"
214            CPPFLAGS="$CPPFLAGS -I$x_includes"
215        fi
216        fi
217        if test "$x_libraries" != "" ; then
218        if test "$x_libraries" != "NONE" ; then
219            LIBS="-L$x_libraries $LIBS"
220        fi
221        fi
222        AC_CHECK_LIB(X11, XCreateGC)
223        AC_CHECK_LIB(Xt, XtMalloc)
224        AC_CHECK_LIB(Xext, XextAddDisplay)
225
226        if test "$xm_includes" != "" ; then
227        if test "$xm_includes" != "NONE" ; then
228            CFLAGS="$CFLAGS -I$xm_includes"
229            CXXFLAGS="$CXXFLAGS -I$xm_includes"
230            CPPFLAGS="$CPPFLAGS -I$xm_includes"
231        fi
232        fi
233        if test "$xm_libraries" != "" ; then
234        if test "$xm_libraries" != "NONE" ; then
235            LIBS="-L$xm_libraries $LIBS"
236        fi
237        fi
238        AC_CHECK_LIB(Xm, XmGetDestination)
239
240    fi
241
242    # TODO: May need AC_PATH_XTRA for Solaris
243
244fi
245# End of Windows/Unix configuration.
246
247# Find out which type of object code exporter to use.
248# If we have winnt use PECOFF.  This really only applies to cygwin here.
249# If we have elf.h use ELF.
250# If we have mach-o/reloc.h use Mach-O
251# Otherwise use the C source code exporter.
252AC_CHECK_TYPES([IMAGE_FILE_HEADER],
253    [AC_DEFINE([HAVE_PECOFF], [], [Define to 1 if you have the PE/COFF types.])]
254        [polyexport=pecoff],
255    [AC_CHECK_HEADER([elf.h],
256        [AC_DEFINE([HAVE_ELF_H], [], [Define to 1 if you have the <elf.h> header file.])]
257            [polyexport=elf],
258              [AC_CHECK_HEADER([mach-o/reloc.h],
259                  [AC_DEFINE([HAVE_MACH_O_RELOC_H], [], [Define to 1 if you have the <mach-o/reloc.h> header file.])]
260                          [polyexport=macho],
261                      [AC_CHECK_HEADERS([elf_abi.h machine/reloc.h],
262                          [AC_DEFINE([HAVE_ELF_ABI_H], [], [Define to 1 if you have <elf_abi.h> and <machine/reloc.h> header files.])]
263                              [polyexport=elf] )]
264                )]
265    )],
266    [#include <windows.h>]
267)
268
269AC_MSG_CHECKING([whether the compiler supports __sync_add_and_fetch])
270AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void) { long i=0; return __sync_fetch_and_add(&i, 0) + __sync_sub_and_fetch(&i, 0); } ]])],
271    [AC_MSG_RESULT([yes])] [AC_DEFINE([HAVE_SYNC_FETCH], [1],
272        [Define to 1 if the compiler supports __sync_fetch_and_add.])],
273    [AC_MSG_RESULT([no])])
274
275
276AM_CONDITIONAL([EXPPECOFF], [test "$polyexport" = pecoff])
277AM_CONDITIONAL([EXPELF], [test "$polyexport" = elf])
278AM_CONDITIONAL([EXPMACHO], [test "$polyexport" = macho])
279
280# Checks for typedefs, structures, and compiler characteristics.
281AC_HEADER_STDBOOL
282AC_C_CONST
283AC_TYPE_INT16_T
284AC_TYPE_UINT16_T
285AC_TYPE_INT32_T
286AC_TYPE_UINT32_T
287AC_TYPE_INT64_T
288AC_TYPE_UINT64_T
289AC_TYPE_INTPTR_T
290AC_TYPE_UINTPTR_T
291AC_TYPE_UID_T
292AC_TYPE_MODE_T
293AC_TYPE_OFF_T
294AC_TYPE_PID_T
295AC_TYPE_SIZE_T
296AC_TYPE_SSIZE_T
297AC_HEADER_TIME
298AC_STRUCT_TM
299
300# Check for the various sub-second fields of the stat structure.
301AC_CHECK_MEMBERS([struct stat.st_atim, struct stat.st_atimespec,
302  struct stat.st_atimensec, struct stat.st_atime_n, struct stat.st_uatime])
303
304# Mac OS X, at any rate, needs signal.h to be included first.
305AC_CHECK_TYPES([ucontext_t], , , [#include "signal.h"
306#include "ucontext.h"])
307AC_CHECK_TYPES([struct sigcontext, stack_t, sighandler_t, sig_t], , ,[#include "signal.h"])
308AC_CHECK_TYPES([socklen_t],,,[#include "sys/types.h"
309#include "sys/socket.h"])
310
311AC_CHECK_TYPES([SYSTEM_LOGICAL_PROCESSOR_INFORMATION],,,[#include "windows.h"])
312
313AC_CHECK_TYPES(long long)
314AC_CHECK_TYPES(ssize_t)
315
316AC_CHECK_SIZEOF(void*)
317AC_CHECK_SIZEOF(long)
318AC_CHECK_SIZEOF(int)
319AC_CHECK_SIZEOF(long long)
320AC_CHECK_SIZEOF(double)
321AC_CHECK_SIZEOF(float)
322
323AC_C_BIGENDIAN
324
325# Checks for library functions.
326AC_FUNC_ERROR_AT_LINE
327AC_FUNC_GETGROUPS
328AC_FUNC_GETPGRP
329AC_PROG_GCC_TRADITIONAL
330AC_FUNC_SELECT_ARGTYPES
331AC_FUNC_STAT
332AC_FUNC_STRTOD
333AC_CHECK_FUNCS([dlopen strtod dtoa getpagesize sigaltstack mmap mkstemp])
334## There does not seem to be a declaration for fpsetmask in mingw64.
335AC_CHECK_DECLS([fpsetmask], [], [], [[#include <ieeefp.h>]])
336AC_CHECK_FUNCS([sysctl sysctlbyname])
337AC_CHECK_FUNCS([localtime_r gmtime_r])
338AC_CHECK_FUNCS([ctermid tcdrain])
339AC_CHECK_FUNCS([_ftelli64])
340
341# Where are the registers when we get a signal?  Used in time profiling.
342#Linux:
343AC_CHECK_MEMBERS([mcontext_t.gregs, mcontext_t.regs, mcontext_t.mc_esp],,,[#include "ucontext.h"])
344#Mac OS X:
345AC_CHECK_MEMBERS([struct mcontext.ss, struct __darwin_mcontext.ss, struct __darwin_mcontext.__ss,
346   struct __darwin_mcontext32.ss, struct __darwin_mcontext32.__ss,
347   struct __darwin_mcontext64.ss, struct __darwin_mcontext64.__ss],,,
348   [#include "signal.h"
349#include "ucontext.h"])
350
351# FreeBSD includes a sun_len member in struct sockaddr_un
352AC_CHECK_MEMBERS([struct sockaddr_un.sun_len],,,
353   [#include <sys/un.h>])
354
355# This option enables the native code generator.  More precisely it allows
356# the byte code interpreter to be built on X86.
357
358AC_ARG_ENABLE([native-codegeneration],
359        [AS_HELP_STRING([--disable-native-codegeneration],
360            [disable the native code generator and use the slow byte code interpreter instead.])],
361        [case "${enableval}" in
362           no)  with_portable=yes ;;
363           yes) with_portable=no ;;
364           *) AC_MSG_ERROR([bad value ${enableval} for --enable-native-codegeneration]) ;;
365        esac],
366        [with_portable=check])
367
368# Check which CPU we're building for.  Can we use a native pre-built compiler
369# or do we need to fall back to the interpreter?  Most of these settings are to tweak
370# the ELF exporter.
371
372case "${host_cpu}" in
373      i[[3456]]86*)
374            AC_DEFINE([HOSTARCHITECTURE_X86], [1], [Define if the host is an X86 (32-bit)])
375            polyarch=i386
376            ;;
377      x86_64* | amd64*)
378            if test X"$ac_cv_sizeof_voidp" = X8; then
379                AC_DEFINE([HOSTARCHITECTURE_X86_64], [1], [Define if the host is an X86 (64-bit)])
380                polyarch=x86_64
381            else
382                AC_DEFINE([HOSTARCHITECTURE_X32], [1], [Define if the host is an X86 (32-bit ABI, 64-bit processor)])
383                polyarch=interpret
384            fi
385            ;;
386      sparc64*)
387            AC_DEFINE([HOSTARCHITECTURE_SPARC64], [1], [Define if the host is a Sparc (64-bit)])
388            polyarch=interpret
389            ;;
390      sparc*)
391            AC_DEFINE([HOSTARCHITECTURE_SPARC], [1], [Define if the host is a Sparc (32-bit)])
392            polyarch=interpret
393            ;;
394      powerpc64* | ppc64*)
395            AC_DEFINE([HOSTARCHITECTURE_PPC64], [1], [Define if the host is a PowerPC (64-bit)])
396            polyarch=interpret
397            ;;
398      power* | ppc*)
399            AC_DEFINE([HOSTARCHITECTURE_PPC], [1], [Define if the host is a PowerPC (32-bit)])
400            polyarch=interpret
401            ;;
402      arm*)
403            AC_DEFINE([HOSTARCHITECTURE_ARM], [1], [Define if the host is an ARM (32-bit)])
404            polyarch=interpret
405            ;;
406      aarch64*)
407            AC_DEFINE([HOSTARCHITECTURE_AARCH64], [1], [Define if the host is an ARM (64-bit)])
408            polyarch=interpret
409            ;;
410      hppa*)
411            AC_DEFINE([HOSTARCHITECTURE_HPPA], [1], [Define if the host is an HP PA-RISC (32-bit)])
412            polyarch=interpret
413            ;;
414      ia64*)
415            AC_DEFINE([HOSTARCHITECTURE_IA64], [1], [Define if the host is an Itanium])
416            polyarch=interpret
417            ;;
418      m68k*)
419            AC_DEFINE([HOSTARCHITECTURE_M68K], [1], [Define if the host is a Motorola 68000])
420            polyarch=interpret
421            ;;
422      mips64*)
423            AC_DEFINE([HOSTARCHITECTURE_MIPS64], [1], [Define if the host is a MIPS (64-bit)])
424            polyarch=interpret
425            ;;
426      mips*)
427            AC_DEFINE([HOSTARCHITECTURE_MIPS], [1], [Define if the host is a MIPS (32-bit)])
428            polyarch=interpret
429            ;;
430      s390x*)
431            AC_DEFINE([HOSTARCHITECTURE_S390X], [1], [Define if the host is an S/390 (64-bit)])
432            polyarch=interpret
433            ;;
434      s390*)
435            AC_DEFINE([HOSTARCHITECTURE_S390], [1], [Define if the host is an S/390 (32-bit)])
436            polyarch=interpret
437            ;;
438      sh*)
439            AC_DEFINE([HOSTARCHITECTURE_SH], [1], [Define if the host is a SuperH (32-bit)])
440            polyarch=interpret
441            ;;
442      alpha*)
443            AC_DEFINE([HOSTARCHITECTURE_ALPHA], [1], [Define if the host is an Alpha (64-bit)])
444            polyarch=interpret
445            # GCC defaults to non-conforming floating-point, and does not respect the rounding mode
446            # in the floating-point control register, so we force it to conform to IEEE and use the
447            # dynamic suffix on the floating-point instructions it produces.
448            CFLAGS="$CFLAGS -mieee -mfp-rounding-mode=d"
449            CXXFLAGS="$CXXFLAGS -mieee -mfp-rounding-mode=d"
450            ;;
451      riscv32)
452            AC_DEFINE([HOSTARCHITECTURE_RISCV32], [1], [Define if the host is a RISC-V (32-bit)])
453            polyarch=interpret
454            ;;
455      riscv64)
456            AC_DEFINE([HOSTARCHITECTURE_RISCV64], [1], [Define if the host is a RISC-V (64-bit)])
457            polyarch=interpret
458            ;;
459      *) AC_MSG_ERROR([Poly/ML is not supported for this architecture]) ;;
460esac
461
462# If we explicitly asked to use the interpreter set the architecture to interpreted.
463if test "x$with_portable" = "xyes" ; then
464    if test "x$polyarch" != "xinterpret" ; then
465        AC_MSG_WARN(
466            [*******You have disabled native code generation.  Are you really sure you want to do that?*******])
467    fi
468    polyarch=interpret
469fi
470
471# If we asked not to use the interpreter check we have native code support.
472if test "x$with_portable" = "xno" ; then
473    if test "x$polyarch" = "xinterpret" ; then
474        AC_MSG_ERROR(
475            [--enable-native-codegeneration was given but native code is not supported on this platform])
476    fi
477fi
478
479# Check for libffi only if we're building the interpreted version
480if test "x$polyarch" = "xinterpret" ; then
481    AC_CHECK_LIB([ffi], [ffi_prep_closure_loc])
482    AC_CHECK_HEADERS([ffi.h])
483fi
484
485# Build 32-bit in 64-bits.  This is only allowed when building on native 64-bit X86.
486AC_ARG_ENABLE([compact32bit],
487        [AS_HELP_STRING([--enable-compact32bit],
488            [use 32-bit values rather than native 64-bits.])])
489
490if test "x$enable_compact32bit" = "xyes"; then
491    if test X"$polyarch" = "Xx86_64" ; then
492        AC_DEFINE([POLYML32IN64], [1], [Define if this should use 32-bit values in 64-bit architectures])
493        polyarch=x86_32in64
494    else
495        AC_MSG_ERROR([--enable-compact32bit is only available on X86/64])
496   fi
497fi
498
499# Put this test at the end where it's less likely to be missed.
500# If we're compiling on Cygwin (and mingw?) and /usr/bin/file is not present
501# the link step will produce some strange warning messages of the form:
502# "Warning: linker path does not have real file for library -lXXX".  I think
503# that's really a bug in autoconf but to explain what's happening to the user
504# add a test here.
505if test "$lt_cv_file_magic_cmd" = "func_win32_libid";
506then
507    if test \! -x /usr/bin/file;
508    then
509        echo ""
510        echo "*** Warning: You are building Poly/ML on Cygwin/Mingw but '/usr/bin/file' cannot be found."
511        echo "*** You can still go ahead and build Poly/ML but libpolyml will not be built as a"
512        echo "*** shared library and you may get strange warning messages from the linker step."
513        echo "*** Install the 'file' package to correct this problem."
514        echo ""
515    fi
516fi
517
518AM_CONDITIONAL([ARCHI386], [test "$polyarch" = i386])
519AM_CONDITIONAL([ARCHX86_64], [test "$polyarch" = x86_64])
520AM_CONDITIONAL([ARCHINTERPRET], [test "$polyarch" = interpret -a X"$ac_cv_sizeof_voidp" = X4])
521AM_CONDITIONAL([ARCHINTERPRET64], [test "$polyarch" = interpret -a X"$ac_cv_sizeof_voidp" = X8])
522AM_CONDITIONAL([ARCHX8632IN64], [test "$polyarch" = x86_32in64])
523# If we are targeting Windows rather than *nix we need the pre=built compiler with Windows conventions.
524AM_CONDITIONAL([WINDOWSCALLCONV], [test "$poly_use_windowscc" = yes])
525
526# This is true if we are building for native Windows rather than Cygwin
527AM_CONDITIONAL([NATIVE_WINDOWS], [test "$poly_native_windows" = yes])
528AM_CONDITIONAL([NO_UNDEFINED], [test "$poly_no_undefined" = yes])
529AM_CONDITIONAL([WINDOWSGUI], [test x$poly_windows_enablegui = xtrue])
530
531AM_CONDITIONAL([MACOSLDOPTS], [test "$poly_need_macosopt" = yes ])
532
533# If we're building only the static version of libpolyml
534# then polyc and polyml.pc have to include the dependent libraries.
535dependentlibs=""
536if test "${enable_shared}" != yes; then
537    dependentlibs=${LIBS}
538fi
539
540AC_SUBST([dependentlibs], ["$dependentlibs"])
541
542# Test whether this is a git directory and set the version if possible
543AC_CHECK_PROG([gitinstalled], [git], [yes], [no])
544if test X"$gitinstalled" = "Xyes" -a -d ".git"; then
545    GIT_VERSION='-DGIT_VERSION=\"$(shell git describe --tags --always)\"'
546    AC_SUBST(GIT_VERSION)
547fi
548
549# Strip -fdebug-prefix-map= from CFLAGS; it's meaningless for users of polyc,
550# and hurts reproducibility.
551polyc_CFLAGS=
552for cflag in $CFLAGS; do
553    cflag="${cflag##-fdebug-prefix-map=*}"
554    if test -n "$cflag"; then
555        if test -n "$polyc_CFLAGS"; then
556            polyc_CFLAGS="$polyc_CFLAGS $cflag"
557        else
558            polyc_CFLAGS="$cflag"
559        fi
560    fi
561done
562AC_SUBST([polyc_CFLAGS], ["$polyc_CFLAGS"])
563
564# Modules directory
565AC_ARG_WITH([moduledir],
566  [AS_HELP_STRING([--with-moduledir=DIR], [directory for Poly/ML modules])],
567  [moduledir=$withval],
568  [moduledir="\${libdir}/polyml/modules"])
569AC_SUBST([moduledir], [$moduledir])
570
571# Control whether to build the basis library with arbitrary precision as the default int
572AC_ARG_ENABLE([intinf-as-int],
573    [AS_HELP_STRING([--enable-intinf-as-int], [set arbitrary precision as the default int type])],
574    [case "${enableval}" in
575       no) intisintinf=no ;;
576       yes) intisintinf=yes ;;
577       *) AC_MSG_ERROR([bad value ${enableval} for --enable-intinf-as-int]) ;;
578        esac],
579        [intisintinf=no])
580
581AM_CONDITIONAL([INTINFISINT], [test "$intisintinf" = "yes"])
582
583# These are needed for building in a separate build directory, as they are
584# referenced from exportPoly.sml.
585AC_CONFIG_COMMANDS([basis], [test -e basis || ln -sf ${ac_top_srcdir}/basis .])
586AC_CONFIG_COMMANDS([mlsource], [test -e mlsource || ln -sf ${ac_top_srcdir}/mlsource .])
587
588AC_CONFIG_FILES([Makefile libpolyml/Makefile libpolyml/polyml.pc libpolymain/Makefile modules/Makefile modules/IntInfAsInt/Makefile])
589AC_CONFIG_FILES([polyc], [chmod +x polyc])
590
591AC_OUTPUT
592