Subversion Repositories tendra.SVN

Rev

Rev 2 | Rev 6 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 7u83 1
#!/bin/sh
2
#
3
#   		 Crown Copyright (c) 1997, 1998
4
#   
5
#   This TenDRA(r) Computer Program is subject to Copyright
6
#   owned by the United Kingdom Secretary of State for Defence
7
#   acting through the Defence Evaluation and Research Agency
8
#   (DERA).  It is made available to Recipients with a
9
#   royalty-free licence for its use, reproduction, transfer
10
#   to other parties and amendment for any purpose not excluding
11
#   product development provided that any such use et cetera
12
#   shall be deemed to be acceptance of the following conditions:-
13
#   
14
#       (1) Its Recipients shall ensure that this Notice is
15
#       reproduced upon any copies or amended versions of it;
16
#   
17
#       (2) Any amended version of it shall be clearly marked to
18
#       show both the nature of and the organisation responsible
19
#       for the relevant amendment or amendments;
20
#   
21
#       (3) Its onward transfer from a recipient to another
22
#       party shall be deemed to be that party's acceptance of
23
#       these conditions;
24
#   
25
#       (4) DERA gives no warranty or assurance as to its
26
#       quality or suitability for any purpose and DERA accepts
27
#       no liability whatsoever in relation to any use to which
28
#       it may be put.
29
#
30
 
31
 
32
#
33
# STANDARD DIRECTORIES
34
#
35
# These directories are used to configure where the release is to be
36
# installed:
37
#
38
#	BASE_DIR	gives the directory in which the source has been
39
#			installed (i.e. the directory containing this script).
40
#
41
#	PUBLIC_BIN	gives the directory in which the public executables
42
#			(tcc, tchk and tspec) are to be installed.  If
43
#			PUBLIC_BIN is left blank then the public executables
44
#			will be installed in the private executables
45
#			directory.
46
#
47
#	INSTALL_DIR	gives the directory in which the configuration files,
48
#			include files, private executables, libraries etc.
49
#			are to be installed.
50
#
51
#	COMMON_DIR	gives the sub-directory of INSTALL_DIR in which the
52
#			target independent components are to be installed.
53
#
54
#	MACH_DIR	gives the sub-directory of INSTALL_DIR in which the
55
#			target dependent components are to be installed.
56
#
57
#	MAN_DIR		gives the directory in which the manual pages are
58
#			to be installed.
59
#
60
#	WORK_DIR	gives the working directory in which binary object
61
#			files etc. created during the build process will
62
#			be stored.
63
#
64
#	TMP_DIR		gives a temporary directory, used both by this
65
#			script and by tcc (so make sure that there is
66
#			plenty of free space).
67
#
68
 
69
BASE_DIR=/usr/local/src/TenDRA-4.1.2
70
PUBLIC_BIN=/usr/local/bin
71
INSTALL_DIR=/usr/local/lib/TenDRA
72
COMMON_DIR=${INSTALL_DIR}/lib
73
MACH_DIR=${INSTALL_DIR}/machines
74
MAN_DIR=/usr/local/man
75
WORK_DIR=${BASE_DIR}/work
76
TEMP_DIR=/var/tmp
77
 
78
 
79
#
80
# BUILD OPTIONS
81
#
82
# These flags control which components of the release should be installed.
83
#
84
# If BUILD_UPDATE is true then the public executables and their configuration
85
# files will be installed (this has to be done on every target platform).
86
#
87
# If BUILD_MACHINE is true then all the other target dependent components
88
# will be installed (this also has to be done on every target platform).
89
#
90
# If BUILD_COMMON is true then the target independent components will be
91
# installed (this only has to be done once, indeed if the release is being
92
# built simultaneously on several platforms then the builds can conflict
93
# with each other, so start the quickest machine off first to install
94
# the complete release, and get the other machines to only install the
95
# target dependent sections).
96
#
97
# BUILD_OK is set to false if an error occurs.
98
#
99
# COMMENT controls whether or not this script prints comments as it goes
100
# along.
101
#
102
 
103
BUILD_UPDATE=true
104
BUILD_MACHINE=true
105
BUILD_COMMON=true
106
BUILD_OK=true
107
COMMENT=echo
108
 
109
 
110
#
111
# COMPILER INFORMATION
112
#
113
# These variables give information on the compiler to be used to install
114
# the release.  CC gives the compiler. CCOPTS and LIBOPTS give any target
115
# specific options required by the build, and are set by this script.  It
116
# is recommended that any extra flags which the user requires are made
117
# part of the definition of CC, so CC="gcc -O" would install using gcc
118
# in optimising mode.  TCCOPTS controls the extra configuration options
119
# required when bootstrapping the system using tcc.  It should be set to:
120
#
121
#	TCCOPTS=			for tcc,
122
#	TCCOPTS="TCCOPTS="		for other compilers.
123
#
124
# To install the bootstrapped compiler, install first using cc or gcc.
125
# Then remove the work directory (WORK_DIR), change the compiler to tcc,
126
# and install again.  Bootstrapping is recommended (all our testing is
127
# on the bootstrapped compiler).
128
#
129
# SYS_INCLUDES gives a list of include file directories to be searched
130
# when building the TDF API libraries.
131
#
132
# STRIP may be set to "strip" in order to ensure that the installed
133
# executables are stripped.
134
#
135
# RANLIB is used on those platforms on which system libraries need to be
136
# ranlib-ed.
137
#
138
# EXEC_SUFFIX is used on those platforms where executable names need to
139
# have a particular suffix, for example it may be set to ".exe".
140
#
141
 
142
CC=cc
143
CCOPTS=
144
LIBOPTS=
145
TCCOPTS="TCCOPTS="
146
SYS_INCLUDES="-I/usr/include"
147
STRIP=:
148
RANLIB=ranlib
149
EXEC_SUFFIX=
150
 
151
 
152
#
153
# COMMAND LINE ARGUMENTS
154
#
155
# The easiest way of configuring this installation script is by direct
156
# editing, however these command line options may be used to make minor
157
# alterations.
158
#
159
 
160
for ARG in $*
161
do
162
    case ${ARG} in
163
    -cc)		CC=cc ; TCCOPTS="TCCOPTS=" ;;
164
    -gcc)		CC=gcc ; TCCOPTS="TCCOPTS=" ;;
165
    -tcc)		CC=tcc ; TCCOPTS="" ;;
166
    -g)			CC="${CC} -g" ;;
167
    -O)			CC="${CC} -O" ;;
168
    -exe)		EXEC_SUFFIX=".exe" ;;
169
    -quiet)		COMMENT=":" ;;
170
    -strip)		STRIP=strip ;;
171
    -target)		BUILD_COMMON=false ;;
172
    -update)		BUILD_COMMON=false ; BUILD_MACHINE=false ;;
173
    *)			${COMMENT} "Unknown option, ${ARG}" ;;
174
    esac
175
done
176
 
177
 
178
#
179
# PRINT THE COPYRIGHT NOTICE
180
#
181
# The copyright notice is printed.  This also checks for the most common
182
# error, running INSTALL before configuring it to the system.
183
#
184
 
185
if [ ! -f ${BASE_DIR}/COPYRIGHT ]
186
then
187
    ${COMMENT} "Please set BASE_DIR in the INSTALL script"
188
    exit 1
189
fi
190
 
191
cat ${BASE_DIR}/COPYRIGHT
192
 
193
 
194
#
195
# FIND HOST TYPE
196
#
197
# The method for finding the operating system type, operating system version
198
# and CPU type is decidedly dirty.  A program tuname, similar to uname, but
199
# more uniform across platforms, is installed.  Feel free to hack tuname
200
# around if it doesn't work properly.
201
#
202
 
203
${COMMENT} building host type determiner, tuname ...
204
TUNAME=${TEMP_DIR}/tuname_$$${EXEC_SUFFIX}
205
MACH_HEADER=${TEMP_DIR}/mach_$$.h
206
SRC=${BASE_DIR}/src/utilities/tuname
207
cd ${TEMP_DIR} || exit 1
208
make -f ${SRC}/Makefile CC="${CC}" ${TCCOPTS}\
209
    BASE=${BASE_DIR} NAME=${TUNAME} all
210
if [ -f ${TUNAME} ]
211
then
212
    MACH_OS=`${TUNAME} -s`
213
    MACH_VERS=`${TUNAME} -r`
214
    MACH_CPU=`${TUNAME} -m`
215
    MACH_EXEC=`${TUNAME} -e`
216
    ${TUNAME} -D > ${MACH_HEADER}
217
    rm -f ${TUNAME}
218
    if [ "X${MACH_OS}X" = "XunknownX" ]
219
    then
220
	${COMMENT} Unknown machine type
221
	exit 1
222
    fi
223
else
224
    ${COMMENT} Unknown machine type
225
    exit 1
226
fi
227
 
228
${COMMENT}
229
${COMMENT} Operating system = ${MACH_OS}
230
${COMMENT} Operating system version = ${MACH_VERS}
231
${COMMENT} Processor type = ${MACH_CPU}
232
${COMMENT} Executable type = ${MACH_EXEC}
233
 
234
 
235
#
236
# FIND MACHINE DEPENDENT FLAGS
237
#
238
# The target specific options required to build the system on the various
239
# platforms are stored in separate configuration files.  Feel free to add
240
# or modify these files as necessary.
241
#
242
 
243
MACH_OPTS=${BASE_DIR}/src/build/${MACH_OS}.opt
244
if [ -f ${MACH_OPTS} ]
245
then
246
    . ${MACH_OPTS}
247
fi
248
 
249
 
250
#
251
# CREATE DIRECTORIES
252
#
253
# All the directories required for the installation are created.  The PATH
254
# is also set to pick up the private and public executables during
255
# installation.
256
#
257
 
258
MACH_BASE=${MACH_DIR}/${MACH_OS}/${MACH_VERS}/${MACH_CPU}
259
MACH_WORK=${WORK_DIR}/${MACH_OS}/${MACH_VERS}/${MACH_CPU}
260
 
261
if [ "X${PUBLIC_BIN}X" = "XX" ]
262
then
263
	PUBLIC_BIN=${MACH_BASE}/bin
264
fi
265
 
266
PATH=${MACH_BASE}/bin:${PUBLIC_BIN}:/usr/ccs/bin:${PATH}
267
export PATH
268
 
269
if ${BUILD_UPDATE}
270
then
271
    CREATE_DIRS="${MACH_DIR}\
272
		 ${MACH_DIR}/${MACH_OS}\
273
		 ${MACH_DIR}/${MACH_OS}/${MACH_VERS}\
274
		 ${MACH_BASE}\
275
		 ${MACH_BASE}/bin\
276
		 ${MACH_BASE}/env\
277
		 ${MACH_BASE}/lib\
278
		 ${MACH_BASE}/lib/diag\
279
		 ${MACH_BASE}/lib/sys\
280
		 ${PUBLIC_BIN}"
281
else
282
    CREATE_DIRS=
283
fi
284
 
285
if ${BUILD_MACHINE}
286
then
287
    MACH_DIRS="${WORK_DIR} ${WORK_DIR}/${MACH_OS}\
288
	       ${WORK_DIR}/${MACH_OS}/${MACH_VERS}\
289
	       ${MACH_WORK}"
290
else
291
    MACH_DIRS=
292
fi
293
 
294
if ${BUILD_COMMON}
295
then
296
    COMMON_DIRS="${INSTALL_DIR}\
297
		 ${COMMON_DIR}\
298
		 ${MAN_DIR}\
299
		 ${MAN_DIR}/man1\
300
		 ${MAN_DIR}/man5"
301
else
302
    COMMON_DIRS=
303
fi
304
 
305
for DIR in ${COMMON_DIRS} ${CREATE_DIRS} ${MACH_DIRS}
306
do
307
    if [ ! -d ${DIR} ]
308
    then
309
	${COMMENT} creating ${DIR} ...
310
	mkdir ${DIR} || exit 1
311
    fi
312
done
313
 
314
${COMMENT}
315
 
316
 
317
#
318
# BUILD PROGRAMS
319
#
320
# The various program executables are now built.  The list of executables
321
# is stored in the PROGRAMS file.  Note that each executable has its own
322
# Makefile which can be used to install the executable in isolation, or
323
# during development work.
324
#
325
 
326
MACH_SED=${TEMP_DIR}/mach$$.sed
327
cat > ${MACH_SED} << EOF
328
1,\$s/MACH_OS/${MACH_OS}/g
329
1,\$s/MACH_CPU/${MACH_CPU}/g
330
EOF
331
 
332
for PROG in `sed -f ${MACH_SED} ${BASE_DIR}/src/build/PROGRAMS`
333
do
334
    NAME=`echo ${PROG} | sed -e 's/:.*//'`
335
    SRC=${BASE_DIR}/src/`echo ${PROG} | sed -e 's/.*://'`
336
 
337
    #
338
    # Build program
339
    #
340
 
341
    if ${BUILD_MACHINE}
342
    then
343
	${COMMENT} building ${NAME} ...
344
	if [ ! -d ${MACH_WORK}/${NAME} ]
345
	then
346
	    ${COMMENT} creating ${MACH_WORK}/${NAME} ...
347
	    mkdir ${MACH_WORK}/${NAME} || exit 1
348
	fi
349
	cd ${MACH_WORK}/${NAME} || exit 1
350
	EXEC=${MACH_BASE}/bin/${NAME}${EXEC_SUFFIX}
351
	make -f ${SRC}/Makefile CC="${CC} ${CCOPTS}" ${TCCOPTS}\
352
	    BASE=${BASE_DIR} NAME=${EXEC} all || BUILD_OK=false
353
	if [ -f ${EXEC} ]
354
	then
355
	    ${STRIP} ${EXEC}
356
	else
357
	    ${COMMENT} compilation failed ...
358
	    BUILD_OK=false
359
	fi
360
	${COMMENT}
361
    fi
362
 
363
    #
364
    # Copy manual pages
365
    #
366
 
367
    if ${BUILD_COMMON}
368
    then
369
	for SUFFIX in 1 5
370
	do
371
	    for MANPAGE in ${SRC}/*.${SUFFIX}
372
	    do
373
		if [ -f ${MANPAGE} ]
374
		then
375
		    NEWPAGE=${MAN_DIR}/man${SUFFIX}/`basename ${MANPAGE}`
376
		    rm -f ${NEWPAGE}
377
		    cp ${MANPAGE} ${NEWPAGE}
378
		fi
379
	    done
380
	done
381
    fi
382
done
383
 
384
rm -f ${MACH_SED}
385
 
386
 
387
#
388
# BUILD DYNAMIC LINKER
389
#
390
# On some platforms a dynamic linker is required to handle the TDF
391
# initial_value construct (used by C++'s non-constant initialisation etc.).
392
# This is built at this stage.
393
#
394
 
395
if ${BUILD_MACHINE}
396
then
397
    ${COMMENT} building machine dependent components ...
398
    SRC=${BASE_DIR}/src/lib/machines/${MACH_OS}/${MACH_CPU}/src
399
    if [ -f ${SRC}/Makefile ]
400
    then
401
	cd ${MACH_BASE}/lib/sys || exit 1
402
	make -f ${SRC}/Makefile CC="${CC} ${CCOPTS}" ${TCCOPTS}\
403
	    BASE=${BASE_DIR} pre || BUILD_OK=false
404
	${COMMENT}
405
    fi
406
fi
407
 
408
 
409
#
410
# INSTALL ENVIRONMENTS
411
#
412
# The user interfaces to the TenDRA compiler, tcc and tchk, use configuration
413
# files called environments to configure them to the particular details of
414
# the platform on which they are installed (including where the private
415
# executables, libraries etc. are to be found).  If the release is moved
416
# then only the environments need to be re-installed, by setting BUILD_UPDATE
417
# to true, but BUILD_COMMON and BUILD_MACHINE to false.
418
#
419
 
420
if ${BUILD_UPDATE}
421
then
422
    ${COMMENT} installing tcc environments ...
423
 
424
    ENV_SED=${TEMP_DIR}/env$$.sed
425
    cat > ${ENV_SED} << EOF
426
1,\$s%-MACH-%${MACH_OS}/${MACH_CPU}%g
427
1,\$s%-MACHDIR-%${MACH_BASE}%g
428
1,\$s%-BINDIR-%${MACH_BASE}/bin%g
429
1,\$s%-ENVDIR-%${MACH_BASE}/env%g
430
1,\$s%-LIBDIR-%${MACH_BASE}/lib%g
431
1,\$s%-INCLDIR-%${COMMON_DIR}/include%g
432
1,\$s%-STARTUPDIR-%${COMMON_DIR}/startup%g
433
1,\$s%-TMPDIR-%${TEMP_DIR}%g
434
EOF
435
 
436
    cd ${MACH_BASE}/env || exit 1
437
    SRC=${BASE_DIR}/src/lib/env
438
    ENVIRON_DIRS="${SRC}/common\
439
		  ${SRC}/${MACH_OS}/common/common\
440
		  ${SRC}/${MACH_OS}/common/${MACH_CPU}\
441
		  ${SRC}/${MACH_OS}/${MACH_EXEC}/common\
442
		  ${SRC}/${MACH_OS}/${MACH_EXEC}/${MACH_CPU}\
443
		  ${SRC}/${MACH_OS}/${MACH_VERS}/common\
444
		  ${SRC}/${MACH_OS}/${MACH_VERS}/${MACH_CPU}"
445
 
446
    for DIR in ${ENVIRON_DIRS}
447
    do
448
	if [ -d ${DIR} ]
449
	then
450
	    for ENVFILE in ${DIR}/*
451
	    do
452
		if [ -f ${ENVFILE} ]
453
		then
454
		    NEWFILE=`basename ${ENVFILE}`
455
		    ${COMMENT} ${ENVFILE} '->' ${NEWFILE}
456
		    rm -f ${NEWFILE}
457
		    sed -f ${ENV_SED} ${ENVFILE} > ${NEWFILE}
458
		fi
459
	    done
460
	fi
461
    done
462
 
463
    ${COMMENT} default.extra '>>' default
464
    rm -f default.new
465
    cat default default.extra > default.new
466
    rm -f default
467
    mv default.new default
468
    rm -f ${ENV_SED}
469
    ${COMMENT}
470
fi
471
 
472
 
473
#
474
# INSTALL WRAPPER FUNCTIONS
475
#
476
# The public executables are actually wrapper scripts which call the
477
# actual programs from the private executables directory with the appropriate
478
# configuration options.
479
#
480
 
481
if ${BUILD_UPDATE}
482
then
483
    ${COMMENT} installing tcc ...
484
    rm -f ${PUBLIC_BIN}/tcc
485
    cat > ${PUBLIC_BIN}/tcc << EOF
486
#!/bin/sh
487
exec ${MACH_BASE}/bin/tcc1${EXEC_SUFFIX} -Y${MACH_BASE}/env/default \${@+"\$@"}
488
EOF
489
    chmod +x ${PUBLIC_BIN}/tcc
490
    ${COMMENT}
491
 
492
    ${COMMENT} installing tchk ...
493
    rm -f ${PUBLIC_BIN}/tchk
494
    cat > ${PUBLIC_BIN}/tchk << EOF
495
#!/bin/sh
496
exec ${MACH_BASE}/bin/tcc1${EXEC_SUFFIX} -Y${MACH_BASE}/env/default -ch \${@+"\$@"}
497
EOF
498
    chmod +x ${PUBLIC_BIN}/tchk
499
    ${COMMENT}
500
 
501
    ${COMMENT} installing tspec ...
502
    rm -f ${PUBLIC_BIN}/tspec
503
    cat > ${PUBLIC_BIN}/tspec << EOF
504
#!/bin/sh
505
TSPEC_INPUT=${BASE_DIR}/src/lib/apis
506
TSPEC_INCL_OUTPUT=${COMMON_DIR}/include
507
TSPEC_SRC_OUTPUT=${COMMON_DIR}/building
508
export TSPEC_INPUT TSPEC_INCL_OUTPUT TSPEC_SRC_OUTPUT
509
exec ${MACH_BASE}/bin/tspec1${EXEC_SUFFIX} \${@+"\$@"}
510
EOF
511
    chmod +x ${PUBLIC_BIN}/tspec
512
    ${COMMENT}
513
fi
514
 
515
 
516
#
517
# INSTALL START-UP FILES
518
#
519
# The machine independent compiler configuration files are installed
520
# (cp -r would do as well as tar, but not all machines support it).
521
#
522
 
523
if ${BUILD_COMMON}
524
then
525
    ${COMMENT} installing start-up files ...
526
    cd ${BASE_DIR}/src/lib || exit 1
527
    rm -f ${MACH_WORK}/startup.tar
528
    tar cvf ${MACH_WORK}/startup.tar startup
529
    cd ${COMMON_DIR} || exit 1
530
    rm -rf startup
531
    tar xvf ${MACH_WORK}/startup.tar
532
    rm -f ${MACH_WORK}/startup.tar
533
    ${COMMENT}
534
fi
535
 
536
 
537
#
538
# INSTALL API DESCRIPTIONS
539
#
540
# The TenDRA API descriptions for the various supported APIs are installed
541
# using the tspec executable built above.  The list of APIs is given in a
542
# separate file, APIS.
543
#
544
 
545
if ${BUILD_COMMON}
546
then
547
    for API in `cat ${BASE_DIR}/src/build/APIS`
548
    do
549
	${COMMENT} installing API ${API} ...
550
	${PUBLIC_BIN}/tspec -w -v ${API}
551
	${COMMENT} all done
552
	${COMMENT}
553
    done
554
fi
555
 
556
 
557
#
558
# INSTALL MACHINE DEPENDENT HEADERS
559
#
560
# The machine dependent include files and configuration files are now
561
# installed.  These are used in particular during TDF API library building
562
# and when the compiler is configured to use the system headers.
563
#
564
 
565
if ${BUILD_MACHINE}
566
then
567
    ${COMMENT} installing machine dependent headers ...
568
    SRC=${BASE_DIR}/src/lib/machines/${MACH_OS}/${MACH_CPU}
569
    if [ -d ${SRC} ]
570
    then
571
	cd ${SRC} || exit 1
572
	rm -f ${MACH_WORK}/machine.tar
573
	tar cvf ${MACH_WORK}/machine.tar include startup
574
	cd ${MACH_BASE} || exit 1
575
	rm -rf include
576
	rm -rf startup
577
	tar xvf ${MACH_WORK}/machine.tar
578
	rm -f ${MACH_WORK}/machine.tar
579
	cp ${MACH_HEADER} startup/machine.h
580
    fi
581
    ${COMMENT}
582
fi
583
rm -f ${MACH_HEADER}
584
 
585
 
586
#
587
# BUILD MACHINE DEPENDENT COMPONENTS
588
#
589
# Any machine dependent libraries etc. are now built.  This includes the
590
# basic TDF token definitions which describe the machine to the compiler.
591
#
592
 
593
if ${BUILD_MACHINE}
594
then
595
    ${COMMENT} building machine dependent components ...
596
    SRC=${BASE_DIR}/src/lib/machines/${MACH_OS}/${MACH_CPU}/src
597
    if [ -f ${SRC}/Makefile ]
598
    then
599
	cd ${MACH_BASE}/lib/sys || exit 1
600
	make -f ${SRC}/Makefile CC="${CC} ${CCOPTS}" ${TCCOPTS}\
601
	    BASE=${BASE_DIR} all || BUILD_OK=false
602
    fi
603
    ${COMMENT}
604
fi
605
 
606
 
607
#
608
# BUILD API LIBRARIES
609
#
610
# And now the tricky bit.  The TDF API libraries are built from the TenDRA
611
# API descriptions and the implementation of the API as described in the
612
# system headers.
613
#
614
# Although this has been tested to the operating system versions listed
615
# in the supported platforms section of the release notes, it is possible
616
# that it may fail for other operating system versions.  Provided the
617
# ansi library builds, you have enough to play with, but to get other
618
# libraries through, you may need to modify the machine dependent include
619
# and start-up files in src/lib/machines/<os>/<cpu>, using the existing
620
# files as a template.  If you get really stuck; you've read all the
621
# documentation, and looked at all what I've done in similar circumstances,
622
# you can email me (Rob) at the address on the web page, but make this a
623
# last resort - I do have other things to do.
624
#
625
# Note that each library is built twice, firstly without diagnostic
626
# information and secondly with.  Really only the ones with diagnostics
627
# are required (the diagnostic information is ignored if not needed),
628
# but building both is traditional.
629
#
630
 
631
DIAG_MSG=
632
DIAG_CC=tcc
633
 
634
for LIBDIR in lib lib/diag
635
do
636
 
637
    #
638
    # Build basic token definitions
639
    #
640
 
641
    if ${BUILD_MACHINE}
642
    then
643
	${COMMENT} building basic C token definitions${DIAG_MSG} ...
644
	if [ ! -d ${MACH_WORK}/${LIBDIR} ]
645
	then
646
	    ${COMMENT} creating ${MACH_WORK}/${LIBDIR} ...
647
	    mkdir ${MACH_WORK}/${LIBDIR} || exit 1
648
	fi
649
	for API in `cat ${BASE_DIR}/src/build/APIS` ansi cpp
650
	do
651
	    API_NAME=`echo ${API} | sed -e 's%/%_%g'`
652
	    if [ ! -d ${MACH_WORK}/${LIBDIR}/${API_NAME} ]
653
	    then
654
		${COMMENT} creating ${MACH_WORK}/${LIBDIR}/${API_NAME} ...
655
		mkdir ${MACH_WORK}/${LIBDIR}/${API_NAME} || exit 1
656
	    fi
657
	done
658
 
659
	SRC=${BASE_DIR}/src/lib/machines/${MACH_OS}/${MACH_CPU}/tokens
660
	if [ -d ${SRC} ]
661
	then
662
	    cd ${MACH_WORK}/${LIBDIR}/ansi || exit 1
663
	    make -f ${SRC}/Makefile TCC="${DIAG_CC}" BASE=${BASE_DIR}\
664
		basic || BUILD_OK=false
665
	fi
666
	${COMMENT}
667
 
668
	SRC=${BASE_DIR}/src/lib/cpp/tokens
669
	if [ -d ${SRC} ]
670
	then
671
	    ${COMMENT} building basic C++ token definitions${DIAG_MSG} ...
672
	    cd ${MACH_WORK}/${LIBDIR}/cpp || exit 1
673
	    make -f ${SRC}/Makefile TCC="${DIAG_CC}" BASE=${BASE_DIR}\
674
		all || BUILD_OK=false
675
	    ${COMMENT}
676
	fi
677
    fi
678
 
679
 
680
    #
681
    # Build API token libraries
682
    #
683
 
684
    if ${BUILD_MACHINE}
685
    then
686
	cd ${MACH_WORK}/${LIBDIR} || exit 1
687
	for API in `cat ${BASE_DIR}/src/build/APIS`
688
	do
689
	    API_NAME=`echo ${API} | sed -e 's%/%_%g'`
690
	    SRC=${COMMON_DIR}/building/${API}.api
691
	    if [ -d ${SRC} ]
692
	    then
693
		${COMMENT} building ${API} API token library${DIAG_MSG} ...
694
		rm -f ${API_NAME}/Makefile
695
		cat > ${API_NAME}/Makefile << EOF
696
BASE=${MACH_BASE}
697
LIB=\${BASE}/${LIBDIR}/${API_NAME}.tl
698
SRC=${COMMON_DIR}/building
699
STARTUP=\${BASE}/startup
700
WORK=.
701
TLIB=tld -mc
702
TDI=${DIAG_CC} -Fj -Ybuilding -Y32bit -I\${BASE}/include ${SYS_INCLUDES}
703
TDP=echo
704
EOF
705
		cat ${SRC}/Makefile >> ${API_NAME}/Makefile
706
		if [ -f ${MACH_BASE}/startup/${API_NAME}.h ]
707
		then
708
		    make -f ${API_NAME}/Makefile all || BUILD_OK=false
709
		else
710
		    ${COMMENT} skipped
711
		fi
712
		${COMMENT}
713
	    fi
714
	done
715
    fi
716
 
717
 
718
    #
719
    # Build TDF standard token library
720
    #
721
 
722
    if ${BUILD_MACHINE}
723
    then
724
	SRC=${BASE_DIR}/src/lib/machines/${MACH_OS}/${MACH_CPU}/tokens
725
	if [ -d ${SRC} ]
726
	then
727
	    ${COMMENT} building TDF standard token library${DIAG_MSG} ...
728
	    LIB=${MACH_BASE}/${LIBDIR}/target_tok.tl
729
	    cd ${MACH_WORK}/${LIBDIR}/ansi || exit 1
730
	    make -f ${SRC}/Makefile LIB=${LIB} TCC="${DIAG_CC}"\
731
		BASE=${BASE_DIR} all || BUILD_OK=false
732
	    ${COMMENT}
733
	fi
734
    fi
735
 
736
 
737
    #
738
    # Now build with diagnostics
739
    #
740
 
741
    DIAG_MSG=" (with diagnostics)"
742
    DIAG_CC="tcc -g"
743
done
744
 
745
 
746
#
747
# BUILD SUPPORT LIBRARIES
748
#
749
# The support libraries are now built.  The list of libraries to be built
750
# is stored in a separate file, LIBRARIES.  It bears repeating that the
751
# C++ support library only contains the minimum language support features.
752
#
753
 
754
if ${BUILD_MACHINE}
755
then
756
    SRC=${BASE_DIR}/src/lib/machines/common/src
757
    if [ -f ${SRC}/Makefile ]
758
    then
759
	${COMMENT} building crtp_n.o ...
760
	cd ${MACH_BASE}/lib/sys || exit 1
761
	make -f ${SRC}/Makefile BASE=${BASE_DIR} all || BUILD_OK=false
762
	${COMMENT}
763
    fi
764
    for PROG in `cat ${BASE_DIR}/src/build/LIBRARIES`
765
    do
766
	NAME=`echo ${PROG} | sed -e 's/:.*//'`
767
	SRC=${BASE_DIR}/src/`echo ${PROG} | sed -e 's/.*://'`
768
	if [ -f ${SRC}/Makefile ]
769
	then
770
	    ${COMMENT} building ${NAME} ...
771
	    if [ ! -d ${MACH_WORK}/${NAME} ]
772
	    then
773
		${COMMENT} creating ${MACH_WORK}/${NAME} ...
774
		mkdir ${MACH_WORK}/${NAME} || exit 1
775
	    fi
776
	    cd ${MACH_WORK}/${NAME} || exit 1
777
	    LIB=${MACH_BASE}/lib/sys/lib${NAME}.a
778
	    make -f ${SRC}/Makefile BASE=${BASE_DIR} NAME=${LIB}\
779
		MACHOPTS="${LIBOPTS}" RANLIB="${RANLIB}" all || BUILD_OK=false
780
	    if [ ! -f ${LIB} ]
781
	    then
782
		${COMMENT} compilation failed ...
783
		BUILD_OK=false
784
	    fi
785
	    ${COMMENT}
786
	fi
787
    done
788
fi
789
 
790
 
791
#
792
# END OF INSTALLATION SCRIPT
793
#
794
# Phew!
795
#
796
 
797
if ${BUILD_OK}
798
then
799
    ${COMMENT} installation completed successfully
800
else
801
    ${COMMENT} installation completed with errors
802
fi
803
exit 0