blob: 59dd0096f4c90317aa47f773d9cf4f2f1e61e154 [file] [log] [blame]
Brian Paul8c20c7b2003-06-01 16:21:45 +00001#!/bin/sh
2
3# Make a shared library.
Brian Paul5396ab22004-02-12 14:48:52 +00004# Basically do a switch/case depending on the OS and make a shared (or static)
5# library conforming to that OS.
Brian Paul8c20c7b2003-06-01 16:21:45 +00006
7
8# Usage:
9# mklib [options] objects ...
10# Options:
Brian Paul1a644b32003-12-06 17:57:12 +000011# -o LIBRARY specifies the name of resulting library
12# ("-o GL" for example, might result in "libGL.so" being made)
Brian Paul8c20c7b2003-06-01 16:21:45 +000013# -major N specifies major version number (default is 1)
14# -minor N specifies minor version number (default is 0)
15# -patch N specifies patch version number (default is 0)
16# -lLIBRARY specifies a dependency on LIBRARY
17# -LDIR search in DIR for library dependencies
18# -cplusplus link with C++ runtime
19# -static make a static library (default is dynamic/shared)
Brian Paul5396ab22004-02-12 14:48:52 +000020# -install DIR move resulting library file(s) to DIR
Brian Paul8c20c7b2003-06-01 16:21:45 +000021# -arch ARCH override using `uname` to determine architecture
22# -archopt OPT specify an extra achitecture-specific option OPT
Brian Pauldd74e362004-04-08 22:26:22 +000023# -noprefix don't prefix library name with "lib" or any suffix
Brian Paul8c20c7b2003-06-01 16:21:45 +000024#
25# The library name should just be "GL" or "GLU", etc. The 'lib' prefix
Brian Pauldd74e362004-04-08 22:26:22 +000026# will be added here if needed, as well as the ".so" or ".a" suffix,
27# etc (unless the -noprefix option is used).
Brian Paul8c20c7b2003-06-01 16:21:45 +000028#
29# objects should be: foo.o bar.o etc.o
30#
31# Environment variables recognized:
32# CC C compiler command
33# CXX C++ compiler command
34#
35
36
37#
38# Option defaults
39#
40LIBNAME=""
41MAJOR=1
42MINOR=0
Brian Paul6e450f22004-02-21 18:08:41 +000043PATCH=""
Brian Paul8c20c7b2003-06-01 16:21:45 +000044DEPS=""
45CPLUSPLUS=0
46STATIC=0
47INSTALLDIR="."
48ARCH="auto"
49ARCHOPT=""
Brian Pauldd74e362004-04-08 22:26:22 +000050NOPREFIX=0
Brian Paul8c20c7b2003-06-01 16:21:45 +000051
52
53#
54# Parse arguments
55#
56while true
57do
58 case $1 in
59 '-o') shift 1; LIBNAME=$1;;
60 '-major') shift 1; MAJOR=$1;;
61 '-minor') shift 1; MINOR=$1;;
62 '-patch') shift 1; PATCH=$1;;
63 -l*) DEPS="$DEPS $1";;
64 -L*) DEPS="$DEPS $1";;
65 '-cplusplus') CPLUSPLUS=1;;
66 '-static') STATIC=1;;
67 '-install') shift 1; INSTALLDIR=$1;;
68 '-arch') shift 1; ARCH=$1;;
69 '-archopt') shift 1; ARCHOPT=$1;;
Brian Pauldd74e362004-04-08 22:26:22 +000070 '-noprefix') NOPREFIX=1;;
Brian Paul8c20c7b2003-06-01 16:21:45 +000071 -*) echo "mklib: Unknown option: " $1 ; exit 1;;
72 *) break
73 esac
74 shift 1
75done
76OBJECTS=$@
77
78if [ ${ARCH} = "auto" ] ; then
79 ARCH=`uname`
80fi
81
82
83#
84# Error checking
85#
86if [ "x${LIBNAME}" = "x" ] ; then
87 echo "mklib: Error: no library name specified"
88 exit 1
89fi
90if [ "x${OBJECTS}" = "x" ] ; then
91 echo "mklib: Error: no object files specified"
92 exit 1
93fi
94
95
96#
97# Debugging info
98#
99if [ ] ; then
100 echo "-----------------"
101 echo ARCH is $ARCH
102 echo LIBNAME is $LIBNAME
103 echo MAJOR is $MAJOR
104 echo MINOR is $MINOR
105 echo PATCH is $PATCH
106 echo DEPS are $DEPS
107 echo "-----------------"
108fi
109
110
111#
112# OK, make the library now
113#
114case $ARCH in
115
Brian Paul12d6cae2004-01-10 22:12:21 +0000116 'Linux' | 'OpenBSD')
117 # GCC-based environment
Brian Paul8c20c7b2003-06-01 16:21:45 +0000118
Brian Pauldd74e362004-04-08 22:26:22 +0000119 if [ $NOPREFIX = 1 ] ; then
120 # No "lib" or ".so" part
121 echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}
122 #OPTS="-shared -Wl,-soname,${LIBNAME}" # soname???
123 OPTS="-shared"
124 if [ $CPLUSPLUS = 1 ] ; then
Ian Romanick9eecb032004-06-25 22:51:39 +0000125 LINK=$CXX
Brian Pauldd74e362004-04-08 22:26:22 +0000126 else
Ian Romanick9eecb032004-06-25 22:51:39 +0000127 LINK=$CC
Brian Pauldd74e362004-04-08 22:26:22 +0000128 fi
129 rm -f ${LIBNAME}
130
131 # make lib
132 ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
133 # finish up
134 FINAL_LIBS="${LIBNAME}"
135 elif [ $STATIC = 1 ] ; then
136 LIBNAME="lib${LIBNAME}" # prefix with "lib"
Brian Paul5b9a9d42004-01-17 18:31:12 +0000137 echo "mklib: Making" $ARCH "static library: " ${LIBNAME}.a
Brian Paul1c4b7112003-10-10 17:58:38 +0000138 LINK="ar"
Brian Paul6e450f22004-02-21 18:08:41 +0000139 OPTS="-ru"
Brian Paul1c4b7112003-10-10 17:58:38 +0000140 # make lib
141 ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
Brian Paul6e450f22004-02-21 18:08:41 +0000142 ranlib ${LIBNAME}.a
Brian Paul1c4b7112003-10-10 17:58:38 +0000143 # finish up
Brian Paul6e450f22004-02-21 18:08:41 +0000144 FINAL_LIBS=${LIBNAME}.a
Brian Paul1c4b7112003-10-10 17:58:38 +0000145 else
Brian Pauldd74e362004-04-08 22:26:22 +0000146 LIBNAME="lib${LIBNAME}" # prefix with "lib"
Brian Paul5b9a9d42004-01-17 18:31:12 +0000147 if [ $ARCH = 'Linux' ] ; then
148 OPTS="-Xlinker -Bsymbolic -shared -Wl,-soname,${LIBNAME}.so.${MAJOR}"
149 else
150 OPTS="-shared -Wl,-soname,${LIBNAME}.so.${MAJOR}"
151 fi
Brian Paul6e450f22004-02-21 18:08:41 +0000152 if [ x${PATCH} = "x" ] ; then
153 VERSION="${MAJOR}.${MINOR}"
154 else
155 VERSION="${MAJOR}.${MINOR}.${PATCH}"
156 fi
Brian Paul8c20c7b2003-06-01 16:21:45 +0000157
Brian Paul5396ab22004-02-12 14:48:52 +0000158 echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}.so.${VERSION}
Brian Paul8c20c7b2003-06-01 16:21:45 +0000159
Brian Paul1c4b7112003-10-10 17:58:38 +0000160 if [ $CPLUSPLUS = 1 ] ; then
Ian Romanick9eecb032004-06-25 22:51:39 +0000161 LINK=$CXX
Brian Paul1c4b7112003-10-10 17:58:38 +0000162 else
Ian Romanick9eecb032004-06-25 22:51:39 +0000163 LINK=$CC
Brian Paul1c4b7112003-10-10 17:58:38 +0000164 fi
Brian Paul8c20c7b2003-06-01 16:21:45 +0000165
Brian Paul1c4b7112003-10-10 17:58:38 +0000166 # rm any old libs
167 rm -f ${LIBNAME}.so.${VERSION}
168 rm -f ${LIBNAME}.so.${MAJOR}
169 rm -f ${LIBNAME}.so
170
171 # make lib
172 ${LINK} ${OPTS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
173 # make usual symlinks
174 ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR}
175 ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
176 # finish up
177 FINAL_LIBS="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so"
178 fi
Brian Paul8c20c7b2003-06-01 16:21:45 +0000179 ;;
180
181 'SunOS')
Brian Paul5396ab22004-02-12 14:48:52 +0000182 if [ $STATIC = 1 ] ; then
183 LIBNAME="lib${LIBNAME}.a"
184 echo "mklib: Making SunOS static library: " ${LIBNAME}
185 rm -f ${LIBNAME}
Brian Paulc193bd02004-03-18 15:41:59 +0000186 ar -ruv ${LIBNAME} ${OBJECTS}
Brian Paul5396ab22004-02-12 14:48:52 +0000187 FINAL_LIBS=${LIBNAME}
188 else
189 LIBNAME="lib${LIBNAME}.so"
190 echo "mklib: Making SunOS shared library: " ${LIBNAME}
191 # XXX OPTS for gcc should be -shared, but that doesn't work.
192 # Using -G does work though.
193 if [ $CPLUSPLUS = 1 ] ; then
194 # determine linker and options for C++ code
195 if [ "x${CXX}" = "xg++" ] ; then
196 # use g++
197 LINK="g++"
198 OPTS="-G"
199 elif [ "x${CXX}" = "xCC" ] ; then
200 # use Sun CC
201 LINK="CC"
202 OPTS="-G"
203 elif [ "x${CXX}" = "xc++" ] ; then
204 # use Sun c++
205 LINK="c++"
206 OPTS="-G"
207 elif [ `which c++` ] ; then
208 # use Sun c++
209 LINK="c++"
210 OPTS="-G"
211 elif [ `type g++` ] ; then
212 # use g++
213 LINK="g++"
214 OPTS="-G"
215 else
216 echo "mklib: warning: can't find C++ comiler, trying CC."
217 LINK="CC"
218 OPTS="-G"
219 fi
220 elif [ "x${CC}" = "xgcc" ] ; then
221 # use gcc for linking
222 LINK="gcc"
Brian Paul4b603442004-01-14 23:18:47 +0000223 OPTS="-G"
Brian Paul8c20c7b2003-06-01 16:21:45 +0000224 else
Brian Paul5396ab22004-02-12 14:48:52 +0000225 # use native Sun linker
226 LINK="ld"
Brian Paul1a644b32003-12-06 17:57:12 +0000227 OPTS="-G"
Brian Paul8c20c7b2003-06-01 16:21:45 +0000228 fi
Brian Paul5396ab22004-02-12 14:48:52 +0000229 echo "mklib: linker is" ${LINK} ${OPTS}
230 rm -f ${LIBNAME}.${MAJOR} ${LIBNAME}
231 ${LINK} ${OPTS} -o ${LIBNAME}.${MAJOR} ${OBJECTS} ${DEPS}
232 ln -s ${LIBNAME}.${MAJOR} ${LIBNAME}
233 FINAL_LIBS="${LIBNAME}.${MAJOR} ${LIBNAME}"
Brian Paul8c20c7b2003-06-01 16:21:45 +0000234 fi
Brian Paul8c20c7b2003-06-01 16:21:45 +0000235 ;;
236
237 'FreeBSD')
Brian Pauldd74e362004-04-08 22:26:22 +0000238 if [ $NOPREFIX = 1 ] ; then
239 # No "lib" or ".so" part
240 echo "mklib: Making FreeBSD shared library: " ${LIBNAME}
241 rm -f ${LIBNAME}
242 ld -Bshareable -o ${LIBNAME} ${OBJECTS}
243 FINAL_LIBS=${LIBNAME}
244 elif [ $STATIC = 1 ] ; then
Brian Paul5396ab22004-02-12 14:48:52 +0000245 STLIB="lib${LIBNAME}.a"
246 echo "mklib: Making FreeBSD static library: " ${STLIB}
247 rm -f ${STLIB}
248 ar cq ${STLIB} ${OBJECTS}
249 ranlib ${STLIB}
250 FINAL_LIBS=${STLIB}
251 else
252 SHLIB="lib${LIBNAME}.so.${MAJOR}.${MINOR}"
253 echo "mklib: Making FreeBSD shared library: " ${SHLIB}
254 rm -f ${SHLIB}
255 ld -Bshareable -o ${SHLIB} ${OBJECTS}
256 # XXX make lib${LIBNAME}.so.${MAJOR} symlink?
257 FINAL_LIBS=${SHLIB}
258 fi
Brian Paul8c20c7b2003-06-01 16:21:45 +0000259 ;;
260
Brian Paul8c20c7b2003-06-01 16:21:45 +0000261 'NetBSD')
Brian Paul5396ab22004-02-12 14:48:52 +0000262 if [ $STATIC = 1 ] ; then
263 LIBNAME="lib${LIBNAME}_pic.a"
264 echo "mklib: Making NetBSD PIC static library: " ${LIBNAME}
265 rm -f ${LIBNAME}
266 ar cq ${LIBNAME} ${OBJECTS}
267 ranlib ${LIBNAME}
268 FINAL_LIBS=${LIBNAME}
269 else
270 LIBNAME="lib${LIBNAME}.so.${MAJOR}.${MINOR}"
271 echo "mklib: Making NetBSD PIC shared library: " ${LIBNAME}
272 rm -f ${LIBNAME}
273 ld -x -Bshareable -Bforcearchive -o ${LIBNAME} ${OBJECTS}
274 FINAL_LIBS=${LIBNAME}
275 fi
Brian Paul8c20c7b2003-06-01 16:21:45 +0000276 ;;
277
Brian Paulf8c31fc2004-01-29 15:21:47 +0000278 'IRIX' | 'IRIX64')
Brian Paul5396ab22004-02-12 14:48:52 +0000279 if [ $STATIC = 1 ] ; then
280 LIBNAME="lib${LIBNAME}.a"
281 rm -f ${LIBNAME}
282 ar rc ${LIBNAME} ${OBJECTS}
283 FINAL_LIBS=${LIBNAME}
Brian Paul8c20c7b2003-06-01 16:21:45 +0000284 else
Brian Paul5396ab22004-02-12 14:48:52 +0000285 LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
286 if [ $ARCHOPT = "64" ] ; then
287 # 64-bit ABI
288 OPTS="-64 -shared -all"
289 echo "mklib: Making IRIX 64-bit shared library: " ${LIBNAME}
290 elif [ $ARCHOPT = "o32" ] ; then
291 # old 32-bit ABI
292 OPTS="-32 -shared -all"
293 echo "mklib: Making IRIX o32-bit shared library: " ${LIBNAME}
294 else
295 # new 32-bit ABI
296 OPTS="-n32 -shared -all"
297 echo "mklib: Making IRIX n32-bit shared library: " ${LIBNAME}
298 fi
299 if [ $CPLUSPLUS = 1 ] ; then
300 LINK="CC"
301 else
302 LINK="ld"
303 fi
304 ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
305 FINAL_LIBS=${LIBNAME}
Brian Paul8c20c7b2003-06-01 16:21:45 +0000306 fi
Brian Paul8c20c7b2003-06-01 16:21:45 +0000307 ;;
308
Brian Paul8c20c7b2003-06-01 16:21:45 +0000309 'linux-cygwin')
310 LIBNAME="lib${LIBNAME}.a"
311 echo "mklib: Making linux-cygwin library: " ${LIBNAME}
Brian Paul5396ab22004-02-12 14:48:52 +0000312 rm -f ${LIBNAME}
Brian Paul8c20c7b2003-06-01 16:21:45 +0000313 gnuwin32ar ruv ${LIBNAME} ${OBJECTS}
314 FINAL_LIBS=${LIBNAME}
315 ;;
316
Brian Paulc193bd02004-03-18 15:41:59 +0000317 'HP-UX')
Brian Paul5396ab22004-02-12 14:48:52 +0000318 if [ $STATIC = 1 ] ; then
319 LIBNAME="lib${LIBNAME}.a"
Brian Paul52fb07e2004-03-30 14:47:02 +0000320 echo "mklib: Making HP-UX static library: " ${LIBNAME}
Brian Paul5396ab22004-02-12 14:48:52 +0000321 rm -f ${LIBNAME}
Brian Paulc193bd02004-03-18 15:41:59 +0000322 ar -ruv ${LIBNAME} ${OBJECTS}
Brian Paul5396ab22004-02-12 14:48:52 +0000323 FINAL_LIBS=${LIBNAME}
324 else
325 RUNLIB="lib${LIBNAME}.${MAJOR}"
326 DEVLIB="lib${LIBNAME}.sl"
Brian Paul52fb07e2004-03-30 14:47:02 +0000327 echo "mklib: Making HP-UX shared library: " ${RUNLIB} ${DEVLIB}
Brian Paul5396ab22004-02-12 14:48:52 +0000328 ld -b -o ${RUNLIB} +b ${RUNLIB} ${OBJECTS} ${DEPS}
329 ln -s ${RUNLIB} ${DEVLIB}
Brian Paulac0cfee2004-04-25 15:13:56 +0000330 FINAL_LIBS="${RUNLIB} ${DEVLIB}"
Brian Paul5396ab22004-02-12 14:48:52 +0000331 fi
Brian Paul8c20c7b2003-06-01 16:21:45 +0000332 ;;
333
Brian Paulc193bd02004-03-18 15:41:59 +0000334 'AIX')
335 if [ $STATIC = 1 ] ; then
336 LIBNAME="lib${LIBNAME}.a"
337 echo "mklib: Making AIX static library: " ${LIBNAME}
338 ar -ruv ${LIBNAME} ${OBJECTS}
339 FINAL_LIBS=${LIBNAME}
340 else
Brian Paul76cfed82004-07-01 15:33:14 +0000341 EXPFILE="lib${LIBNAME}.exp"
342 OFILE=shr.o #Want to be consistent with the IBM libGL.a
343 LIBNAME="lib${LIBNAME}.a" # shared objects are still stored in the .a libraries
344 OPTS="-bE:${EXPFILE} -bM:SRE -bnoentry"
345 rm -f ${EXPFILE} ${OFILE}
346 NM="/bin/nm -eC"
347 echo "#! /usr/lib/${LIBNAME}" > ${EXPFILE}
348 ${NM} ${OBJECTS} | awk '{
349 if ((($2 == "T") || ($2 == "D") || ($2 == "B")) \
350 && ( substr($1,1,1) != ".")) {
351 if (substr ($1, 1, 7) != "__sinit" &&
352 substr ($1, 1, 7) != "__sterm") {
353 if (substr ($1, 1, 5) == "__tf1")
354 print (substr ($1, 7))
355 else if (substr ($1, 1, 5) == "__tf9")
356 print (substr ($1, 15))
357 else
358 print $1
359 }
360 }
361 }' | sort -u >> ${EXPFILE}
362 cc ${OPTS} -o ${OFILE} ${OBJECTS} ${DEPS}
363 ar -r ${LIBNAME} ${OFILE}
364 FINAL_LIBS="${LIBNAME}"
Brian Paulc193bd02004-03-18 15:41:59 +0000365 fi
366 ;;
367
368 'AIX64')
369 if [ $STATIC = 1 ] ; then
370 LIBNAME="lib${LIBNAME}.a"
371 echo "mklib: Making AIX static library: " ${LIBNAME}
372 ar -X64 -ruv ${LIBNAME} ${OBJECTS}
373 FINAL_LIBS=${LIBNAME}
374 else
Karl Schultza16bdb52004-10-01 13:33:26 +0000375 EXPFILE="lib${LIBNAME}.exp"
376 OFILE=shr.o #Want to be consistent with the IBM libGL.a
377 LIBNAME="lib${LIBNAME}.a" # shared objects are still stored in the .a libraries
378 OPTS="-bE:${EXPFILE} -bM:SRE -bnoentry -q64"
379 rm -f ${EXPFILE} ${OFILE}
380 NM="/bin/nm -eC -X64"
381 echo "#! /usr/lib/${LIBNAME}" > ${EXPFILE}
382 ${NM} ${OBJECTS} | awk '{
383 if ((($2 == "T") || ($2 == "D") || ($2 == "B")) \
384 && ( substr($1,1,1) != ".")) {
385 if (substr ($1, 1, 7) != "__sinit" &&
386 substr ($1, 1, 7) != "__sterm") {
387 if (substr ($1, 1, 5) == "__tf1")
388 print (substr ($1, 7))
389 else if (substr ($1, 1, 5) == "__tf9")
390 print (substr ($1, 15))
391 else
392 print $1
393 }
394 }
395 }' | sort -u >> ${EXPFILE}
396 cc ${OPTS} -o ${OFILE} ${OBJECTS} ${DEPS}
397 ar -X64 -r ${LIBNAME} ${OFILE}
398 FINAL_LIBS="${LIBNAME}"
Brian Paulc193bd02004-03-18 15:41:59 +0000399 fi
400 ;;
401
Brian Paul8c20c7b2003-06-01 16:21:45 +0000402 'OpenSTEP')
403 LIBNAME="lib${LIBNAME}.a"
404 echo "mklib: Making OpenSTEP static library: " ${LIBNAME}
405 libtool -static -o ${LIBNAME} - ${OBJECTS}
406 FINAL_LIBS=${LIBNAME}
407 ;;
408
409 'OSF1')
Brian Paul5396ab22004-02-12 14:48:52 +0000410 if [ $STATIC = 1 ] ; then
411 LIBNAME="lib${LIBNAME}.a"
412 echo "mklib: Making OSF/1 static library: " ${LIBNAME}
413 rm -f ${LIBNAME}
Brian Paulc193bd02004-03-18 15:41:59 +0000414 ar -ruv ${LIBNAME} ${OBJECTS}
Brian Paul5396ab22004-02-12 14:48:52 +0000415 FINAL_LIBS=${LIBNAME}
416 else
417 VERSION="${MAJOR}.${MINOR}"
418 LIBNAME="lib${LIBNAME}.so"
419 echo "mklib: Making OSF/1 shared library: " ${LIBNAME}
420 rm -f ${LIBNAME}.${VERSION}
421 ld -o ${LIBNAME}.${VERSION} -shared -no_archive -set_version ${VERSION} -soname ${LIBNAME}.${VERSION} -expect_unresolved \* -all ${OBJECTS} ${DEPS}
422 ln -sf ${LIBNAME}.${VERSION} ${LIBNAME}
423 FINAL_LIBS="${LIBNAME} ${LIBNAME}.${VERSION}"
424 fi
Brian Paul8c20c7b2003-06-01 16:21:45 +0000425 ;;
426
427 'Darwin')
Brian Paulc193bd02004-03-18 15:41:59 +0000428 if [ $STATIC = 1 ] ; then
429 LIBNAME="lib${LIBNAME}.a"
430 echo "mklib: Making Darwin static library: " ${LIBNAME}
431 LINK="ar"
432 OPTS="-ruv"
433 ${LINK} ${OPTS} ${LIBNAME} ${OBJECTS}
434 FINAL_LIBS=${LIBNAME}
435 else
Brian Paulc193bd02004-03-18 15:41:59 +0000436 LIBNAME="${LIBNAME}.dylib"
Brian Paulc50d77a2004-04-13 17:35:17 +0000437 echo "mklib: Making Darwin shared library: " ${LIBNAME}
Brian Paulc193bd02004-03-18 15:41:59 +0000438 FLAGS="-dynamiclib -multiply_defined suppress"
Brian Paulc05658d2004-03-25 21:18:32 +0000439 if [ $CPLUSPLUS = 1 ] ; then
440 LINK="g++"
441 else
442 LINK="cc"
443 fi
444 ${LINK} ${FLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
Brian Paulaaba0752004-03-23 23:25:47 +0000445 FINAL_LIBS=${LIBNAME}
Brian Paulc193bd02004-03-18 15:41:59 +0000446 fi
447 ;;
Brian Paul8c20c7b2003-06-01 16:21:45 +0000448
449 'LynxOS')
450 LIBNAME="lib${LIBNAME}.a"
Brian Paul5396ab22004-02-12 14:48:52 +0000451 echo "mklib: Making LynxOS static library: " ${LIBNAME}
452 rm -f ${LIBNAME}
Brian Paul8c20c7b2003-06-01 16:21:45 +0000453 ar ru ${LIBNAME} ${OBJECTS}
454 FINAL_LIBS=${LIBNAME}
455 ;;
456
457 'BeOS')
Philippe Houdoinef4dd5a2004-08-14 10:12:38 +0000458 if [ $STATIC = 1 ] ; then
459 LIBNAME="lib${LIBNAME}.a"
460 echo "mklib: Making BeOS static library: " ${LIBNAME}
461 ar -cru "${LIBNAME}" ${OBJECTS}
462 else
Brian Paulb784b8f2004-08-14 14:30:36 +0000463 LIBNAME="lib${LIBNAME}.so"
464 echo "mklib: Making BeOS shared library: " ${LIBNAME}
465 gcc -nostart -Xlinker "-soname=${LIBNAME}" -L/Be/develop/lib/x86 -lbe ${DEPS} ${OBJECTS} -o "${LIBNAME}"
466 mimeset -f "${LIBNAME}"
467 setversion "${LIBNAME}" -app ${MAJOR} ${MINOR} ${PATCH} -short "Powered by Mesa3D!" -long "Powered by Mesa3D!"
468 fi
469 FINAL_LIBS=${LIBNAME}
Brian Paul8c20c7b2003-06-01 16:21:45 +0000470 ;;
471
472 'QNX')
473 LIBNAME="lib${LIBNAME}.a"
474 echo "mklib: Making QNX library: " ${LIBNAME}
475 wlib ${LIBNAME} ${OBJECTS}
476 FINAL_LIBS=${LIBNAME}
477 ;;
478
Brian Paul65e2ab32003-10-27 18:13:37 +0000479 'MorphOS')
480 LIBNAME="lib${LIBNAME}.a"
481 echo "mklib: Making MorphOS library: " ${LIBNAME}
482 ppc-morphos-ar rc ${LIBNAME} ${OBJECTS}
483 FINAL_LIBS="${LIBNAME}"
484 ;;
485
Brian Paulb3b725b2003-12-15 16:14:55 +0000486 'icc')
487 # Intel C compiler
488 LIBNAME="lib${LIBNAME}" # prefix with "lib"
489
490 if [ $STATIC = 1 ] ; then
491 echo "mklib: Making Intel ICC static library: " ${LIBNAME}.a
492 LINK="ar"
493 OPTS="-ruv"
494 # make lib
495 ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
496 # finish up
497 FINAL_LIBS="${LIBNAME}.a"
498 else
499 OPTS="-shared"
500 VERSION="${MAJOR}.${MINOR}.${PATCH}"
Brian Paulb3b725b2003-12-15 16:14:55 +0000501 echo "mklib: Making Intel ICC shared library: " ${LIBNAME}.so.${VERSION}
502
503 if [ $CPLUSPLUS = 1 ] ; then
504 LINK="icc"
505 else
506 LINK="icc"
507 fi
Brian Paulb3b725b2003-12-15 16:14:55 +0000508 # rm any old libs
509 rm -f ${LIBNAME}.so.${VERSION}
510 rm -f ${LIBNAME}.so.${MAJOR}
511 rm -f ${LIBNAME}.so
Brian Paulb3b725b2003-12-15 16:14:55 +0000512 # make lib
513 ${LINK} ${OPTS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
514 # make usual symlinks
515 ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR}
516 ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
517 # finish up
518 FINAL_LIBS="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so"
519 fi
520 ;;
521
Brian Paul12d6cae2004-01-10 22:12:21 +0000522 'aix-gcc')
523 # AIX with gcc
Brian Paul5396ab22004-02-12 14:48:52 +0000524 if [ $STATIC = 1 ] ; then
525 LIBNAME="lib${LIBNAME}.a"
526 echo "mklib: Making AIX GCC static library: " ${LIBNAME}
527 rm -f ${LIBNAME}
528 ar ru ${LIBNAME} ${OBJECTS}
529 FINAL_LIBS=${LIBNAME}
530 else
531 LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
532 echo "mklib: Making AIX GCC shared library: " ${LIBNAME}
533 # remove old lib
534 rm -f ${LIBNAME}
535 # make the lib
536 gcc -shared -Wl,-G ${OBJECTS} ${DEPS} -o ${LIBNAME}
Brian Paul5396ab22004-02-12 14:48:52 +0000537 # NOTE: the application linking with this library must specify
538 # the -Wl,-brtl flags to gcc
Brian Paul5396ab22004-02-12 14:48:52 +0000539 FINAL_LIBS=${LIBNAME}
540 fi
541 ;;
542
543 'ultrix')
544 # XXX untested
545 if [ $STATIC = 0 ] ; then
546 echo "mklib: Warning shared libs not supported on Ultrix"
547 fi
548 LIBNAME="lib${LIBNAME}.a"
549 echo "mklib: Making static library for Ultrix: " ${LIBNAME}
Brian Paul12d6cae2004-01-10 22:12:21 +0000550 rm -f ${LIBNAME}
Brian Paul5396ab22004-02-12 14:48:52 +0000551 ar ru ${LIBNAME} ${OBJECTS}
552 FINAL_LIBS="${LIBNAME}"
Brian Paul12d6cae2004-01-10 22:12:21 +0000553 ;;
Brian Paulb3b725b2003-12-15 16:14:55 +0000554
Brian Paul580548d2004-04-22 16:16:42 +0000555 CYGWIN*)
556 # GCC-based environment
557 CYGNAME="cyg${LIBNAME}" # prefix with "cyg"
558 LIBNAME="lib${LIBNAME}" # prefix with "lib"
559
560 if [ $STATIC = 1 ] ; then
561 echo "mklib: Making" $ARCH "static library: " ${LIBNAME}.a
562 LINK="ar"
563 OPTS="-ru"
564 # make lib
565 ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
566 ranlib ${LIBNAME}.a
567 # finish up
568 FINAL_LIBS=${LIBNAME}.a
569 else
570 OPTS="-shared -Wl,-export-all -Wl,--out-implib=${LIBNAME}-${MAJOR}.dll.a"
571 echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}-${MAJOR}.dll
572
573 if [ $CPLUSPLUS = 1 ] ; then
574 LINK="g++"
575 else
576 LINK="gcc"
577 fi
578
579 # rm any old libs
580 rm -f ${LIBNAME}-${MAJOR}.dll
581 rm -f ${LIBNAME}.dll.a
582 rm -f ${LIBNAME}.a
583
584 # make lib
585 ${LINK} ${OPTS} -o ${CYGNAME}-${MAJOR}.dll ${OBJECTS} ${DEPS}
586 # make usual symlinks
587 ln -s ${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a
588 # finish up
589 FINAL_LIBS="${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a"
590 # special case for installing in bin
591 FINAL_BINS="${CYGNAME}-${MAJOR}.dll"
592 fi
593 ;;
594
Brian Paul8c20c7b2003-06-01 16:21:45 +0000595 'example')
596 # If you're adding support for a new architecture, you can
597 # start with this:
Brian Paul5396ab22004-02-12 14:48:52 +0000598 if [ $STATIC = 1 ] ; then
599 LIBNAME="lib${LIBNAME}.a"
600 echo "mklib: Making static library for example arch: " ${LIBNAME}
601 rm -f ${LIBNAME}
602 ar rv ${LIBNAME} ${OBJECTS}
603 FINAL_LIBS="${LIBNAME}"
604 else
605 LIBNAME="lib${LIBNAME}.so" # prefix with "lib"
606 echo "mklib: Making shared library for example arch: " ${LIBNAME}
607 ld -o ${LIBNAME} ${OBJECTS} ${DEPS}
608 FINAL_LIBS="${LIBNAME}"
609 fi
Brian Paul8c20c7b2003-06-01 16:21:45 +0000610 ;;
611
612 *)
Brian Paul5396ab22004-02-12 14:48:52 +0000613 echo "mklib: ERROR: Don't know how to make a static/shared library for" ${ARCH}
614 echo "mklib: Please add necessary commands to mklib script."
Brian Paul8c20c7b2003-06-01 16:21:45 +0000615 ;;
616esac
617
618
619#
620# Put library files into installation directory if specified.
621#
622if [ ${INSTALLDIR} != "." ] ; then
623 echo "mklib: Installing" ${FINAL_LIBS} "in" ${INSTALLDIR}
624 mv ${FINAL_LIBS} ${INSTALLDIR}/
625fi