comparison setup @ 1:4d6502ffaa5e

Initial revision
author darius
date Sat, 06 Dec 1997 04:36:59 +0000
parents
children
comparison
equal deleted inserted replaced
0:52b8d91ecc32 1:4d6502ffaa5e
1 #!/bin/sh
2 #
3 # NETREK II -- Paradise server setup script
4 #
5 # Permission to use, copy, modify, and distribute this software and its
6 # documentation for any NON-COMMERCIAL purpose
7 # (read the files 'src/copyright*.h')) and without
8 # fee is hereby granted, provided that this copyright notice appear in all
9 # copies. No representations are made about the suitability of this
10 # software for any purpose. This software is provided "as is" without
11 # express or implied warranty.
12 #
13 # Xtrek Copyright 1986 Chris Guthrie
14 # Netrek (Xtrek II) Copyright 1989 Kevin P. Smith
15 # Scott Silvey
16 # Paradise (Netrek II) Copyright 1993 Larry Denys
17 # Kurt Olsen
18 # Brandon Gillespie
19 # Rob Forsman
20 #
21 # Comprehensive Credits available in the file docs/CREDITS
22 #
23 # Note: this is just a quick hack I made, we can probably improve it later
24 # -Brandon
25
26 trap "rm -f test.c a.out core $0.tmp; exit" 2 3
27
28 t=" "
29 i="- "
30
31 echo "-- Netrek II (Paradise) --
32
33 ${t}Setup script for the Netrek II (Paradise) Server.
34
35 ${t}To rebuild the Makefile using previous options (in the instance that
36 ${t}Makefile.in was changed), use the \"-p\" (previous) flag, \"make
37 ${t}makefile\" will also execute \"setup -p\".
38 "
39
40 # figure out what to do with echo -- from perl's Configure
41 # This blows chunks on Linux; fixed line from echotmp to $0.tmp.
42
43 (echo "hi there \c" ; echo " ") > $0.tmp
44 if grep c $0.tmp >/dev/null 2>&1 ; then
45 echo "${i}Supressing newlines with -n..."
46 n='-n'
47 c=''
48 else
49 echo "${i}Supressing newlines with \\\c..."
50 n=''
51 c='\c'
52 fi
53
54 echo ''
55 echo $n "${i}The asterisk should be here => $c"
56 echo '*'
57 echo ''
58
59 if [ X$1 != X -a X$1 = X"-p" ]; then
60 echo "${i}Reading previous setup configuration..."
61 if [ ! -f etc/$0.conf ]; then
62 echo
63 echo "${t}previous configuration file (etc/$0.conf) not found!"
64 exit 1
65 fi
66 else
67
68 ###########################################################################
69 # Global vars
70 LIBS="-lm"
71
72 ###########################################################################
73 SYS=`(/bin/uname || /usr/bin/uname) 2>/dev/null`
74
75 case $SYS in
76 SunOS)
77 # check for Solaris the hard way
78 if [ "`/bin/uname -rs | cut -c0-9`" != "SunOS 4.1" ]; then
79 SYS="SOLARIS"
80 CCOPTIONS="-DSYSV -DSVR4 ${CCOPTIONS}"
81 LIBS="-lnsl -lsocket ${LIBS}"
82 fi
83 ;;
84 HP-UX)
85 CCOPTIONS="-Ae -DSYSV ${CCOPTIONS}"
86 ;;
87 IRIX)
88 CCOPTIONS="-mips2 -DSYSV -DSVR4 -DBAD_SVR4_HACKS ${CCOPTIONS}"
89 LIBS="-lsun ${LIBS}"
90 ;;
91 OSF1)
92 CCOPTIONS="-DSYSV ${CCOPTIONS}"
93 ;;
94 *)
95 # this is a hack because Unixware returns odd things with /bin/uname
96 echo $n "Are you running Unixware? [yn] (default: n) $c"
97 read ANSWER
98 if [ X$ANSWER = X"y" ]; then
99 SYS="UNIXWARE"
100 CCOPTIONS="-DSYSV -DSVR4 -DBAD_SVR4_HACKS ${CCOPTIONS}"
101 LIBS="-lnsl -lsocket -lresolv ${LIBS}"
102 fi
103 ;;
104 esac
105
106 echo ""
107 echo "${i}Looks like you are running ${SYS}..."
108 # Should probably check for RAND48, will add later if anybody complains
109 CCOPTIONS="-D${SYS} -DHAVE_RAND48 ${CCOPTIONS}"
110
111
112 ############################################################################
113 ## compiler
114 echo ""
115 echo $n "${i}Checking for cc or gcc...$c"
116
117 cat > test.c <<EOF
118 int main() { exit(0); }
119 EOF
120 err=`eval "(gcc test.c >/dev/null) 2>&1"`
121 rm -f test.c a.out
122
123 if [ X"$err" != X ]; then
124 echo "using cc"
125 CC=cc
126 else
127 echo "using gcc"
128 CC=gcc
129 fi
130
131 echo $n "
132 1 -- Basic optimization (-O -s)
133 2 -- Full optimization (-O2 -s)
134 3 -- Debug, no optimization (-g)
135
136 Specify optimization/debug state. [123] (default: 1) $c"
137
138 read DEBUG
139
140 if [ X${DEBUG} = X ]; then
141 DEBUG="1"
142 fi
143
144 if [ ${DEBUG} = "1" ]; then
145 DEBUG="Basic optimization."
146 CDEBUGFLAGS="-O -s"
147 elif [ ${DEBUG} = "2" ]; then
148 DEBUG="Full optimization."
149 CDEBUGFLAGS="-O2 -s"
150 elif [ ${DEBUG} = "3" ]; then
151 while [ "${DEBUG}" = "3" ]; do
152 echo $n "
153 gdb -- GNU Debugger
154 dbx -- source level debugger
155 none -- no debugger
156 <other> -- other debugger
157
158 Use which debugger? (default: none) $c"
159 read DEBUGGER
160 if [ X${DEBUGGER} = X ]; then
161 DEBUGGER="none"
162 fi
163
164 if [ ${DEBUGGER} = "none" ]; then
165 DEBUG="Debug (No debugger), no optimization"
166 CDEBUGFLAGS="-g"
167 elif [ ${DEBUGGER} = "gdb" ]; then
168 DEBUG="Debug (GNU debugger), no optimization"
169 CDEBUGFLAGS="-ggdb"
170 elif [ ${DEBUGGER} = "dbx" ]; then
171 DEBUG="Debug, no optimization"
172 CDEBUGFLAGS="-gdbx"
173 else
174 echo $n "${t}\"${DEBUGGER}\" is an unknown debugger, use anyway? [yn] (default: y) $c"
175 read ANSWER
176 if [ X${ANSWER} = X"y" ]; then
177 DEBUG="Debug (Other: ${DEBUGGER}), no optimization"
178 CDEBUGFLAGS="-g${DEBUGGER}"
179 fi
180 fi
181 done
182 else
183 echo "$0: unknown option \"${DEBUG}\", exiting."
184 exit 1
185 fi
186
187 #########################################################################
188
189 if [ -f "rsa/Makefile" ]; then
190 echo $n "
191 You seem to have the RSA files. RSA verification is NOT required
192 for the server to function, and is usually enabled only on high
193 profile public servers.
194
195 Do you wish to enable RSA verification? [yn] (default: n) $c"
196
197 read ANSWER
198 if [ X${ANSWER} = X"y" ]; then
199 RSA="-DAUTHORIZE"
200 AUTHOBJS="rsa-server.o rsa_util.o reserved.o"
201 else
202 RSA=""
203 AUTHOBJS=""
204 fi
205 else
206 echo "
207 RSA files do not exist, RSA verification is not enabled (RSA
208 verification is not required for the server to run, and is
209 usually only enabled on high profile public servers)."
210 fi
211
212 ###########################################################################
213 echo ""
214 echo $n "${i}Does the mp library exist...$c"
215
216 cat > test.c <<EOF
217 int main() { exit(0); }
218 int t() { main(); }
219 EOF
220
221 err=`eval "($CC test.c -lmp >/dev/null) 2>&1"`
222 rm -f test.c a.out
223
224 if [ -z "$err" ]; then
225 echo "yes."
226 LIBS="-lmp ${LIBS}"
227 if [ ! -z "$RSA" ]; then
228 echo ""
229 echo "${i}Using appropriate mp RSA files."
230 echo ""
231 AUTHOBJS="rsa-server.o rsa_utilmp.o reserved.o"
232 fi
233 else
234 echo "no."
235 fi
236
237 ###########################################################################
238 # strdup()
239
240 echo $n "${i}Does strdup() exist...$c"
241
242 cat > test.c <<EOF
243 #include <string.h>
244 main () { char *str, *str2 = "test\n"; str = strdup(str2); }
245 EOF
246
247 err=`eval "($CC test.c >/dev/null) 2>&1"`
248 if [ ! -z "$err" ]; then
249 CCOPTIONS="${CCOPTIONS} -DNO_STRDUP "
250 echo "no."
251 else
252 echo "yes."
253 fi
254
255 rm -f test.c a.out
256
257 ##########################################################################
258 # qsort()
259
260 echo $n "${i}Does qsort() exist...$c"
261
262 cat > test.c <<EOF
263 #include <string.h>
264 main () { qsort(); }
265 EOF
266
267 err=`eval "($CC test.c >/dev/null) 2>&1"`
268 rm -f test.c a.out
269
270 if [ ! -z "$err" ]; then
271 CCOPTIONS="${CCOPTIONS} -DNO_QSORT"
272 echo "no."
273 else
274 echo "yes."
275 fi
276
277 ##########################################################################
278
279 # This is inefficient to do it seperately for each option, but it is
280 # the cleanest way.
281
282 echo "sed \"s:^#@@LIBS@:LIBS=${LIBS}:g\" src/Makefile.in > /tmp/a\$\$.setup" > etc/$0.conf
283 echo "sed \"s:^#@@CC@:CC=${CC}:g\" /tmp/a\$\$.setup > /tmp/\$\$.setup" >> etc/$0.conf
284 echo "sed \"s:^#@@CDEBUGFLAGS@:CDEBUGFLAGS=${CDEBUGFLAGS}:g\" /tmp/\$\$.setup > /tmp/a\$\$.setup" >> etc/$0.conf
285 echo "sed \"s:^#@@RSA@:RSA=${RSA}:g\" /tmp/a\$\$.setup > /tmp/\$\$.setup" >> etc/$0.conf
286 echo "sed \"s:^#@@AUTHOBJS@:AUTHOBJS=${AUTHOBJS}:g\" /tmp/\$\$.setup > /tmp/a\$\$.setup" >> etc/$0.conf
287 echo "sed \"s:^#@@CCOPTIONS@:CCOPTIONS=${CCOPTIONS}:g\" /tmp/a\$\$.setup > /tmp/\$\$.setup" >> etc/$0.conf
288 echo "echo \$\$" >> etc/$0.conf
289
290 # This 'fi' is from the first if (checking "-d")
291 fi
292
293 echo ""
294 echo $n "${i}Generating \"src/Makefile\" from \"src/Makefile.in\"...$c"
295
296 SPID=`sh etc/$0.conf`
297
298 echo "# This file generated by \"$0\" on `date`." > /tmp/${SPID}.Makefile
299 echo "# Make changes to \"Makefile.in\" and run the setup script" >> /tmp/${SPID}.Makefile
300 echo "#" >> /tmp/${SPID}.Makefile
301
302 cat /tmp/${SPID}.Makefile > src/Makefile
303 cat /tmp/${SPID}.setup >> src/Makefile
304
305 rm -f /tmp/${SPID}.setup
306 rm -f /tmp/a${SPID}.setup
307 rm -f /tmp/${SPID}.Makefile
308
309 echo "Done."
310 echo ""
311 echo " use 'make <option>' to compile the server."
312 echo ""
313 echo " To change the server game configuration check the file \"src/config.h\"."
314 echo ""
315
316 exit