File: configure.ac

package info (click to toggle)
polyml 5.2.1-1.1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 19,692 kB
  • ctags: 17,567
  • sloc: cpp: 37,221; sh: 9,591; asm: 4,120; ansic: 428; makefile: 203; ml: 191; awk: 91; sed: 10
file content (303 lines) | stat: -rw-r--r-- 10,181 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
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_INIT([[Poly/ML]], [[5.1]], [[polyml AT polyml DOT org]])
AM_INIT_AUTOMAKE
AC_PREREQ(2.59)

ac_debug_mode="no"

AC_ARG_ENABLE([debug],
   [  --enable-debug          Compiles without optimisation for debugging ],
   [ac_debug_mode="yes"])

if test "$ac_debug_mode" != "yes"; then
	# Default to maximum optimisation. -O2 is not good enough.
        # Set CCASFLAGS to empty so that it doesn't get set to CFLAGS.
        #   The -g option on assembler causes problems on Sparc/Solaris 10.
        # test X || Y  is equivalent to  if !X then Y
        test "${CFLAGS+set}" = set || CFLAGS="-O3"
        test "${CXXFLAGS+set}" = set || CXXFLAGS="-O3"
	test "${CCASFLAGS+set}" = set || CCASFLAGS=""
else
        test "${CFLAGS+set}" = set || CFLAGS="-g"
        test "${CXXFLAGS+set}" = set || CXXFLAGS="-g"
        test "${CCASFLAGS+set}" = set || CCASFLAGS=""
fi

AC_CANONICAL_HOST
# Set the OS flag.  This should not really be required but is still used in
# a few places for OS-specific quirks that can't be handled by more specific tests.
# Check also for mingw in which case we want to build native Windows.
poly_native_windows=no
# If we are building on cygwin or mingw we need to give the -no-defined flag to
# build a DLL.
# On mingw we need the -mthreads flag and this must be included in CFLAGS and
# CXXFLAGS before the LIBTOOL macros.
poly_no_undefined=no
case "${host_os}" in
    darwin*)
        AC_SUBST([OSFLAG], [-DMACOSX])
        ;;
    sunos* | solaris*)
        AC_SUBST([OSFLAG], [-DSOLARIS])
        ;;
    *mingw*)
        AC_SUBST([OSFLAG], [-DWINDOWS_PC])
        poly_native_windows=yes
        poly_no_undefined=yes
        CFLAGS="$CFLAGS -mthreads"
        CXXFLAGS="$CXXFLAGS -mthreads"
        ;;
    *cygwin*)
        poly_no_undefined=yes
        if test "$ac_cv_c_compiler_gnu" = "yes"; then
            if $CC -dumpmachine | grep -q mingw; then
                AC_SUBST([OSFLAG], [-DWINDOWS_PC])
                poly_native_windows=yes
                CFLAGS="$CFLAGS -mthreads"
                CXXFLAGS="$CXXFLAGS -mthreads"
            fi
        fi
        ;;
esac

AC_LIBTOOL_WIN32_DLL # libpolyml can be a DLL but libpolymain can't.
AC_PROG_LIBTOOL
AM_PROG_LIBTOOL
AM_MAINTAINER_MODE


# Check we're in the right directory
AC_CONFIG_SRCDIR([polyexports.h])
AC_CONFIG_HEADER([config.h])


# Checks for programs.
AC_PROG_CXX
AC_PROG_CC
AC_PROG_MAKE_SET
AC_PROG_CPP

AM_PROG_AS

# Checks for libraries.
AC_CHECK_LIB(gcc, main)
AC_CHECK_LIB(gcc_s, main)
AC_CHECK_LIB(stdc++, main)
AC_CHECK_LIB(dl, dlopen)
AC_CHECK_LIB(m, floor)
AC_CHECK_LIB(pthread, pthread_create)
# The next two are only used with mingw
AC_CHECK_LIB(wsock32, main)
AC_CHECK_LIB(gdi32, main)
# Solaris needs -lsocket, -lnsl and -lrt
# Use AC_CHECK_FUNC first so that the library is only included if it's really needed
# and not just because it's present.
AC_CHECK_FUNC(gethostbyname, , AC_CHECK_LIB(nsl, gethostbyname))
AC_CHECK_FUNC(getsockopt, , AC_CHECK_LIB(socket, getsockopt))
AC_CHECK_FUNC(sem_wait, , AC_CHECK_LIB(rt, sem_wait))

# Check for X and Motif headers and libraries
AC_PATH_X

if test "${with_x+set}" = set; then
	
	if test "$x_includes" != "" ; then
	if test  "$x_includes" != "NONE" ; then
		CFLAGS="$CFLAGS -I$x_includes"
		CXXFLAGS="$CXXFLAGS -I$x_includes"
		CPPFLAGS="$CPPFLAGS -I$x_includes"
	fi
	fi
	if test "$x_libraries" != "" ; then
	if test "$x_libraries" != "NONE" ; then
		LIBS="-L$x_libraries $LIBS"
	fi
	fi
	AC_CHECK_LIB(X11, XCreateGC)
	AC_CHECK_LIB(Xt, XtMalloc)
	AC_CHECK_LIB(Xext, XextAddDisplay)
	
	if test "$xm_includes" != "" ; then
	if test "$xm_includes" != "NONE" ; then
		CFLAGS="$CFLAGS -I$xm_includes"
		CXXFLAGS="$CXXFLAGS -I$xm_includes"
		CPPFLAGS="$CPPFLAGS -I$xm_includes"
	fi
	fi
	if test "$xm_libraries" != "" ; then
	if test "$xm_libraries" != "NONE" ; then
		LIBS="-L$xm_libraries $LIBS"
	fi
	fi
	AC_CHECK_LIB(Xm, XmGetDestination)

fi

# TODO: May need AC_PATH_XTRA for Solaris

# Check for headers

AC_FUNC_ALLOCA
AC_HEADER_DIRENT
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS([stdio.h time.h fcntl.h float.h limits.h locale.h malloc.h netdb.h netinet/in.h stddef.h])
AC_CHECK_HEADERS([stdlib.h string.h sys/file.h sys/ioctl.h sys/param.h sys/socket.h sys/systeminfo.h])
AC_CHECK_HEADERS([sys/time.h unistd.h values.h dlfcn.h signal.h ucontext.h])
AC_CHECK_HEADERS([assert.h ctype.h direct.h errno.h excpt.h fenv.h fpu_control.h grp.h])
AC_CHECK_HEADERS([ieeefp.h io.h math.h memory.h netinet/tcp.h poll.h pwd.h siginfo.h])
AC_CHECK_HEADERS([stdarg.h sys/errno.h sys/filio.h sys/mman.h sys/resource.h])
AC_CHECK_HEADERS([sys/signal.h sys/sockio.h sys/stat.h sys/termios.h sys/times.h])
AC_CHECK_HEADERS([sys/types.h sys/uio.h sys/un.h sys/utsname.h sys/select.h sys/sysctl.h])
AC_CHECK_HEADERS([sys/elf_SPARC.h sys/elf_386.h])
AC_CHECK_HEADERS([windows.h tchar.h pthread.h semaphore.h])

# Only check for the X headers if the user said --with-x.
if test "${with_x+set}" = set; then
    AC_CHECK_HEADERS([X11/Xlib.h Xm/Xm.h])
fi


# Find out which type of object code exporter to use.
# If we have winnt use PECOFF.  This really only applies to cygwin here.
# If we have elf.h use ELF.
# If we have mach-o/reloc.h use Mach-O
# Otherwise use the C source code exporter.
AC_CHECK_TYPES([IMAGE_FILE_HEADER],
    [AC_DEFINE([HAVE_PECOFF], [], [Define to 1 if you have the PE/COFF types.])]
        [polyexport=pecoff],
	[AC_CHECK_HEADER([elf.h],
		[AC_DEFINE([HAVE_ELF_H], [], [Define to 1 if you have the <elf.h> header file.])]
			[polyexport=elf],
              [AC_CHECK_HEADER([mach-o/reloc.h],
                  [AC_DEFINE([HAVE_MACH_O_RELOC_H], [], [Define to 1 if you have the <mach-o/reloc.h> header file.])]
                          [polyexport=macho]
                )]
    )],
    [#include <windows.h>]
)

AM_CONDITIONAL([EXPPECOFF], [test "$polyexport" = pecoff])
AM_CONDITIONAL([EXPELF], [test "$polyexport" = elf])
AM_CONDITIONAL([EXPMACHO], [test "$polyexport" = macho])

# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_C_CONST
AC_TYPE_UID_T
AC_TYPE_MODE_T
AC_TYPE_OFF_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_HEADER_TIME
AC_STRUCT_TM
# Mac OS X, at any rate, needs signal.h to be included first.
AC_CHECK_TYPES([ucontext_t], , , [#include "signal.h"
#include "ucontext.h"])
AC_CHECK_TYPES([struct sigcontext, stack_t, sighandler_t, sig_t], , ,[#include "signal.h"])
AC_CHECK_TYPES([socklen_t],,,[#include "sys/types.h"
#include "sys/socket.h"])

AC_CHECK_TYPES(long long)

AC_CHECK_SIZEOF(void*)
AC_CHECK_SIZEOF(long)

# Checks for library functions.
AC_FUNC_CHOWN
AC_FUNC_CLOSEDIR_VOID
AC_FUNC_ERROR_AT_LINE
AC_FUNC_FORK
AC_FUNC_GETGROUPS
AC_FUNC_GETPGRP
AC_PROG_GCC_TRADITIONAL
AC_FUNC_LSTAT
AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
AC_FUNC_REALLOC
AC_FUNC_SELECT_ARGTYPES
AC_FUNC_SETVBUF_REVERSED
AC_TYPE_SIGNAL
AC_FUNC_STAT
AC_FUNC_STRFTIME
AC_FUNC_STRTOD
AC_FUNC_VPRINTF
AC_CHECK_FUNCS([bzero dup2 floor ftruncate getcwd gethostbyaddr gethostname gettimeofday memmove])
AC_CHECK_FUNCS([memset mkdir mkfifo munmap pathconf pow realpath rmdir select setlocale socket sqrt strdup strerror])
AC_CHECK_FUNCS([uname dlopen getrusage strtod dtoa sigaction mkstemp getpagesize sigaltstack mmap mprotect])
AC_CHECK_FUNCS([getnetbyname getnetbyaddr sysctl])

# Where are the registers?
#Linux:
AC_CHECK_MEMBERS([mcontext_t.gregs, mcontext_t.regs, mcontext_t.mc_esp],,,[#include "ucontext.h"])
#Mac OS X:
AC_CHECK_MEMBERS([struct mcontext.ss, struct __darwin_mcontext.ss, struct __darwin_mcontext.__ss,
   struct __darwin_mcontext32.ss, struct __darwin_mcontext32.__ss,
   struct __darwin_mcontext64.ss, struct __darwin_mcontext64.__ss],,,
   [#include "signal.h"
#include "ucontext.h"])

# FreeBSD includes a sun_len member in struct sockaddr_un
AC_CHECK_MEMBERS([struct sockaddr_un.sun_len],,,
   [#include <sys/un.h>])

# Additional checks. AC_CANONICAL_HOST has already been called.
#AC_CANONICAL_HOST

# Test the --with-portable option to build the interpreter even if
# we have a code-generator.
AC_ARG_WITH(portable,
    [  --with-portable         Build the portable interpreter version of Poly/ML instead of native], [
    ac_cv_with_portable=yes], [
    ac_cv_with_portable=no])

case "${host_cpu}" in
      i[[3456]]86*)
            AC_DEFINE([HOSTARCHITECTURE_X86], [1], [Define if the host is an X86 (32 bit)])
            polyarch=i386
            ;;
      sparc*)
            AC_DEFINE([HOSTARCHITECTURE_SPARC], [1], [Define if the host is a Sparc (32 bit)])
            polyarch=sparc
            ;;
      power* | ppc*)
            AC_DEFINE([HOSTARCHITECTURE_PPC], [1], [Define if the host is a Power PC (32 bit)])
            polyarch=ppc
            ;;
      x86_64* | amd64*)
            AC_DEFINE([HOSTARCHITECTURE_X86_64], [1], [Define if the host is an X86 (64 bit)])
            polyarch=x86_64
            ;;
      arm*)
            AC_DEFINE([HOSTARCHITECTURE_ARM], [1], [Define if the host is an ARM (32 bit)])
            ac_cv_with_portable=yes
            ;;
      *) AC_MSG_ERROR([Poly/ML is not supported for this architecture]) ;;
esac

# If we have explicitly set --with-portable or we are on a machine without
# a code-generator set to use the interpreter.
if test "$ac_cv_with_portable" = "yes"; then
       AC_DEFINE([INTERPRETED], [1], [Define if using the interpreter] )
       polyarch=interpret
fi

AM_CONDITIONAL([ARCHI386], [test "$polyarch" = i386])
AM_CONDITIONAL([ARCHPPC], [test "$polyarch" = ppc])
AM_CONDITIONAL([ARCHSPARC], [test "$polyarch" = sparc])
AM_CONDITIONAL([ARCHINTERPRET], [test "$polyarch" = interpret -a X"$ac_cv_sizeof_voidp" = X4])
AM_CONDITIONAL([ARCHINTERPRET64], [test "$polyarch" = interpret -a X"$ac_cv_sizeof_voidp" = X8])
AM_CONDITIONAL([ARCHX86_64], [test "$polyarch" = x86_64])

AM_CONDITIONAL([NATIVE_WINDOWS], [test "$poly_native_windows" = yes])
AM_CONDITIONAL([NO_UNDEFINED], [test "$poly_no_undefined" = yes])

AH_TOP([
#ifndef CONF_H_INCLUDED
#define CONF_H_INCLUDED])
AH_BOTTOM([
#endif])

AC_CONFIG_FILES([Makefile libpolyml/Makefile libpolymain/Makefile])
AC_OUTPUT