+:
+#
+# Netris -- A free networked version of T*tris
+# Copyright (C) 1994-1996,1999 Mark H. Weaver <mhw@netris.org>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+
+CC="gcc"
+COPT="-O"
+CEXTRA="-m486"
+LEXTRA=""
+CURSES_HACK=false
+
+while [ $# -ge 1 ]; do
+ opt="$1"
+ shift
+ case "$opt" in
+ -g)
+ COPT="-g -O0"
+# CEXTRA="-Wall -Wstrict-prototypes -m486"
+ ;;
+ -O*)
+ COPT="$opt"
+ CEXTRA="-DNDEBUG"
+ ;;
+ --cc)
+ CC="$1"
+ shift
+ ;;
+ --copt)
+ COPT="$1"
+ shift
+ ;;
+ --cextra)
+ CEXTRA="$1"
+ shift
+ ;;
+ --lextra)
+ LEXTRA="$1"
+ shift
+ ;;
+ --curses-hack)
+ CURSES_HACK=true
+ ;;
+ *)
+ cat << "END"
+Usage: ./configure [options...]
+ -g: Full debugging, no optimization, and full warnings
+ -O?: Optimization, no debugging or warnings
+ --cc <compiler>: Set the C compiler to use (default "gcc")
+ --copt <opt>: Set C optimization flags
+ --cextra <opt>: Set extra C flags
+ --lextra <opt>: Set extra linker flags
+ --curses-hack: Disable scroll-optimization for broken curses
+END
+ exit 1
+ ;;
+ esac
+done
+
+CFLAGS="$COPT $CEXTRA"
+
+echo "Checking for libraries"
+echo 'main(){}' > test.c
+LFLAGS=""
+for lib in -lcurses -lncurses; do
+ if $CC $CFLAGS $LEXTRA test.c $lib > /dev/null 2>&1; then
+ LFLAGS="$lib"
+ fi
+done
+for lib in -lsocket -lnsl -ltermcap; do
+ if $CC $CFLAGS $LEXTRA test.c $lib > /dev/null 2>&1; then
+ LFLAGS="$LFLAGS $lib"
+ fi
+done
+
+echo "Checking for on_exit()"
+cat << END > test.c
+void handler(void) {}
+main() { on_exit(handler, (void *)0); }
+END
+if $CC $CFLAGS $LEXTRA test.c > /dev/null 2>&1; then
+ HAS_ON_EXIT=true
+else
+ HAS_ON_EXIT=false
+fi
+
+echo "Checking for sigprocmask()"
+cat << END > test.c
+#include <signal.h>
+main() { sigset_t set; sigprocmask(SIG_BLOCK, &set, &set); }
+END
+if $CC $CFLAGS $LEXTRA test.c > /dev/null 2>&1; then
+ HAS_SIGPROCMASK=true
+else
+ HAS_SIGPROCMASK=false
+fi
+
+echo "Checking for getopt.h"
+cat << END > test.c
+#include <getopt.h>
+main(){}
+END
+
+if $CC $CFLAGS $LEXTRA test.c > /dev/null 2>&1; then
+ HAS_GETOPT_H=true
+else
+ HAS_GETOPT_H=false
+fi
+
+echo "Checking for memory.h"
+cat << END > test.c
+#include <memory.h>
+main(){}
+END
+
+if $CC $CFLAGS $LEXTRA test.c > /dev/null 2>&1; then
+ HAS_MEMORY_H=true
+else
+ HAS_MEMORY_H=false
+fi
+
+rm -f test.c test.o a.out
+
+echo "Creating config.mak"
+cat > config.mak << END
+### Automatically generated by ./configure ###
+
+CC = $CC
+COPT = $COPT
+CEXTRA = $CEXTRA
+LEXTRA = $LEXTRA
+LFLAGS = $LEXTRA $LFLAGS
+CFLAGS = \$(CEXTRA) \$(COPT)
+END
+
+echo "Creating config.h"
+cat << END > config.h
+/*** Automatically generated by ./configure ***/
+
+END
+
+if [ "$HAS_GETOPT_H" = "true" ]; then
+ echo "#include <getopt.h>" >> config.h
+else
+ echo "extern char *optarg;" >> config.h
+ echo "extern int optind;" >> config.h
+fi
+if [ "$HAS_MEMORY_H" = "true" ]; then
+ echo "#include <memory.h>" >> config.h
+fi
+if [ "$HAS_ON_EXIT" = "true" ]; then
+ echo "#define HAS_ON_EXIT" >> config.h
+fi
+if [ "$HAS_SIGPROCMASK" = "true" ]; then
+ echo "#define HAS_SIGPROCMASK" >> config.h
+fi
+if [ "$CURSES_HACK" = "true" ]; then
+ echo "#define CURSES_HACK" >> config.h
+fi
+
+cat << END
+
+Now do a 'make'
+
+END
+