[go: up one dir, main page]

Menu

[7cd455]: / configure  Maximize  Restore  History

Download this file

92 lines (76 with data), 1.5 kB

#! /bin/sh

prefix=/usr/local

usage="USAGE: $0 [<options>]"

help=`cat <<EOF
Options:

--prefix <prefix>
	Location to install to (default: $prefix)
EOF
`

# Process arguments

while [ $# -gt 0 ]
do
    case "$1" in
	'--prefix')
	    shift
	    prefix="$1"
	    ;;
	'--help'|'-h')
	    printf '%s\n%s\n' "$usage" "$help"
	    exit
	    ;;
	*)
	    printf 'Option not recognized: %s\n' >&2
	    printf '\n%s\n' "$help"
	    exit 80
	    ;;
    esac
    shift
done

c99_test=`cat <<'EOF'
#include <stdio.h>

int main(int argc, char **argv) {
  printf("%ld\n", __STDC_VERSION__);
  return 0;
}
EOF
`

printf 'determining C compiler to use...'
if [ -z "$CC" ]
then
    printf "%s" "$c99_test" > configure_test.c
    trap "rm configure_test.c configure_test 2>/dev/null" EXIT
    for cc in c99 'cc -std=c99' 'gcc -std=c99' 'cc'
    do
	$cc configure_test.c -o configure_test 2>/dev/null
	status=$?
	if [ $status -eq 0 ]
	then
	    output=`./configure_test 2>/dev/null`
	    if [ "$output" -ge 19901 ]
	    then
		CC="$cc"
		break
	    fi
	fi
    done
fi

if [ -z "$CC" ]
then
    echo 'WARNING: no working C99 compiler found; using default CC'
    printf '' > Makefile.cfg
else
    echo $CC
    printf 'CC = %s\n\n' "$CC" > Makefile.cfg
fi

version=`cat VERSION`
major_version=`cut -f 1 -d . VERSION`

cat <<EOF >> Makefile.cfg
VERSION = $version
MAJOR_VERSION = $major_version

PREFIX = /usr/local

BINDIR = \$(PREFIX)/bin
INCLUDEDIR = \$(PREFIX)/include
LIBDIR = \$(PREFIX)/lib
EOF

echo "Done. Run 'make' to build cconstants."