]> git.deb.at Git - pkg/netris.git/blob - Configure
Imported Upstream version 0.52
[pkg/netris.git] / Configure
1 :
2 #
3 # Netris -- A free networked version of T*tris
4 # Copyright (C) 1994-1996,1999  Mark H. Weaver <mhw@netris.org>
5
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.
10
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.
15
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.
19 #
20 # $Id: Configure,v 1.18 1999/05/16 06:56:19 mhw Exp $
21 #
22
23 CC="gcc"
24 COPT="-g -O"
25 CEXTRA=""
26 LEXTRA=""
27 CURSES_HACK=false
28
29 while [ $# -ge 1 ]; do
30         opt="$1"
31         shift
32         case "$opt" in
33                 -g)
34                         COPT="-g"
35                         CEXTRA="-Wall -Wstrict-prototypes"
36                         ;;
37                 -O*)
38                         COPT="$opt"
39                         CEXTRA="-DNDEBUG"
40                         ;;
41                 --cc)
42                         CC="$1"
43                         shift
44                         ;;
45                 --copt)
46                         COPT="$1"
47                         shift
48                         ;;
49                 --cextra)
50                         CEXTRA="$1"
51                         shift
52                         ;;
53                 --lextra)
54                         LEXTRA="$1"
55                         shift
56                         ;;
57                 --curses-hack)
58                         CURSES_HACK=true
59                         ;;
60                 *)
61                         cat << "END"
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
70 END
71                         exit 1
72                         ;;
73         esac
74 done
75
76 CFLAGS="$COPT $CEXTRA"
77
78 echo "Checking for libraries"
79 echo 'main(){}' > test.c
80 LFLAGS=""
81 for lib in -lcurses -lncurses; do
82         if $CC $CFLAGS $LEXTRA test.c $lib > /dev/null 2>&1; then
83                 LFLAGS="$lib"
84         fi
85 done
86 for lib in -lsocket -lnsl -ltermcap; do 
87         if $CC $CFLAGS $LEXTRA test.c $lib > /dev/null 2>&1; then
88                 LFLAGS="$LFLAGS $lib"
89         fi
90 done
91
92 echo "Checking for on_exit()"
93 cat << END > test.c
94 void handler(void) {}
95 main() { on_exit(handler, (void *)0); }
96 END
97 if $CC $CFLAGS $LEXTRA test.c > /dev/null 2>&1; then
98         HAS_ON_EXIT=true
99 else
100         HAS_ON_EXIT=false
101 fi
102
103 echo "Checking for sigprocmask()"
104 cat << END > test.c
105 #include <signal.h>
106 main() { sigset_t set; sigprocmask(SIG_BLOCK, &set, &set); }
107 END
108 if $CC $CFLAGS $LEXTRA test.c > /dev/null 2>&1; then
109         HAS_SIGPROCMASK=true
110 else
111         HAS_SIGPROCMASK=false
112 fi
113
114 echo "Checking for getopt.h"
115 cat << END > test.c
116 #include <getopt.h>
117 main(){}
118 END
119
120 if $CC $CFLAGS $LEXTRA test.c > /dev/null 2>&1; then
121         HAS_GETOPT_H=true
122 else
123         HAS_GETOPT_H=false
124 fi
125
126 echo "Checking for memory.h"
127 cat << END > test.c
128 #include <memory.h>
129 main(){}
130 END
131
132 if $CC $CFLAGS $LEXTRA test.c > /dev/null 2>&1; then
133         HAS_MEMORY_H=true
134 else
135         HAS_MEMORY_H=false
136 fi
137
138 rm -f test.c test.o a.out
139
140 ORIG_SOURCES="game- curses- shapes- board- util- inet- robot-"
141 GEN_SOURCES="version-"
142 SOURCES="$ORIG_SOURCES $GEN_SOURCES"
143
144 SRCS="`echo $SOURCES | sed -e s/-/.c/g`"
145 OBJS="`echo $SOURCES | sed -e s/-/.o/g`"
146
147 DISTFILES="README FAQ COPYING VERSION Configure netris.h sr.c robot_desc"
148 DISTFILES="$DISTFILES `echo $ORIG_SOURCES | sed -e s/-/.c/g`"
149
150 echo > .depend
151
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" \
157         << "END" > Makefile
158 #
159 # Automatically generated by ./Configure -- DO NOT EDIT!
160 #
161
162 CC = -CC-
163 COPT = -COPT-
164 CEXTRA = -CEXTRA-
165 LEXTRA = -LEXTRA-
166 LFLAGS = -LEXTRA- -LFLAGS-
167 CFLAGS = $(CEXTRA) $(COPT)
168
169 PROG = netris
170 HEADERS = netris.h
171
172 SRCS = -SRCS-
173 OBJS = -OBJS-
174 DISTFILES = -DISTFILES-
175
176 all: Makefile config.h proto.h $(PROG) sr
177
178 $(PROG): $(OBJS)
179         $(CC) -o $(PROG) $(OBJS) $(LFLAGS)
180
181 sr: sr.o
182         $(CC) -o sr sr.o $(LFLAGS)
183
184 .c.o:
185         $(CC) $(CFLAGS) -c $<
186
187 Makefile config.h: Configure
188         @echo "Makefile and/or config.h is out of date"
189         @echo "Run ./Configure now"
190         @false
191
192 version.c: VERSION
193         @echo "Creating version.c"
194         @sed -e 's/^\(.*\)$$/char *version_string = "\1";/' VERSION > $@
195
196 proto.h: $(SRCS)
197         @touch $@
198         @mv $@ $@.old
199         @cat $(SRCS) | grep '^ExtFunc[  ]' | sed -e 's/)$$/);/' > $@
200         @if diff $@.old $@ > /dev/null 2>&1; then :; else \
201                 echo "proto.h changed"; \
202                 touch proto.chg; \
203         fi
204         @rm -f $@.old
205
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
211
212 dist: $(DISTFILES)
213         @vers=`cat VERSION`; \
214         dir="netris-$$vers"; \
215         echo "Creating $$dir directory"; \
216         rm -rf $$dir; \
217         mkdir $$dir; \
218         cp $(DISTFILES) $$dir; \
219         chmod 755 $$dir; \
220         chmod 644 $$dir/*; \
221         chmod 755 $$dir/Configure; \
222         echo "Creating $$dir.tar.gz"; \
223         tar -cvzof $$dir.tar.gz $$dir
224
225 clean:
226         rm -f proto.h proto.chg $(PROG) $(OBJS) version.c test.c a.out sr sr.o
227
228 cleandir: clean
229         rm -f .depend Makefile config.h
230
231 ##### DO NOT EDIT OR DELETE THIS LINE, it's needed by make depend #####
232 END
233
234 echo "Creating config.h"
235 cat << END > config.h
236 /*
237  * Automatically generated by ./Configure -- DO NOT EDIT!
238  */
239
240 END
241
242 if [ "$HAS_GETOPT_H" = "true" ]; then
243         echo "#include <getopt.h>" >> config.h
244 else
245         echo "extern char *optarg;" >> config.h
246         echo "extern int optind;" >> config.h
247 fi
248 if [ "$HAS_MEMORY_H" = "true" ]; then
249         echo "#include <memory.h>" >> config.h
250 fi
251 if [ "$HAS_ON_EXIT" = "true" ]; then
252         echo "#define HAS_ON_EXIT" >> config.h
253 fi
254 if [ "$HAS_SIGPROCMASK" = "true" ]; then
255         echo "#define HAS_SIGPROCMASK" >> config.h
256 fi
257 if [ "$CURSES_HACK" = "true" ]; then
258         echo "#define CURSES_HACK" >> config.h
259 fi
260
261 echo "Running 'make depend'"
262 if make depend; then :; else cat << END; fi
263
264 make depend failed, but that's OK unless you're doing development
265 END
266 cat << END
267
268 Now do a 'make'
269
270 END
271
272 # vi: ts=4 ai