File: configure.gtc

package info (click to toggle)
fis-gtm 7.0-005-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 32,264 kB
  • sloc: ansic: 336,687; asm: 5,184; csh: 4,823; sh: 1,945; awk: 291; makefile: 72; sed: 13
file content (747 lines) | stat: -rwxr-xr-x 22,868 bytes parent folder | download
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
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
#!/bin/sh
#################################################################
#								#
# Copyright (c) 2009-2022 Fidelity National Information		#
# Services, Inc. and/or its subsidiaries. All rights reserved.	#
#								#
#	This source code contains the intellectual property	#
#	of its copyright holder(s), and is made available	#
#	under a license.  If you do not know the terms of	#
#	the license, please stop and do not read further.	#
#								#
#################################################################

. ./arch.gtc

# Path to the correct echo program
# depending on the list of locales configured, locale -a might be considered a binary output.
# grep needs -a option to process the output as text but -a is not supported on the non-linux servers we have.
if [ $arch = "linux" ]; then
	echo="/bin/echo -e"
	binaryopt="-a"
else
	echo=/bin/echo
	binaryopt=""
fi

# Options to ps
psopts="-ea"

# GTCM definitions
if [ -f gtcm_server ]; then
	deliver_gtcm="yes"
else
	deliver_gtcm="no"
fi

if [ -f gtcm_gnp_server ]; then
	deliver_gtcm_gnp="yes"
else
	deliver_gtcm_gnp="no"
fi

# create symbolic links if utf8 directory exists.  Ignore the "file exists" errors for the .o files
# which exist in both directories.

if [ -d utf8 ]; then
	(cd utf8; ln -s ../* . 2> /dev/null)
fi

# Native shared library extension.
ext=".so"

# Flags to build shared libraries of M routines
if [ "ibm" = $arch ] ; then ldflags="-brtl -G -bexpfull -bnoentry -b64" ; ldcmd="ld" # AIX
elif [ "linux" = $arch ] ; then ldflags="-shared" ; ldcmd="ld" # Linux - all platforms
else echo "Shared libary ldflags not set for this platform"; exit 1
fi

# Binaries
binaries="mupip mumps libgtmshr$ext lke dse"

# Normal scripts - executed by anyone
nscripts="gtmbase lowerc_cp"

# Root scripts - only executed by root
rscripts="gtmstart gtmstop"
if [ $deliver_gtcm = "yes" ]; then
	rscripts="$rscripts gtcm_run gtcm_slist"
	binaries="$binaries gtcm_server gtcm_pkdisp gtcm_play gtcm_shmclean"
fi

if [ $deliver_gtcm_gnp = "yes" ]; then
	binaries="$binaries gtcm_gnp_server"
fi

# Help files
hlpfiles="*help.dat *help.gld *.h"

# Other files (left here for future use)
ofiles="$hlpfiles"

# Files that need to have $gtm_dist, $echo, etc. set in them.
pathmods="gtmbase.gtc gtmstart.gtc gtmstop.gtc gtmcshrc.gtc gtmprofile.gtc gtm.gtc gtmprofile_preV54000.gtc gdedefaults.gtc"

# Files deprecated in various releases. These should explicitly removed if installation is done on an existing directory.
deprecatedfiles="geteuid semstat2 ftok"

if [ $deliver_gtcm = "yes" ]; then
	pathmods="$pathmods gtcm_run.gtc gtcm_slist.gtc"
fi

if [ "`whoami`" != "root" ] ; then
	$echo "You must run Configure as root."
	exit
fi

$echo "                     GT.M Configuration Script"
$echo "Copyright 2009-YYYY Fidelity Information Services, Inc. and/or its subsidiaries."
$echo "Use of this software is restricted by the provisions of your license agreement."
$echo ""

# Native super user and group
rootuser=root
bingroup=bin
defowner=bin

# create temporary file to test for valid user and group names
touch tmp_owngrp
$echo "What user account should own the files? ($defowner) \c"
read resp
if [ "$resp" = "" ] ; then
	owner=$defowner
else
	owner=$resp
fi

chown $owner tmp_owngrp 2> /dev/null
if [ 0 != "$?" ] ; then
	$echo $owner is not a valid user name - exiting!
	rm tmp_owngrp
	exit
fi

$echo "What group should own the files? ($bingroup) \c"
read resp
if [ "$resp" != "" ] ; then
	bingroup=$resp
fi

chgrp $bingroup tmp_owngrp 2> /dev/null
if [ 0 != "$?" ] ; then
	$echo $bingroup is not a valid group name - exiting!
	rm tmp_owngrp
	exit 1
fi

$echo "Should execution of GT.M be restricted to this group? (y or n) \c"
read resp
if [ "$resp" = "Y" -o "$resp" = "y" ] ; then
	# root and bin are invalid groups to be restricted
	if [ 0 = $bingroup -o "bin" = $bingroup -o "root" = $bingroup ] ; then
		$echo GTM-E-GROUPNOTVALID - $bingroup not allowed to be a restricted group - exiting!
		exit 1
	fi
	# for all owners other than root or bin do an owner in group membership check
	if [ 0 != $owner -a "bin" != $owner -a "root" != $owner -a  `groups $owner | grep -w -c $bingroup` -eq 0 ] ; then
		$echo GTM-E-NOTINGROUP - $owner is not a member of $bingroup - exiting!
		exit 1
	fi
	group=$bingroup
fi

rm tmp_owngrp

$echo "In what directory should GT.M be installed? \c"
read gtmdist

# if gtmdist is relative then need to make it absolute

if [ `$echo $gtmdist | grep -c '^/'` -eq 0 ] ; then
    gtmdist=`pwd`/$gtmdist
fi

# ensure that canonical paths do not exceed PATH_MAX
getconf PATH_MAX $gtmdist | \
	awk '{max=$0-max;if(max<0)max+=1024;if(length(dist)>max){print dist" exceeds the maximum path length: "max;exit 1}}' \
		dist=$gtmdist max=50 || exit
$echo ""

if [ -d $gtmdist ]; then
	$echo "Directory $gtmdist exists. If you proceed with this installation then"
	$echo "some files will be over-written. Is it ok to proceed? (y or n) \c"
else
	$echo "Directory $gtmdist does not exist. Do you wish to create it as part of"
	$echo "this installation? (y or n) \c"
fi
read resp
if [ "$resp" = "Y" -o "$resp" = "y" ] ; then
	mkdir -p        $gtmdist
	chmod ug-s,-t   $gtmdist
	mkdir -p        $gtmdist/plugin/r $gtmdist/plugin/o
	chmod 0755      $gtmdist/plugin/r $gtmdist/plugin/o $gtmdist
	chown $owner    $gtmdist/plugin/r $gtmdist/plugin/o $gtmdist
	chgrp $bingroup $gtmdist/plugin/r $gtmdist/plugin/o $gtmdist
	remove_deprecated=1
else
	exit
fi

if [ ! -w $gtmdist ]; then
	$echo "Directory $gtmdist is not writeable, so exiting"
	exit
fi

server_id=42

$echo ""
$echo "Installing GT.M...."
$echo ""

is64bit_gtm=`file mumps | grep -c 64.bit`

if [ -d "utf8" ]; then
	unset icu_version
	doutf8=1
	# If package has utf8 directory, see if system has libicu and locale
	$echo "Should UTF-8 support be installed? (y or n) \c"
	read resp
	if [ "$resp" = "Y" -o "$resp" = "y" ] ; then
		if [ -x "$(command -v pkg-config)" -a $(pkg-config --exists icu-io; echo $?) -eq 0 ]; then
			versioncmd="pkg-config --modversion icu-io"
			libcmd="pkg-config --variable=libdir icu-io"
		elif [ -x "$(command -v icu-config)" ] ; then
			versioncmd="icu-config --version"
			libcmd="icu-config --libdir"
		elif [ -x "$(command -v pkg-config)" -a $(pkg-config --exists icu; echo $?) -eq 0 ]; then
			versioncmd="pkg-config --modversion icu"
			libcmd="pkg-config --variable=libdir icu"
		fi
		if [ -n "$versioncmd" ]; then
			icu_version=`$versioncmd | awk '{ver=+$0;if(ver>5){ver=ver/10}printf("%.1f\n",ver);exit}'`
			extendlibpath=`$libcmd`
		fi
		if [ "$icu_version" != "" ] ; then
			maj=`$echo $icu_version | cut -f 1 -d "."`
			if [ "$maj" -ge "49" ] ; then
				# Assuming the input is of the form 52.1. As of ICU 49 (aka 4.9),
				# the version reported by icu-config --version is <major><minor>.<milli> and not <major>.<minor>
				majmin=$maj
			else
				# Assuming the input is of the form 4.2.1
				majmin=`$echo $icu_version | cut -d "." -f 1,2 | sed 's/\.//'`
			fi
			if [ "$majmin" -lt "36" ] ; then
				$echo "ICU version version found : $icu_version"
				$echo "Install ICU version 3.6 or above to enable UTF-8 support."
				doutf8=0
			fi
		else
			$echo "Could not find ICU version in the default location."
			doutf8=0
		fi
		# Look for locale
		utflocale=`locale -a | grep $binaryopt -iE '\.utf.?8$' | head -n1`
		if [ "$utflocale" = "" ] ; then
			$echo "UTF-8 locale not found."
			doutf8=0
		fi
		if [ "$doutf8" -eq 0 ] ; then
			$echo "UTF-8 support was requested, but not all dependencies were satisfied."
			$echo "Please fix the above and re-run installation."
			exit 1
		fi
		if [ "$doutf8" -eq 1 -a "linux" = $arch ]; then
			# We do not recommend setting gtm_icu_version on AIX
			gtm_icu_version=$icu_version
			export gtm_icu_version
		fi
	else
		doutf8=0
	fi
else
	# If utf8 dir does not exist in package, can't install UTF-8 support
	doutf8=0
fi

# Solaris 10 bourne shell does not support ${var#word} syntax
install_dest=$gtmdist
if [ X"$gtm_destdir" != X"" ] ; then
	install_dest=`echo $install_dest | sed "s;${gtm_destdir};;"`
fi

# Modify the scripts as necessary for target configuration
cat << SEDSCRIPT > sedin$$
s|ARCH|$arch|g
s|ECHO|"$echo"|g
s|GTMDIST|${install_dest}|g
s|SERVERID|$server_id|g
SEDSCRIPT
for i in $pathmods
do
	dest=`basename $i .gtc`
	sed -f sedin$$ $i > $dest
	if [ "$doutf8" -ne 0 ]; then
		cd utf8
		if ( test -f "$dest" ) then rm $dest; fi
		ln -fs ../$dest $dest
		cd ..
	fi
done
rm sedin$$
if [ "$doutf8" -ne 0 ]; then
	if [ ! -d $gtmdist/utf8 ]; then
		mkdir -p $gtmdist/utf8 $gtmdist/plugin/o/utf8
		chmod 0755 $gtmdist/utf8 $gtmdist/plugin/o/utf8
		chown ${owner}:${bingroup} $gtmdist/utf8 $gtmdist/plugin/o/utf8
	fi
fi

# Remove deprecated files first if applicable
if [ -n "$remove_deprecated" ]; then
	$echo ""
	$echo "Checking for deprecated files in $gtmdist"
	$echo ""
	for file in $deprecatedfiles
	do
		if [ -f "$gtmdist/$file" -o -f "$gtmdist/utf8/$file" ]; then
			echo "	Removing $file"
			rm -f $gtmdist/$file $gtmdist/utf8/$file
		fi
	done
fi

# Install COPYING if it is applicable
file=COPYING
if [ -f $file ]; then
	cp -p $file $gtmdist
	if [ "$doutf8" -ne 0 ]; then
		ln -fs ../$file $gtmdist/utf8/$file
	fi
fi

# Install README.txt if it is applicable
file=README.txt
if [ -f $file ]; then
	cp -p $file $gtmdist
	if [ "$doutf8" -ne 0 ]; then
		ln -fs ../$file $gtmdist/utf8/$file
	fi
fi

# Install custom_errors_sample.txt if it is applicable
file=custom_errors_sample.txt
if [ -f $file ]; then
	cp -p $file $gtmdist
	if [ "$doutf8" -ne 0 ]; then
		ln -fs ../$file $gtmdist/utf8/$file
	fi
fi
# Install the .cshrc and .profile files
cp -p gdedefaults gtmgblstat.xc gtmprofile gtmprofile_preV54000 gtm gtmcshrc $gtmdist
chmod 0444 $gtmdist/gdedefaults
chown $owner $gtmdist/gdedefaults
chmod 0444 $gtmdist/gtmgblstat.xc
chown $owner $gtmdist/gtmgblstat.xc
chmod 0755 $gtmdist/gtmprofile
chown $owner $gtmdist/gtmprofile
chmod 0755 $gtmdist/gtmprofile_preV54000
chown $owner $gtmdist/gtmprofile_preV54000
chmod 0755 $gtmdist/gtm
chown $owner $gtmdist/gtm
chmod 0755 $gtmdist/gtmcshrc
chown $owner $gtmdist/gtmcshrc

# Install the normal scripts
for i in $nscripts
do
	cp -p $i $gtmdist
	chmod 0755 $gtmdist/$i
	chown $owner $gtmdist/$i
done

# Install the root scripts
for i in $rscripts
do
	cp -p $i $gtmdist
	chmod 0744 $gtmdist/$i
	chown $rootuser $gtmdist/$i
done

# Install the normal binaries
for i in $binaries
do
	if [ $arch = "linux" ]; then
		install -g $bingroup -o $owner -m 644 $i $gtmdist
	elif [ $arch = "ibm" ]; then
		/usr/bin/install -f $gtmdist -M 644 -O $owner -G $bingroup $i
	elif [ -x /usr/sbin/install ]; then
		/usr/sbin/install -f $gtmdist -m 644 -u $owner -g $bingroup $i $gtmdist
	else
		install -f $gtmdist -m 644 -u $owner -g $bingroup $i $gtmdist
	fi
#		strip $gtmdist/$i >/dev/null 2>&1
done

# Install other individual files
for i in  $ofiles
do
	cp -p $i $gtmdist
	chown $owner $gtmdist/$i
done

# For linux systems, attempt to execute the chcon command to allow use of the libgtmshr shared library. This
# command is required on many modern SELinux based systems but depends on the filesystem in use (requires context
# support). For that reason, we attempt the command and if it works, great. If it doesn't, oh well we tried.
if [ -f /usr/bin/chcon ]; then
	chcon -t texrel_shlib_t $gtmdist/libgtmshr$ext > /dev/null 2>&1
fi

# Create $gtmdist/plugin/gtmcrypt directory if this platform supports encryption

# Define variables to denote plugin and gtmcrypt directory names
plugin="plugin"
plugin_gtmcrypt="$plugin/gtmcrypt"

# Gtmcrypt scripts
gtmcryptscripts="gen_sym_key.sh encrypt_sign_db_key.sh gen_keypair.sh pinentry-gtm.sh"
gtmcryptscripts="$gtmcryptscripts import_and_sign_key.sh gen_sym_hash.sh show_install_config.sh"

# Gtmcrypt related M file
gtmcryptmfile="pinentry.m"

# Gtmcrypt source files
gtmcryptsrcfiles="Makefile README gtmcrypt_ref.c gtmcrypt_ref.h gtmcrypt_interface.h maskpass.c"
gtmcryptsrcfiles="$gtmcryptsrcfiles gtmcrypt_dbk_ref.c gtmcrypt_dbk_ref.h gtmcrypt_pk_ref.c gtmcrypt_pk_ref.h"
gtmcryptsrcfiles="$gtmcryptsrcfiles gtmcrypt_sym_ref.h gtmcrypt_sym_ref.c gtm_tls_interface.h gtm_tls_impl.h"
gtmcryptsrcfiles="$gtmcryptsrcfiles gtm_tls_impl.c gtmcrypt_util.c gtmcrypt_util.h $gtmcryptmfile"

dogtmcrypt=0
if [ -d "$plugin_gtmcrypt" ]; then
	dogtmcrypt=1
	# Create plugin directory and gtmcrypt directory
	mkdir -p $gtmdist/plugin/gtmcrypt
	chmod 0755 $gtmdist/plugin
	chown $owner $gtmdist/plugin
	chgrp $bingroup $gtmdist/plugin
	chmod 0755 $gtmdist/plugin/gtmcrypt
	chown $owner $gtmdist/plugin/gtmcrypt/
	chgrp $bingroup $gtmdist/plugin/gtmcrypt

	# Tar the source files
	cat > $plugin_gtmcrypt/README << EOF
#
# WARNING: This file was generated by the GT.M install script at install time.
#
# Dependency information:
#  Please install a compiler toolchain and libgcrypt, libgpgme, libconfig, and
#  libssl development libraries. On Debian you can do:
#    sudo apt-get install libgcrypt11-dev libgpgme11-dev libconfig-dev libssl-dev
#
# Installation instructions:
#  You may need to edit the Makefile to add include (IFLAGS) and library paths
#  (LIBFLAGS) for your system.
#
#  The commands below to compile, install and set the file permissions on the
#  encryption plugin libraries make the following assumptions:
#    - The shell is bourne shell compatible
#    - The user is root
#    - The permissions defined for the gtm installation are appropriate for the
#      plug-in
#
#  You should be able to cut and paste the following commands
#
gtm_dist="$gtmdist"
export gtm_dist
make && make install && make clean
find \$gtm_dist/plugin -type f -exec chown ${owner}:${bingroup} {} +
EOF
	if [ "$group" != "" ] ; then
		echo "chmod -R o-rwx \$gtm_dist/plugin" >> $plugin_gtmcrypt/README
	fi
	(cd $plugin_gtmcrypt			&& \
	 chmod 0644 $gtmcryptsrcfiles		&& \
	 chmod 0755 $gtmcryptscripts 		&& \
	 chown ${owner}:${bingroup} *		&& \
	 tar -cvf $gtmdist/$plugin_gtmcrypt/source.tar $gtmcryptsrcfiles $gtmcryptscripts >/dev/null 2>&1)
	chmod 0644 $gtmdist/$plugin_gtmcrypt/source.tar
	chown ${owner}:${bingroup} $gtmdist/$plugin_gtmcrypt/source.tar
	rm $plugin_gtmcrypt/README
	(cd $gtmdist/$plugin_gtmcrypt && tar -xvf source.tar)
fi

# Install GDE, GTMHELP, and all the percent routines
cp -p *.o *.m $gtmdist

# Install a mirror image (using soft links) of $gtmdist under $gtmdist/utf8 if this platform can support "UTF-8" mode.
if [ "$doutf8" -ne 0 ]; then
	cd utf8
	for file in *
	do
		# Skip directories
		if [ -d "$file" ]; then
			continue
		fi
		# Skip gtmsecshr/dir
		if [ "$file" = "gtmsecshr" -o "$file" = "gtmsecshrdir" ]; then
			continue
		fi
		# Install .o files
		base="`basename $file .o`"
		if [ "$base" != "$file" ]; then
			cp -p "$file" $gtmdist/utf8
		else
			# Soft link everything else
			if [ -f $gtmdist/utf8/"$file" ]; then
				rm -f $gtmdist/utf8/"$file"
			fi
			if [ -f $gtmdist/"$file" ]; then
				ln -fs ../"$file" $gtmdist/utf8/"$file"
			fi
		fi
	done
	if [ "$dogtmcrypt" -ne 0 ]; then
		ln -fs ../plugin $gtmdist/utf8/plugin
	fi
	cd ..
fi

$echo ""
$echo "All of the GT.M MUMPS routines are distributed with uppercase names."
$echo "You can create lowercase copies of these routines if you wish, but"
$echo "to avoid problems with compatibility in the future, consider keeping"
$echo "only the uppercase versions of the files."
$echo ""
$echo "Do you want uppercase and lowercase versions of the MUMPS routines? (y or n) \c"
read resp
if [ "$resp" = "Y" -o "$resp" = "y" ] ; then
	$echo ""
	$echo "Creating lowercase versions of the MUMPS routines."
	(cd $gtmdist; ./lowerc_cp *.m)
	if [ "$doutf8" -ne 0 ]; then
		(cd $gtmdist/utf8; ./lowerc_cp *.m)
	fi
fi

# Change mode to executable for mumps and libgtmshr to do the compiles
chmod 755 $gtmdist/mumps $gtmdist/libgtmshr$ext

gtmroutines=$gtmdist
gtmgbldir=$gtmdist/mumps.gld
gtm_dist=$gtmdist
export gtm_dist
export gtmroutines
export gtmgbldir

$echo ""
$echo "Compiling all of the MUMPS routines. This may take a moment."
$echo ""

# Ensure we are NOT in UTF-8 mode
gtm_chset="M"
export gtm_chset
(cd $gtmdist; ./mumps -noignore *.m; $echo $?>compstat ; \
 if [ "$is64bit_gtm" -eq 1 -o "linux" != $arch ] ; then $ldcmd $ldflags -o libgtmutil$ext *.o ; fi )

# Now work on UTF-8 mode
if [ "$doutf8" -ne 0 ]; then
	# Enclose UTF-8 operations inside a subshell. This avoids changing the current M mode execution
	(
		# Ensure we ARE in UTF-8 mode
		utflocale=`locale -a | grep $binaryopt -iE 'en_us\.utf.?8$' | head -n1`
		if [ "$utflocale" = "" ]; then
			# If no locale defined, try C.UTF-8
			utflocale="C.UTF-8"
		fi
		LC_CTYPE=$utflocale
		export LC_CTYPE
		unset LC_ALL
		gtm_chset="UTF-8"
		export gtm_chset
		if [ $arch = "ibm" ]; then
			export LIBPATH=$extendlibpath
		else
			LD_LIBRARY_PATH=$extendlibpath
			export LD_LIBRARY_PATH
		fi
		(gtm_dist=$gtmdist/utf8; export gtm_dist; cd $gtm_dist; ./mumps -noignore *.m; $echo $?>>$gtmdist/compstat; \
		if [ $is64bit_gtm -eq 1 -o "linux" != $arch ] ; then $ldcmd $ldflags -o libgtmutil$ext *.o ; fi )
	)
fi

# Change mode to executable for the normal binaries
for i in $binaries
do
	chmod 755 $gtmdist/$i
done

chmod 0644 $gtmdist/*.m
chmod 0644 $gtmdist/*.o
chown $owner $gtmdist/*.m
chown $owner $gtmdist/*.o
chown $owner $gtmdist/*.txt
chgrp $bingroup $gtmdist/*.m
chgrp $bingroup $gtmdist/*.o
chgrp $bingroup $gtmdist/*.txt

if [ "$doutf8" -ne 0 ]; then
	chmod 0644 $gtmdist/utf8/*.m
	chmod 0644 $gtmdist/utf8/*.o
	chown $owner $gtmdist/utf8
	chown $owner $gtmdist/utf8/*.m
	chown $owner $gtmdist/utf8/*.o
	chown $owner $gtmdist/utf8/*.txt
	chgrp $bingroup $gtmdist/utf8/*.m
	chgrp $bingroup $gtmdist/utf8/*.o
	chgrp $bingroup $gtmdist/utf8/*.txt
fi

if [ -f $gtm_dist/libgtmutil$ext ] ; then
    gtmroutines="$gtm_dist/libgtmutil$ext $gtmdist"
else
    gtmroutines="$gtmdist"
fi
export gtmroutines

other_object_files=""
csh_script_files=""

# make database files read only
chmod 0444 $gtmdist/*.dat
chmod 0444 $gtmdist/*.gld

# $other_object_files, $csh_script_files should be removed unconditionally
savedir=`pwd`
# temporarily change to $gtmdist
cd $gtmdist
\rm -rf $other_object_files $csh_script_files lowerc_cp

if [ -d utf8 ]; then
	cd utf8
	\rm -rf $other_object_files $csh_script_files lowerc_cp
fi
# change back to original directory
cd $savedir

# Optionally remove .o files if they are in a shared library
if [ -f $gtm_dist/libgtmutil$ext ] ; then
	chown ${owner}:${bingroup} $gtm_dist/libgtmutil$ext
	chmod 755 $gtm_dist/libgtmutil$ext
	$echo ""
	$echo "Object files of M routines placed in shared library $gtm_dist/libgtmutil$ext"
	$echo "Keep original .o object files (y or n)? \c"
	read resp
	if [ "n" = "$resp" -o "N" = "$resp" ] ; then rm -f $gtm_dist/*.o $gtm_dist/utf8/*.o ; fi
	$echo ""
	if [ -f $gtm_dist/utf8/libgtmutil$ext ] ; then
		chown ${owner}:${bingroup} $gtm_dist/utf8/libgtmutil$ext
		chmod 755 $gtm_dist/utf8/libgtmutil$ext
	fi
fi

# change group ownership of all files if group restricted
# otherwise change to the default as some files were created with root group
if [ "$group" != "" ] ; then
	chgrp -R $group $gtmdist
	chmod -R o-rwx $gtmdist
else
	chgrp -R $bingroup $gtmdist
fi

# Install real gtmsecshr with special permissions in $gtmdist/gtmsecshrdir
tgtmsecshrdir=$gtmdist/gtmsecshrdir
mkdir -p $tgtmsecshrdir
chmod 700 $tgtmsecshrdir
chgrp $bingroup $tgtmsecshrdir

# Install gtmsecshr and the wrapper with special permissions
if [ $arch = "linux" ]; then
	install -m 4555 -o root -g $bingroup gtmsecshr $gtmdist
	install -m 4500 -o root -g $bingroup gtmsecshrdir/gtmsecshr $tgtmsecshrdir/gtmsecshr
elif [ $arch = "ibm" ]; then
	/usr/bin/install -f $gtmdist -M 4555 -O root -G $bingroup gtmsecshr
	/usr/bin/install -f $tgtmsecshrdir -M 4500 -O root -G $bingroup gtmsecshrdir/gtmsecshr
elif [ -x /usr/sbin/install ]; then
	/usr/sbin/install -f $gtmdist -m 4555 -u root -g $bingroup gtmsecshr $gtmdist
	/usr/sbin/install -f $tgtmsecshrdir -m 4500 -u root -g $bingroup gtmsecshrdir/gtmsecshr $tgtmsecshrdir
else
	install -f $gtmdist -m 4555 -u root -g $bingroup gtmsecshr $gtmdist
	install -f $tgtmsecshrdir -m 4500 -u root -g $bingroup gtmsecshrdir/gtmsecshr $tgtmsecshrdir
fi

strip $gtmdist/gtmsecshr > /dev/null 2>&1
strip $tgtmsecshrdir/gtmsecshr > /dev/null 2>&1

if [ -d $gtmdist/utf8 ]; then

	# Delete the gtmsecshr symlink
	if [ -f $gtmdist/utf8/gtmsecshr -o -h $gtmdist/utf8/gtmsecshr ]; then
		rm -f $gtmdist/utf8/gtmsecshr
	fi
	ln -f $gtmdist/gtmsecshr $gtmdist/utf8/gtmsecshr || \
		echo ln -f $gtmdist/gtmsecshr $gtmdist/utf8/gtmsecshr

	# Delete the gtmsecshrdir symlink
	if [ -f $gtmdist/utf8/gtmsecshrdir -o -h $gtmdist/utf8/gtmsecshrdir ]; then
		rm -f $gtmdist/utf8/gtmsecshrdir
	fi
	mkdir -p $gtmdist/utf8/gtmsecshrdir
	chmod 0500 $gtmdist/utf8/gtmsecshrdir
	ln -f $gtmdist/gtmsecshrdir/gtmsecshr $gtmdist/utf8/gtmsecshrdir/gtmsecshr || \
		echo ln -f $gtmdist/gtmsecshrdir/gtmsecshr $gtmdist/utf8/gtmsecshrdir/gtmsecshr

fi

# change group ownership of wrapper if group restricted
# also remove user privileges for wrapper if group changed
if [ "$group" != "" ] ; then
	chgrp $group $gtmdist/gtmsecshr
	$echo ""
	$echo "Removing world permissions from gtmsecshr wrapper since group restricted to \"$group\""
	chmod 4550 $gtmdist/gtmsecshr
fi

# leave nothing writeable
chmod -R a-w $gtmdist

# if we had a mumps error then remove executable bit recursively and exit
# this could include compile and/or library load errors
if [ 0 != `grep -c '[1-9]' $gtm_dist/compstat` ]; then
	$echo ""
	$echo "GT.M installation FAILED – please review error messages"
	$echo ""
	( cd $gtm_dist && find . -type f -exec chmod a-x {} + )
	exit 1
fi

rm -f $gtmdist/compstat

if [ "$gtm_icu_version" != "" ] ; then
	icumessage=" Used gtm_icu_version=$gtm_icu_version for UTF-8 installation."
fi
$echo ""
$echo "Installation completed.$icumessage"
$echo "Would you like all the temporary files removed from this directory? (y or n) \c"
read resp

if [ "$resp" = "Y" -o "$resp" = "y" ] ; then
	\rm -rf $binaries $pathmods $rscripts $nscripts $dirs configure \
		*.gtc gtm* gde* GDE*.o _*.m _*.o mumps.dat mumps.gld $other_object_files $csh_script_files lowerc_cp\
		*.hlp core *.h *.m *help.dat *help.gld COPYING README.txt
	\rm -rf GETPASS.o plugin GTMHELP.o custom_errors_sample.txt
	if [ -d utf8 ]; then
		\rm -rf utf8
	fi
fi

# Save long listing of files, including permissions and sha256 for future reference
find $gtmdist -type f \! -name install_permissions.log  -exec ls -l {} \; > $gtmdist/install_permissions.log
chmod 0444 $gtmdist/install_permissions.log
chown ${owner}:${bingroup} $gtmdist/install_permissions.log
OPENSSL=$(command -p command -v openssl)
if [ -x "$OPENSSL" ]; then
	find $gtmdist -type f \! -name install_sha256_checksum.log -exec $OPENSSL sha256 {} \; \
									> $gtmdist/install_sha256_checksum.log
	chmod 0444 $gtmdist/install_sha256_checksum.log
	chown ${owner}:${bingroup} $gtmdist/install_sha256_checksum.log
fi