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