diff configure @ 0:13d2b8934445

Import AnaGram (near-)release tree into Mercurial.
author David A. Holland
date Sat, 22 Dec 2007 17:52:45 -0500
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/configure	Sat Dec 22 17:52:45 2007 -0500
@@ -0,0 +1,699 @@
+#!/bin/sh
+# configure - configure script for AnaGram
+# usage: path-to-source/configure [options]
+# for options, do configure --help, or read down.
+#
+# Note: this is a hand-written script, not GNU autoconf output.
+# Its primary purpose is to set up the build tree, not to perform
+# tests on the build platform.
+#
+# Also note: changing to autoconf will not make this any easier, or
+# add any useful functionality for free, so please don't bother
+# suggesting it.
+#
+# Supported compilers and targets are listed below. Note that there is
+# vestigial support in the source tree for various other Windows
+# compilers (Borland, Watcom, etc.) - I don't have these, but will
+# cheerfully add support if someone tells me how to invoke them and
+# sends patches to clean up the template instantiations. I will also
+# take patches for supporting for other Unix compilers. And if anyone
+# wants to update the once-upon-a-time Amiga support, I'll even take 
+# patches for that.
+#
+# Also, this script should not be expected to work for native builds
+# on Windows. I don't have a Windows machine, Windows is a crippled
+# platform, and it's too much trouble to sort out. If someone wants to
+# make it work under Cygwin, however, I'll take the patches.
+#
+
+usage() {
+cat 1>&2 <<EOF
+Usage: PATH-TO-SOURCE/configure [options] [ostype]
+Options:
+    --with-compiler=COMPILER    Choose compiler (see below)
+    --with-ptests=DIR           Use private testsuite in DIR
+    --enable-gui=GUI            Enable a GUI (see below)
+    --disable-gui               Build command-line version only
+    --enable-maintainer-mode    Set maintainer-specific build options
+    --enable-debug              Enable debugging information
+    --enable-prof               Enable profiling
+For Unix installs:
+    --destdir=DIR               Set install chroot (default: none)
+    --prefix=DIR                Set install prefix (default: /usr/local)
+    --bindir=DIR                Install directory for binaries
+    --libdir=DIR                Install directory for libraries
+    --mandir=DIR                Install directory for man pages
+    --docdir=DIR                Install directory for HTML docs
+    --examplesdir=DIR           Install directory for examples
+Compilers:
+    gcc                         The GNU compiler (gcc/g++).
+    vacpp                       IBM Visual Age C++ for Windows
+GUIs:
+    vaclgui                     The IBM Visual Age C++ for Windows GUI
+    dummygui                    Equivalent to --disable-gui
+OSes:
+    native                      Current Unix type (default)
+    windows                     Cross-compiled Windows
+    *-* or *-*-*                A cross-compiled Unix type
+Notes:
+    1. Compiling in the source directory is not supported. Run
+       configure in a subdirectory or somewhere else.
+    2. Native builds on Windows are not supported.
+    3. Read the install instructions before cross-compiling.
+EOF
+}
+
+############################################################
+#
+# 1. Know thyself.
+#
+
+SRCDIR=`dirname "$0"`
+
+if [ ! -d "$SRCDIR" -o "$SRCDIR" = "" ]; then
+    # ...?
+    usage
+    exit 1
+fi
+
+if [ "$SRCDIR" = . ]; then
+    # just warn, don't error
+    echo "$0: Compiling in the source directory is not recommended" 1>&2
+    #echo "Please do this:" 1>&2
+    #echo "   mkdir build" 1>&2
+    #echo "   cd build" 1>&2
+    #echo "   ../configure $@" 1>&2
+    #exit 1
+fi
+
+if [ ! -f "$SRCDIR"/anagram/agcore/pgg24.syn ]; then
+    echo "$0: please run me out of the AnaGram source directory" 1>&2
+    exit 1
+fi
+
+############################################################
+#
+# 2. options
+#
+
+DESTDIR=
+PREFIX=
+BINDIR=
+LIBDIR=
+MANDIR=
+DOCDIR=
+EXAMPLESDIR=
+COMPILER=
+PTESTS=
+GUI=
+PLATFORM=
+MAINTAINER=0
+MODE=opt
+
+while [ "x$1" != x ]; do
+    case "$1" in
+	--destdir=*) DESTDIR=`echo "$1" | sed 's/^[^=]*=//'`;;
+	--prefix=*) PREFIX=`echo "$1" | sed 's/^[^=]*=//'`;;
+	--bindir=*) BINDIR=`echo "$1" | sed 's/^[^=]*=//'`;;
+	--libdir=*) LIBDIR=`echo "$1" | sed 's/^[^=]*=//'`;;
+	--mandir=*) MANDIR=`echo "$1" | sed 's/^[^=]*=//'`;;
+	--docdir=*) DOCDIR=`echo "$1" | sed 's/^[^=]*=//'`;;
+	--examplesdir=*) EXAMPLESDIR=`echo "$1" | sed 's/^[^=]*=//'`;;
+	--with-compiler=*) COMPILER=`echo "$1" | sed 's/^[^=]*=//'`;;
+	--without-compiler) echo "$0: You're joking, right?" 1>&2; exit 1;;
+	--with-ptests=*) PTESTS=`echo "$1" | sed 's/^[^=]*=//'`;;
+	--without-ptests) PTESTS= ;;
+	--enable-gui=*) GUI=`echo "$1" | sed 's/^[^=]*=//'`;;
+	--disable-gui) GUI=dummygui;;
+	--enable-maintainer-mode) MAINTAINER=1;;
+	--disable-maintainer-mode) MAINTAINER=0;;
+	--enable-debug) MODE=debug;;
+	--enable-prof) MODE=prof;;
+	--disable-debug|--disable-prof) MODE=opt;;
+	--help) usage; exit 0;;
+	--*|-*) usage; exit 1;;
+	*)
+	    if [ "x$PLATFORM" != x ]; then
+		usage
+		exit 1
+	    fi
+	    PLATFORM="$1"
+	    ;;
+    esac
+shift
+done
+
+# Default platform
+
+if [ "x$PLATFORM" = x ]; then
+    PLATFORM=native
+fi
+
+# Check platform
+
+case "$PLATFORM" in
+    native) OSTYPE=unix; CROSS=0;;
+    *-*-*)  OSTYPE=unix; CROSS=1; CROSSNAME="$PLATFORM";;
+    *-*)    OSTYPE=unix; CROSS=1; CROSSNAME="$PLATFORM";;
+    windows) OSTYPE=windows; CROSS=1; CROSSNAME=windows;;
+    *) echo "$0: Invalid platform $PLATFORM" 1>&2; exit 1;;
+esac
+
+# Default compiler
+
+if [ "x$COMPILER" = x ]; then
+    if [ "$OSTYPE" = windows ]; then
+	COMPILER=vacpp
+    else
+	COMPILER=gcc
+    fi
+fi
+
+# Check compiler
+
+case "$COMPILER" in
+    gcc) ;;
+    vacpp) ;;
+    *) echo "$0: Unrecognized compiler $COMPILER" 1>&2; exit 1;;
+esac
+
+# Default GUI
+
+if [ "x$GUI" = x ]; then
+    if [ "$COMPILER" = vacpp ]; then
+	GUI=vaclgui
+    else
+	GUI=dummygui
+    fi
+fi
+
+# Check GUI
+
+case "$GUI" in
+    vaclgui) ;;
+    dummygui) ;;
+    *) echo "$0: Unrecognized GUI $GUI" 1>&2; exit 1;;
+esac
+
+# Default PREFIX
+
+if [ "x$PREFIX" = x ]; then
+    if [ $OSTYPE = unix ]; then
+	if [ $CROSS = 1 ]; then
+	    PREFIX="/usr/local/$CROSSNAME"
+	else
+	    PREFIX=/usr/local
+	fi
+    else
+	# Windows build doesn't use this
+	PREFIX=/error
+    fi
+fi
+
+# Do not need to check PREFIX
+
+# Default DESTDIR is empty - do not need to set it
+
+# Check DESTDIR
+
+if [ "x$DESTDIR" != x ]; then
+    if [ ! -d "$DESTDIR" ]; then
+	echo "$0: DESTDIR $DESTDIR does not exist" 1>&2
+	exit 1
+    fi
+fi
+
+# Pick default install dirs
+if [ $OSTYPE = unix ]; then
+
+    if [ "x$BINDIR" = x ]; then
+	BINDIR="$PREFIX/bin"
+    fi
+
+    if [ "x$LIBDIR" = x ]; then
+	LIBDIR="$PREFIX/lib"
+    fi
+
+    if [ "x$MANDIR" = x ]; then
+	# probe default man directory 
+	if [ -d "${DESTDIR}$PREFIX/share/man" ]; then
+	    MANDIR="$PREFIX/share/man"
+	else
+	    MANDIR="$PREFIX/man"
+	fi
+    fi
+
+    if [ "x$DOCDIR" = x ]; then
+	if [ -d "${DESTDIR}$PREFIX/share/doc/html" ]; then
+	    DOCDIR="$PREFIX/share/doc/html/AnaGram"
+	else if [ -d "${DESTDIR}$PREFIX/doc" ]; then
+	    DOCDIR="$PREFIX/doc/AnaGram"
+	else
+	    DOCDIR="$PREFIX/share/doc/AnaGram"
+	fi;fi
+    fi
+
+    if [ "x$EXAMPLESDIR" = x ]; then
+	if [ -d "${DESTDIR}$PREFIX/share/examples" ];then
+	    EXAMPLESDIR="$PREFIX/share/examples/AnaGram"
+	else
+	    EXAMPLESDIR="$DOCDIR"
+	fi
+    fi
+
+fi
+
+
+# Check for (in)valid combinations
+
+case "${COMPILER}-${GUI}-${OSTYPE}" in
+    vacpp-vaclgui-windows) ;;
+    vacpp-dummygui-windows) ;;
+    gcc-dummygui-unix) ;;
+
+    vacpp-*-unix) echo "$0: compiler vacpp requires Windows" 1>&2; exit 1;;
+    gcc-*-windows) echo "$0: gcc not supported on Windows yet" 1>&2; exit 1;;
+    *-vaclgui-*) echo "$0: GUI vaclgui requires compiler vacpp" 1>&2; exit 1;;
+    *) echo "$0: invalid configuration" 1>&2; exit 1;;
+esac
+
+############################################################
+#
+# 3. Report what we're doing
+#
+
+echo "Configuring for $COMPILER on $OSTYPE with GUI $GUI."
+case $MODE in
+    opt) ;;
+    debug) echo "Enabling debugging." ;;
+    prof) echo "Enabling profiling." ;;
+esac
+if [ $MAINTAINER = 1 ]; then
+    echo "Enabling maintainer mode."
+fi
+if [ $OSTYPE = unix ]; then
+    echo "Settings:"
+    echo "   DESTDIR         ${DESTDIR:-[none]}"
+    echo "   PREFIX          ${PREFIX:-[none]}"
+    echo "      BINDIR       ${BINDIR:-[none]}"
+    echo "      LIBDIR       ${LIBDIR:-[none]}"
+    echo "      MANDIR       ${MANDIR:-[none]}"
+    echo "      DOCDIR       ${DOCDIR:-[none]}"
+    echo "      EXAMPLESDIR  ${EXAMPLESDIR:-[none]}"
+    echo "   CROSSNAME       ${CROSSNAME:-[none]}"
+fi
+
+############################################################
+#
+# 4. Collect settings
+#
+
+DEFS=
+CFLAGS=
+LDFLAGS=
+LIBS=
+CLEANFILES=
+DISTCLEANFILES=
+
+case $OSTYPE in
+    unix)
+	DEFS="$DEFS AG_ON_UNIX"
+	CLEANFILES="$CLEANFILES *.o *.a *.so"
+    ;;
+    windows)
+	DEFS="$DEFS AG_ON_WINDOWS"
+	CLEANFILES="$CLEANFILES *.obj *.lib *.dll *.res"
+    ;;
+    amiga)
+	# No way to get to this, but there was an Amiga port once, so...
+	DEFS="$DEFS AG_ON_AMIGA"
+	CLEANFILES="$CLEANFILES *.obj *.lib *.library"
+    ;;
+esac
+
+case $GUI in
+    dummygui)
+	DEFS="$DEFS DUMMYGUI"
+    ;;
+    vaclgui)
+	DEFS="$DEFS VACLGUI"
+    ;;
+esac
+
+case $COMPILER in
+    gcc)
+	#
+	# Not used:
+	#   -Wmissing-prototypes  ...only valid for C, not C++.
+	#   -Wshadow              ...not yet
+	#
+	CFLAGS="$CFLAGS -MMD -Wall -W -Wwrite-strings -fno-strict-aliasing"
+	if [ $MAINTAINER = 1 ]; then
+	    CFLAGS="$CFLAGS -Werror"
+	fi
+	LIBS="$LIBS -lstdc++ -lm"
+	DISTCLEANFILES="$DISTCLEANFILES *.d"
+
+	case $MODE in
+	    opt)   CFLAGS="$CFLAGS -O2"; LDFLAGS="$LDFLAGS -s";;
+	    debug) CFLAGS="$CFLAGS -g";;
+	    # note: some versions of Linux can't do -O2 -pg
+	    prof)  CFLAGS="$CFLAGS -O -pg";;
+	esac
+
+	for D in $DEFS; do
+	    CFLAGS="$CFLAGS -D$D"
+	done
+    ;;
+    vacpp)
+	DEFS="$DEFS typename="
+	if [ $MAINTAINER = 1 ]; then
+	    : # vacpp doesn't seem to have a -Werror equivalent...
+	fi
+	CLEANFILES="$CLEANFILES *.map *.exp .*.map .*.lib .*.exp"
+	DISTCLEANFILES="$DISTCLEANFILES *.dep *.u *.log"
+
+	case $MODE in
+	    opt)   CFLAGS="$CFLAGS -O";;
+	    debug) CFLAGS="$CFLAGS -g";;
+	    prof)  ;; # XXX how?
+	esac
+
+	for D in $DEFS; do
+	    CFLAGS="$CFLAGS -D$D"
+	done
+    ;;
+esac
+
+if [ $CROSS = 1 ]; then
+    if [ "$CROSSNAME" = windows ]; then
+	CROSSRUN="wine"
+    else
+	CROSSRUN="${CROSSNAME}-run"
+    fi
+else
+    CROSSRUN=
+fi
+
+############################################################
+#
+# 5. Write config.mk
+#
+
+(
+    echo '# Automatically generated -- do not edit'
+    echo DESTDIR="$DESTDIR"
+    echo PREFIX="$PREFIX"
+    echo BINDIR.unix="$BINDIR"
+    echo LIBDIR.unix="$LIBDIR"
+    echo MANDIR.unix="$MANDIR"
+    echo DOCDIR.unix="$DOCDIR"
+    echo EXAMPLESDIR.unix="$EXAMPLESDIR"
+    echo OS="$OSTYPE"
+    echo COMPILER="$COMPILER"
+    echo GUI="$GUI"
+    if [ $GUI = dummygui ]; then
+	echo HASGUI=nogui
+    else
+	echo HASGUI=hasgui
+    fi
+    echo CROSSRUN="$CROSSRUN"
+    echo
+
+    if [ "x$PTESTS" != x ]; then
+	echo HASPTESTS=hasptests
+    else
+	echo HASPTESTS=noptests
+    fi
+
+    if [ $MAINTAINER = 1 ]; then
+	echo MAINTAINER=maintainer
+    else
+	echo MAINTAINER=nonmaintainer
+    fi
+
+    case $OSTYPE in
+	unix)
+	    echo OBJEXT=.o
+	    echo LIBEXT=.o
+	    echo SHLIBEXT=.so
+	    echo EXEEXT=
+	;;
+	windows)
+	    echo OBJEXT=.obj
+	    echo LIBEXT=.lib
+	    echo SHLIBEXT=.dll
+	    echo EXEEXT=.exe
+	;;
+	amiga)
+	    # No way to get this, but there was an Amiga port once, so...
+	    echo OBJEXT=.obj
+	    echo LIBEXT=.lib
+	    echo SHLIBEXT=.library
+	    echo EXEEXT=
+	;;
+    esac
+    echo
+
+    case $COMPILER in
+	gcc)
+	    if [ $CROSS = 1 ]; then
+		echo TOOLPREFIX="${CROSSNAME}-"
+	    else
+		echo TOOLPREFIX=
+	    fi
+	    echo CC='$(TOOLPREFIX)gcc'
+	    echo LDR='$(TOOLPREFIX)ld -r -o'
+	    echo SHLDCC='$(TOOLPREFIX)gcc -shared'
+	    echo LDCC='$(TOOLPREFIX)gcc'
+	    echo CPPFILT='$(TOOLPREFIX)cppfilt'
+	    echo WINDRES='$(TOOLPREFIX)windres'
+	    echo
+
+	    echo MKDEP='cat *.d > depend.mk'
+	    echo CFLAGS.PROG=
+	    echo CFLAGS.LIB=
+	    echo CFLAGS.SHLIB=-fPIC
+	;;
+	vacpp)
+	    echo CC='$(TOP)/ibmscripts/cc'
+	    echo LDR='$(TOP)/ibmscripts/lib'
+	    echo SHLDCC='$(TOP)/ibmscripts/shldcc'
+	    echo LDCC='$(TOP)/ibmscripts/ldcc'
+	    echo CPPFILT='$(TOP)/ibmscripts/cppfilt'
+	    echo WINDRES='$(TOP)/ibmscripts/irc'
+	    echo
+
+	    T='s,\\,/,g;/^[^:]*: *[A-Z]:/d'
+	    echo MKDEP="cat *.u 2>/dev/null | expand | sed '$T' > depend.mk"
+	    echo CFLAGS.PROG=
+	    echo CFLAGS.LIB=
+	    echo CFLAGS.SHLIB=-fPIC
+	;;
+
+    esac
+    echo
+
+    case $OSTYPE in
+	windows)
+	    # main ag lib is shared
+	    echo 'AGLIBEXT=$(SHLIBEXT)'
+	    echo 'AGLIBTYPE=SHLIB'
+	    echo 'HASSHLIB=hasshlib'
+	;;
+	unix)
+	    # main ag lib is static
+	    echo 'AGLIBEXT=$(LIBEXT)'
+	    echo 'AGLIBTYPE=LIB'
+	    echo 'HASSHLIB=noshlib'
+	;;
+    esac
+    echo
+
+    echo CFLAGS="$CFLAGS"
+    echo LDFLAGS="$LDFLAGS"
+    echo LIBS="$LIBS"
+    echo
+
+    echo CLEANFILES="$CLEANFILES"
+    echo DISTCLEANFILES="$DISTCLEANFILES"
+    echo
+
+    # Per-host stuff.
+    # XXX this shouldn't assume gcc.
+
+    echo HOST_OBJEXT=.o
+    echo HOST_EXEEXT=
+
+    echo HOST_CC=gcc
+    echo HOST_LDCC=gcc
+    T='-MMD -Wall -W -Wwrite-strings -g'
+    if [ $MAINTAINER = 1 ]; then
+	T="$T -Werror"
+    fi
+    echo HOST_MKDEP='cat *.d > depend.mk'
+    echo HOST_CFLAGS="$T"
+    echo HOST_LDFLAGS=
+    echo HOST_LIBS=
+
+    echo HOST_CLEANFILES='*.o *.d'
+    echo
+
+    # Which AG to run.
+    if [ $CROSS = 0 ]; then
+	echo UNSAFE_AGCL='$(BUILDTOP)/anagram/run/agcl$(HOST_EXEEXT)'
+    else
+	echo UNSAFE_AGCL='false'
+    fi
+    echo 'ORDINARY_AGCL=$(TOP)/bin/agcl$(HOST_EXEEXT)'
+    echo 'SAFE_AGCL=$(TOP)/bin/safe-agcl$(HOST_EXEEXT)'
+    echo
+
+    # Choice mechanism
+    echo 'SAFE?=0'
+    echo 'UNSAFE?=0'
+    echo 'AGCL01=$(UNSAFE_AGCL)'
+    echo 'AGCL00=$(ORDINARY_AGCL)'
+    echo 'AGCL10=$(SAFE_AGCL)'
+    echo 'AGCL=$(AGCL$(SAFE)$(UNSAFE))'
+    echo 'AGCLQUAL01=UNSAFE'
+    echo 'AGCLQUAL00='
+    echo 'AGCLQUAL10=SAFE'
+    echo 'AGCLQUAL11='      # define this just in case
+    echo 'AGCLQUAL=$(AGCLQUAL$(SAFE)$(UNSAFE))'
+    echo
+
+) > config.mk.new
+
+mv -f config.mk.new config.mk
+
+############################################################
+#
+# 6. Write makefiles.
+#
+
+makemake() {
+    local SRCDIRNAME CHOP D DS U
+
+    SRCDIRNAME="$1"; shift
+    CHOP="$1"; shift
+
+    for D in "$@"; do
+	if [ "$D" != . ]; then
+	    D=`echo $D | sed 's,^\./,,'`
+	    U=`echo $D | sed 's,[^/]*,..,g'`
+
+	    if [ $CHOP = 1 ]; then
+		DS=`echo $D | sed 's,^[^/]*,,'`
+	    else
+		DS=`echo $D | sed 's,^,/,'`
+	    fi
+
+	    if [ ! -d $D ]; then
+		mkdir $D
+	    fi
+	    (
+		echo '# Automatically generated -- do not edit'
+		case "$SRCDIR" in
+		    /*) echo TOP="$SRCDIR";;
+		    *)  echo TOP="${U}/$SRCDIR";;
+		esac
+		if [ "x$PTESTS" != x ]; then
+		    case "$PTESTS" in
+			/*) echo PTESTTOP="$PTESTS";;
+			*)  echo PTESTTOP="${U}/$PTESTS";;
+		    esac
+		fi
+		echo BUILDTOP="$U"
+		echo SRCDIR="${SRCDIRNAME}$DS"
+		echo 'include $(BUILDTOP)/config.mk'
+		echo 'include $(SRCDIR)/DEFS.mk'
+	    ) > $D/Makefile
+	else
+	    (
+		echo '# Automatically generated -- do not edit'
+		echo TOP="$SRCDIR"
+		echo BUILDTOP=.
+		echo SRCDIR="$SRCDIRNAME"
+		echo 'include $(BUILDTOP)/config.mk'
+		echo 'include $(SRCDIR)/DEFS.mk'
+	    ) > $D/Makefile
+	fi
+	touch $D/depend.mk
+	touch $D/rules.mk
+	echo -n "."
+    done
+}
+
+echo -n "Creating makefiles..."
+
+DIRS=`(cd "$SRCDIR" && find . -name DEFS.mk -print) | sed 's,/[^/]*$,,' | sort`
+makemake '$(TOP)' 0 $DIRS
+
+if [ "x$PTESTS" != x ]; then
+    if [ ! -d ptests ]; then
+	mkdir ptests
+    fi
+    DIRS=`(cd "$PTESTS" && find . -name DEFS.mk -print) |\
+	    sed 's,/[^/]*$,,;s,^\.,ptests,' | sort`
+    makemake '$(PTESTTOP)' 1 $DIRS
+fi
+
+echo
+
+############################################################
+#
+# 7. Write config.status.
+#
+
+(
+    echo '#!/bin/sh'
+    echo '# Automatically generated -- do not edit'
+    echo -n "$0"
+    if [ $OSTYPE = unix ]; then
+	echo -n " --destdir=$DESTDIR"
+	echo -n " --prefix=$PREFIX"
+	echo -n " --bindir=$BINDIR"
+	echo -n " --libdir=$LIBDIR"
+	echo -n " --mandir=$MANDIR"
+	echo -n " --docdir=$DOCDIR"
+	echo -n " --examplesdir=$EXAMPLESDIR"
+    fi
+    echo -n " --with-compiler=$COMPILER"
+    echo -n " --enable-gui=$GUI"
+    if [ $MAINTAINER = 1 ]; then
+	echo -n " --enable-maintainer-mode"
+    fi
+    case $MODE in
+	opt)   ;;
+	debug) echo -n ' --enable-debug';;
+	prof)  echo -n ' --enable-prof';;
+    esac
+    if [ "x$PTESTS" != x ]; then
+	echo -n ' --with-ptests='"$PTESTS"
+    fi
+
+    echo -n ' "$@"'
+
+    echo " $PLATFORM"
+
+) > config.status.new
+chmod a+x config.status.new
+mv -f config.status.new config.status
+
+############################################################
+#
+# 8. done
+#
+
+# don't do this here - with gmake it spews tons of crap, and doing
+# it with >/dev/null 2>&1 isn't really a good idea.
+#echo 'make rules'
+#make rules || exit 1
+
+echo 'Now do:'
+echo '   make rules'
+echo '   make'
+echo '   make install'
+
+exit 0