3 # Netris -- A free networked version of T*tris
4 # Copyright (C) 1994-1996,1999 Mark H. Weaver <mhw@netris.org>
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 2
9 # of the License, or (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 # $Id: Configure,v 1.18 1999/05/16 06:56:19 mhw Exp $
29 while [ $# -ge 1 ]; do
35 CEXTRA="-Wall -Wstrict-prototypes"
62 Usage: ./Configure [options...]
63 -g: Full debugging, no optimization, and full warnings
64 -O?: Optimization, no debugging or warnings
65 --cc <compiler>: Set the C compiler to use (default "gcc")
66 --copt <opt>: Set C optimization flags
67 --cextra <opt>: Set extra C flags
68 --lextra <opt>: Set extra linker flags
69 --curses-hack: Disable scroll-optimization for broken curses
76 CFLAGS="$COPT $CEXTRA"
78 echo "Checking for libraries"
79 echo 'main(){}' > test.c
81 for lib in -lcurses -lncurses; do
82 if $CC $CFLAGS $LEXTRA test.c $lib > /dev/null 2>&1; then
86 for lib in -lsocket -lnsl -ltermcap; do
87 if $CC $CFLAGS $LEXTRA test.c $lib > /dev/null 2>&1; then
92 echo "Checking for on_exit()"
95 main() { on_exit(handler, (void *)0); }
97 if $CC $CFLAGS $LEXTRA test.c > /dev/null 2>&1; then
103 echo "Checking for sigprocmask()"
106 main() { sigset_t set; sigprocmask(SIG_BLOCK, &set, &set); }
108 if $CC $CFLAGS $LEXTRA test.c > /dev/null 2>&1; then
111 HAS_SIGPROCMASK=false
114 echo "Checking for getopt.h"
120 if $CC $CFLAGS $LEXTRA test.c > /dev/null 2>&1; then
126 echo "Checking for memory.h"
132 if $CC $CFLAGS $LEXTRA test.c > /dev/null 2>&1; then
138 rm -f test.c test.o a.out
140 ORIG_SOURCES="game- curses- shapes- board- util- inet- robot-"
141 GEN_SOURCES="version-"
142 SOURCES="$ORIG_SOURCES $GEN_SOURCES"
144 SRCS="`echo $SOURCES | sed -e s/-/.c/g`"
145 OBJS="`echo $SOURCES | sed -e s/-/.o/g`"
147 DISTFILES="README FAQ COPYING VERSION Configure netris.h sr.c robot_desc"
148 DISTFILES="$DISTFILES `echo $ORIG_SOURCES | sed -e s/-/.c/g`"
152 echo "Creating Makefile"
153 sed -e "s/-LFLAGS-/$LFLAGS/g" -e "s/-SRCS-/$SRCS/g" \
154 -e "s/-OBJS-/$OBJS/g" -e "s/-DISTFILES-/$DISTFILES/g" \
155 -e "s/-COPT-/$COPT/g" -e "s/-CEXTRA-/$CEXTRA/g" \
156 -e "s/-LEXTRA-/$LEXTRA/g" -e "s/-CC-/$CC/g" \
159 # Automatically generated by ./Configure -- DO NOT EDIT!
166 LFLAGS = -LEXTRA- -LFLAGS-
167 CFLAGS = $(CEXTRA) $(COPT)
174 DISTFILES = -DISTFILES-
176 all: Makefile config.h proto.h $(PROG) sr
179 $(CC) -o $(PROG) $(OBJS) $(LFLAGS)
182 $(CC) -o sr sr.o $(LFLAGS)
185 $(CC) $(CFLAGS) -c $<
187 Makefile config.h: Configure
188 @echo "Makefile and/or config.h is out of date"
189 @echo "Run ./Configure now"
193 @echo "Creating version.c"
194 @sed -e 's/^\(.*\)$$/char *version_string = "\1";/' VERSION > $@
199 @cat $(SRCS) | grep '^ExtFunc[ ]' | sed -e 's/)$$/);/' > $@
200 @if diff $@.old $@ > /dev/null 2>&1; then :; else \
201 echo "proto.h changed"; \
206 depend: proto.h $(SRCS)
207 @echo "Checking dependencies"
208 @sed -n -e '1,/make depend #####$$/p' Makefile > Makefile.new
209 @$(CC) -M $(SRCS) | sed -e 's/proto\.h/proto.chg/g' >> Makefile.new
210 @mv -f Makefile.new Makefile
213 @vers=`cat VERSION`; \
214 dir="netris-$$vers"; \
215 echo "Creating $$dir directory"; \
218 cp $(DISTFILES) $$dir; \
221 chmod 755 $$dir/Configure; \
222 echo "Creating $$dir.tar.gz"; \
223 tar -cvzof $$dir.tar.gz $$dir
226 rm -f proto.h proto.chg $(PROG) $(OBJS) version.c test.c a.out sr sr.o
229 rm -f .depend Makefile config.h
231 ##### DO NOT EDIT OR DELETE THIS LINE, it's needed by make depend #####
234 echo "Creating config.h"
235 cat << END > config.h
237 * Automatically generated by ./Configure -- DO NOT EDIT!
242 if [ "$HAS_GETOPT_H" = "true" ]; then
243 echo "#include <getopt.h>" >> config.h
245 echo "extern char *optarg;" >> config.h
246 echo "extern int optind;" >> config.h
248 if [ "$HAS_MEMORY_H" = "true" ]; then
249 echo "#include <memory.h>" >> config.h
251 if [ "$HAS_ON_EXIT" = "true" ]; then
252 echo "#define HAS_ON_EXIT" >> config.h
254 if [ "$HAS_SIGPROCMASK" = "true" ]; then
255 echo "#define HAS_SIGPROCMASK" >> config.h
257 if [ "$CURSES_HACK" = "true" ]; then
258 echo "#define CURSES_HACK" >> config.h
261 echo "Running 'make depend'"
262 if make depend; then :; else cat << END; fi
264 make depend failed, but that's OK unless you're doing development