forked from cisco/ChezScheme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·557 lines (520 loc) · 15.7 KB
/
configure
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
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
#! /bin/sh
# configure
# Copyright 1984-2017 Cisco Systems, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
machs=""; last=""; sep0=""; sep1=""; sep2=""; sep3=""; sep4=" and ";
for fn in boot/*/scheme.boot ; do
machs=$machs$sep0$last
last=`echo $fn | sed -e 's/boot\/\(.*\)\/scheme.boot/\1/'`
sep0=$sep1; sep1=", "; sep2=$sep3; sep3=$sep4; sep4=", and "
done
machs=$machs$sep2$last
m=""
w=""
threads=no
temproot=""
help=no
gzipmanpages=yes
installowner=""
installgroup=""
installbin=""
installlib=""
installman=""
installdoc=""
installcsug=""
installreleasenotes=""
installschemename="scheme"
installpetitename="petite"
installscriptname="scheme-script"
disablex11=no
disablecurses=no
: ${CC:="gcc"}
: ${CPPFLAGS:=""}
: ${CFLAGS:=""}
: ${LD:="ld"}
: ${LDFLAGS:=""}
: ${AR:="ar"}
: ${ARFLAGS:="rc"}
: ${RANLIB:="ranlib"}
: ${WINDRES:="windres"}
zlibInc=-I../zlib
LZ4Inc=-I../lz4/lib
zlibDep=../zlib/libz.a
LZ4Dep=../lz4/lib/liblz4.a
zlibLib=../zlib/libz.a
LZ4Lib=../lz4/lib/liblz4.a
zlibHeaderDep="../zlib/zconf.h ../zlib/zlib.h"
LZ4HeaderDep="../lz4/lib/lz4.h ../lz4/lib/lz4frame.h"
Kernel=KernelO
installkerneltarget=installkernelobj
installzlibtarget=
installlz4target=
# On WSL, set OS to "Windows_NT" to create a Windows
# build instead of a Linux (on Windows) build:
if [ "$OS" = "Windows_NT" ] ; then
CONFIG_UNAME="CYGWIN_NT-"
else
CONFIG_UNAME=`uname`
fi
case "${CONFIG_UNAME}" in
Linux)
if uname -a | egrep 'i386|i686|amd64|athlon|x86_64' > /dev/null 2>&1 ; then
m32=i3le
m64=a6le
tm32=ti3le
tm64=ta6le
elif uname -a | grep -i power > /dev/null 2>&1 ; then
m32=ppc32le
m64=""
tm32=tppc32le
tm64=""
fi
installprefix=/usr
installmansuffix=share/man
;;
QNX)
if uname -a | egrep 'x86' > /dev/null 2>&1 ; then
m32=i3qnx
tm32=ti3qnx
fi
installprefix=/usr/local
installmansuffix=man
;;
FreeBSD)
if uname -a | egrep 'i386|i686|amd64|athlon|x86_64' > /dev/null 2>&1 ; then
m32=i3fb
m64=a6fb
tm32=ti3fb
tm64=ta6fb
fi
installprefix=/usr/local
installmansuffix=man
;;
OpenBSD)
if uname -a | egrep 'i386|i686|amd64|athlon|x86_64' > /dev/null 2>&1 ; then
m32=i3ob
m64=a6ob
tm32=ti3ob
tm64=ta6ob
fi
installprefix=/usr/local
installmansuffix=man
;;
NetBSD)
if uname -a | egrep 'i386|i686|amd64|athlon|x86_64' > /dev/null 2>&1 ; then
m32=i3nb
m64=a6nb
tm32=ti3nb
tm64=ta6nb
fi
installprefix=/usr
installmansuffix=share/man
gzipmanpages=no
;;
Darwin)
if uname -a | egrep 'i386|i686|amd64|athlon|x86_64' > /dev/null 2>&1 ; then
m32=i3osx
m64=a6osx
tm32=ti3osx
tm64=ta6osx
elif uname -a |egrep 'arm64' > /dev/null 2>&1 ; then
is_arm64osx=1
fi
installprefix=/usr/local
installmansuffix=share/man
;;
SunOS)
if uname -a | egrep 'i386|i686|amd64|athlon|x86_64' > /dev/null 2>&1 ; then
m32=i3s2
m64=a6s2
tm32=ti3s2
tm64=ta6s2
installprefix=/usr
installmansuffix=share/man
gzipmanpages=no
fi
;;
CYGWIN_NT-*)
if uname -a | egrep 'i386|i686|amd64|athlon|x86_64' > /dev/null 2>&1 ; then
m32=i3nt
m64=a6nt
tm32=ti3nt
tm64=ta6nt
installprefix=/usr/local
installmansuffix=share/man
fi
;;
esac
threads=""
bits=""
while [ $# != 0 ] ; do
case $1 in
-m=*)
m=`echo $1 | sed -e 's/^-m=//'`
;;
--machine=*)
m=`echo $1 | sed -e 's/^--machine=//'`
;;
--threads)
threads=yes
;;
--64)
bits=64
;;
--32)
bits=32
;;
--installprefix=*)
installprefix=`echo $1 | sed -e 's/^--installprefix=//'`
;;
--installlib=*)
installlib=`echo $1 | sed -e 's/^--installlib=//'`
;;
--installbin=*)
installbin=`echo $1 | sed -e 's/^--installbin=//'`
;;
--installman=*)
installman=`echo $1 | sed -e 's/^--installman=//'`
;;
--installdoc=*)
installdoc=`echo $1 | sed -e 's/^--installdoc=//'`
;;
--installcsug=*)
installcsug=`echo $1 | sed -e 's/^--installcsug=//'`
;;
--installreleasenotes=*)
installreleasenotes=`echo $1 | sed -e 's/^--installreleasenotes=//'`
;;
--installowner=*)
installowner=`echo $1 | sed -e 's/^--installowner=//'`
;;
--installgroup=*)
installgroup=`echo $1 | sed -e 's/^--installgroup=//'`
;;
--installschemename=*)
installschemename=`echo $1 | sed -e 's/^--installschemename=//'`
;;
--installpetitename=*)
installpetitename=`echo $1 | sed -e 's/^--installpetitename=//'`
;;
--installscriptname=*)
installscriptname=`echo $1 | sed -e 's/^--installscriptname=//'`
;;
--toolprefix=*)
toolprefix=`echo $1 | sed -e 's/^--toolprefix=//'`
CC="${toolprefix}${CC}"
LD="${toolprefix}${LD}"
AR="${toolprefix}${AR}"
RANLIB="${toolprefix}${RANLIB}"
WINDRES="${toolprefix}${WINDRES}"
;;
--gzip-man-pages)
gzipmanpages=yes
;;
--nogzip-man-pages)
gzipmanpages=no
;;
--temproot=*)
temproot=`echo $1 | sed -e 's/^--temproot=//'`
;;
--workarea=*)
w=`echo $1 | sed -e 's/^--workarea=//'`
;;
--help)
help=yes
;;
--disable-x11)
disablex11=yes
;;
--disable-curses)
disablecurses=yes
;;
--libkernel)
Kernel=KernelLib
installkerneltarget=installkernellib
if [ "$zlibInc" != "" ]; then
installzlibtarget=installzlib
fi
if [ "$LZ4Inc" != "" ]; then
installlz4target=installlz4
fi
;;
--kernelobj)
Kernel=KernelO
installkerneltarget=installkernelobj
installzlibtarget=
installlz4target=
;;
CC=*)
CC=`echo $1 | sed -e 's/^CC=//'`
;;
CPPFLAGS=*)
CPPFLAGS=`echo $1 | sed -e 's/^CPPFLAGS=//'`
;;
CFLAGS=*)
CFLAGS=`echo $1 | sed -e 's/^CFLAGS=//'`
;;
LD=*)
LD=`echo $1 | sed -e 's/^LD=//'`
;;
LDFLAGS=*)
LDFLAGS=`echo $1 | sed -e 's/^LDFLAGS=//'`
;;
AR=*)
AR=`echo $1 | sed -e 's/^AR=//'`
;;
ARFLAGS=*)
ARFLAGS=`echo $1 | sed -e 's/^ARFLAGS=//'`
;;
RANLIB=*)
RANLIB=`echo $1 | sed -e 's/^RANLIB=//'`
;;
WINDRES=*)
WINDRES=`echo $1 | sed -e 's/^WINDRES=//'`
;;
ZLIB=*)
zlibLib=`echo $1 | sed -e 's/^ZLIB=//'`
zlibInc=
zlibDep=
zlibHeaderDep=
installzlibtarget=
;;
LZ4=*)
LZ4Lib=`echo $1 | sed -e 's/^LZ4=//'`
LZ4Inc=
LZ4Dep=
LZ4HeaderDep=
installlz4target=
;;
*)
echo "option '$1' unrecognized or missing an argument; try $0 --help"
exit 1
;;
esac
shift
done
if [ "$bits" = "" ] ; then
if uname -a | egrep 'amd64|x86_64' > /dev/null 2>&1 ; then
bits=64
else
bits=32
fi
fi
if [ "$threads" = "" ] ; then
threads=no
fi
if [ "$m" = "" ] ; then
if [ $bits = 64 ] ; then
if [ $threads = yes ] ; then m=$tm64 ; else m=$m64 ; fi
else
if [ $threads = yes ] ; then m=$tm32 ; else m=$m32 ; fi
fi
fi
if [ "$w" = "" ] ; then
w=$m
fi
if [ "$installbin" = "" ] ; then
installbin=$installprefix/bin
fi
if [ "$installlib" = "" ] ; then
installlib=$installprefix/lib
fi
if [ "$installman" = "" ] ; then
installman=$installprefix/$installmansuffix
fi
if [ "$installdoc" = "" ] ; then
installdoc=$installprefix/share/doc
fi
if [ "$installcsug" = "" ] ; then
installcsug=$installdoc/csug9.5
fi
if [ "$installreleasenotes" = "" ] ; then
installreleasenotes=$installdoc/csv9
fi
if [ "$disablex11" = "no" ] ; then
if [ "$m" = "a6osx" ] || [ "$m" = "ta6osx" ] ; then
if [ ! -d /opt/X11/include/ ] ; then
disablex11=yes
fi
fi
fi
if [ "$help" = "yes" ]; then
echo "Purpose:"
echo " $0 determines the machine type and constructs a custom Makefile"
echo " and Mf-install, taking into account the options below."
echo ""
echo "Options (defaults shown in parens):"
echo " --machine=<machine type> explicitly specify machine type ($m)"
echo " -m=<machine type> same as --machine <machine type> ($m)"
echo " --threads specify threaded version ($threads)"
echo " --32|--64 specify 32/64-bit version ($bits)"
echo " --disable-x11 disable X11 support"
echo " --disable-curses disable [n]curses support"
echo " --libkernel build libkernel.a instead of kernel.o"
echo " --kernelobj build kernel.o (the default)"
echo " --installprefix=<pathname> final installation root ($installprefix)"
echo " --installbin=<pathname> bin directory ($installbin)"
echo " --installlib=<pathname> lib directory ($installlib)"
echo " --installman=<pathname> manpage directory ($installman)"
echo " --installdoc=<pathname> documentation root ($installdoc)"
echo " --installcsug=<pathname> guide directory ($installcsug)"
# abbreviate "release notes" to fit default help in 80 cols:
echo " --installreleasenotes=<pathname> notes directory ($installreleasenotes)"
echo " --temproot=<pathname> staging root ($temproot)"
echo " --installowner=<ownername> install with owner ($installowner)"
echo " --installgroup=<groupname> install with group ($installgroup)"
echo " --installschemename=<schemename> install scheme as ($installschemename)"
echo " --installpetitename=<petitename> install petite as ($installpetitename)"
echo " --installscriptname=<scriptname> install scheme-script as ($installscriptname)"
echo " --toolprefix=<prefix> prefix tool (compiler, linker, ...) names"
echo " --[no]gzip-man-pages compress manual pages ($gzipmanpages)"
echo " --workarea=<pathname> build directory ($w)"
echo " CC=<C compiler> C compiler"
echo " CPPFLAGS=<C preprocessor flags> additional C preprocessor flags ($CPPFLAGS)"
echo " CFLAGS=<C compiler flags> additional C compiler flags ($CFLAGS)"
echo " LD=<linker> linker"
echo " LDFLAGS=<linker flags> additional linker flags ($LDFLAGS)"
echo " AR=<archiver> archiver"
echo " ARFLAGS=<archiver flgs> archiver flags"
echo " RANLIB=<archive indexer> archive indexer"
echo " WINDRES=<resource compiler> resource compiler"
echo " ZLIB=<lib> link to <lib> instead of own zlib"
echo " LZ4=<lib> link to <lib> instead of own LZ4"
echo ""
echo "Available machine types: $machs"
echo ""
echo "Examples:"
echo " $0 --machine=i3le"
echo ""
echo " set machine-type to i3le rather than to determined type"
echo ""
echo " $0 --threads --installprefix=/usr/local"
echo ""
echo " specify threaded version and set installation directory to /usr/local."
echo ""
echo " $0 --installprefix=/usr/local --temproot=/tmp"
echo ""
echo " declare the final destination to be /usr/local but staging area"
echo " to be /tmp/usr/local. Make will record the final destination in the"
echo " installed manual pages but actually install the system and manual"
echo " pages in the staging area."
echo ""
exit 0
fi
if [ "$m" = "" -a "$is_arm64osx" != "" ] ; then
echo "Compiling for Apple Silicon is not yet supported."
echo "You can build under Rosetta2 by running configure and make inside an"
echo "x86 shell, started via the following command:"
echo " /usr/bin/arch -x86_64 /bin/bash -l"
echo
fi
if [ "$m" = "" -o ! -f boot/$m/scheme.boot ] ; then
echo "no suitable machine type found"
echo "try rerunning as $0 -m=<machine type>"
echo "available machine types: $machs"
exit 1
fi
if [ -d '.git' ] && command -v git >/dev/null 2>&1 ; then
git submodule init && git submodule update || exit 1
else
if [ ! -f 'nanopass/nanopass.ss' ] ; then
rmdir nanopass > /dev/null 2>&1
(curl -L -o v1.9.2.tar.gz https://github.com/nanopass/nanopass-framework-scheme/archive/v1.9.2.tar.gz && tar -zxf v1.9.2.tar.gz && mv nanopass-framework-scheme-1.9.2 nanopass && rm v1.9.2.tar.gz) || exit 1
fi
if [ "${zlibDep}" != "" ] ; then
if [ ! -f 'zlib/configure' ] ; then
rmdir zlib > /dev/null 2>&1
(curl -L -o v1.2.12.tar.gz https://github.com/madler/zlib/archive/v1.2.12.tar.gz && tar -xzf v1.2.12.tar.gz && mv zlib-1.2.12 zlib && rm v1.2.12.tar.gz) || exit 1
fi
fi
if [ "${LZ4Dep}" != "" ] ; then
if [ ! -f 'lz4/lib/Makefile' ] ; then
rmdir lz4 > /dev/null 2>&1
(curl -L -o v1.9.3.tar.gz https://github.com/lz4/lz4/archive/v1.9.3.tar.gz && tar -xzf v1.9.3.tar.gz && mv lz4-1.9.3 lz4 && rm v1.9.3.tar.gz) || exit 1
fi
fi
if [ ! -f 'stex/Mf-stex' ] ; then
rmdir stex > /dev/null 2>&1
(curl -L -o v1.2.2.tar.gz https://github.com/dybvig/stex/archive/v1.2.2.tar.gz && tar -zxf v1.2.2.tar.gz && mv stex-1.2.2 stex && rm v1.2.2.tar.gz) || exit 1
fi
fi
./workarea $m $w
sed -e 's/$(m)/'$m'/g'\
-e 's/$(workarea)/'$w'/g'\
makefiles/Makefile.in > Makefile
sed -e 's/$(m)/'$m'/g'\
-e "s;^installdir=.*\$;installdir=$installcsug;"\
makefiles//Makefile-csug.in > csug/Makefile
sed -e 's/$(m)/'$m'/g'\
-e "s;^installdir=.*\$;installdir=$installreleasenotes;"\
makefiles//Makefile-release_notes.in > release_notes/Makefile
cat makefiles/Makefile-workarea.in > $w/Makefile
sed -e 's/$(m)/'$m'/g'\
-e 's/$(workarea)/'$w'/g'\
makefiles/Mf-boot.in > $w/Mf-boot
sed -e "s;^m=none\$;m=$m;"\
-e "s;^InstallBin=.*\$;InstallBin=$installbin;"\
-e "s;^InstallLib=.*\$;InstallLib=$installlib;"\
-e "s;^InstallMan=.*\$;InstallMan=$installman/man1;"\
-e "s;^InstallOwner=.*\$;InstallOwner=$installowner;"\
-e "s;^InstallGroup=.*\$;InstallGroup=$installgroup;"\
-e "s;^TempRoot=.*;TempRoot=$temproot;"\
-e "s;^GzipManPages=.*$;GzipManPages=$gzipmanpages;"\
-e "s;^InstallSchemeName=.*$;InstallSchemeName=$installschemename;"\
-e "s;^InstallPetiteName=.*$;InstallPetiteName=$installpetitename;"\
-e "s;^InstallScriptName=.*$;InstallScriptName=$installscriptname;"\
-e "s;^InstallKernelTarget=.*$;InstallKernelTarget=$installkerneltarget;"\
-e "s;^InstallZlibTarget=.*$;InstallZlibTarget=$installzlibtarget;"\
-e "s;^InstallLZ4Target=.*$;InstallLZ4Target=$installlz4target;"\
makefiles/Mf-install.in > $w/Mf-install
cat > $w/c/config.h << END
#define SCHEME_SCRIPT "$installscriptname"
#ifndef WIN32
#define DEFAULT_HEAP_PATH "$installlib/csv%v/%m"
#endif
END
if [ "$disablex11" = "yes" ]; then
echo '#define DISABLE_X11' >> $w/c/config.h
fi
cursesLib=-lcurses
ncursesLib=-lncurses
if [ "$disablecurses" = "yes" ]; then
echo '#define DISABLE_CURSES' >> $w/c/config.h
cursesLib=
ncursesLib=
fi
cat > $w/c/Mf-config << END
CC=$CC
CPPFLAGS=$CPPFLAGS
CFLAGS=$CFLAGS
LD=$LD
LDFLAGS=$LDFLAGS
AR=$AR
ARFLAGS=$ARFLAGS
RANLIB=$RANLIB
WINDRES=$WINDRES
cursesLib=$cursesLib
ncursesLib=$ncursesLib
zlibInc=$zlibInc
LZ4Inc=$LZ4Inc
zlibDep=$zlibDep
LZ4Dep=$LZ4Dep
zlibLib=$zlibLib
LZ4Lib=$LZ4Lib
zlibHeaderDep=$zlibHeaderDep
LZ4HeaderDep=$LZ4HeaderDep
Kernel=\${${Kernel}}
KernelLinkDeps=\${${Kernel}LinkDeps}
KernelLinkLibs=\${${Kernel}LinkLibs}
END