-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.FluffOS
executable file
·478 lines (428 loc) · 11.5 KB
/
build.FluffOS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
#!/bin/sh
ENABLE_M64=0
export ENABLE_M64
if test $# -ne 0; then
case $1 in
develop)
echo Preparing to build developmental version of MudOS driver ...
OPTIMIZE="-O0 -Wall -Wundef -DPEDANTIC -pedantic -Wmissing-declarations"
DEBUG="-g -DDEBUG -DDEBUG_MACRO"
;;
debug)
echo Preparing to build debugging version of MudOS driver ...
OPTIMIZE="-O0"
DEBUG="-g -DDEBUG"
;;
*)
echo Unknown build type
exit 1
;;
esac
else
echo Preparing to build standard MudOS driver ...
fi
# If this is uncommented, the specified 'make' is used instead of looking for
# one
#MAKE=make
# define this to be where you want the temporary compiled files to go
# (only used with GNU make)
OBJDIR=obj
# change this if you wish the driver binary to be named something else
DRIVER_BIN=driver
# uncomment PROOF if using CenterLine's TestCenter to debug the driver.
#PROOF=proof
# Set INSTALL_DIR to the directory where you want to install the executables.
INSTALL_DIR="../bin"
#Enable warnings from the compiler (gcc), if wanted.
#WARN=-Wall
#PIPE=-pipe
# define profiling if you want it
# note: the gmon.out file will likely be written in the mudlib dir.
# PROFILE_ON controls whether or not monitoring is active at driver
# startup. Comment PROFILE_ON to make profiling not active at startup.
# Use moncontrol(1) efun to enable profiling and moncontrol(0) to turn
# it off.
#PROFILE_ON="-DPROFILE_ON"
# Uncomment this if you want to enable profiling of the driver (gcc)
#PROFIL="-pg -DPROFILING $(PROFILE_ON)"
# Enable run time debugging
#DEBUG="-g"
# With extra driver debug code
#DEBUG="-g -DDEBUG"
# For DEC Alpha: to have optimization and debugging
#DEBUG="-g3 -DDEBUG"
# Prevent -DDEBUG from aborting the driver (when in -DDEBUG mode)
#DEBUG_NON_FATAL="-DDEBUG_NON_FATAL"
# Compile in debug() macro code
#DEBUG_MACRO="-DDEBUG_MACRO"
# define this if you want to specify (compiler) optimization.
#
# if nothing is defined here, and DEBUG is not defined, something appropriate
# to the compiler in question is used.
#
# *WARNING* using high levels of optimization (e.g. -O3) can cause some
# compilers to produce incorrect code. If the driver is behaving
# inexplicably, try using a lower level of optimization (or none).
#
# Uncomment one or none of the following optimization lines.
#
# -O is usually a safe level of optimization for most compilers
#OPTIMIZE="-O"
# high optimization for gcc:
#OPTIMIZE="-O2 -fstrength-reduce"
# uncomment below for RS/6000(AIX) xlc compiler only.
# remove the -Q if xlc complains.
#OPTIMIZE="-O -Q"
# might need this one with newer versions of AIX (ie 3.2.4)
#OPTIMIZE="-O -Q -qMAXMEM=16000"
# high optimization for HP-UX 7.x/8.x's cc (don't use with 9.x)
#OPTIMIZE="+O3 +Obb3000"
# MIPS R3000 running EP/IX Version 1.4.3. Compiler is RISCompiler C 2.11 (cc).
#OPTIMIZE="-Olimit 1802"
# DEC Alpha's cc's highest optimization: -O5
#OPTIMIZE="-O -Olimit 2000"
# DEC Ultrix's cc's highest optimization:
#OPTIMIZE="-O2 -Olimit 5000"
# high optimization for cc on SGI
#OPTIMIZE="-O2 -Olimit 2500"
# System V Release 4 (386/486 or if using Sun's cc under Solaris 2.x)
# ARCH: need a way to detect this
#OSFLAGS=-DSVR4
# MIPS R3000 running EP/IX Version 1.4.3. Compiler is RISCompiler C 2.11 (cc).
# ARCH: this one too
#OSFLAGS=-I/usr/include/bsd
# Solaris (SunOS 5): for BSD compatible ioctl()
# If using CC=cc, you can also add:
# -w to turn off warnings, in order to get a cleaner compile
# For 5.4, also add the following:
# -I/usr/bsdinclude
# ARCH: anyone figured a good hack to detect this one yet?
#OSFLAGS="-DBSD_COMP -DSunOS_5"
# SCO 3.2v4.2
# ARCH: *sigh* and this one ...
#OSFLAGS=-DSCO
#Static for compiling Discworld on MINGW
#OSFLAGS=-static
# try uncommenting this if you are using gcc and at runtime you see socket
# errors saying that the "set socket nonblocking" operation is not supported.
# That error is caused by old-style macros (that gcc doesn't normally grok)
# used by ioctl on some systems.
#NEED_OLD_CPP=-traditional-cpp
# Location of libmsgql.a, if you are using PACKAGE_DB
#EXTRALIBS=-L/usr/local/lib -lmsql
####### END OF USER CONFIGURABLE OPTIONS
echo "Trying out some stuff to see what works; ignore errors ..."
# Mac OS X needs this in order to build properly with gcc < 3
if test "`uname`" = "Darwin"; then
GCC_MAJOR="`gcc -v 2>&1 | grep "gcc version" | cut -d ' ' -f 3 | cut -d '.' -f 1`"
GCC_MINOR="`gcc -v 2>&1 | grep "gcc version" | cut -d ' ' -f 3 | cut -d '.' -f 2`"
if test "$GCC_MAJOR" -eq "2"; then
NEED_OLD_CPP=-traditional-cpp
fi
fi
#
# Figure out what make is, and how to invoke it
#
if test "${MAKE-x}" = "x"; then
gmake nothing
if test $? -eq 0; then
MAKE=gmake
MAKEFILE=GNUmakefile
else
make nothing
if test $? -eq 0; then
MAKE=make
tmp=`make which_makefile 2>./2.out | grep -v echo`
if test "x$tmp" = "xMakeIsGNU"; then
MAKEFILE=GNUmakefile
else
MAKEFILE=Makefile
OBJDIR=
fi
else
echo 'FATAL ERROR: Cannot find make or gmake'
exit
fi
fi
else
tmp=`make which_makefile 2>./2.out | grep -v echo`
if test "x$tmp" = "xMakeIsGNU"; then
MAKEFILE=GNUmakefile
else
MAKEFILE=Makefile
OBJDIR=
fi
fi
echo MAKE=$MAKE >Makefile.tmp
#
# Determine if running under Cygwin-32 and use a.exe instead
# of a.out if so
#
if test $CYGWIN; then
A_OUT=a.exe
echo Using a.exe for Cygwin GNU compiler default executable
else
A_OUT=a.out
echo Using standard a.out for compiler default executable
fi
#
# Figure out what to use for CC
#
cat >comptest.c <<END
int main() {
}
END
xlc comptest.c
if test $? -eq 0; then
CC=xlc
if test "${DEBUG-x}" = "x"; then
OPTIMIZE=${OPTIMIZE-"-O2 -Q -qMAXMEM=16000"}
fi
else
gcc comptest.c
if test $? -eq 0; then
CC="gcc"
if test "${DEBUG-x}" = "x"; then
OPTIMIZE=${OPTIMIZE-"-O2"}
fi
if (test $? -eq 0); then
if (test $ENABLE_M64 -eq 1); then
CC="gcc -m64"
OPTIMIZE=$OPTIMIZE" -DM64"
fi
fi
echo "CC: "$CC
GNUC=1
CCFLAGS=-D__USE_FIXED_PROTOTYPES__
else
clcc comptest.c
if test $? -eq 0; then
CC=clcc
if test "${DEBUG-x}" = "x"; then
OPTIMIZE=${OPTIMIZE-"-O"}
fi
else
cc comptest.c
if test $? -eq 0; then
CC=cc
if test "${DEBUG-x}" = "x"; then
OPTIMIZE=${OPTIMIZE-"-O"}
cat >comptest.c <<END
#ifndef __GNUC__
Oh darn it's not gcc
#endif
END
cc comptest.c
if test $? -eq 0; then
OPTIMIZE=${OPTIMIZE-"-O2"}
GNUC=1
fi
fi
else
echo "FATAL ERROR: Cannot find a C compiler"
exit
fi
fi
fi
fi
#
# are we using gcc on a 486?
#
if test $GNUC; then
tmp=`uname -m`
if test "x$tmp" = "xi486" -o "x$tmp" = "xi586"; then
OPTIMIZE="$OPTIMIZE -m486"
fi
fi
#
# Figure out how to run CPP
#
cat >comptest.c <<END
#define foo
Make this fail if we actually get compiled
END
$CC -E comptest.c >./1.out
if test $? -eq 0; then
CPP="$CC -E $NEED_OLD_CPP"
else
cpp comptest.c >./1.out
if test $? -eq 0; then
CPP="cpp"
else
$CC -E -traditional-cpp comptest.c >./1.out
if test $? -eq 0; then
CPP="$CC -E -traditional-cpp"
else
echo "FATAL ERROR: Can't figure out how to run the C preprocessor"
exit
fi
fi
fi
#
# Figure out what to use for install
#
mkdir tmp
cat >insttest <<END
whatever
END
rm tmp/insttest
# install -f insttest tmp
if test $? -eq 0 && test -f tmp/insttest; then
INSTALL="install -f"
else
rm tmp/insttest
install -c insttest tmp
if test $? -eq 0 && test -f tmp/insttest; then
INSTALL="install -c"
else
INSTALL="cp"
fi
fi
cat >comptest.c <<END
void foo() { }
END
$CC -c comptest.c -o comptest.o
#
# Check if ranlib exists/is needed. Also check ar.
#
cat >comptest.c <<END
int if_you_are_reading_this_you_must_be_bored() { return 1; }
END
$CC -c comptest.c
ar rcu comptest.a comptest.o
if test $? -ne 0; then
echo "FATAL ERROR: Could not find ar."
exit
fi
ranlib comptest.a
if test $? -eq 0; then
RANLIB=ranlib
else
RANLIB=/bin/true
fi
#
# Find yacc/bison/byacc
#
cat >comptest.y <<END
%token FOO
%%
all: FOO
END
bison comptest.y
if test $? -eq 0 && test "$CC" != "xlc"; then
YACC="bison -d -y"
else
byacc comptest.y
if test $? -eq 0; then
YACC="byacc -d"
else
yacc comptest.y
if test $? -eq 0; then
YACC="yacc -d"
else
echo "FATAL ERROR: Could not find bison or yacc."
exit
fi
fi
fi
# Some of these are probably unnecessary
CFLAGS="$CCFLAGS $OSFLAGS $WARN $PROFIL $DEBUG $DEBUG_MACRO $DEBUG_NON_FATAL $STR $PIPE $NEED_OLD_CPP $EXPORT_DYNAMIC"
#
# Determine system type
#
cat >comptest.c <<END
#include <stdio.h>
#include "arch.h"
int main() {
printf("%s\n", ARCH);
}
END
$CC $CFLAGS comptest.c
ARCH=`./$A_OUT`
cat >comptest.c <<END
int main(int argc, char **argv) { return 0; }
END
case $ARCH in
AIX)
OSFLAGS="$OSFLAGS -D_BSD -D_ALL_SOURCE"
CFLAGS="$CFLAGS -D_BSD -D_ALL_SOURCE"
;;
Solaris)
OSFLAGS="$OSFLAGS -DSunOS_5"
CFLAGS="$CFLAGS -DSunOS_5"
;;
esac
#don't use dynamic at the moment
# Linux*)
# EXPORT_DYNAMIC=-rdynamic
# ;;
# FreeBSD)
# cc -export-dynamic comptest.c
# if test $? -eq 0; then
# EXPORT_DYNAMIC=-export-dynamic
# else
# cc -rdynamic comptest.c
# if test $? -eq 0; then
# EXPORT_DYNAMIC=-rdynamic
# fi
# fi
# ;;
#esac
rm $A_OUT
CFLAGS="$CCFLAGS $OSFLAGS $WARN $PROFIL $DEBUG $DEBUG_MACRO $DEBUG_NON_FATAL $STR $PIPE $NEED_OLD_CPP $INCLUDE $EXPORT_DYNAMIC"
if test ! "$OBJDIR" = ""; then
mkdir $OBJDIR
fi
echo SHELL=/bin/sh >>Makefile.tmp
echo OBJDIR=$OBJDIR >>Makefile.tmp
echo DRIVER_BIN=$DRIVER_BIN >>Makefile.tmp
echo PROOF=$PROOF >>Makefile.tmp
echo STRFUNCS=$STRFUNCS >>Makefile.tmp
echo INSTALL=$INSTALL >>Makefile.tmp
echo INSTALL_DIR=$INSTALL_DIR >>Makefile.tmp
echo OPTIMIZE=$OPTIMIZE >>Makefile.tmp
echo CPP=$CPP >>Makefile.tmp
echo CFLAGS=$CFLAGS >>Makefile.tmp
echo CC=$CC >>Makefile.tmp
echo YACC=$YACC >>Makefile.tmp
echo RANLIB=$RANLIB >>Makefile.tmp
echo A=a >>Makefile.tmp
echo O=o >>Makefile.tmp
echo A_OUT=$A_OUT >>Makefile.tmp
echo "***************** Configuration completed **************"
echo "Installing MudOS on $ARCH"
echo
echo "Using $INSTALL to install binaries in $INSTALL_DIR."
echo "Using $CPP for preprocessing."
echo "Using $CC $CFLAGS $OPTIMIZE to compile."
echo "Using $YACC $YFLAGS to make the compiler."
echo "Edit $MAKEFILE if this is not what you want"
echo
echo "Otherwise, type '$MAKE' to build MudOS, then '$MAKE install'."
cat Makefile.tmp ${MAKEFILE}.in >$MAKEFILE
rm Makefile.tmp
if test $MAKEFILE = Makefile; then
cat >GNUmakefile <<END
all:
@echo MudOS is currently configured to use 'Makefile'. Edit 'build.MudOS'
@echo if this is not what you want.
.DEFAULT:
@echo MudOS is currently configured to use 'Makefile'. Edit 'build.MudOS'
@echo if this is not what you want.
nothing:
which_makefile:
echo MakeIsGNU
END
else
cat >Makefile <<END
all:
@echo MudOS is currently configured to use 'GNUmakefile'. Edit 'build.MudOS'
@echo if this is not what you want.
.DEFAULT:
@echo MudOS is currently configured to use 'GNUmakefile'. Edit 'build.MudOS'
@echo if this is not what you want.
nothing:
which_makefile:
echo MakeIsMake
END
fi