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 SOURCES="$ORIG_SOURCES"
143 SRCS="`echo $SOURCES | sed -e s/-/.c/g`"
144 OBJS="`echo $SOURCES | sed -e s/-/.o/g`"
146 DISTFILES="README FAQ COPYING VERSION Configure netris.h sr.c server.c robot_desc"
147 DISTFILES="$DISTFILES `echo $ORIG_SOURCES | sed -e s/-/.c/g`"
151 echo "Creating Makefile"
152 sed -e "s/-LFLAGS-/$LFLAGS/g" -e "s/-SRCS-/$SRCS/g" \
153 -e "s/-OBJS-/$OBJS/g" -e "s/-DISTFILES-/$DISTFILES/g" \
154 -e "s/-COPT-/$COPT/g" -e "s/-CEXTRA-/$CEXTRA/g" \
155 -e "s/-LEXTRA-/$LEXTRA/g" -e "s/-CC-/$CC/g" \
158 # Automatically generated by ./Configure -- DO NOT EDIT!
165 LFLAGS = -LEXTRA- -LFLAGS-
166 CFLAGS = $(CEXTRA) $(COPT)
173 DISTFILES = -DISTFILES-
175 all: Makefile config.h proto.h $(PROG) sr server
178 $(CC) -o $(PROG) $(OBJS) $(LFLAGS) $(CFLAGS)
181 $(CC) -o sr sr.o $(LFLAGS) $(CFLAGS)
184 $(CC) -o server server.o $(LFLAGS) $(CFLAGS)
187 $(CC) $(CFLAGS) -c $<
189 Makefile config.h: Configure
190 @echo "Makefile and/or config.h is out of date"
191 @echo "Run ./Configure now"
197 @cat $(SRCS) | grep '^ExtFunc[ ]' | sed -e 's/)$$/);/' > $@
198 @if diff $@.old $@ > /dev/null 2>&1; then :; else \
199 echo "proto.h changed"; \
204 depend: proto.h $(SRCS)
205 @echo "Checking dependencies"
206 @sed -n -e '1,/make depend #####$$/p' Makefile > Makefile.new
207 @$(CC) -M $(SRCS) | sed -e 's/proto\.h/proto.chg/g' >> Makefile.new
208 @mv -f Makefile.new Makefile
211 @vers=`cat VERSION`; \
212 dir="netris-$$vers"; \
213 echo "Creating $$dir directory"; \
216 cp $(DISTFILES) $$dir; \
219 chmod 755 $$dir/Configure; \
220 echo "Creating $$dir.tar.gz"; \
221 tar -cvzof $$dir.tar.gz $$dir
224 rm -f proto.h proto.chg $(PROG) $(OBJS) test.c a.out sr sr.o server server.o
227 rm -f .depend Makefile config.h
229 ##### DO NOT EDIT OR DELETE THIS LINE, it's needed by make depend #####
232 echo "Creating config.h"
233 cat << END > config.h
235 * Automatically generated by ./Configure -- DO NOT EDIT!
240 if [ "$HAS_GETOPT_H" = "true" ]; then
241 echo "#include <getopt.h>" >> config.h
243 echo "extern char *optarg;" >> config.h
244 echo "extern int optind;" >> config.h
246 if [ "$HAS_MEMORY_H" = "true" ]; then
247 echo "#include <memory.h>" >> config.h
249 if [ "$HAS_ON_EXIT" = "true" ]; then
250 echo "#define HAS_ON_EXIT" >> config.h
252 if [ "$HAS_SIGPROCMASK" = "true" ]; then
253 echo "#define HAS_SIGPROCMASK" >> config.h
255 if [ "$CURSES_HACK" = "true" ]; then
256 echo "#define CURSES_HACK" >> config.h
259 echo "Running 'make depend'"
260 if make depend; then :; else cat << END; fi
262 make depend failed, but that's OK unless you're doing development