3 # Netris -- A free networked version of T*tris
4 # Copyright (C) 1994,1995,1996 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.17 1996/02/09 08:22:03 mhw Exp $
28 while [ $# -ge 1 ]; do
34 CEXTRA="-Wall -Wstrict-prototypes"
58 Usage: ./Configure [options...]
59 -g: Full debugging, no optimization, and full warnings
60 -O?: Optimization, no debugging or warnings
61 --cc <compiler>: Set the C compiler to use (default "gcc")
62 --copt <opt>: Set C optimization flags
63 --cextra <opt>: Set extra C flags
64 --lextra <opt>: Set extra linker flags
71 CFLAGS="$COPT $CEXTRA"
73 echo "Checking for libraries"
74 echo 'main(){}' > test.c
76 for lib in -lsocket -lnsl -lcurses -ltermcap
78 if $CC $CFLAGS $LEXTRA test.c $lib > /dev/null 2>&1; then
83 echo "Checking for on_exit()"
86 main() { on_exit(handler, (void *)0); }
88 if $CC $CFLAGS $LEXTRA test.c > /dev/null 2>&1; then
94 echo "Checking for sigprocmask()"
97 main() { sigset_t set; sigprocmask(SIG_BLOCK, &set, &set); }
99 if $CC $CFLAGS $LEXTRA test.c > /dev/null 2>&1; then
102 HAS_SIGPROCMASK=false
105 echo "Checking for getopt.h"
111 if $CC $CFLAGS $LEXTRA test.c > /dev/null 2>&1; then
117 echo "Checking for memory.h"
123 if $CC $CFLAGS $LEXTRA test.c > /dev/null 2>&1; then
129 rm -f test.c test.o a.out
131 ORIG_SOURCES="game- curses- shapes- board- util- inet- robot-"
132 GEN_SOURCES="version-"
133 SOURCES="$ORIG_SOURCES $GEN_SOURCES"
135 SRCS="`echo $SOURCES | sed -e s/-/.c/g`"
136 OBJS="`echo $SOURCES | sed -e s/-/.o/g`"
138 DISTFILES="README FAQ COPYING VERSION Configure netris.h sr.c robot_desc"
139 DISTFILES="$DISTFILES `echo $ORIG_SOURCES | sed -e s/-/.c/g`"
143 echo "Creating Makefile"
144 sed -e "s/-LFLAGS-/$LFLAGS/g" -e "s/-SRCS-/$SRCS/g" \
145 -e "s/-OBJS-/$OBJS/g" -e "s/-DISTFILES-/$DISTFILES/g" \
146 -e "s/-COPT-/$COPT/g" -e "s/-CEXTRA-/$CEXTRA/g" \
147 -e "s/-LEXTRA-/$LEXTRA/g" -e "s/-CC-/$CC/g" << "END" > Makefile
149 # Automatically generated by ./Configure -- DO NOT EDIT!
156 LFLAGS = -LEXTRA- -LFLAGS-
157 CFLAGS = $(CEXTRA) $(COPT)
164 DISTFILES = -DISTFILES-
166 all: Makefile config.h proto.h $(PROG) sr
169 $(CC) -o $(PROG) $(OBJS) $(LFLAGS)
172 $(CC) -o sr sr.o $(LFLAGS)
175 $(CC) $(CFLAGS) -c $<
177 Makefile config.h: Configure
178 @echo "Makefile and/or config.h is out of date"
179 @echo "Run ./Configure now"
183 @echo "Creating version.c"
184 @sed -e 's/^\(.*\)$$/char *version_string = "\1";/' VERSION > $@
189 @cat $(SRCS) | grep '^ExtFunc[ ]' | sed -e 's/)$$/);/' > $@
190 @if diff $@.old $@ > /dev/null 2>&1; then :; else \
191 echo "proto.h changed"; \
196 depend: proto.h $(SRCS)
197 @echo "Checking dependencies"
198 @sed -n -e '1,/make depend #####$$/p' Makefile > Makefile.new
199 @$(CC) -M $(SRCS) | sed -e 's/proto\.h/proto.chg/g' >> Makefile.new
200 @mv -f Makefile.new Makefile
203 @vers=`cat VERSION`; \
204 dir="netris-$$vers"; \
205 echo "Creating $$dir directory"; \
208 cp $(DISTFILES) $$dir; \
211 chmod 755 $$dir/Configure; \
212 echo "Creating $$dir.tar.gz"; \
213 tar -cvzof $$dir.tar.gz $$dir
216 rm -f proto.h proto.chg $(PROG) $(OBJS) version.c test.c a.out sr sr.o
219 rm -f .depend Makefile config.h
221 ##### DO NOT EDIT OR DELETE THIS LINE, it's needed by make depend #####
224 echo "Creating config.h"
225 cat << END > config.h
227 * Automatically generated by ./Configure -- DO NOT EDIT!
232 if [ "$HAS_GETOPT_H" = "true" ]; then
233 echo "#include <getopt.h>" >> config.h
235 echo "extern char *optarg;" >> config.h
236 echo "extern int optind;" >> config.h
238 if [ "$HAS_MEMORY_H" = "true" ]; then
239 echo "#include <memory.h>" >> config.h
241 if [ "$HAS_ON_EXIT" = "true" ]; then
242 echo "#define HAS_ON_EXIT" >> config.h
244 if [ "$HAS_SIGPROCMASK" = "true" ]; then
245 echo "#define HAS_SIGPROCMASK" >> config.h
248 echo "Running 'make depend'"
249 if make depend; then :; else cat << END; fi
251 make depend failed, but that's OK unless you're doing development