configure.ac 9.65 KB
Newer Older
1
### Configuration
Stephan Herhut's avatar
Stephan Herhut committed
2

3
4
5
dnl Old versions of Autoconf appear to fail
AC_PREREQ([2.63])

Stephan Herhut's avatar
Stephan Herhut committed
6
7
dnl tell configure who we are
dnl parameters: package name, version, where to send bugreports
Artem Shinkarov's avatar
Artem Shinkarov committed
8
AC_INIT(sac2c, git, info@sac-home.org)
Stephan Herhut's avatar
Stephan Herhut committed
9
10

dnl set source directory and scripting directory
Stephan Herhut's avatar
Stephan Herhut committed
11
AC_CONFIG_SRCDIR(.)
Stephan Herhut's avatar
Stephan Herhut committed
12
13
14
15
16
17
AC_CONFIG_AUX_DIR(./config)

dnl we use C as our compiler language
AC_LANG(C)

dnl and which files to create
18
19
AC_CONFIG_FILES(../src/makefiles/config.mkf sac2crc)
AC_CONFIG_HEADER(../src/include/config.h)
Stephan Herhut's avatar
Stephan Herhut committed
20
21
22
23
24
25

dnl check for host type
AC_CANONICAL_BUILD()
AC_CANONICAL_HOST()
AC_CANONICAL_TARGET()

26
27
28
29
30
31
32
33
dnl if cygwin set IS_CYGWIN
is_cygwin=0
case "$target_os" in
  *cygwin*) is_cygwin=1 ;;
esac
AC_DEFINE_UNQUOTED([IS_CYGWIN], [$is_cygwin],
                   [Set to 1 if target is Cygwin, otherwise 0.])

Stephan Herhut's avatar
Stephan Herhut committed
34
dnl set OS and ARCH flags
35
36
AC_DEFINE_UNQUOTED([OS], ["$target_os"], [OS string])
AC_DEFINE_UNQUOTED([ARCH], ["$target_cpu"], [CPU architecture string])
Stephan Herhut's avatar
Stephan Herhut committed
37

38
# Enable sac2c compilation with C++
39
40
41
42
43
44
45
46
47
48
AC_ARG_ENABLE(cplusplus,
[AS_HELP_STRING([[--enable-cplusplus[=ARG]]],
                [Compile sources with C++ compiler @<:@ARG={yes,no}@:>@])],
ENABLE_CPLUSPLUS=$enableval,
ENABLE_CPLUSPLUS=no)
enable_cplusplus=
if test "${ENABLE_CPLUSPLUS}" = "yes" ; then
  enable_cplusplus=yes
fi

49
50
# Check if C preprocessor is available
AC_PROG_CPP()
51

52
53
54
# Enable system extensions when they are disabled by default
AC_USE_SYSTEM_EXTENSIONS

55
56
# Find out if we are using GCC/SunC/DECC/"Mac C"
CHECK_COMPILER_VENDOR
57

58
59
60
# Try to enable link time optimizations (LTO)
CHECK_LTO

61
62
# Check if C compiler supports SIMD syntax
CHECK_SIMD_SYNTAX
63

64
65
66
dnl check for ranlib
AC_PROG_RANLIB()

Stephan Herhut's avatar
Stephan Herhut committed
67
68
69
dnl check, whether we need -traditinal flag
AC_PROG_GCC_TRADITIONAL

70
71
72
# Check for SAC back-ends (CHECK_LPEL must appear after CHECK_MT)
CHECK_MT
CHECK_LPEL
73
CHECK_CUDA
74
CHECK_SL
75
CHECK_OMP
76
77
# enable private heap manager?
CHECK_PHM
78

79
80
# find a code beautifier.
CHECK_CODE_BEAUTIFIER
81

82
83
# search for lex/flex/yacc/bison
CHECK_LEX_YACC
Clemens Grelck's avatar
Clemens Grelck committed
84

85
86
87
88
89
# search/check various utilities
CHECK_REQUIRED_TOOL([SORT], [sort])
CHECK_REQUIRED_TOOL([UNIQ], [uniq])
CHECK_REQUIRED_TOOL([M4], [gm4 m4])
CHECK_REQUIRED_TOOL([XSLT], [xsltproc sabcmd])
90

91
92
# search for dot
CHECK_GRAPHVIZ
93

94
95
96
97
98
99
100
# check for various environment features
CHECK_PTR_PREFIX
CHECK_CONST_STDERR
AC_CHECK_HEADERS([malloc.h])
AC_CHECK_FUNCS([mkdtemp])
AC_SEARCH_LIBS([sqrt], [m])
AC_CHECK_FUNCS([strtok strrchr])
Stephan Herhut's avatar
Stephan Herhut committed
101

102
103
104
105
AC_SEARCH_LIBS([clock_gettime], [rt], [dnl
  AC_DEFINE([HAVE_GETTIME], 1,
            [Define is clock_gettime from POSIX RT is available.])
])
Stephan Herhut's avatar
Stephan Herhut committed
106

107
108
109
# check support for dynamic libraries
AC_CHECK_HEADER([dlfcn.h], [], [AC_MSG_ERROR([dlfcn.h is required.])])
AC_SEARCH_LIBS([dlopen], [dl])
110
CHECK_DLL_EXT
111

112
dnl set rtspec flag
113
114
115
enable_rtspec=no
if test x"$ac_cv_search_dlopen" != xno -a x"$enable_mt" = xyes; then
  enable_rtspec=yes
116
fi
117
118
119
120
case $ac_cv_search_dlopen in
  no | none required) dlopen_libs= ;;
  * ) dlopen_libs=$ac_cv_search_dlopen ;;
esac
121
122
123
124
have_rtspec=`if test $enable_rtspec = yes; then echo 1; else echo 0; fi`
AC_DEFINE_UNQUOTED([ENABLE_RTSPEC], [$have_rtspec],
                   [Define to 1 if runtime specialization is enabled, otherwise 0.])
AC_SUBST([ENABLE_RTSPEC], [$enable_rtspec])
125

126
127
128
129
130
131
132
133
134
135
136
137

# Check which GCC warning options are available and 
# add them later to MKCCFLAGS and PDCCFLAGS
gcc_options=
if test "$GCC" = yes ; then
  CHECK_CC_OPTION([-Wall], [gcc_options])
  CHECK_CC_OPTION([-Wextra], [gcc_options])
  CHECK_CC_OPTION([-Wstrict-prototypes], [gcc_options])
  CHECK_CC_OPTION([-Wno-unused-parameter], [gcc_options])
  CHECK_CC_OPTION([-Wno-unused-but-set-variable], [gcc_options])
fi

138
139
140
dnl
dnl test for compiler flags for sac2crc
dnl
141

Artem Shinkarov's avatar
Artem Shinkarov committed
142
dnl test for compiler flags for sac2crc
Stephan Herhut's avatar
Stephan Herhut committed
143
144
145
146
147
148
149
150
AC_MSG_CHECKING([sac2crc compiler flags])
if [ test "$GCC" = yes ]; then
  AC_SUBST(OPT_O0, [""])
  AC_SUBST(OPT_O1, [-O1])
  AC_SUBST(OPT_O2, [-O2])
  AC_SUBST(OPT_O3, [-O3])
  AC_SUBST(OPT_g, [-g])
  AC_SUBST(RCLDFLAGS, [""])
151
152
153
  AC_SUBST(RCCCFLAGS, ["-Wall -Wno-unused -fno-builtin -std=c99 $flags_lto"])  
  AC_SUBST(MKCCFLAGS, ["$gcc_options -pedantic -g -std=c99 $flags_lto"])
  AC_SUBST(PDCCFLAGS, ["$gcc_options -pedantic -O3 -std=c99 $flags_lto"])
154
155
156
157
158
  if [ test "$IS_CYGWIN" = yes ]; then
    AC_SUBST(GENPIC, ["-DPIC"])
  else
    AC_SUBST(GENPIC, ["-fPIC -DPIC"])
  fi  
Stephan Herhut's avatar
Stephan Herhut committed
159
  AC_SUBST(DEPSFLAG, ["-M"])
160
161
  AC_SUBST(CPPFILE, ["$CPP -C -x c"])
  AC_SUBST(CPP, ["$CPP -P -x c"])
Stephan Herhut's avatar
Stephan Herhut committed
162
163
164
165
166
  AC_MSG_RESULT([gcc settings])
elif [ test "$SUNC" = yes ]; then
  AC_SUBST(OPT_O0, [""])
  AC_SUBST(OPT_O1, [-xO2])
  AC_SUBST(OPT_O2, [-xO4])
167
  AC_SUBST(OPT_O3, [-xO5])
Stephan Herhut's avatar
Stephan Herhut committed
168
169
  AC_SUBST(OPT_g, [-g])
  AC_SUBST(RCLDFLAGS, [""])
170
  AC_SUBST(RCCCFLAGS, ["-dalign -fsimple -xsafe=mem -xc99=all"])
171
  AC_SUBST(MKCCFLAGS, ["-erroff=E_CAST_DOESNT_YIELD_LVALUE -g -xc99=all"])
Stephan Herhut's avatar
Stephan Herhut committed
172
  AC_SUBST(PDCCFLAGS, ["-erroff=E_CAST_DOESNT_YIELD_LVALUE -g -xO4 -xc99=all -KPIC"])
173
  AC_SUBST(GENPIC, ["-KPIC"])
Stephan Herhut's avatar
Stephan Herhut committed
174
  AC_SUBST(DEPSFLAG, ["-xM"])
175
176
  AC_SUBST(CPPFILE, ["$CPP -C -x c"])
  AC_SUBST(CPP, ["$CPP -P -x c"])
Stephan Herhut's avatar
Stephan Herhut committed
177
178
179
  AC_MSG_RESULT([Sun cc settings])
elif [ test "$DECC" = yes ]; then
  AC_SUBST(OPT_O0, [""])
Stephan Herhut's avatar
Stephan Herhut committed
180
181
  AC_SUBST(OPT_O1, [-O1])
  AC_SUBST(OPT_O2, [-O2])
182
  AC_SUBST(OPT_O3, [-O3])
Stephan Herhut's avatar
Stephan Herhut committed
183
  AC_SUBST(OPT_g, [-g])
184
  AC_SUBST(RCLDFLAGS, [""])
Stephan Herhut's avatar
Stephan Herhut committed
185
186
187
  AC_SUBST(RCCCFLAGS, [""])
  AC_SUBST(MKCCFLAGS, ["-g"])
  AC_SUBST(PDCCFLAGS, ["-g3"])
188
  AC_SUBST(GENPIC, [""])
Stephan Herhut's avatar
Stephan Herhut committed
189
  AC_SUBST(DEPSFLAG, ["-M"])
190
191
  AC_SUBST(CPPFILE, ["$CPP -C -x c"])
  AC_SUBST(CPP, ["$CPP -P -x c"])
Stephan Herhut's avatar
Stephan Herhut committed
192
193
194
  AC_MSG_RESULT([Compaq/DEC cc settings])
elif [ test "$MACC" = yes ]; then
  AC_SUBST(OPT_O0, [""])
Stephan Herhut's avatar
Stephan Herhut committed
195
196
197
  AC_SUBST(OPT_O1, [-O1])
  AC_SUBST(OPT_O2, [-O2])
  AC_SUBST(OPT_O3, [-O3])
Stephan Herhut's avatar
Stephan Herhut committed
198
  AC_SUBST(OPT_g, [-g])
199
  AC_SUBST(RCLDFLAGS, [""])
Artem Shinkarov's avatar
Artem Shinkarov committed
200
  AC_SUBST(RCCCFLAGS, ["-Wall -Wno-unused -fno-builtin -std=c99"])
201
  AC_SUBST(MKCCFLAGS, ["-Wall -std=c99 -g"])
202
  AC_SUBST(PDCCFLAGS, ["-std=c99"])
203
  AC_SUBST(GENPIC, [""])
Stephan Herhut's avatar
Stephan Herhut committed
204
  AC_SUBST(DEPSFLAG, ["-M"])
205
206
  AC_SUBST(CPPFILE, ["$CPP -C -x c"])
  AC_SUBST(CPP, ["$CPP -P -x c"])
Stephan Herhut's avatar
Stephan Herhut committed
207
208
209
210
211
212
213
214
215
  AC_MSG_RESULT([Apple cc settings])
else
  AC_SUBST(OPT_O0, [""])
  AC_SUBST(OPT_O1, [""])
  AC_SUBST(OPT_O2, [""])
  AC_SUBST(OPT_O3, [""])
  AC_SUBST(OPT_g, [""])
  AC_SUBST(RCLDFLAGS, [""])
  AC_SUBST(RCCCFLAGS, [""])
Stephan Herhut's avatar
Stephan Herhut committed
216
217
  AC_SUBST(MKCCFLAGS, [""])
  AC_SUBST(PDCCFLAGS, [""])
218
  AC_SUBST(GENPIC, [""])
Stephan Herhut's avatar
Stephan Herhut committed
219
  AC_SUBST(DEPSFLAG, ["-M"])
220
221
  AC_SUBST(CPPFILE, ["$CPP -C"])
  AC_SUBST(CPP, ["$CPP -P"])
Stephan Herhut's avatar
Stephan Herhut committed
222
223
  AC_MSG_RESULT([none found])
fi   
224
AC_SUBST(CCMTLINK, ["$PTHREAD_LIBS"])
225
AC_SUBST(CCDLLINK, ["$dlopen_libs $flags_lto"])
Stephan Herhut's avatar
Stephan Herhut committed
226

227
228
229
230
231
232
233
234
235
236
237
238
239
240
# This is a special case for building sac2c with c++ compiler.
if [[ "$GXX" = yes -a "$enable_cplusplus" = yes ]]; then
  AC_SUBST(SAC2C_CC, ["g++"])
  AC_SUBST(OPT_O0, [""])
  AC_SUBST(OPT_O1, [-O1])
  AC_SUBST(OPT_O2, [-O2])
  AC_SUBST(OPT_O3, [-O3])
  AC_SUBST(OPT_g, [-g])
  AC_SUBST(RCLDFLAGS, [""])
  AC_SUBST(RCCCFLAGS, ["-Wall -Wno-unused -fno-builtin -std=c99"])
  AC_SUBST(SAC2C_MKCCFLAGS, ["-Wno-write-strings -g -std=c++98"])
  AC_SUBST(SAC2C_PDCCFLAGS, ["-Wno-write-strings -O3 -std=c++98"])
  AC_SUBST(GENPIC, ["-fPIC -DPIC"])
  AC_SUBST(DEPSFLAG, ["-M"])
241
242
  AC_SUBST(CPPFILE, ["$CPP -C -x c"])
  AC_SUBST(CPP, ["$CPP -P -x c"])
243
244
245
246
247
248
  AC_MSG_RESULT([gcc settings])
else
  AC_SUBST(SAC2C_CC, ["$CC"])
  AC_SUBST(SAC2C_MKCCFLAGS, ["$MKCCFLAGS"])
  AC_SUBST(SAC2C_PDCCFLAGS, ["$PDCCFLAGS"])
fi
Artem Shinkarov's avatar
Artem Shinkarov committed
249
250
 
# append platform specific files to sac2crc
Stephan Herhut's avatar
Stephan Herhut committed
251
252
253
254
AC_SUBST_FILE(RCSUN)
AC_SUBST_FILE(RCX86)
AC_SUBST_FILE(RCALPHA)
AC_SUBST_FILE(RCMAC)
255
256
257
258
RCSUN=./sac2crc.SUN
RCX86=./sac2crc.X86
RCALPHA=./sac2crc.ALPHA
RCMAC=./sac2crc.MAC
Stephan Herhut's avatar
Stephan Herhut committed
259

260

Artem Shinkarov's avatar
Artem Shinkarov committed
261
# generate specific flags for known os
262
AC_MSG_CHECKING([sac2crc system flags])
263

Stephan Herhut's avatar
Stephan Herhut committed
264
265
OSFLAGS=""
case "$target_os" in
266
  solaris*)     
267
    OSFLAGS=["-D__EXTENSIONS__ -D_XPG6 -DMUST_INIT_YY -DPIC"]
268
    LD_DYNAMIC=["-G -dy"]
269
    LD_PATH=["-L%path% -R%path%"]
Stephan Herhut's avatar
Stephan Herhut committed
270
    LD_FLAGS="-Wl,-z,nodefs,-z,lazyload"
271
    AC_MSG_RESULT([solaris settings])
272
273
    ;;
  *linux*)      
Artem Shinkarov's avatar
Artem Shinkarov committed
274
    OSFLAGS=["-fPIC -DPIC -D_POSIX_SOURCE -D_SVID_SOURCE -D_BSD_SOURCE"]
275
    LD_DYNAMIC=["-shared -Wl,-allow-shlib-undefined -O3 $flags_lto"]
276
    LD_PATH=["-L%path% -Wl,-rpath,%path%"]
277
    LD_FLAGS="-Wl,-allow-shlib-undefined $flags_lto"
278
    AC_MSG_RESULT([linux settings])
279
    ;;
280
 *cygwin* | *mingw*)      
Artem Shinkarov's avatar
Artem Shinkarov committed
281
    OSFLAGS=["-D_POSIX_SOURCE -D_SVID_SOURCE -D_BSD_SOURCE"]
282
283
284
285
286
    LD_DYNAMIC=["-dy -shared"]
    LD_PATH=["-L%path% -Wl,-rpath,%path%"]
    LD_FLAGS=""
    AC_MSG_RESULT([cygwin settings])
    ;;
287
288
  *osf*)	
    OSFLAGS=["-D_OSF_SOURCE"]
289
    LD_DYNAMIC=[""]
290
    LD_PATH=["-L%path%"]
Stephan Herhut's avatar
Stephan Herhut committed
291
    LD_FLAGS=""
292
    AC_MSG_RESULT([OSF settings])
293
294
    ;;
  *darwin*)      
295
    dnl darwin needs some extra flags
296
297
    AC_DEFINE(ENABLE_PHM, 0)
    AC_SUBST(ENABLE_PHM, no)
298
    RANLIB="$RANLIB -c"
Artem Shinkarov's avatar
Artem Shinkarov committed
299
300
301
302
303
304
    OSFLAGS=["-D_DARWIN_C_SOURCE"]
    LD_DYNAMIC=["-undefined suppress -flat_namespace -dynamiclib -install_name '@rpath/%libname%' "]
    LD_PATH=["-L%path% -Wl,-rpath,%path%"]
    LD_FLAGS=""
    AC_MSG_RESULT([darwin settings])
    ;;
Stephan Herhut's avatar
Stephan Herhut committed
305
306
307
  *bsd*)
    OSFLAGS=["-fpic"]
    LD_DYNAMIC=["ld -dy -shared -symbolic"]
308
    LD_PATH=["-L -Wl,-rpath,%path%"]
Stephan Herhut's avatar
Stephan Herhut committed
309
    LD_FLAGS=""
Stephan Herhut's avatar
Stephan Herhut committed
310
311
    AC_MSG_RESULT([BSD settings])
    ;;
312
  *)
313
314
315
316
    OSFLAGS=["-fPIC -DPIC -D_POSIX_SOURCE -D_SVID_SOURCE -D_BSD_SOURCE -Dlint"]
    LD_DYNAMIC=["-dy -shared -Wl,-allow-shlib-undefined"]
    LD_PATH=["-L%path% -Wl,-rpath,%path%"]
    LD_FLAGS="-Wl,-allow-shlib-undefined"
317
    AC_MSG_RESULT([unknown])
318
    ;;
Stephan Herhut's avatar
Stephan Herhut committed
319
esac
320

Artem Shinkarov's avatar
Artem Shinkarov committed
321

322
323
AC_SUBST(OS,$target_os)
AC_SUBST(ARCH,$target_cpu)
Stephan Herhut's avatar
Stephan Herhut committed
324
AC_SUBST(OSFLAGS)
325
AC_SUBST(LD_DYNAMIC)
326
AC_SUBST(LD_PATH)
Stephan Herhut's avatar
Stephan Herhut committed
327
AC_SUBST(LD_FLAGS)
Artem Shinkarov's avatar
Artem Shinkarov committed
328
 
Stephan Herhut's avatar
Stephan Herhut committed
329

Artem Shinkarov's avatar
Artem Shinkarov committed
330
# static sac2c settings for config.h
331
332
333
334
335
336
AC_DEFINE( PF_MAXFUN, 100, [set to maximum number of sac functions for profiling])
AC_DEFINE( PF_MAXFUNAP, 100, 
           [set to maximum number of sac function applications for profiling])
AC_DEFINE( PF_MAXFUNNAMELEN, 100, 
           [set to maximum length of sac function names for profiling])

Clemens Grelck's avatar
Clemens Grelck committed
337
AC_DEFINE( SAC_PRELUDE_NAME, "sacprelude", [name of sac prelude])
338
AC_DEFINE( UNUSED, __attribute__((unused)), define macro for unused variables)
Stephan Herhut's avatar
Stephan Herhut committed
339

340

Artem Shinkarov's avatar
Artem Shinkarov committed
341
# create configure-generated file
Stephan Herhut's avatar
Stephan Herhut committed
342
AC_OUTPUT()