: # # Netris -- A free networked version of T*tris # Copyright (C) 1994-1996,1999 Mark H. Weaver # # 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. # # $Id: Configure,v 1.18 1999/05/16 06:56:19 mhw Exp $ # CC="gcc" COPT="-g -O" CEXTRA="" LEXTRA="" CURSES_HACK=false while [ $# -ge 1 ]; do opt="$1" shift case "$opt" in -g) COPT="-g" CEXTRA="-Wall -Wstrict-prototypes" ;; -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 ;; --disable-ipv6|--enable-ipv6=no) ENABLE_IPV6=no ;; --enable-ipv6) ENABLE_IPV6=yes ;; *) cat << "END" Usage: ./Configure [options...] -g: Full debugging, no optimization, and full warnings -O?: Optimization, no debugging or warnings --cc : Set the C compiler to use (default "gcc") --copt : Set C optimization flags --cextra : Set extra C flags --lextra : Set extra linker flags --curses-hack: Disable scroll-optimization for broken curses --enable-ipv6: Enable IPv6 feature END exit 1 ;; esac done CFLAGS="$COPT $CEXTRA" echo "Checking for libraries" echo 'main(){}' > test.c LFLAGS="" for lib in -lncurses -lcurses; 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 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 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 main(){} END if $CC $CFLAGS $LEXTRA test.c > /dev/null 2>&1; then HAS_MEMORY_H=true else HAS_MEMORY_H=false fi if test X"$ENABLE_IPV6" = X""; then echo "Checking for whether we enable IPv6 feature" cat << END >test.c #include #include main(){ if (socket(AF_INET6, SOCK_STREAM, 0) < 0) return(1); else return(0); } END if $CC $CFLAGS $LEXTRA test.c > /dev/null 2>&1; then if ./a.out 2>&1; then ENABLE_IPV6=yes else ENABLE_IPV6=no fi fi fi if test X"$ENABLE_IPV6" = X"yes"; then echo "Checking for IPv6 library" CEXTRA="-DINET6 $CEXTRA" IPV6_ENV="KAME V6 INET6" IPV6_KAME_DIR=/usr/local/v6 IPV6_KAME_LIB=inet6 IPV6_V6_DIR=/usr/local/v6 IPV6_V6_DIB=v6 IPV6_INET6_DIR=/usr/inet6 IPV6_INET6_LIB=inet6 for i in $IPV6_ENV; do eval IPV6_DIR=\$IPV6_${i}_DIR eval IPV6_LIB=\$IPV6_${i}_LIB if [ -f $IPV6_DIR/lib/lib${IPV6_LIB}.a ]; then CEXTRA="-I$IPV6_DIR/include $CEXTRA" LEXTRA="-L$IPV6_DIR/lib -l${IPV6_LIB} $LEXTRA" break fi done fi rm -f test.c test.o a.out ORIG_SOURCES="game- curses- shapes- board- util- inet- robot-" GEN_SOURCES="version-" SOURCES="$ORIG_SOURCES $GEN_SOURCES" SRCS="`echo $SOURCES | sed -e s/-/.c/g`" OBJS="`echo $SOURCES | sed -e s/-/.o/g`" DISTFILES="README FAQ COPYING VERSION Configure netris.h sr.c robot_desc" DISTFILES="$DISTFILES `echo $ORIG_SOURCES | sed -e s/-/.c/g`" echo > .depend echo "Creating Makefile" _LFLAGS=`echo "$LFLAGS" | sed -e 's#/#\\\\/#g'` _LEXTRA=`echo "$LEXTRA" | sed -e 's#/#\\\\/#g'` _COPT=`echo "$COPT" | sed -e 's#/#\\\\/#g'` _CEXTRA=`echo "$CEXTRA" | sed -e 's#/#\\\\/#g'` sed -e "s/-LFLAGS-/$_LFLAGS/g" -e "s/-SRCS-/$SRCS/g" \ -e "s/-OBJS-/$OBJS/g" -e "s/-DISTFILES-/$DISTFILES/g" \ -e "s/-COPT-/$_COPT/g" -e "s/-CEXTRA-/$_CEXTRA/g" \ -e "s/-LEXTRA-/$_LEXTRA/g" -e "s/-CC-/$CC/g" \ << "END" > Makefile # # Automatically generated by ./Configure -- DO NOT EDIT! # CC = -CC- COPT = -COPT- CEXTRA = -CEXTRA- LEXTRA = -LEXTRA- LFLAGS = $(LEXTRA) -LFLAGS- CFLAGS = $(CEXTRA) $(COPT) PROG = netris HEADERS = netris.h PREFIX?=/usr/local SRCS = -SRCS- OBJS = -OBJS- DISTFILES = -DISTFILES- DESTDIR = $(PREFIX)/bin INSTALL = install -c all: Makefile config.h proto.h $(PROG) sr $(PROG): $(OBJS) $(CC) -o $(PROG) $(OBJS) $(LFLAGS) sr: sr.o $(CC) -o sr sr.o $(LFLAGS) .c.o: $(CC) $(CFLAGS) -c $< Makefile config.h: Configure @echo "Makefile and/or config.h is out of date" @echo "Run ./Configure now" @false version.c: VERSION @echo "Creating version.c" @sed -e 's/^\(.*\)$$/char *version_string = "\1";/' VERSION > $@ proto.h: $(SRCS) @touch $@ @mv $@ $@.old @cat $(SRCS) | grep '^ExtFunc[ ]' | sed -e 's/)$$/);/' > $@ @if diff $@.old $@ > /dev/null 2>&1; then :; else \ echo "proto.h changed"; \ touch proto.chg; \ fi @rm -f $@.old depend: proto.h $(SRCS) @echo "Checking dependencies" @sed -n -e '1,/make depend #####$$/p' Makefile > Makefile.new @$(CC) -M $(SRCS) | sed -e 's/proto\.h/proto.chg/g' >> Makefile.new @mv -f Makefile.new Makefile dist: $(DISTFILES) @vers=`cat VERSION`; \ dir="netris-$$vers"; \ echo "Creating $$dir directory"; \ rm -rf $$dir; \ mkdir $$dir; \ cp $(DISTFILES) $$dir; \ chmod 755 $$dir; \ chmod 644 $$dir/*; \ chmod 755 $$dir/Configure; \ echo "Creating $$dir.tar.gz"; \ tar -cvzof $$dir.tar.gz $$dir clean: rm -f proto.h proto.chg $(PROG) $(OBJS) version.c test.c a.out sr sr.o cleandir: clean rm -f .depend Makefile config.h install: $(INSTALL) -o bin -g bin -s -m 755 $(PROG) $(DESTDIR) $(INSTALL) -o bin -g bin -s -m 755 sr $(DESTDIR)/sample-robot ##### DO NOT EDIT OR DELETE THIS LINE, it's needed by make depend ##### END echo "Creating config.h" cat << END > config.h /* * Automatically generated by ./Configure -- DO NOT EDIT! */ END if [ "$HAS_GETOPT_H" = "true" ]; then echo "#include " >> config.h else echo "extern char *optarg;" >> config.h echo "extern int optind;" >> config.h fi if [ "$HAS_MEMORY_H" = "true" ]; then echo "#include " >> 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 if [ "$ENABLE_IPV6" = "yes" ]; then echo "#define ENABLE_IPV6" >> config.h fi echo "Running 'make depend'" if make depend; then :; else cat << END; fi make depend failed, but that's OK unless you're doing development END cat << END Now do a 'make' END # vi: ts=4 ai