Add casts to quiet compiler warnings.
[mesa.git] / bin / mklib.aix
1 #!/bin/ksh
2
3 # Make an AIX shared library (tricky!!!)
4 # Based on a script from Athanasios G. Gaitatzes (gaitat@vnet.ibm.com)
5 # Improved by Greg Thompson <gregt@visix.com> -gt
6
7 #--identification------------------------------------------------------
8
9 # $Id: mklib.aix,v 1.2 1999/09/15 15:10:20 brianp Exp $
10
11 # $Log: mklib.aix,v $
12 # Revision 1.2 1999/09/15 15:10:20 brianp
13 # added third, tiny version number to arguments
14 #
15 # Revision 1.1 1999/08/19 13:52:56 brianp
16 # initial check-in (post-crash)
17 #
18
19
20 #--common--------------------------------------------------------------
21
22 LIBRARY=$1
23 shift 1
24
25 MAJOR=$1
26 shift 1
27
28 MINOR=$1
29 shift 1
30
31 TINY=$1
32 shift 1
33
34 OBJECTS=$*
35
36 #--platform------------------------------------------------------------
37
38 # BASENAME = LIBRARY without .a suffix
39 BASENAME=`echo ${LIBRARY} | sed "s/\.a//g"`
40
41 # Name of exports file
42 EXPFILE=${BASENAME}.exp
43
44 # Name of temporary shared lib file
45 OFILE=shr.o
46 ####OFILE=${BASENAME}.o
47
48
49 # Remove any old files from previous make
50 rm -f ${LIBRARY} ${EXPFILE} ${OFILE}
51
52 # Pick a way to use nm -gt
53 NM=${NM-/bin/nm -eC}
54
55 # Determine which version of AIX this is
56 AIXVERSION=`uname -v`
57
58 # Pick a way to tell the linker there's no entrypoint -gt
59 case ${AIXVERSION}
60 {
61 3*)
62 ENTRY='-e _nostart'
63 ;;
64 4*)
65 ENTRY=-bnoentry
66 ;;
67 *)
68 echo "Error in mklib.aix!"
69 exit 1
70 ;;
71 }
72
73
74 # Other libraries which we may be dependent on. Since we make the libraries
75 # in the order libGL.a, libaGLU.a, libglut.a just depends on its predecessor.
76 # modified to make otherlibs in the form of -lfoo -gt
77 OTHERLIBS=`ls ../lib/*.a | sed "s/..\/lib\/lib/-l/g" | sed "s/\.a//g"`
78
79 ##echo OTHERLIBS are ${OTHERLIBS}
80
81
82 # Make exports (.exp) file header
83 echo "#! ${LIBRARY}" > ${EXPFILE}
84
85 # Append list of exported symbols to exports file -gt
86 case ${AIXVERSION}
87 {
88 3*)
89 ${NM} ${OBJECTS} | awk -F'|' '{
90 if ($3 != "extern" || substr($7,1,1) == " ") continue
91 sub (" *", "", $1); sub (" *", "", $7)
92 if ( (($7 == ".text") || ($7 == ".data") || ($7 == ".bss")) \
93 && ( substr($1,1,1) != ".")) {
94 if (substr ($1, 1, 7) != "__sinit" &&
95 substr ($1, 1, 7) != "__sterm") {
96 if (substr ($1, 1, 5) == "__tf1")
97 print (substr ($1, 7))
98 else if (substr ($1, 1, 5) == "__tf9")
99 print (substr ($1, 15))
100 else
101 print $1
102 }
103 }
104 }' | sort -u >> ${EXPFILE}
105 ;;
106
107 4*)
108 ${NM} ${OBJECTS} | awk '{
109 if ((($2 == "T") || ($2 == "D") || ($2 == "B")) \
110 && ( substr($1,1,1) != ".")) {
111 if (substr ($1, 1, 7) != "__sinit" &&
112 substr ($1, 1, 7) != "__sterm") {
113 if (substr ($1, 1, 5) == "__tf1")
114 print (substr ($1, 7))
115 else if (substr ($1, 1, 5) == "__tf9")
116 print (substr ($1, 15))
117 else
118 print $1
119 }
120 }
121 }' | sort -u >> ${EXPFILE}
122 ;;
123 }
124
125
126 # This next line is a hack to allow full compatibility with IBM's OpenGL
127 # libraries. IBM mistakenly exports glLoadIdentity from the libGLU.a
128 # library. We have to do the same thing. Problem reported by Yemi Adesanya
129 # (adesanya@afsmail.cern.ch) and Patrick Brown (pbrown@austin.ibm.com)
130 if [ "${BASENAME}" = libGLU ] ; then
131 echo "glLoadIdentity" >> ${EXPFILE}
132 fi
133
134
135 # Make the shared lib file
136 cc -o ${OFILE} ${OBJECTS} -L../lib ${OTHERLIBS} -lX11 -lXext -lXmu -lXi -lm -lc -bE:${EXPFILE} -bM:SRE ${ENTRY}
137
138
139 # Make the .a file
140 ar ruv ${LIBRARY} ${OFILE}
141
142 # Put exports file in Mesa lib directory
143 mv ${EXPFILE} ../lib
144
145 # Remove OFILE
146 rm -f ${OFILE}
147
148
149 #NOTES
150 # AIX 4.x /usr/bin/nm -B patch from ssclift@mach.me.queensu.ca (Simon Clift)
151 # Robustified symbol extraction for AIX 3 and 4
152 # Greg Thompson <gregt@visix.com>
153