diff options
author | Tristan Gingold <tgingold@free.fr> | 2014-11-05 20:47:13 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2014-11-05 20:47:13 +0100 |
commit | 81cd0858f805c9339cce3a85c620ec7d44c6d5a7 (patch) | |
tree | f576ba348f5eaf3237b44a874125603a466111b5 /configure | |
parent | 8b90118c3e035f191670cfa978ab1d81a93b54df (diff) | |
download | ghdl-81cd0858f805c9339cce3a85c620ec7d44c6d5a7.tar.gz ghdl-81cd0858f805c9339cce3a85c620ec7d44c6d5a7.tar.bz2 ghdl-81cd0858f805c9339cce3a85c620ec7d44c6d5a7.zip |
Add configure and Makefile.in for mcode.
Diffstat (limited to 'configure')
-rw-r--r-- | configure | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/configure b/configure new file mode 100644 index 000000000..6aea32d84 --- /dev/null +++ b/configure @@ -0,0 +1,130 @@ +#!/bin/sh +# +# configure script for ghdl (c) 2014 Tristan Gingold +# + +backend=mcode +CC=${CC:-gcc} +CFLAGS=${CFLAGS:--g} +GNATMAKE=${GNATMAKE:-gnatmake} +prefix=/usr/local +build= + +show_help=no +progname=$0 + +subst_vars="CC GNATMAKE CFLAGS build srcdir" + +# Find srcdir +srcdir=`dirname $progname` +if test x$srcdir = x; then + srcdir=. +fi + +# Check echo -n / echo \c +if test x`echo -n` = x"-n" ; then + echon="" + echoc="\c" +else + echon="-n" + echoc="" +fi + +# Decode options +for opt do + optarg=`expr x$opt : 'x[^=]*=\(.*\)'` + case "$opt" in + CC=*|CFLAGS=*|GNATMAKE=*) + optvar=`expr x$opt : 'x\([^=]*\)=.*'` + eval $optvar="$optarg" + ;; + --prefix=*) prefix="$optarg";; + --srcdir=*) srcdir="$optarg";; + -h|-help|--help) show_help=yes;; + *) echo "$0: unknown option $opt; try $0 --help" + exit 1 + ;; + esac +done + +if test $show_help != no; then +cat <<EOF +Usage: configure [options] + +Options [defaults in brackets]: + --prefix=PREFIX install in PREFIX [$prefix] + --srcdir=SRCDIR source code path [$srcdir] +EOF +exit 0 +fi + +# Sanity checks +# Check that gnatmake exists +if ! $GNATMAKE 2> /dev/null; then + echo "Sorry, you need GNAT to build GHDL. See the README" + echo "(gnatmake is $GNATMAKE)" + exit 1 +fi + +# Check that compiler exists +if ! $CC -v 2> /dev/null; then + echo "Sorry, you need a C compiler to build GHDL. See the README" + exit 1 +fi + +# For mcode, check that gcc emits i386 +if test $backend = mcode; then + if ! $CC $CFLAGS -dumpmachine | grep -q "[3-6]86"; then + echo "WARNING: GHDL for mcode is supported only on x86 (32 bits)" + echo "continuing, but build failure expected (See the README)" + fi +fi + +# Compute build machine +if test x$build = x; then + build=`$CC $CFLAGS -dumpmachine` +fi +echo "Build machine is: $build" + +# Generate config.status +rm -f config.status +{ +echo "#! /bin/sh" +echo "# Generated by configure." +echo "# Run this file to recreate the current configuration." +echo +echo "# Generated by:" +echo $echon "# $progname" $echoc +for opt do + echo $echon " " $opt $echoc +done +echo +echo +echo subst_vars=\"$subst_vars\" +for v in $subst_vars; do + eval vval=\$$v + echo $v="$vval" +done +echo +echo 'sed_opts=""' +echo 'for v in $subst_vars; do' +echo ' eval vval=\$$v' +echo ' sed_opts="$sed_opts -e s/@${v}@/$vval/g"' +echo 'done' +echo +echo 'echo "Creating Makefile"' +echo 'sed $sed_opts < $srcdir/Makefile.in > Makefile' +} > config.status || \ +{ + echo "$progname: cannot create config.status" + exit 1 +} + +chmod +x ./config.status + +if ! sh ./config.status; then + echo "$progname: cannot execute config.status" + exit 1 +fi + +exit 0 |