source: mainline/uspace/app/pcc/configure.ac@ 4ac901c

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 4ac901c was a7de7182, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 14 years ago

Added pcc source tree (contents of pcc-1.0.0.tgz)

  • Property mode set to 100644
File size: 11.6 KB
Line 
1 -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3
4AC_PREREQ(2.59)
5AC_INIT([pcc], [1.0.0.RELEASE], <pcc-list@ludd.ltu.se>)
6AC_CONFIG_HEADER([config.h])
7
8AC_CANONICAL_TARGET
9
10abi=unknown
11endian=little
12targosver=0
13tls=no
14gcccompat=yes
15# allowed: UNSIGNED (4-char u_int), INT (4-char int), SHORT (2-char u_short)
16wchar_type=INT
17
18case "$target_os" in
19
20 apple)
21 targos=apple
22 abi=classic68k
23 case "$target_cpu" in
24 m68k) targmach=m68k endian=big ;;
25 esac
26 ;;
27
28 bsd)
29 targos=bsd
30 abi=aout
31 targmach=pdp11
32 wchar_type=USHORT
33 ;;
34
35 darwin*)
36 targos=darwin
37 abi=macho
38 case "$target_os" in
39 *10.*) targosver=10 ;;
40 *9.*) targosver=9 ;;
41 *8.*) targosver=8 ;;
42 *7.*) targosver=7 ;;
43 esac
44 case "$target_cpu" in
45 i?86) targmach=i386 ;;
46 powerpc) targmach=powerpc endian=big ;;
47 x86_64) targmach=amd64 ;;
48 esac
49 ;;
50
51 dragonfly*)
52 targos=dragonfly
53 abi=elf
54 tls=yes
55 case "$target_cpu" in
56 i?86) targmach=i386 ;;
57 x86_64) targmach=amd64 ;;
58 esac
59 ;;
60
61 freebsd*)
62 targos=freebsd
63 abi=elf
64 case "$target_os" in
65 *9.*) targosver=9 ;;
66 *8.*) targosver=8 ;;
67 *7.*) targosver=7 ;;
68 *6.*) targosver=6 ;;
69 *5.*) targosver=5 ;;
70 *4.*) targosver=4 ;;
71 esac
72 case "$target_cpu" in
73 i386) targmach=i386 ;;
74 x86_64) targmach=amd64 ;;
75 esac
76 ;;
77
78 linux*)
79 targos=linux
80 abi=elf
81 case "$target_cpu" in
82 i?86) targmach=i386 ;;
83 powerpc*) targmach=powerpc endian=big ;;
84 x86_64) targmach=amd64 ;;
85 mipseb) targmach=mips endian=big ;;
86 mips*) targmach=mips ;;
87 esac
88 ;;
89
90 midnightbsd*)
91 targos=midnightbsd
92 abi=elf
93 case "$target_cpu" in
94 i?86) targmach=i386 ;;
95 sparc64) targmach=sparc64 endian=big ;;
96 esac
97 ;;
98
99 mingw*)
100 targos=win32
101 abi=pecoff
102 wchar_type=USHORT
103 targmach=i386
104 altincdir="c:/mingw/include"
105 altlibdir="c:/mingw/lib"
106 ;;
107
108 minix)
109 targos=minix
110 abi=coff
111 case "$target_cpu" in
112 m68k) targmach=m68k endian=big ;;
113 esac
114 ;;
115
116 mirbsd*)
117 targos=mirbsd
118 abi=elf
119 wchar_type=USHORT
120 case "$target_cpu" in
121 i?86) targmach=i386 ;;
122 esac
123 ;;
124
125 netbsd*)
126 targos=netbsd
127 abi=elf
128 case "$target_os" in
129 *5.*) targosver=5 ;;
130 *4.*) targosver=4 ;;
131 *3.*) targosver=3 ;;
132 *2.*) targosver=2 ;;
133 *1.*) targosver=1 ;;
134 esac
135 case "$target_cpu" in
136 armeb) targmach=arm endian=big ;;
137 arm*) targmach=arm ;;
138 i?86) targmach=i386 ;;
139 m68k*) targmach=m68k endian=big ;;
140 mipseb) targmach=mips endian=big ;;
141 mips*) targmach=mips ;;
142 pdp10) targmach=pdp10 ;;
143 powerpc) targmach=powerpc endian=big ;;
144 sparc64) targmach=sparc64 endian=big ;;
145 vax) targmach=vax ;;
146 x86_64) targmach=amd64 ;;
147 esac
148 ;;
149
150 nextstep*)
151 targos=nextstep
152 abi=macho
153 case "$target_cpu" in
154 i?86) targmach=i386 ;;
155 sparc) targmach=sparc endian=big ;;
156 hppa) targmach=hppa endian=big ;;
157 esac
158 ;;
159
160 openbsd*)
161 targos=openbsd
162 abi=elf
163 case "$target_cpu" in
164 i?86) targmach=i386 ;;
165 vax) targmach=vax ;;
166 powerpc) targmach=powerpc endian=big ;;
167 sparc64) targmach=sparc64 endian=big ;;
168 x86_64) targmach=amd64 ;;
169 esac
170 ;;
171
172 sunos*|solaris*)
173 targos=sunos
174 abi=elf
175 case "$target_cpu" in
176 i?86) targmach=i386 ;;
177 sparc*) targmach=sparc64 endian=big ;;
178 esac
179 ;;
180
181 windows*|pe*)
182 target_alias=i386-pe
183 targos=win32
184 abi=pecoff
185 wchar_type=USHORT
186 targmach=i386
187 ;;
188
189 *)
190 targos="$target_os"
191 case "$target_cpu" in
192 m16c) targmach=m16c ;;
193 nova) targmach=nova ;;
194 esac
195 ;;
196esac
197
198if test "X$targos" = X -o "X$targmach" = X ; then
199 AC_MSG_ERROR(['$target' is not (yet) supported by pcc.])
200fi
201
202case "$host_os" in
203
204 pe*)
205 # quick hack for cross-build to win32 host
206 if "$prefix" = NONE; then
207 prefix="c:/pcc"
208 assembler="yasm.exe -p gnu -f win32"
209 linker="link.exe /nologo"
210 ADD_CFLAGS=-DMSLINKER
211 fi
212 ;;
213
214 sunos*|solaris*)
215 ADD_CPPFLAGS="$ADD_CPPFLAGS -D_XOPEN_SOURCE=600"
216 ;;
217
218 darwin*)
219 if test "$targosver" -ge 10 ; then
220 targmach=amd64
221 fi
222 ;;
223
224esac
225
226if test "X$endian" = "Xbig" ; then
227 AC_DEFINE(TARGET_BIG_ENDIAN, 1,
228 [Define if target defaults to BIG endian])
229else
230 AC_DEFINE(TARGET_LITTLE_ENDIAN, 1,
231 [Define if target defaults to LITTLE endian])
232fi
233
234case "$abi" in
235 elf*) AC_DEFINE(ELFABI, [], [Using ELF ABI]) ;;
236 aout) AC_DEFINE(AOUTABI, [], [Using a.out ABI]) ;;
237 macho) AC_DEFINE(MACHOABI, [], [Using Mach-O ABI]) ;;
238 coff) AC_DEFINE(COFFABI, [], [Using COFF ABI]) ;;
239 ecoff) AC_DEFINE(ECOFFABI, [], [Using ECOFF ABI]) ;;
240 pecoff) AC_DEFINE(PECOFFABI, [], [Using PE/COFF ABI]) ;;
241 classic68k) AC_DEFINE(CLASSIC68K, [], [Using Classic 68k ABI]) ;;
242esac
243
244# Specify alternate assembler, linker, include and lib paths
245AC_ARG_WITH(incdir,
246 AC_HELP_STRING([--with-incdir=<path>],
247 [Specify the default include path.]),
248 altincdir=$withval,
249 [])
250AC_ARG_WITH(libdir,
251 AC_HELP_STRING([--with-libdir=<path>],
252 [Specify the default library path.]),
253 altlibdir=$withval,
254 [])
255AC_ARG_WITH(assembler,
256 AC_HELP_STRING([--with-assembler=<path>],
257 [Specify alternate assember.]),
258 assembler=$withval,
259 [])
260AC_ARG_WITH(linker,
261 AC_HELP_STRING([--with-linker=<path>],
262 [Specify alternate linker.]),
263 linker=$withval,
264 [])
265AC_ARG_ENABLE(tls,
266 AC_HELP_STRING([--enable-tls],
267 [Enable Thread-local storage (TLS).]),
268 [tls=$enableval], [])
269if test "$tls" = "yes"; then
270 AC_DEFINE(TLS, 1, [Enable thread-local storage (TLS).])
271fi
272AC_ARG_ENABLE(gcc-compat,
273 AC_HELP_STRING([--disable-gcc-compat],
274 [Disable GCC compatibility]),
275 [gcccompat=$enableval], [])
276if test "$gcccompat" = "yes"; then
277 ADD_CPPFLAGS="$ADD_CPPFLAGS -DGCC_COMPAT";
278fi
279
280# setup for building a cross-compiler
281if test "X$target_alias" = "X$host_alias" -o "X$target_alias" = "X"; then
282 BINPREFIX=""
283else
284 BINPREFIX="${target_alias}-"
285 test "X$prefix" = XNONE && prefix="$ac_default_prefix"
286 test "X$exec_prefix" = XNONE && exec_prefix="${prefix}"
287 if test -z "$altincdir"; then
288 altincdir=${exec_prefix}/${target_alias}/include
289 fi
290 if test -z "$altlibdir"; then
291 altlibdir=${exec_prefix}/${target_alias}/lib
292 fi
293 if test -z "$assembler"; then
294 assembler=${BINPREFIX}as
295 fi
296 if test -z "$linker"; then
297 linker=${BINPREFIX}ld
298 fi
299 preprocessor="${BINPREFIX}cpp"
300 compiler="${BINPREFIX}ccom"
301fi
302AC_SUBST(BINPREFIX)
303
304if test -n "$altincdir"; then
305 AC_DEFINE_UNQUOTED(STDINC, "$altincdir",
306 [Define alternate standard include directory])
307fi
308if test -n "$altlibdir"; then
309 AC_DEFINE_UNQUOTED(LIBDIR, "${altlibdir}/",
310 [Define alternate standard lib directory])
311fi
312if test -n "$assembler"; then
313 AC_DEFINE_UNQUOTED(ASSEMBLER, "$assembler",
314 [Define path to alternate assembler])
315fi
316if test -n "$linker"; then
317 AC_DEFINE_UNQUOTED(LINKER, "$linker",
318 [Define path to alternate linker])
319fi
320if test -n "$preprocessor"; then
321 AC_DEFINE_UNQUOTED(PREPROCESSOR, "${BINPREFIX}cpp",
322 [Define path to alternate preprocessor])
323fi
324if test -n "$compiler"; then
325 AC_DEFINE_UNQUOTED(COMPILER, "${BINPREFIX}ccom",
326 [Define path to alternate compiler])
327fi
328
329case $wchar_type in
330USHORT) wchar_size=2 ;;
331UNSIGNED|INT) wchar_size=4 ;;
332*) AC_MSG_ERROR([Unknown wchar_t '$wchar_type'.]) ;;
333esac
334
335AC_DEFINE_UNQUOTED(WCHAR_TYPE, $wchar_type, [Type to use for wide characters])
336AC_DEFINE_UNQUOTED(WCHAR_SIZE, $wchar_size, [Size of wide character type in chars])
337
338# check for additional compiler flags
339AC_PROG_CC
340DESIRED_FLAGS="-Wall -Wmissing-prototypes -Wstrict-prototypes -Wshadow -Wsign-compare -Wtruncate"
341for flag in $DESIRED_FLAGS
342do
343 AC_MSG_CHECKING([whether $CC accepts $flag])
344 AC_LANG_CONFTEST([int main() { return 0; }])
345 $CC $CFLAGS $flag -c conftest.c > /dev/null 2> /dev/null
346 if test $? = 0 ; then
347 ADD_CFLAGS="$ADD_CFLAGS $flag"
348 AC_MSG_RESULT([yes]);
349 else
350 AC_MSG_RESULT([no]);
351 fi
352 rm -f conftest.o
353done
354
355# setup for cross-compiling mkext
356AC_MSG_CHECKING([for a C compiler for mkext])
357if test $cross_compiling = yes; then
358 AC_MSG_RESULT([cross compiling])
359 AC_CHECK_PROGS(CC_FOR_BUILD, [pcc gcc cc])
360else
361 AC_MSG_RESULT([not cross compiling])
362 CC_FOR_BUILD=${CC-cc}
363 AC_SUBST(CC_FOR_BUILD)
364fi
365
366AC_CACHE_CHECK([for C99 printf size specifiers], ac_have_c99_format, [
367 AC_RUN_IFELSE([
368 AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], [[
369 char buf[64];
370 if (sprintf(buf, "%lld%hhd%jd%zd%td", (long long int)1, (char)2, (intmax_t)3, (size_t)4, (ptrdiff_t)5) != 5)
371 exit(1);
372 else if (strcmp(buf, "12345"))
373 exit(2);
374 ]])],
375 [ ac_have_c99_format=yes ],
376 [ ac_have_c99_format=no ],
377 [ ac_have_c99_format=yes ])
378])
379if test $ac_have_c99_format = yes; then
380 AC_DEFINE([HAVE_C99_FORMAT], 1,
381 [Define to 1 if printf supports C99 size specifiers])
382fi
383
384AC_CACHE_CHECK([for C99 variadic macro support], ac_have_variadic, [
385 AC_COMPILE_IFELSE([
386 #define macro(...) func(__VA_ARGS__)
387 int func(int a, ...);
388 int test() { return macro(1, 2, 3); }
389 ], [ ac_have_variadic=yes ], [ ac_have_variadic=no ])])
390if test $ac_have_variadic = yes ; then
391 AC_DEFINE([HAVE_CPP_VARARG_MACRO_GCC], 1,
392 [Define to 1 if your compiler supports C99 variadic macros])
393fi
394
395# Byteorder of host
396AC_C_BIGENDIAN([AC_DEFINE(HOST_BIG_ENDIAN,[],[Define if host is BIG endian])],
397 [AC_DEFINE(HOST_LITTLE_ENDIAN,[],[Define if host is LITTLE endian])],
398 [],[])
399
400
401# Checks for programs.
402AC_PROG_MAKE_SET
403AC_PROG_INSTALL
404AC_PROG_YACC
405AC_CHECK_PROG(strip,strip,yes,no)
406
407AC_PROG_LEX
408if test "$LEX" = flex ; then
409 AC_DEFINE_UNQUOTED(ISFLEX, 1, [lex is flex])
410fi
411
412# Checks for libraries.
413
414# Checks for header files.
415# AC_CHECK_HEADERS([fcntl.h stdlib.h string.h unistd.h])
416AC_CHECK_HEADERS([string.h malloc.h libgen.h])
417AC_HEADER_SYS_WAIT
418
419# Checks for library functions.
420## AC_FUNC_STRTOD
421# AC_FUNC_VPRINTF
422# AC_CHECK_FUNCS([memset strchr strdup strrchr strtol])
423AC_CHECK_FUNCS([strtold vsnprintf snprintf mkstemp strlcat strlcpy basename getopt ffs vfork])
424
425AC_EXEEXT
426
427AC_SUBST(targos)
428AC_SUBST(targosver)
429AC_SUBST(targmach)
430AC_SUBST(prefix)
431AC_SUBST(exec_prefix)
432AC_SUBST(libexecdir)
433AC_SUBST(includedir)
434AC_SUBST(strip)
435AC_SUBST(PACKAGE_VERSION)
436AC_SUBST(ADD_CFLAGS)
437AC_SUBST(ADD_CPPFLAGS)
438
439pcc_major=`echo $PACKAGE_VERSION | awk -F. '{print $1}'`
440pcc_minor=`echo $PACKAGE_VERSION | awk -F. '{print $2}'`
441pcc_minorminor=`echo $PACKAGE_VERSION | awk -F. '{print $3}'`
442versstr="\"$PACKAGE_STRING `cat $srcdir/DATESTAMP` for $target, $USER@`hostname`\""
443
444AC_DEFINE_UNQUOTED(TARGOS, $targos, [Target OS])
445AC_DEFINE_UNQUOTED(TARGOSVER, $targosver, [Target OS version])
446AC_DEFINE_UNQUOTED(PCC_MAJOR, $pcc_major, [Major version no])
447AC_DEFINE_UNQUOTED(PCC_MINOR, $pcc_minor, [Minor version no])
448AC_DEFINE_UNQUOTED(PCC_MINORMINOR, $pcc_minorminor, [Minor minor version no])
449AC_DEFINE_UNQUOTED(VERSSTR, $versstr, [Version string])
450
451AC_CONFIG_FILES([Makefile
452 cc/Makefile
453 cc/cc/Makefile
454 cc/cpp/Makefile
455 cc/ccom/Makefile
456 f77/Makefile
457 f77/f77/Makefile
458 f77/fcom/Makefile
459])
460AC_OUTPUT
461
462eval "exec_prefix=$exec_prefix"
463eval "bindir=$bindir"
464eval "libexecdir=$libexecdir"
465
466echo
467echo "Target CPU is .................... ${targmach}"
468echo "Target ABI is .................... ${abi}"
469echo "Target OS is ..................... ${targos}"
470echo "Compiler is called ............... ${BINPREFIX}pcc${EXEEXT}"
471echo "Installing compiler into ......... ${bindir}"
472echo "Installing pre-processor into .... ${libexecdir}"
473echo "Using assembler .................. ${assembler-<default>}"
474echo "Using linker ..................... ${linker-<default>}"
475echo "Using include path ............... ${altincdir-<default>}"
476echo "Using library path ............... ${altlibdir-<default>}"
477echo "Has TLS support .................. $tls"
478echo "Has GCC compatibility ............ $gcccompat"
479echo "Type of wchar_t is ............... ${wchar_type} (${wchar_size} chars)"
480echo
481echo "Configure finished. Do 'make && make install' to compile and install.
482"
Note: See TracBrowser for help on using the repository browser.