1 -*- Autoconf -*- 2# Process this file with autoconf to produce a configure script. 3 4AC_PREREQ(2.59) 5AC_INIT([pcc], [1.1.0], [pcc@lists.ludd.ltu.se]) 6AC_CONFIG_HEADER([config.h]) 7 8AC_CANONICAL_TARGET 9 10abi=unknown 11endian=little 12targosver=0 13tls=no 14gcccompat=yes 15pccdebug=yes 16stripping=yes 17native=no 18useyasm=no 19stabs=no 20# allowed: UNSIGNED (4-char u_int), INT (4-char int), SHORT (2-char u_short) 21wchar_type=INT 22 23case "$target_os" in 24 25 apple) 26 targos=apple 27 abi=classic68k 28 stabs=yes 29 case "$target_cpu" in 30 m68k) targmach=m68k endian=big ;; 31 esac 32 ;; 33 34 bsd) 35 targos=bsd 36 abi=aout 37 case "$target_cpu" in 38 pdp11) targmach=pdp11 ;; 39 nova) targmach=nova ;; 40 esac 41 wchar_type=USHORT 42 ;; 43 44 darwin*) 45 targos=darwin 46 abi=macho 47 stabs=yes 48 case "$target_os" in 49 *10.*) targosver=10 ;; 50 *9.*) targosver=9 ;; 51 *8.*) targosver=8 ;; 52 *7.*) targosver=7 ;; 53 esac 54 case "$target_cpu" in 55 i?86) targmach=i386 ;; 56 powerpc) targmach=powerpc endian=big ;; 57 x86_64) targmach=amd64 ;; 58 esac 59 ;; 60 61 dragonfly*) 62 targos=dragonfly 63 abi=elf 64 stabs=yes 65 tls=yes 66 case "$target_cpu" in 67 i?86) targmach=i386 ;; 68 x86_64) targmach=amd64 ;; 69 esac 70 ;; 71 72 freebsd*) 73 targos=freebsd 74 abi=elf 75 stabs=yes 76 case "$target_os" in 77 *10.*) targosver=10 ;; 78 *9.*) targosver=9 ;; 79 *8.*) targosver=8 ;; 80 *7.*) targosver=7 ;; 81 *6.*) targosver=6 ;; 82 *5.*) targosver=5 ;; 83 *4.*) targosver=4 ;; 84 esac 85 case "$target_cpu" in 86 i386) targmach=i386 ;; 87 sparc64) targmach=sparc64 endian=big ;; 88 x86_64) targmach=amd64 ;; 89 esac 90 ;; 91 92 linux*) 93 targos=linux 94 abi=elf 95 stabs=yes 96 case "$target_cpu" in 97 i?86) targmach=i386 ;; 98 powerpc*) targmach=powerpc endian=big ;; 99 x86_64) targmach=amd64 ;; 100 mipseb) targmach=mips endian=big ;; 101 mips*) targmach=mips ;; 102 esac 103 ;; 104 105 midnightbsd*) 106 targos=midnightbsd 107 abi=elf 108 stabs=yes 109 case "$target_cpu" in 110 i?86) targmach=i386 ;; 111 sparc64) targmach=sparc64 endian=big ;; 112 esac 113 ;; 114 115 mingw*) 116 targos=win32 117 abi=pecoff 118 wchar_type=USHORT 119 targmach=i386 120 altincdir="c:/mingw/include" 121 altlibdir="c:/mingw/lib" 122 ;; 123 124 minix*) 125 targos=minix 126 stabs=yes 127 case "$target_os" in 128 # explicit setting 129 minixaout|minix2|*aout) abi=aout ;; 130 minixelf|minix3|*elf) abi=elf ;; 131 # default to ELF 132 *) abi=elf ;; 133 esac 134 case "$target_cpu" in 135 i86) targmach=i86 ;; 136 i?86) targmach=i386 ;; 137 esac 138 ;; 139 140 mirbsd*) 141 targos=mirbsd 142 abi=elf 143 stabs=yes 144 wchar_type=USHORT 145 case "$target_cpu" in 146 i?86) targmach=i386 ;; 147 esac 148 ;; 149 150 netbsd*) 151 targos=netbsd 152 abi=elf 153 stabs=yes 154 case "$target_os" in 155 *7.*) targosver=7 ;; 156 *6.*) targosver=6 ;; 157 *5.*) targosver=5 ;; 158 *4.*) targosver=4 ;; 159 *3.*) targosver=3 ;; 160 *2.*) targosver=2 ;; 161 *1.*) targosver=1 ;; 162 esac 163 case "$target_cpu" in 164 armeb) targmach=arm endian=big ;; 165 arm*) targmach=arm ;; 166 i?86) targmach=i386 ;; 167 m68k*) targmach=m68k endian=big ;; 168 mipseb) targmach=mips endian=big ;; 169 mips*) targmach=mips ;; 170 pdp10) targmach=pdp10 ;; 171 powerpc) targmach=powerpc endian=big ;; 172 sparc64) targmach=sparc64 endian=big ;; 173 vax) targmach=vax ;; 174 x86_64) targmach=amd64 ;; 175 esac 176 ;; 177 178 nextstep*) 179 targos=nextstep 180 abi=macho 181 stabs=yes 182 case "$target_cpu" in 183 i?86) targmach=i386 ;; 184 sparc) targmach=sparc endian=big ;; 185 hppa) targmach=hppa endian=big ;; 186 esac 187 ;; 188 189 openbsd*) 190 targos=openbsd 191 abi=elf 192 stabs=yes 193 case "$target_cpu" in 194 i?86) targmach=i386 ;; 195 vax) targmach=vax ;; 196 powerpc) targmach=powerpc endian=big ;; 197 sparc64) targmach=sparc64 endian=big ;; 198 m68k) targmach=m68k endian=big ;; 199 x86_64) targmach=amd64 ;; 200 esac 201 ;; 202 203 sysv4*) 204 targos=sysv4 205 abi=elf 206 case "$target_cpu" in 207 i?86) targmach=i386 ;; 208 esac 209 ;; 210 211 sunos*|solaris*) 212 targos=sunos 213 abi=elf 214 stabs=yes 215 case "$target_cpu" in 216 i?86) targmach=i386 ;; 217 sparc*) targmach=sparc64 endian=big ;; 218 esac 219 ;; 220 221 windows*|pe*) 222 target_alias=i386-pe 223 targos=win32 224 abi=pecoff 225 wchar_type=USHORT 226 targmach=i386 227 ;; 228 229 *) 230 targos="$target_os" 231 case "$target_cpu" in 232 m16c) targmach=m16c ;; 233 nova) targmach=nova ;; 234 esac 235 ;; 236esac 237 238if test "X$targos" = X -o "X$targmach" = X ; then 239 AC_MSG_ERROR(['$target' is not (yet) supported by pcc.]) 240fi 241 242case "$host_os" in 243 244 apple) 245 hostos=apple 246 ;; 247 bsd) 248 hostos=bsd 249 ;; 250 darwin*) 251 echo $targosver 252 if test "$targosver" -ge 10 ; then 253 targmach=amd64 254 fi 255 hostos=darwin 256 ;; 257 dragonfly*) 258 hostos=dragonfly 259 ;; 260 freebsd*) 261 hostos=freebsd 262 ;; 263 linux*) 264 hostos=linux 265 ;; 266 midnightbsd*) 267 hostos=midnightbsd 268 ;; 269 mingw*) 270 hostos=win32 271 ;; 272 minix*) 273 hostos=minix 274 ;; 275 mirbsd*) 276 hostos=mirbsd 277 ;; 278 netbsd*) 279 hostos=netbsd 280 ;; 281 nextstep*) 282 hostos=nextstep 283 ;; 284 openbsd*) 285 hostos=openbsd 286 ;; 287 sunos*|solaris*) 288 ADD_CPPFLAGS="$ADD_CPPFLAGS -D_XOPEN_SOURCE=600" 289 hostos=sunos 290 ;; 291 pe*|windows*) 292 # quick hack for cross-build to win32 host 293 hostos=win32 294 if "$prefix" = NONE; then 295 prefix="c:/pcc" 296 assembler="yasm.exe -p gnu -f win32" 297 linker="link.exe /nologo" 298 ADD_CPPFLAGS="$ADD_CPPFLAGS -DMSLINKER" 299 fi 300 ;; 301 302esac 303 304if test "X$endian" = "Xbig" ; then 305 AC_DEFINE(TARGET_BIG_ENDIAN, 1, 306 [Define if target defaults to BIG endian]) 307else 308 AC_DEFINE(TARGET_LITTLE_ENDIAN, 1, 309 [Define if target defaults to LITTLE endian]) 310fi 311 312case "$abi" in 313 elf*) AC_DEFINE(ELFABI, 1, [Using ELF ABI]) ;; 314 aout) AC_DEFINE(AOUTABI, 1, [Using a.out ABI]) ;; 315 macho) AC_DEFINE(MACHOABI, 1, [Using Mach-O ABI]) ;; 316 coff) AC_DEFINE(COFFABI, 1, [Using COFF ABI]) ;; 317 ecoff) AC_DEFINE(ECOFFABI, 1, [Using ECOFF ABI]) ;; 318 pecoff) AC_DEFINE(PECOFFABI, 1, [Using PE/COFF ABI]) ;; 319 classic68k) AC_DEFINE(CLASSIC68K, 1, [Using Classic 68k ABI]) ;; 320esac 321 322if test "$stabs" = "yes"; then 323 AC_DEFINE(STABS, 1, [Enable STABS debugging output]) 324fi 325 326# Specify alternate assembler, linker, include and lib paths 327AC_ARG_ENABLE(multiarch, 328 AC_HELP_STRING([--enable-multiarch=yes/no/auto/<triplet>], 329 [Enable use of Linux Multi-Arch paths (default: auto)]), 330 [multiarch=$enableval], [multiarch=auto]) 331AC_ARG_WITH(incdir, 332 AC_HELP_STRING([--with-incdir=<path>], 333 [Specify the default include path.]), 334 altincdir=$withval, 335 []) 336AC_ARG_WITH(libdir, 337 AC_HELP_STRING([--with-libdir=<path>], 338 [Specify the default library path.]), 339 altlibdir=$withval, 340 []) 341AC_ARG_WITH(assembler, 342 AC_HELP_STRING([--with-assembler=<path>], 343 [Specify alternate assember.]), 344 assembler=$withval, 345 []) 346AC_ARG_WITH(linker, 347 AC_HELP_STRING([--with-linker=<path>], 348 [Specify alternate linker.]), 349 linker=$withval, 350 []) 351AC_ARG_ENABLE(tls, 352 AC_HELP_STRING([--enable-tls], 353 [Enable Thread-local storage (TLS).]), 354 [tls=$enableval], []) 355if test "$tls" = "yes"; then 356 AC_DEFINE(TLS, 1, [Enable thread-local storage (TLS).]) 357fi 358AC_ARG_ENABLE(Werror, 359 AC_HELP_STRING([--enable-Werror], 360 [Enable use of compiler -Werror flag]), 361 [werror=$enableval], []) 362if test "$werror" = "yes"; then 363 ADD_CFLAGS="$ADD_CFLAGS -Werror" 364fi 365AC_ARG_ENABLE(gcc-compat, 366 AC_HELP_STRING([--disable-gcc-compat], 367 [Disable GCC compatibility]), 368 [gcccompat=$enableval], []) 369if test "$gcccompat" = "yes"; then 370 ADD_CPPFLAGS="$ADD_CPPFLAGS -DGCC_COMPAT"; 371fi 372AC_ARG_ENABLE(pcc-debug, 373 AC_HELP_STRING([--disable-pcc-debug], 374 [Disable PCC debugging]), 375 [pccdebug=$enableval], []) 376if test "$pccdebug" = "yes"; then 377 ADD_CPPFLAGS="$ADD_CPPFLAGS -DPCC_DEBUG"; 378fi 379 380AC_ARG_ENABLE(stripping, 381 AC_HELP_STRING([--disable-stripping], 382 [Disable stripping of symbols in installed binaries]), 383 [stripping=$enableval], []) 384if test "$stripping" = "yes"; then 385 if test -z "$INSTALL_PROGRAM"; then 386 INSTALL_PROGRAM='${INSTALL} -s' 387 else 388 AC_MSG_WARN([Installed binaries may be unstripped]) 389 fi 390fi 391 392AC_ARG_WITH(yasm, 393 AC_HELP_STRING([--use-yasm], [Use yasm assembler]), 394 useyasm=$withval, 395 []) 396if test "$useyasm" = "yes"; then 397 assembler="yasm" 398 ADD_CPPFLAGS="$ADD_CPPFLAGS -DUSE_YASM" 399fi 400AC_ARG_ENABLE(native, 401 AC_HELP_STRING([--enable-native], 402 [Build the compiler as a native rather than cross-build compiler]), 403 [native=$enableval], []) 404 405# Setup for ubuntu multiarch 406multiarch_path= 407case x$multiarch in 408xno) 409 ;; 410xyes) 411 multiarch_path=`dpkg-architecture -qDEB_HOST_MULTIARCH 2>/dev/null` || multiarch_path= 412 case $multiarch_path in 413 *-*-*) ;; 414 *) 415 AC_MSG_ERROR([Cannot determine Multi-Arch path '$multiarch_path'!]) 416 ;; 417 esac 418 ;; 419xauto|x) 420 multiarch_path=`dpkg-architecture -qDEB_HOST_MULTIARCH 2>/dev/null` || multiarch_path= 421 case x$multiarch_path in 422 x*-*-*) ;; 423 x) ;; 424 *) 425 AC_MSG_WARN([Ignoring unrecognised Multi-Arch path '$multiarch_path'!]) 426 multiarch_path= 427 ;; 428 esac 429 ;; 430x*-*-*) 431 multiarch_path=$multiarch 432 ;; 433*) 434 AC_MSG_ERROR([Ignoring unrecognised Multi-Arch path '$multiarch_path'!]) 435 ;; 436esac 437if test -n "$multiarch_path"; then 438 AC_DEFINE_UNQUOTED([MULTIARCH_PATH], ["$multiarch_path"], 439 [Define target Multi-Arch path]) 440 multiarch="\"$multiarch_path\"" 441else 442 multiarch="(no)" 443fi 444# setup for building a cross-compiler 445if test "X$native" = "Xyes" -o "X$target_alias" = "X$host_alias" -o "X$target_alias" = "X"; then 446 BINPREFIX="" 447else 448 BINPREFIX="${target_alias}-" 449 test "X$prefix" = XNONE && prefix="$ac_default_prefix" 450 test "X$exec_prefix" = XNONE && exec_prefix="${prefix}" 451 if test -z "$altincdir"; then 452 altincdir=${exec_prefix}/${target_alias}/include 453 fi 454 if test -z "$altlibdir"; then 455 altlibdir=${exec_prefix}/${target_alias}/lib 456 fi 457 if test -z "$assembler"; then 458 assembler=${BINPREFIX}as 459 fi 460 if test -z "$linker"; then 461 linker=${BINPREFIX}ld 462 fi 463 preprocessor="${BINPREFIX}cpp" 464 compiler="${BINPREFIX}ccom" 465fi 466AC_SUBST(BINPREFIX) 467 468if test -n "$altincdir"; then 469 AC_DEFINE_UNQUOTED(STDINC, "$altincdir", 470 [Define alternate standard include directory]) 471fi 472if test -n "$altlibdir"; then 473 AC_DEFINE_UNQUOTED(LIBDIR, "${altlibdir}/", 474 [Define alternate standard lib directory]) 475fi 476if test -n "$assembler"; then 477 AC_DEFINE_UNQUOTED(ASSEMBLER, "$assembler", 478 [Define path to alternate assembler]) 479fi 480if test -n "$linker"; then 481 AC_DEFINE_UNQUOTED(LINKER, "$linker", 482 [Define path to alternate linker]) 483fi 484if test -n "$preprocessor"; then 485 AC_DEFINE_UNQUOTED(PREPROCESSOR, "$preprocessor", 486 [Define path to alternate preprocessor]) 487fi 488if test -n "$compiler"; then 489 AC_DEFINE_UNQUOTED(COMPILER, "$compiler", 490 [Define path to alternate compiler]) 491fi 492 493case $wchar_type in 494USHORT) wchar_size=2 ;; 495UNSIGNED|INT) wchar_size=4 ;; 496*) AC_MSG_ERROR([Unknown wchar_t '$wchar_type'.]) ;; 497esac 498 499AC_DEFINE_UNQUOTED(WCHAR_TYPE, $wchar_type, [Type to use for wide characters]) 500AC_DEFINE_UNQUOTED(WCHAR_SIZE, $wchar_size, [Size of wide-character type in chars]) 501 502# check for additional compiler flags 503AC_PROG_CC 504DESIRED_FLAGS="-Wall -Wmissing-prototypes -Wstrict-prototypes -Wshadow -Wsign-compare -Wtruncate" 505for flag in $DESIRED_FLAGS 506do 507 AC_MSG_CHECKING([whether $CC accepts $flag]) 508 cflags="$CFLAGS" 509 CFLAGS="$CFLAGS $flag -Werror" 510 AC_COMPILE_IFELSE([ 511 AC_LANG_PROGRAM([[]], [[]]) 512 ], [ 513 use_flag=yes 514 ], [ 515 use_flag=no 516 ]) 517 CFLAGS="$cflags" 518 519 AC_MSG_RESULT([$use_flag]) 520 if test $use_flag = yes; then 521 ADD_CFLAGS="$ADD_CFLAGS $flag" 522 fi 523done 524 525# setup for cross-compiling mkext 526AC_MSG_CHECKING([for a C compiler for mkext]) 527if test $cross_compiling = yes; then 528 AC_MSG_RESULT([cross compiling]) 529 AC_CHECK_PROGS(CC_FOR_BUILD, [pcc gcc cc]) 530else 531 AC_MSG_RESULT([not cross compiling]) 532 CC_FOR_BUILD=${CC-cc} 533 AC_SUBST(CC_FOR_BUILD) 534fi 535 536AC_CACHE_CHECK([for C99 printf size specifiers], ac_cv_have_c99_format, [ 537 AC_RUN_IFELSE([ 538 AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], [[ 539 char buf[64]; 540 if (sprintf(buf, "%lld%hhd%jd%zd%td", (long long int)1, (char)2, (intmax_t)3, (size_t)4, (ptrdiff_t)5) != 5) 541 exit(1); 542 else if (strcmp(buf, "12345")) 543 exit(2); 544 ]])], 545 [ ac_cv_have_c99_format=yes ], 546 [ ac_cv_have_c99_format=no ], 547 [ ac_cv_have_c99_format=yes ]) 548]) 549if test $ac_cv_have_c99_format = yes; then 550 AC_DEFINE([HAVE_C99_FORMAT], 1, 551 [Define to 1 if printf supports C99 size specifiers]) 552fi 553 554# Byteorder of host 555AC_C_BIGENDIAN([AC_DEFINE(HOST_BIG_ENDIAN, 1, [Define if host is BIG endian])], 556 [AC_DEFINE(HOST_LITTLE_ENDIAN, 1, [Define if host is LITTLE endian])], 557 [],[]) 558 559# Checks for programs. 560AC_PROG_MAKE_SET 561AC_PROG_INSTALL 562AC_PROG_YACC 563AC_PROG_LEX 564 565# Checks for libraries. 566 567# Checks for header files. 568# AC_CHECK_HEADERS([fcntl.h stdlib.h string.h unistd.h]) 569AC_CHECK_HEADERS([string.h malloc.h libgen.h]) 570AC_HEADER_SYS_WAIT 571 572# Checks for library functions. 573## AC_FUNC_STRTOD 574# AC_FUNC_VPRINTF 575# AC_CHECK_FUNCS([memset strchr strdup strrchr strtol]) 576AC_CHECK_FUNCS([strtold vsnprintf snprintf mkstemp strlcat strlcpy basename getopt ffs vfork]) 577 578AC_EXEEXT 579 580AC_SUBST(targos) 581AC_SUBST(targosver) 582AC_SUBST(targmach) 583AC_SUBST(hostos) 584AC_SUBST(prefix) 585AC_SUBST(exec_prefix) 586AC_SUBST(libexecdir) 587AC_SUBST(includedir) 588AC_SUBST(PACKAGE_VERSION) 589AC_SUBST(ADD_CFLAGS) 590AC_SUBST(ADD_CPPFLAGS) 591 592pcc_major=`echo $PACKAGE_VERSION | awk -F. '{print $1}'` 593pcc_minor=`echo $PACKAGE_VERSION | awk -F. '{print $2}'` 594pcc_minorminor=`echo $PACKAGE_VERSION | awk -F. '{print $3}'` 595test -n "$MPVERSION" && MPVERSION=", $MPVERSION" 596versstr="\"$PACKAGE_STRING `cat $srcdir/DATESTAMP` for $target$MPVERSION\"" 597 598AC_DEFINE_UNQUOTED(PCC_MAJOR, $pcc_major, [Major version no]) 599AC_DEFINE_UNQUOTED(PCC_MINOR, $pcc_minor, [Minor version no]) 600AC_DEFINE_UNQUOTED(PCC_MINORMINOR, $pcc_minorminor, [Minor minor version no]) 601AC_DEFINE_UNQUOTED(VERSSTR, $versstr, [Version string]) 602 603AC_CONFIG_FILES([Makefile 604 cc/Makefile 605 cc/cc/Makefile 606 cc/cpp/Makefile 607 cc/ccom/Makefile 608 cc/cxxcom/Makefile 609 cc/driver/Makefile 610 f77/Makefile 611 f77/f77/Makefile 612 f77/fcom/Makefile 613]) 614AC_OUTPUT 615 616eval "exec_prefix=$exec_prefix" 617eval "bindir=$bindir" 618eval "libexecdir=$libexecdir" 619 620echo 621echo "Target CPU is .................... ${targmach}" 622echo "Target ABI is .................... ${abi}" 623echo "Target OS is ..................... ${targos}" 624echo "Compiler is called ............... ${BINPREFIX}pcc${EXEEXT}" 625echo "Installing compiler into ......... ${bindir}" 626echo "Installing pre-processor into .... ${libexecdir}" 627echo "Using assembler .................. ${assembler-<default>}" 628echo "Using linker ..................... ${linker-<default>}" 629echo "Using Multi-Arch path ............ ${multiarch}" 630echo "Using include path ............... ${altincdir-<default>}" 631echo "Using library path ............... ${altlibdir-<default>}" 632echo "Has TLS support .................. $tls" 633echo "Has GCC compatibility ............ $gcccompat" 634echo "Has PCC debugging ................ $pccdebug" 635echo "Type of wchar_t is ............... ${wchar_type} (${wchar_size} chars)" 636echo 637echo "Configure finished. Do 'make && make install' to compile and install. 638" 639