Merge branch 'nouveau-import'
[mesa.git] / bin / mklib
1 #!/bin/sh
2
3 # Make a shared library.
4 # This script should be useful for projects other than Mesa.
5 # Improvements/fixes are welcome.
6
7
8 # Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
9 #
10 # Permission is hereby granted, free of charge, to any person obtaining a
11 # copy of this software and associated documentation files (the "Software"),
12 # to deal in the Software without restriction, including without limitation
13 # the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 # and/or sell copies of the Software, and to permit persons to whom the
15 # Software is furnished to do so, subject to the following conditions:
16 #
17 # The above copyright notice and this permission notice shall be included
18 # in all copies or substantial portions of the Software.
19 #
20 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23 # BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
24 # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25 # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26
27
28 #
29 # Option defaults
30 #
31 LIBNAME=""
32 MAJOR=1
33 MINOR=0
34 PATCH=""
35 DEPS=""
36 LINK=""
37 CPLUSPLUS=0
38 STATIC=0
39 DLOPEN=0
40 INSTALLDIR="."
41 ARCH="auto"
42 ARCHOPT=""
43 NOPREFIX=0
44 EXPORTS=""
45
46
47 #
48 # Parse arguments
49 #
50 while true
51 do
52 case $1 in
53 '-h' | '--help')
54 echo 'Usage: mklib [options] objects'
55 echo 'Create a shared library from object files.'
56 echo ' -o LIBRARY specifies the name of the resulting library, without'
57 echo ' the leading "lib" or any suffix.'
58 echo ' (eg: "-o GL" might result in "libGL.so" being made)'
59 echo ' -major N specifies major version number (default is 1)'
60 echo ' -minor N specifies minor version number (default is 0)'
61 echo ' -patch N specifies patch version number (default is 0)'
62 echo ' -lLIBRARY specifies a dependency on LIBRARY'
63 echo ' -LDIR search in DIR for library dependencies'
64 echo ' -linker L explicity specify the linker program to use (eg: gcc, g++)'
65 echo ' Not observed on all systems at this time.'
66 echo ' -cplusplus link with C++ runtime'
67 echo ' -static make a static library (default is dynamic/shared)'
68 echo ' -dlopen make a shared library suitable for dynamic loading'
69 echo ' -install DIR put resulting library file(s) in DIR'
70 echo ' -arch ARCH override using `uname` to determine host system'
71 echo ' -archopt OPT specify an extra achitecture-specific option OPT'
72 echo " -noprefix don't prefix library name with 'lib' nor add any suffix"
73 echo ' -exports FILE only export the symbols listed in FILE'
74 echo ' -h, --help display this information and exit'
75 exit 1
76 ;;
77 '-o')
78 shift 1;
79 LIBNAME=$1
80 ;;
81 '-major')
82 shift 1;
83 MAJOR=$1
84 ;;
85 '-minor')
86 shift 1;
87 MINOR=$1
88 ;;
89 '-patch')
90 shift 1;
91 PATCH=$1
92 ;;
93 '-linker')
94 shift 1;
95 LINK=$1
96 ;;
97 -l*)
98 DEPS="$DEPS $1"
99 ;;
100 -L*)
101 DEPS="$DEPS $1"
102 ;;
103 '-cplusplus')
104 CPLUSPLUS=1
105 ;;
106 '-static')
107 STATIC=1
108 ;;
109 '-dlopen')
110 DLOPEN=1
111 ;;
112 '-install')
113 shift 1;
114 INSTALLDIR=$1
115 ;;
116 '-arch')
117 shift 1;
118 ARCH=$1
119 ;;
120 '-archopt')
121 shift 1;
122 ARCHOPT=$1
123 ;;
124 '-noprefix')
125 NOPREFIX=1
126 ;;
127 '-exports')
128 shift 1;
129 EXPORTS=$1
130 ;;
131 -*)
132 echo "mklib: Unknown option: " $1 ;
133 exit 1
134 ;;
135 *)
136 # This should be the first object file, stop parsing
137 break
138 esac
139 shift 1
140 done
141 OBJECTS=$@
142
143
144 if [ ${ARCH} = "auto" ] ; then
145 ARCH=`uname`
146 fi
147
148
149 #
150 # Error checking
151 #
152 if [ "x${LIBNAME}" = "x" ] ; then
153 echo "mklib: Error: no library name specified"
154 exit 1
155 fi
156 if [ "x${OBJECTS}" = "x" ] ; then
157 echo "mklib: Error: no object files specified"
158 exit 1
159 fi
160
161
162 #
163 # Debugging info
164 #
165 if [ ] ; then
166 echo "-----------------"
167 echo ARCH is $ARCH
168 echo LIBNAME is $LIBNAME
169 echo MAJOR is $MAJOR
170 echo MINOR is $MINOR
171 echo PATCH is $PATCH
172 echo DEPS are $DEPS
173 echo "EXPORTS in" $EXPORTS
174 echo "-----------------"
175 fi
176
177
178 #
179 # OK, make the library now
180 #
181 case $ARCH in
182
183 'Linux' | 'OpenBSD' | 'GNU' | GNU/*)
184 # we assume gcc
185
186 if [ "x$LINK" = "x" ] ; then
187 # -linker was not specified so set default link command now
188 if [ $CPLUSPLUS = 1 ] ; then
189 LINK=g++
190 else
191 LINK=gcc
192 fi
193 fi
194
195 if [ $NOPREFIX = 1 ] ; then
196 # No "lib" or ".so" part
197 echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}
198 #OPTS="-shared -Wl,-soname,${LIBNAME}" # soname???
199 OPTS="-shared"
200
201 # Check if objects are 32-bit and we're running in 64-bit
202 # environment. If so, pass -m32 flag to linker.
203 set ${OBJECTS}
204 ABI32=`file $1 | grep 32-bit`
205 if [ "${ABI32}" -a `uname -m` = "x86_64" ] ; then
206 OPTS="-m32 ${OPTS}"
207 fi
208
209 rm -f ${LIBNAME}
210 # make lib
211 ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
212 # finish up
213 FINAL_LIBS="${LIBNAME}"
214 elif [ $STATIC = 1 ] ; then
215 LIBNAME="lib${LIBNAME}" # prefix with "lib"
216 echo "mklib: Making" $ARCH "static library: " ${LIBNAME}.a
217 LINK="ar"
218 OPTS="-ru"
219 # make lib
220 ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
221 ranlib ${LIBNAME}.a
222 # finish up
223 FINAL_LIBS=${LIBNAME}.a
224 else
225 LIBNAME="lib${LIBNAME}" # prefix with "lib"
226 case $ARCH in 'Linux' | 'GNU' | GNU/*)
227 OPTS="-Xlinker -Bsymbolic -shared -Wl,-soname,${LIBNAME}.so.${MAJOR}"
228 ;;
229 *)
230 OPTS="-shared -Wl,-soname,${LIBNAME}.so.${MAJOR}"
231 ;;
232 esac
233 if [ $EXPORTS ] ; then
234 #OPTS="${OPTS} -Xlinker --retain-symbols-file ${EXPORTS}"
235 # Make the 'exptmp' file for --version-script option
236 echo "VERSION_${MAJOR}.${MINOR} {" > exptmp
237 echo "global:" >> exptmp
238 sed 's/$/;/' ${EXPORTS} >> exptmp
239 echo "local:" >> exptmp
240 echo "*;" >> exptmp
241 echo "};" >> exptmp
242 OPTS="${OPTS} -Xlinker --version-script=exptmp"
243 # exptmp is removed below
244 fi
245
246 # Check if objects are 32-bit and we're running in 64-bit
247 # environment. If so, pass -m32 flag to linker.
248 set ${OBJECTS}
249 ABI32=`file $1 | grep 32-bit`
250 if [ "${ABI32}" -a `uname -m` = "x86_64" ] ; then
251 OPTS="-m32 ${OPTS}"
252 fi
253
254 if [ x${PATCH} = "x" ] ; then
255 VERSION="${MAJOR}.${MINOR}"
256 else
257 VERSION="${MAJOR}.${MINOR}.${PATCH}"
258 fi
259
260 echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}.so.${VERSION}
261
262 # rm any old libs
263 rm -f ${LIBNAME}.so.${VERSION}
264 rm -f ${LIBNAME}.so.${MAJOR}
265 rm -f ${LIBNAME}.so
266
267 # make lib
268 ${LINK} ${OPTS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
269 # make usual symlinks
270 ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR}
271 ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
272 # finish up
273 FINAL_LIBS="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so"
274 # rm -f exptmp
275 fi
276 ;;
277
278 'SunOS')
279 if [ $STATIC = 1 ] ; then
280 LIBNAME="lib${LIBNAME}.a"
281 echo "mklib: Making SunOS static library: " ${LIBNAME}
282 rm -f ${LIBNAME}
283 ar -ruv ${LIBNAME} ${OBJECTS}
284 FINAL_LIBS=${LIBNAME}
285 else
286 if [ $NOPREFIX = 0 ] ; then
287 LIBNAME="lib${LIBNAME}.so"
288 fi
289 echo "mklib: Making SunOS shared library: " ${LIBNAME}
290
291 if [ "x$LINK" = "x" ] ; then
292 # -linker was not specified, choose default linker now
293 if [ $CPLUSPLUS = 1 ] ; then
294 # determine linker and options for C++ code
295 if [ `which c++` ] ; then
296 # use Sun c++
297 LINK="c++"
298 elif [ `type g++` ] ; then
299 # use g++
300 LINK="g++"
301 else
302 echo "mklib: warning: can't find C++ comiler, trying CC."
303 LINK="CC"
304 fi
305 else
306 # use native Sun linker for C code
307 LINK="ld"
308 fi
309 fi
310
311 # linker options
312 if [ ${LINK} = "ld" -o ${LINK} = "cc" -o ${LINK} = "CC" ] ; then
313 # SunOS tools, -G to make shared libs
314 OPTS="-G"
315 else
316 # gcc linker
317 # Check if objects are 32-bit and we're running in 64-bit
318 # environment. If so, pass -m32 flag to linker.
319 set ${OBJECTS}
320 ABI32=`file $1 | grep 32-bit`
321 if [ "${ABI32}" ] ; then
322 OPTS="-m32 -shared -Wl,-Bdynamic"
323 else
324 OPTS="-m64 -shared -Wl,-Bdynamic"
325 fi
326 fi
327
328 # Check if objects are SPARC v9
329 # file says: ELF 64-bit MSB relocatable SPARCV9 Version 1
330 set ${OBJECTS}
331 SPARCV9=`file $1 | grep SPARCV9`
332 if [ "${SPARCV9}" ] ; then
333 OPTS="${OPTS} -xarch=v9"
334 fi
335
336 # for debug:
337 #echo "mklib: linker is" ${LINK} ${OPTS}
338 if [ $NOPREFIX = 1 ] ; then
339 rm -f ${LIBNAME}
340 ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
341 else
342 rm -f ${LIBNAME}.${MAJOR} ${LIBNAME}
343 ${LINK} ${OPTS} -o ${LIBNAME}.${MAJOR} ${OBJECTS} ${DEPS}
344 ln -s ${LIBNAME}.${MAJOR} ${LIBNAME}
345 fi
346 FINAL_LIBS="${LIBNAME}.${MAJOR} ${LIBNAME}"
347 fi
348 ;;
349
350 'FreeBSD')
351 # we assume gcc
352
353 if [ "x$LINK" = "x" ] ; then
354 # -linker was not specified so set default link command now
355 if [ $CPLUSPLUS = 1 ] ; then
356 LINK=g++
357 else
358 LINK=gcc
359 fi
360 fi
361
362 if [ $NOPREFIX = 1 ] ; then
363 # No "lib" or ".so" part
364 echo "mklib: Making FreeBSD shared library: " ${LIBNAME}
365 OPTS="-shared"
366 rm -f ${LIBNAME}
367 ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
368 FINAL_LIBS=${LIBNAME}
369 elif [ $STATIC = 1 ] ; then
370 STLIB="lib${LIBNAME}.a"
371 echo "mklib: Making FreeBSD static library: " ${STLIB}
372 rm -f ${STLIB}
373 ar cq ${STLIB} ${OBJECTS}
374 ranlib ${STLIB}
375 FINAL_LIBS=${STLIB}
376 else
377 SHLIB="lib${LIBNAME}.so.${MAJOR}"
378 OPTS="-shared -Wl,-soname,${SHLIB}"
379 echo "mklib: Making FreeBSD shared library: " ${SHLIB}
380 rm -f ${SHLIB}
381 ${LINK} ${OPTS} -o ${SHLIB} ${OBJECTS} ${DEPS}
382 ln -sf ${SHLIB} "lib${LIBNAME}.so"
383 FINAL_LIBS="${SHLIB} lib${LIBNAME}.so"
384 fi
385 ;;
386
387 'NetBSD')
388 if [ $STATIC = 1 ] ; then
389 LIBNAME="lib${LIBNAME}_pic.a"
390 echo "mklib: Making NetBSD PIC static library: " ${LIBNAME}
391 rm -f ${LIBNAME}
392 ar cq ${LIBNAME} ${OBJECTS}
393 ranlib ${LIBNAME}
394 FINAL_LIBS=${LIBNAME}
395 else
396 LIBNAME="lib${LIBNAME}.so.${MAJOR}.${MINOR}"
397 echo "mklib: Making NetBSD PIC shared library: " ${LIBNAME}
398 rm -f ${LIBNAME}
399 ld -x -Bshareable -Bforcearchive -o ${LIBNAME} ${OBJECTS}
400 FINAL_LIBS=${LIBNAME}
401 fi
402 ;;
403
404 'IRIX' | 'IRIX64')
405 if [ $STATIC = 1 ] ; then
406 LIBNAME="lib${LIBNAME}.a"
407 rm -f ${LIBNAME}
408 ar rc ${LIBNAME} ${OBJECTS}
409 FINAL_LIBS=${LIBNAME}
410 else
411 LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
412
413 # examine first object to determine ABI
414 set ${OBJECTS}
415 ABI_O32=`file $1 | grep 'ELF 32-bit'`
416 ABI_N32=`file $1 | grep 'ELF N32'`
417 ABI_N64=`file $1 | grep 'ELF 64-bit'`
418 if [ "${ABI_O32}" ] ; then
419 OPTS="-32 -shared -all"
420 ABI="o32-bit"
421 elif [ "${ABI_N32}" ] ; then
422 OPTS="-n32 -shared -all"
423 ABI="n32-bit"
424 elif [ "${ABI_N64}" ] ; then
425 OPTS="-64 -shared -all"
426 ABI="64-bit"
427 else
428 echo "Error: Unexpected IRIX ABI!"
429 exit 1
430 fi
431
432 if [ $CPLUSPLUS = 1 ] ; then
433 LINK="CC"
434 else
435 LINK="ld"
436 fi
437
438 echo "mklib: Making IRIX " ${ABI} " shared library: " ${LIBNAME}
439 ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
440 FINAL_LIBS=${LIBNAME}
441 fi
442 ;;
443
444 'linux-cygwin')
445 LIBNAME="lib${LIBNAME}.a"
446 echo "mklib: Making linux-cygwin library: " ${LIBNAME}
447 rm -f ${LIBNAME}
448 gnuwin32ar ruv ${LIBNAME} ${OBJECTS}
449 FINAL_LIBS=${LIBNAME}
450 ;;
451
452 'HP-UX')
453 if [ $STATIC = 1 ] ; then
454 LIBNAME="lib${LIBNAME}.a"
455 echo "mklib: Making HP-UX static library: " ${LIBNAME}
456 rm -f ${LIBNAME}
457 ar -ruv ${LIBNAME} ${OBJECTS}
458 FINAL_LIBS=${LIBNAME}
459 else
460 # HP uses a .2 for their current GL/GLU libraries
461 if [ ${LIBNAME} = "GL" -o ${LIBNAME} = "GLU" ] ; then
462 MAJOR=2
463 fi
464 RUNLIB="lib${LIBNAME}.${MAJOR}"
465 DEVLIB="lib${LIBNAME}.sl"
466 echo "mklib: Making HP-UX shared library: " ${RUNLIB} ${DEVLIB}
467 ld -b -o ${RUNLIB} +b ${RUNLIB} ${OBJECTS} ${DEPS}
468 ln -s ${RUNLIB} ${DEVLIB}
469 FINAL_LIBS="${RUNLIB} ${DEVLIB}"
470 fi
471 ;;
472
473 'AIX' )
474 # examine first object to determine ABI
475 set ${OBJECTS}
476 ABI_64=`file $1 | grep '64-bit'`
477 if [ "${ABI_64}" ] ; then
478 X64="-X64"
479 Q64="-q64"
480 OFILE=shr_64.o
481 else
482 OFILE=shr.o #Want to be consistent with the IBM libGL.a
483 fi
484
485 if [ $STATIC = 1 ] ; then
486 LIBNAME="lib${LIBNAME}.a"
487 echo "mklib: Making AIX static library: " ${LIBNAME}
488 ar -ruv ${X64} ${LIBNAME} ${OBJECTS}
489 FINAL_LIBS=${LIBNAME}
490 else
491 EXPFILE="lib${LIBNAME}.exp"
492 LIBNAME="lib${LIBNAME}.a" # shared objects are still stored in the .a libraries
493 OPTS="-bE:${EXPFILE} -bM:SRE -bnoentry ${Q64}"
494 rm -f ${EXPFILE} ${OFILE}
495 NM="/bin/nm -eC ${X64}"
496 echo "#! /usr/lib/${LIBNAME}" > ${EXPFILE}
497 ${NM} ${OBJECTS} | awk '{
498 if ((($2 == "T") || ($2 == "D") || ($2 == "B")) \
499 && ( substr($1,1,1) != ".")) {
500 if (substr ($1, 1, 7) != "__sinit" &&
501 substr ($1, 1, 7) != "__sterm") {
502 if (substr ($1, 1, 5) == "__tf1")
503 print (substr ($1, 7))
504 else if (substr ($1, 1, 5) == "__tf9")
505 print (substr ($1, 15))
506 else
507 print $1
508 }
509 }
510 }' | sort -u >> ${EXPFILE}
511
512 # On AIX a shared library is linked differently when
513 # you want to dlopen the file
514 if [ $DLOPEN = "1" ] ; then
515 cc -G ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
516 else
517 cc ${OPTS} -o ${OFILE} ${OBJECTS} ${DEPS}
518 ar ${X64} -r ${LIBNAME} ${OFILE}
519 fi
520
521 FINAL_LIBS="${LIBNAME}"
522 fi
523 ;;
524
525 'OpenSTEP')
526 LIBNAME="lib${LIBNAME}.a"
527 echo "mklib: Making OpenSTEP static library: " ${LIBNAME}
528 libtool -static -o ${LIBNAME} - ${OBJECTS}
529 FINAL_LIBS=${LIBNAME}
530 ;;
531
532 'OSF1')
533 if [ $STATIC = 1 ] ; then
534 LIBNAME="lib${LIBNAME}.a"
535 echo "mklib: Making OSF/1 static library: " ${LIBNAME}
536 rm -f ${LIBNAME}
537 ar -ruv ${LIBNAME} ${OBJECTS}
538 FINAL_LIBS=${LIBNAME}
539 else
540 VERSION="${MAJOR}.${MINOR}"
541 LIBNAME="lib${LIBNAME}.so"
542 echo "mklib: Making OSF/1 shared library: " ${LIBNAME}
543 if [ "x$LINK" = "x" ] ; then
544 if [ $CPLUSPLUS = 1 ] ; then
545 LINK=cxx
546 else
547 LINK=cc
548 fi
549 fi
550 rm -f ${LIBNAME}.${VERSION}
551 ${LINK} -o ${LIBNAME}.${VERSION} -shared -set_version ${VERSION} -soname ${LIBNAME}.${VERSION} -expect_unresolved \* -all ${OBJECTS} ${DEPS}
552 ln -sf ${LIBNAME}.${VERSION} ${LIBNAME}
553 FINAL_LIBS="${LIBNAME} ${LIBNAME}.${VERSION}"
554 fi
555 ;;
556
557 'Darwin')
558 if [ $STATIC = 1 ] ; then
559 LIBNAME="lib${LIBNAME}.a"
560 echo "mklib: Making Darwin static library: " ${LIBNAME}
561 LINK="ar"
562 OPTS="-ruvs"
563 ${LINK} ${OPTS} ${LIBNAME} ${OBJECTS}
564 FINAL_LIBS=${LIBNAME}
565 else
566 # On Darwin a .bundle is used for a library that you want to dlopen
567 if [ $DLOPEN = "1" ] ; then
568 LIBSUFFIX="bundle"
569 OPTS="${ARCHOPT} -bundle -multiply_defined suppress"
570 else
571 LIBSUFFIX="dylib"
572 OPTS="${ARCHOPT} -dynamiclib -multiply_defined suppress -current_version ${MAJOR}.${MINOR}.0 -compatibility_version ${MAJOR}.${MINOR}.0 -install_name lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}"
573 fi
574 LINKNAME="lib${LIBNAME}.${LIBSUFFIX}"
575 LIBNAME="lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}"
576
577 # examine first object to determine ABI
578 set ${OBJECTS}
579 ABI_PPC=`file $1 | grep 'object ppc'`
580 ABI_I386=`file $1 | grep 'object i386'`
581 if [ "${ABI_PPC}" ] ; then
582 OPTS="${OPTS} -arch ppc"
583 fi
584 if [ "${ABI_I386}" ] ; then
585 OPTS="${OPTS} -arch i386"
586 fi
587
588 # XXX can we always add -isysroot /Developer/SDKs/MacOSX10.4u.sdk
589 # to OPTS here?
590
591 # determine linker
592 if [ $CPLUSPLUS = 1 ] ; then
593 LINK="g++"
594 else
595 LINK="cc"
596 fi
597
598 echo "mklib: Making Darwin shared library: " ${LIBNAME}
599 ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
600 ln -s ${LIBNAME} ${LINKNAME}
601 FINAL_LIBS="${LIBNAME} ${LINKNAME}"
602 fi
603 ;;
604
605 'LynxOS')
606 LIBNAME="lib${LIBNAME}.a"
607 echo "mklib: Making LynxOS static library: " ${LIBNAME}
608 rm -f ${LIBNAME}
609 ar ru ${LIBNAME} ${OBJECTS}
610 FINAL_LIBS=${LIBNAME}
611 ;;
612
613 'BeOS')
614 if [ $STATIC = 1 ] ; then
615 LIBNAME="lib${LIBNAME}.a"
616 echo "mklib: Making BeOS static library: " ${LIBNAME}
617 ar -cru "${LIBNAME}" ${OBJECTS}
618 else
619 LIBNAME="lib${LIBNAME}.so"
620 echo "mklib: Making BeOS shared library: " ${LIBNAME}
621 gcc -nostart -Xlinker "-soname=${LIBNAME}" -L/Be/develop/lib/x86 -lbe ${DEPS} ${OBJECTS} -o "${LIBNAME}"
622 mimeset -f "${LIBNAME}"
623 # XXX remove the Mesa3D stuff here since mklib isn't mesa-specific.
624 setversion "${LIBNAME}" -app ${MAJOR} ${MINOR} ${PATCH} -short "Powered by Mesa3D!" -long "Powered by Mesa3D!"
625 fi
626 FINAL_LIBS=${LIBNAME}
627 ;;
628
629 'QNX')
630 LIBNAME="lib${LIBNAME}.a"
631 echo "mklib: Making QNX library: " ${LIBNAME}
632 wlib ${LIBNAME} ${OBJECTS}
633 FINAL_LIBS=${LIBNAME}
634 ;;
635
636 'MorphOS')
637 LIBNAME="lib${LIBNAME}.a"
638 echo "mklib: Making MorphOS library: " ${LIBNAME}
639 ppc-morphos-ar rc ${LIBNAME} ${OBJECTS}
640 FINAL_LIBS="${LIBNAME}"
641 ;;
642
643 'icc' | 'icc-istatic')
644 # Intel C compiler
645 # This should get merged into the Linux code, above, since this isn't
646 # really a different architecture.
647 LIBNAME="lib${LIBNAME}" # prefix with "lib"
648
649 if [ $STATIC = 1 ] ; then
650 echo "mklib: Making Intel ICC static library: " ${LIBNAME}.a
651 LINK="ar"
652 OPTS="-ruv"
653 # make lib
654 ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
655 # finish up
656 FINAL_LIBS="${LIBNAME}.a"
657 else
658 if [ $ARCH = icc-istatic ] ; then
659 OPTS="-shared -i-static -cxxlib-icc"
660 else
661 OPTS="-shared"
662 fi
663 VERSION="${MAJOR}.${MINOR}.${PATCH}"
664 echo "mklib: Making Intel ICC shared library: " ${LIBNAME}.so.${VERSION}
665
666 if [ $CPLUSPLUS = 1 ] ; then
667 LINK="icpc"
668 else
669 LINK="icc"
670 fi
671 # rm any old libs
672 rm -f ${LIBNAME}.so.${VERSION}
673 rm -f ${LIBNAME}.so.${MAJOR}
674 rm -f ${LIBNAME}.so
675 # make lib
676 ${LINK} ${OPTS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
677 # make usual symlinks
678 ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR}
679 ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
680 # finish up
681 FINAL_LIBS="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so"
682 fi
683 ;;
684
685 'aix-gcc')
686 # AIX with gcc
687 if [ $STATIC = 1 ] ; then
688 LIBNAME="lib${LIBNAME}.a"
689 echo "mklib: Making AIX GCC static library: " ${LIBNAME}
690 rm -f ${LIBNAME}
691 ar ru ${LIBNAME} ${OBJECTS}
692 FINAL_LIBS=${LIBNAME}
693 else
694 LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
695 echo "mklib: Making AIX GCC shared library: " ${LIBNAME}
696 # remove old lib
697 rm -f ${LIBNAME}
698 # make the lib
699 gcc -shared -Wl,-G ${OBJECTS} ${DEPS} -o ${LIBNAME}
700 # NOTE: the application linking with this library must specify
701 # the -Wl,-brtl flags to gcc
702 FINAL_LIBS=${LIBNAME}
703 fi
704 ;;
705
706 'ultrix')
707 # XXX untested
708 if [ $STATIC = 0 ] ; then
709 echo "mklib: Warning shared libs not supported on Ultrix"
710 fi
711 LIBNAME="lib${LIBNAME}.a"
712 echo "mklib: Making static library for Ultrix: " ${LIBNAME}
713 rm -f ${LIBNAME}
714 ar ru ${LIBNAME} ${OBJECTS}
715 FINAL_LIBS="${LIBNAME}"
716 ;;
717
718 CYGWIN*)
719 # GCC-based environment
720 CYGNAME="cyg${LIBNAME}" # prefix with "cyg"
721 LIBNAME="lib${LIBNAME}" # prefix with "lib"
722
723 if [ $STATIC = 1 ] ; then
724 echo "mklib: Making" $ARCH "static library: " ${LIBNAME}.a
725 LINK="ar"
726 OPTS="-ru"
727 # make lib
728 ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
729 ranlib ${LIBNAME}.a
730 # finish up
731 FINAL_LIBS=${LIBNAME}.a
732 else
733 OPTS="-shared -Wl,-export-all -Wl,--out-implib=${LIBNAME}-${MAJOR}.dll.a"
734 echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}-${MAJOR}.dll
735
736 if [ $CPLUSPLUS = 1 ] ; then
737 LINK="g++"
738 else
739 LINK="gcc"
740 fi
741
742 # rm any old libs
743 rm -f ${LIBNAME}-${MAJOR}.dll
744 rm -f ${LIBNAME}.dll.a
745 rm -f ${LIBNAME}.a
746
747 # make lib
748 ${LINK} ${OPTS} -o ${CYGNAME}-${MAJOR}.dll ${OBJECTS} ${DEPS}
749 # make usual symlinks
750 ln -s ${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a
751 # finish up
752 FINAL_LIBS="${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a"
753 # special case for installing in bin
754 FINAL_BINS="${CYGNAME}-${MAJOR}.dll"
755 fi
756 ;;
757
758 'example')
759 # If you're adding support for a new architecture, you can
760 # start with this:
761 if [ $STATIC = 1 ] ; then
762 LIBNAME="lib${LIBNAME}.a"
763 echo "mklib: Making static library for example arch: " ${LIBNAME}
764 rm -f ${LIBNAME}
765 ar rv ${LIBNAME} ${OBJECTS}
766 FINAL_LIBS="${LIBNAME}"
767 else
768 LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
769 echo "mklib: Making shared library for example arch: " ${LIBNAME}
770 ld -o ${LIBNAME} ${OBJECTS} ${DEPS}
771 FINAL_LIBS="${LIBNAME}"
772 fi
773 ;;
774
775 *)
776 echo "mklib: ERROR: Don't know how to make a static/shared library for" ${ARCH}
777 echo "mklib: Please add necessary commands to mklib script."
778 ;;
779 esac
780
781
782 #
783 # Put library files into installation directory if specified.
784 #
785 if [ ${INSTALLDIR} != "." ] ; then
786 echo "mklib: Installing" ${FINAL_LIBS} "in" ${INSTALLDIR}
787 mv ${FINAL_LIBS} ${INSTALLDIR}/
788 fi