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 -m486"
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 SOURCES="game- curses- board- util- inet-"
141 SRCS="`echo $SOURCES | sed -e s/-/.c/g`"
142 OBJS="`echo $SOURCES | sed -e s/-/.o/g`"
143 SSOURCES="server- util-"
144 SSRCS="`echo $SSOURCES | sed -e s/-/.c/g`"
145 SOBJS="`echo $SSOURCES | sed -e s/-/.o/g`"
147 DISTFILES="README FAQ INSTALL COPYING VERSION TODO ChangeLog Configure netris.h"
148 DISTFILES="$DISTFILES $SRCS server.c"
150 echo "Creating Makefile"
151 sed -e "s/-LFLAGS-/$LFLAGS/g" -e "s/-OBJS-/$OBJS/g" \
152 -e "s/-SOBJS-/$SOBJS/g" -e "s/-DISTFILES-/$DISTFILES/g" \
153 -e "s/-COPT-/$COPT/g" -e "s/-CEXTRA-/$CEXTRA/g" \
154 -e "s/-LEXTRA-/$LEXTRA/g" -e "s/-CC-/$CC/g" \
157 # Automatically generated by ./Configure -- DO NOT EDIT!
164 LFLAGS = -LEXTRA- -LFLAGS-
165 CFLAGS = $(CEXTRA) $(COPT)
172 DISTFILES = -DISTFILES-
174 all: Makefile config.h $(PROG) $(SPROG)
177 $(CC) -o $(PROG) $(OBJS) $(LFLAGS) $(CFLAGS)
180 $(CC) -o $(SPROG) $(SOBJS) $(LFLAGS) $(CFLAGS)
183 $(CC) $(CFLAGS) -c $<
185 Makefile config.h: Configure
186 @echo "Makefile and/or config.h is out of date"
187 @echo "Run ./Configure now"
191 @vers=`cat VERSION`; \
192 dir="netris-$$vers"; \
193 echo "Creating $$dir directory"; \
196 cp $(DISTFILES) $$dir; \
199 chmod 755 $$dir/Configure; \
200 echo "Creating $$dir.tar.gz"; \
201 tar -cvzof $$dir.tar.gz $$dir
204 rm -f $(PROG) $(OBJS) $(SPROG) $(SOBJS) a.out
207 rm -f Makefile config.h
211 echo "Creating config.h"
212 cat << END > config.h
214 * Automatically generated by ./Configure -- DO NOT EDIT!
219 if [ "$HAS_GETOPT_H" = "true" ]; then
220 echo "#include <getopt.h>" >> config.h
222 echo "extern char *optarg;" >> config.h
223 echo "extern int optind;" >> config.h
225 if [ "$HAS_MEMORY_H" = "true" ]; then
226 echo "#include <memory.h>" >> config.h
228 if [ "$HAS_ON_EXIT" = "true" ]; then
229 echo "#define HAS_ON_EXIT" >> config.h
231 if [ "$HAS_SIGPROCMASK" = "true" ]; then
232 echo "#define HAS_SIGPROCMASK" >> config.h
234 if [ "$CURSES_HACK" = "true" ]; then
235 echo "#define CURSES_HACK" >> config.h