summaryrefslogtreecommitdiffstats
path: root/src/util/makeshlib.sh
blob: 66d3e21503d341b275193f94278569a6111b2380 (plain)
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
#!/bin/sh
#
# makeshlib: Make a shared library.....
#
# Usage: makeshlib  <library> <libdirfl> <liblist> <flags>	\
#	<library version> <directories>
#

host=@HOST_TYPE@
CC="@CC@"
HAVE_GCC=@HAVE_GCC@

library=$1 ; shift
libdirfl=$1; shift
liblist=$1; shift
ldflags=$1; shift
VERSION="$1" ; shift

case $host  in
*-*-netbsd*)
	FILES=`for i
	do
		sed -e "s;^;$i/shared/;" -e "s; ; $i/shared/;g" -e "s;^$i/shared/\$;;" $i/DONE
	done`
	# Hack to deal with the fact that with cc options are different
	# from ld...
	ldflags=`echo $ldflags |sed  -e "s/-Wl,//g"`
	echo ld -Bshareable $ldflags -o $library $FILES $libdirfl $liblist
	ld -Bshareable $ldflags -o $library $FILES $libdirfl $liblist
	stat=$?
	;;
*-*-hpux*)
	FILES=`for i
	do
		sed -e "s;^;$i/shared/;" -e "s; ; $i/shared/;g" $i/DONE
	done`
	ldflags="`echo $ldflags | sed 's/-Wl,+b,/+b /g'`"
	echo ld -b $ldflags -o $library $FILES $libdirfl $liblist
	ld -b $ldflags -o $library $FILES $libdirfl $liblist
	stat=$?
	;;
*-*-linux*)
	FILES=`for i 
	do
		sed -e "s;^;$i/shared/;" -e "s; ; $i/shared/;g" $i/DONE
	done`
 
	echo $CC -G $ldflags -o $library $optflags $FILES $libdirfl $liblist 
	$CC --shared $ldflags -o $library $FILES $libdirfl $liblist
	stat=$?
	;;
mips-sni-sysv4)
	FILES=`for i 
	do
		sed -e "s;^;$i/shared/;" -e "s; ; $i/shared/;g" $i/DONE
	done`
 
	optflags=""
	if test "$HAVE_GCC"x = "x" ; then
		optflags="-h $library"
	fi
	ldflags="`echo $ldflags | sed -e 's/-R /-R/g'`"

	echo $CC -G $ldflags -o $library $optflags $FILES $libdirfl $liblist 
	$CC -G $ldflags -o $library $optflags $FILES $libdirfl $liblist
	stat=$?
	;;
*-*-solaris*)
	FILES=`for i 
	do
		sed -e "s;^;$i/shared/;" -e "s; ; $i/shared/;g" $i/DONE
	done`
 
	optflags=""
	if test "$HAVE_GCC"x = "x" ; then
		optflags="-h $library"
	fi

	echo $CC -G $ldflags -o $library $optflags $FILES $libdirfl $liblist 
	$CC -G $ldflags -o $library $optflags $FILES $libdirfl $liblist
	stat=$?
	;;
*-*-aix*)
	FILES=`for i 
	do
		sed -e "s;^;$i/;" -e "s; ; $i/;g" $i/DONE
	done`
echo rm $library 
rm -f $library 2>/dev/null
ar cq $library $FILES || exit $?
	dump -g $library | sed -e 's/^[ 	]*[0-9][0-9]*[ 	]*\([^ 	.][^ 	]*\)$/\1/p;d' | sort | uniq > ${library}.syms
	stat=$?
	if [ $stat -eq 0 ]
	then
	if test "$HAVE_GCC" = "yes" ; then
		$CC -o shr.o.$VERSION $library -nostartfiles -Xlinker -bgcbypass:1 -Xlinker -bfilelist -Xlinker -bM:SRE -Xlinker -bE:${library}.syms $ldflags $liblist $libdirfl
		else ld -o shr.o.$VERSION $library -H512 -T512 -bM:SRE -lc $ldflags -bfilelist -bgcbypass:1 -bnodelcsect -x -bE:${library}.syms $libdirfl $liblist
            fi
 stat=$?
	if [ $stat -eq 0 ]
	      then
	      rm $library ${library}.syms
	      ar cq $library shr.o.$VERSION
	      stat=$?
	      rm shr.o.$VERSION
	     else
	     rm -f $library
fi
	   fi
;;
alpha-*-osf*)
	FILES=`for i 
	do
		sed -e "s;^;$i/;" -e "s; ; $i/;g" $i/DONE

	done`

	echo 	ld -shared -error_unresolved $ldflags -o $library -all $FILES $libdirfl $liblist -none -lc -update_registry ../../so_locations
	ld -shared -error_unresolved $ldflags -o $library -all $FILES $libdirfl $liblist -none -lc -update_registry ../../so_locations
	stat=$?
	;;

*)
	echo "Host type $host not supported!"
	exit 1
esac
exit $stat