configure.ac 8.63 KB
Newer Older
Stephan Herhut's avatar
Stephan Herhut committed
1
2
dnl
dnl $Log$
Stephan Herhut's avatar
Stephan Herhut committed
3
4
5
6
dnl Revision 1.11  2003/03/21 16:59:24  sah
dnl added test on
dnl bison functionality
dnl
Stephan Herhut's avatar
Stephan Herhut committed
7
8
9
dnl Revision 1.10  2003/03/21 16:41:37  sah
dnl updated sbrk detection
dnl
Stephan Herhut's avatar
Stephan Herhut committed
10
11
12
13
dnl Revision 1.9  2003/03/21 15:53:04  sah
dnl added handling of platform
dnl specific compiler flags
dnl
Stephan Herhut's avatar
Stephan Herhut committed
14
15
16
dnl Revision 1.8  2003/03/21 11:37:47  sah
dnl fixed alpha cc bug
dnl
Stephan Herhut's avatar
Stephan Herhut committed
17
18
19
dnl Revision 1.7  2003/03/21 01:29:51  sah
dnl stderr bugfix
dnl
Stephan Herhut's avatar
Stephan Herhut committed
20
21
22
dnl Revision 1.6  2003/03/21 01:23:09  sah
dnl minor fixes
dnl
23
24
25
26
dnl Revision 1.5  2003/03/21 00:43:23  sah
dnl fixed bug in stderr_is_constant
dnl detection
dnl
Stephan Herhut's avatar
Stephan Herhut committed
27
28
29
30
dnl Revision 1.4  2003/03/21 00:34:39  sah
dnl added support for linux
dnl (tested on gentoo linux)
dnl
31
32
33
dnl Revision 1.3  2003/03/20 23:12:59  sah
dnl cpu sparc now matches sac SPARC setting
dnl
34
35
36
dnl Revision 1.2  2003/03/20 22:28:07  sah
dnl os solaris* os now matched to SOLARIS
dnl
Stephan Herhut's avatar
Stephan Herhut committed
37
38
39
40
41
42
43
44
45
46
47
48
49
dnl Revision 1.1  2003/03/20 22:19:39  sah
dnl Initial revision
dnl
dnl

dnl configure script for building sac2c compiler 
dnl on different hosts and os

dnl tell configure who we are
dnl parameters: package name, version, where to send bugreports
AC_INIT(sac2c, rcs, info@sac-home.org)

dnl set source directory and scripting directory
Stephan Herhut's avatar
Stephan Herhut committed
50
AC_CONFIG_SRCDIR(.)
Stephan Herhut's avatar
Stephan Herhut committed
51
52
53
54
55
56
AC_CONFIG_AUX_DIR(./config)

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

dnl and which files to create
Stephan Herhut's avatar
Stephan Herhut committed
57
AC_CONFIG_FILES(Makefile.Config src/runtime/sac2crc)
Stephan Herhut's avatar
Stephan Herhut committed
58
59
60
61
62
63
64
65
66
67
68
69
70
71
AC_CONFIG_HEADER(./src/global/config.h)

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

dnl set OS and ARCH flags
AC_DEFINE_UNQUOTED(OS,"$target_os",set to the os type)
AC_SUBST(OS,$target_os)
AC_DEFINE_UNQUOTED(ARCH,"$target_cpu",set to the architecture)
AC_SUBST(ARCH,$target_cpu)

dnl search for a C compiler
Stephan Herhut's avatar
Stephan Herhut committed
72
AC_PROG_CC(gcc cc)
Stephan Herhut's avatar
Stephan Herhut committed
73

Stephan Herhut's avatar
Stephan Herhut committed
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
dnl check whether its suns cc
AC_MSG_CHECKING(whether cc is a Sun Pro C compiler)
AC_TRY_COMPILE(,
[#ifndef __SUNPRO_C
  choke me
#endif],
AC_MSG_RESULT(yes)
SUNC=yes,
AC_MSG_RESULT(no)
SUNC=no
)

dnl check whether its comapcs (or dec) cc
AC_MSG_CHECKING(whether cc is a Compaq/DEC C compiler)
AC_TRY_COMPILE(,
[#ifndef __DECC
  choke me
#endif],
AC_MSG_RESULT(yes)
DECC=yes,
AC_MSG_RESULT(no)
DECC=no
)

dnl check whether popen is an extension
AC_MSG_CHECKING([need of _EXTENSIONS_ flag])
AC_TRY_COMPILE([#include <stdio.h>],[popen("rw","testfile")],
AC_MSG_RESULT(no)
need_ext_flags=no,
AC_MSG_RESULT(yes)
need_ext_flags=yes)

dnl check for C preprocessor
AC_PROG_CPP()

dnl check for ranlib
AC_PROG_RANLIB()
if test "$RANLIB"; then
  RANLIB="$RANLIB -c"
fi

Stephan Herhut's avatar
Stephan Herhut committed
115
116
117
118
119
120
dnl check, whether we need -traditinal flag
AC_PROG_GCC_TRADITIONAL

dnl search for bison, byacc or yacc
AC_PROG_YACC()

Stephan Herhut's avatar
Stephan Herhut committed
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
dnl check whether a non yacc works
if [ test "$YACC" != "yacc" ]; then
  AC_MSG_CHECKING([whether $YACC works])
  mkdir .ac_yacc_test
  cd .ac_yacc_test
  cp ../src/scanparse/sac.y .
  if [ $YACC sac.y ]; then
    AC_MSG_RESULT(ok)
  else
    YACC=yacc
    AC_MSG_RESULT(failed)
  fi
  cd ..
  rm -rf .ac_yacc_test
fi

Stephan Herhut's avatar
Stephan Herhut committed
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
dnl search for flex or lex
AC_PROG_LEX()

dnl search for malloc.h
AC_CHECK_HEADERS(malloc.h)

dnl search for pthread.h
AC_CHECK_HEADER(pthread.h,[

dnl if found, enable multi threading
AC_DEFINE(HAVE_PTHREAD_H, 1, set to 1 if you have the <pthread.h> header file)
AC_SUBST(DISABLE_MT, no)

],[

dnl otherwise disable mt
AC_DEFINE(DISABLE_MT, 1, set to 1 to disable multi threading)
AC_SUBST(DISABLE_MT, yes)

])

Stephan Herhut's avatar
Stephan Herhut committed
158
159
160
dnl check whether to link math library
AC_SEARCH_LIBS(fabs, m)

Stephan Herhut's avatar
Stephan Herhut committed
161
162
163
164
165
166
167
168
169
170
dnl checking for presence of strtok and strrchr
AC_CHECK_FUNCS([strtok strrchr])

dnl check for sbrk function
AC_CHECK_FUNC(sbrk, [

dnl if found, check type
dnl  check definition of sbrk
AC_MSG_CHECKING(for sbrk argument type)
include_file_list=`ls -1 /usr/include/*.h`
Stephan Herhut's avatar
Stephan Herhut committed
171
sbrk_types=`for name in $include_file_list; do grep sbrk $name 2>/dev/null; done`
Stephan Herhut's avatar
Stephan Herhut committed
172
[sbrk_types=`echo "$sbrk_types" | sed -e 's/[A-Za-z0-9 _*]*([ ]*//g' | sed -e 's/)[A-Za-z0-9_* ;]*//g' | sed -e 's/ [A-Za-z0-9_* ]*//g'` ]
Stephan Herhut's avatar
Stephan Herhut committed
173
[ for name in $sbrk_types; do ]
Stephan Herhut's avatar
Stephan Herhut committed
174
175
176
177
178
179
180
181
182
 AC_TRY_COMPILE([#include <unistd.h>],[sbrk(($name) 0)],break,name=none)
[ done ]

[ if test $name = none ; then ]
AC_DEFINE(DISABLE_PHM, 1)
AC_SUBST(DISABLE_PHM, yes)
AC_MSG_RESULT(not found)
[ else ]
AC_DEFINE_UNQUOTED(SBRK_T,$name,set to the type of sbrk argument)
Stephan Herhut's avatar
Stephan Herhut committed
183
AC_MSG_RESULT($name)
Stephan Herhut's avatar
Stephan Herhut committed
184
AC_SUBST(DISABLE_PHM, no)
Stephan Herhut's avatar
Stephan Herhut committed
185
[ fi ]
Stephan Herhut's avatar
Stephan Herhut committed
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
],[

dnl otherwise disable pm
AC_DEFINE(DISABLE_PHM, 1, set to disable private heapmanagement)
AC_SUBST(DISABLE_PHM, yes)
])

dnl check if we need to define _REENTRANT
dnl or if its defined in pthreads.d
AC_MSG_CHECKING(for need of _REENTRANT)
AC_EGREP_CPP(yes, 
[#include <pthread.h>
#ifdef _REENTRANT
no
#else
yes
#endif
], need_reentrant_definition=yes, need_reentrant_definition=no)
if [ test $need_reentrant_definition = yes ]; then
  AC_MSG_RESULT(yes)
  AC_DEFINE(NEED_REENTRANT, 1, set to 1 if pthread.h does not define _REENTRANT)
else
  AC_MSG_RESULT(no)
fi

dnl check if printf generates leading 0x for pointers
AC_MSG_CHECKING(for 0x prefix when printing pointers)
AC_EGREP_CPP(0x0*,
[#include <stdio.h>
int main()
{
printf("%p", (void*) 0);
}
], has_ptr_prefix=yes, has_ptr_prefix=no)
if [ test $has_ptr_prefix = yes ]; then
  AC_MSG_RESULT(yes)
else
  AC_MSG_RESULT(no)
  AC_DEFINE(NEED_PTR_PREFIX, 1, set to 1 if printf does not print a leading
0x in front of pointers)
fi

dnl check if stderr is a constant (needed for dbug.c
AC_MSG_CHECKING(whether stderr is a constant)
AC_TRY_COMPILE([
#include <stdio.h>
#include <unistd.h>
Stephan Herhut's avatar
Stephan Herhut committed
233
234
#include <stdlib.h>

Stephan Herhut's avatar
Stephan Herhut committed
235
FILE *_db_fp_ = stderr;
236
],[],stderr_is_constant=yes,stderr_is_constant=no)
Stephan Herhut's avatar
Stephan Herhut committed
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
if [ test $stderr_is_constant = yes ]; then
  AC_MSG_RESULT(yes)
  AC_DEFINE(STDERR_IS_CONSTANT, 1, set to 1 if stderr is a constant)
else
  AC_MSG_RESULT(no)
fi

dnl check whether to remove ar magic file
AC_MSG_CHECKING(for ar magic file)
mkdir .ar_magic_file_test
cd .ar_magic_file_test
touch testfile
ar -rc test.ar testfile
rm testfile
ar -x test.ar
[if [ -f ________64ELEL_ ]; then]
  AC_DEFINE(MUST_KILL_AR_MAGIC_FILE,1,set to 1 if ar generates a magic file)
  rm ________64ELEL_
  AC_MSG_RESULT(found);
else
  AC_MSG_RESULT(not found);
fi
rm testfile test.ar
cd ..
rmdir .ar_magic_file_test

dnl when not using bison, we need to
dnl reference YYLABELS
265
if test "$YACC" = "yacc"; then
Stephan Herhut's avatar
Stephan Herhut committed
266
267
268
  AC_DEFINE(MUST_REFERENCE_YYLABELS, 1, set to 1 if gcc complains about unused labels)
fi

Stephan Herhut's avatar
Stephan Herhut committed
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
dnl test for compiler flags
dnl for sac2crc
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, [""])
  AC_SUBST(RCCCFLAGS, ["-Wall -Wno-unused -fno-builtin"])
  AC_SUBST(MKCCFLAGS, ["-ansi -Wall -g"])
  AC_SUBST(PDCCFLAGS, ["-ansi -Wall -g -O3"])
  AC_SUBST(DEPSFLAG, ["-M"])
  AC_MSG_RESULT([gcc settings])
elif [ test "$SUNC" = yes ]; then
  AC_SUBST(OPT_O0, [""])
  AC_SUBST(OPT_O1, [-xO2])
  AC_SUBST(OPT_O2, [-xO4])
  AC_SUBST(OPT_O3, [-x05])
  AC_SUBST(OPT_g, [-g])
  AC_SUBST(RCLDFLAGS, [""])
  AC_SUBST(RCCCFLAGS, ["-dalign -fsimple -xsafe=mem"])
  AC_SUBST(MKCCFLAGS, ["-erroff=E_CAST_DOESNT_YIELD_LVALUE -g"])
  AC_SUBST(PDCCFLAGS, ["-erroff=E_CAST_DOESNT_YIELD_LVALUE -g -xO4"])
  AC_SUBST(DEPSFLAG, ["-xM"])
  AC_MSG_RESULT([Sun cc settings])
elif [ test "$DECC" = yes ]; then
  AC_SUBST(OPT_O0, [""])
  AC_SUBST(OPT_O1, [-xO2])
  AC_SUBST(OPT_O2, [-xO4])
  AC_SUBST(OPT_O3, [-x05])
  AC_SUBST(OPT_g, [-g])
  AC_SUBST(RCLDFLAGS, [""])
  AC_SUBST(RCCCFLAGS, [""])
  AC_SUBST(MKCCFLAGS, ["-g"])
  AC_SUBST(PDCCFLAGS, ["-g3"])
  AC_SUBST(DEPSFLAG, ["-M"])
  AC_MSG_RESULT([Compaq/DEC cc settings])
elif [ test "$MACC" = yes ]; then
  AC_SUBST(OPT_O0, [""])
  AC_SUBST(OPT_O1, [-xO2])
  AC_SUBST(OPT_O2, [-xO4])
  AC_SUBST(OPT_O3, [-x05])
  AC_SUBST(OPT_g, [-g])
  AC_SUBST(RCLDFLAGS, ["-Wl,-multiply_defined,suppress"])
  AC_SUBST(RCCCFLAGS, ["-Wall -Wno-unused -fno-builtin"])
  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, [""])
  AC_MSG_RESULT([none found])
fi   

dnl append platform specific files
dnl to sac2crc
AC_SUBST_FILE(RCSUN)
AC_SUBST_FILE(RCX86)
AC_SUBST_FILE(RCALPHA)
AC_SUBST_FILE(RCMAC)
RCSUN=$srcdir/src/runtime/sac2crc.SUN
RCX86=$srcdir/src/runtime/sac2crc.X86
RCALPHA=$srcdir/src/runtime/sac2crc.ALPHA
RCMAC=$srcdir/src/runtime/sac2crc.MAC

dnl generate specific flags for known os
OSFLAGS=""
case "$target_os" in
  solaris*)     OSFLAGS=["-D__EXTENSIONS__ -D__STDC__=0 -DMUST_INIT_YY"];;
  *linux*)      OSFLAGS=["-D_POSIX_SOURCE -D_SVID_SOURCE -D_BSD_SOURCE"];;
  *osf*)	OSFLAGS=["-D_OSF_SOURCE"];;
  *macos*)      OSFLAGS=["-traditional-cpp -Wno-long-double"];;
esac
AC_SUBST(OSFLAGS)



Stephan Herhut's avatar
Stephan Herhut committed
351
352
dnl generate the Makefile.Config out of Makefile.Config.in
AC_OUTPUT()