view configure @ 545:11d95002dfe1

Split option parsing logic into a separate source file.
author Rob Landley <rob@landley.net>
date Thu, 27 Dec 2007 20:53:10 -0600
parents 756927e16211
children 1dadc72cb41f
line wrap: on
line source

#!/bin/bash

# Set lots of environment variables to default values.  All of these are
# overridden by existing local variables.

[ -z "$CC" ] && CC=cc
[ -z "$AR" ] && AR=ar
[ -z "$STRIP" ] && STRIP=strip
[ -z "$LIBSUF" ] && LIBSUF=.a
[ -z "$EXESUF" ] && EXESUF=
[ -z "$CFLAGS" ] && CFLAGS="-g -Wall -fsigned-char -Os -fno-strict-aliasing"
[ -z "$LIBS" ] && LIBS="-lm -ldl"
[ -z "$HOST" ] && HOST=$(uname -m | sed 's/i.86/i686/')
[ -z "$PREFIX" ] && PREFIX=/usr/local



# Set the compiler's search/install paths.

# i386 runs on an x86-64 host, but the library paths are abnormal.

LIB="lib"
[ "$HOST" == "x86_64" ] && [ TARGET="i386" ] && LIB="lib32"

# Directory for tinycc libraries (such as libtinycc.a) and headers (stdarg.h)
[ -z "$TINYCC_INSTALLDIR" ] && TINYCC_INSTALLDIR="$PREFIX"/tinycc
# Where should the linker look for C runtime files (crt1.o, crti.o, crtn.o)
[ -z "$CC_CRTDIR" ] && CC_CRTDIR="/usr/$LIB"
# Path to search for system libraries.
[ -z "$CC_LIBPATH" ] && CC_LIBPATH="/usr/local/$LIB:/usr/$LIB:/$LIB"
# Path to search for system #include files.
[ -z "$CC_HEADERPATH" ] && CC_HEADERPATH="/usr/include:/usr/local/include"

# For ./configure -v display all the variables we just set.

if [ "$1" == "-v" ]
then
  for i in CC AR STRIP LIBSUF EXESUF CFLAGS LIBS HOST PREFIX TINYCC_INSTALLDIR CC_CRTDIR CC_LIBPATH CC_HEADERPATH TARGET
  do
    echo -n "$i="
    eval 'echo "$'$i'"'
  done
fi