fix tabbing
[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 -pthread)
104 # this is a special case (see bugzilla 10876)
105 DEPS="$DEPS $1"
106 ;;
107 '-cplusplus')
108 CPLUSPLUS=1
109 ;;
110 '-static')
111 STATIC=1
112 ;;
113 '-dlopen')
114 DLOPEN=1
115 ;;
116 '-install')
117 shift 1;
118 INSTALLDIR=$1
119 ;;
120 '-arch')
121 shift 1;
122 ARCH=$1
123 ;;
124 '-archopt')
125 shift 1;
126 ARCHOPT=$1
127 ;;
128 '-noprefix')
129 NOPREFIX=1
130 ;;
131 '-exports')
132 shift 1;
133 EXPORTS=$1
134 ;;
135 -*)
136 echo "mklib: Unknown option: " $1 ;
137 exit 1
138 ;;
139 *)
140 # This should be the first object file, stop parsing
141 break
142 esac
143 shift 1
144 done
145 OBJECTS=$@
146
147
148 if [ ${ARCH} = "auto" ] ; then
149 ARCH=`uname`
150 fi
151
152
153 #
154 # Error checking
155 #
156 if [ "x${LIBNAME}" = "x" ] ; then
157 echo "mklib: Error: no library name specified"
158 exit 1
159 fi
160 if [ "x${OBJECTS}" = "x" ] ; then
161 echo "mklib: Error: no object files specified"
162 exit 1
163 fi
164
165
166 #
167 # Debugging info
168 #
169 if [ ] ; then
170 echo "-----------------"
171 echo ARCH is $ARCH
172 echo LIBNAME is $LIBNAME
173 echo MAJOR is $MAJOR
174 echo MINOR is $MINOR
175 echo PATCH is $PATCH
176 echo DEPS are $DEPS
177 echo "EXPORTS in" $EXPORTS
178 echo "-----------------"
179 fi
180
181
182 #
183 # OK, make the library now
184 #
185 case $ARCH in
186
187 'Linux' | 'OpenBSD' | 'GNU' | GNU/*)
188 # we assume gcc
189
190 if [ "x$LINK" = "x" ] ; then
191 # -linker was not specified so set default link command now
192 if [ $CPLUSPLUS = 1 ] ; then
193 LINK=g++
194 else
195 LINK=gcc
196 fi
197 fi
198
199 if [ $NOPREFIX = 1 ] ; then
200 # No "lib" or ".so" part
201 echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}
202 #OPTS="-shared -Wl,-soname,${LIBNAME}" # soname???
203 OPTS="-shared"
204
205 # Check if objects are 32-bit and we're running in 64-bit
206 # environment. If so, pass -m32 flag to linker.
207 set ${OBJECTS}
208 ABI32=`file $1 | grep 32-bit`
209 if [ "${ABI32}" -a `uname -m` = "x86_64" ] ; then
210 OPTS="-m32 ${OPTS}"
211 fi
212
213 rm -f ${LIBNAME}
214 # make lib
215 ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
216 # finish up
217 FINAL_LIBS="${LIBNAME}"
218 elif [ $STATIC = 1 ] ; then
219 LIBNAME="lib${LIBNAME}.a" # prefix with "lib", suffix with ".a"
220 echo "mklib: Making" $ARCH "static library: " ${LIBNAME}
221 LINK="ar"
222 OPTS="-ru"
223 rm -f ${LIBNAME}
224 # make lib
225 ${LINK} ${OPTS} ${LIBNAME} ${OBJECTS}
226 ranlib ${LIBNAME}
227 # finish up
228 FINAL_LIBS=${LIBNAME}
229 else
230 LIBNAME="lib${LIBNAME}" # prefix with "lib"
231 case $ARCH in 'Linux' | 'GNU' | GNU/*)
232 OPTS="-Xlinker -Bsymbolic -shared -Wl,-soname,${LIBNAME}.so.${MAJOR}"
233 ;;
234 *)
235 OPTS="-shared -Wl,-soname,${LIBNAME}.so.${MAJOR}"
236 ;;
237 esac
238 if [ $EXPORTS ] ; then
239 #OPTS="${OPTS} -Xlinker --retain-symbols-file ${EXPORTS}"
240 # Make the 'exptmp' file for --version-script option
241 echo "VERSION_${MAJOR}.${MINOR} {" > exptmp
242 echo "global:" >> exptmp
243 sed 's/$/;/' ${EXPORTS} >> exptmp
244 echo "local:" >> exptmp
245 echo "*;" >> exptmp
246 echo "};" >> exptmp
247 OPTS="${OPTS} -Xlinker --version-script=exptmp"
248 # exptmp is removed below
249 fi
250
251 # Check if objects are 32-bit and we're running in 64-bit
252 # environment. If so, pass -m32 flag to linker.
253 set ${OBJECTS}
254 ABI32=`file $1 | grep 32-bit`
255 if [ "${ABI32}" -a `uname -m` = "x86_64" ] ; then
256 OPTS="-m32 ${OPTS}"
257 fi
258
259 if [ x${PATCH} = "x" ] ; then
260 VERSION="${MAJOR}.${MINOR}"
261 else
262 VERSION="${MAJOR}.${MINOR}.${PATCH}"
263 fi
264
265 echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}.so.${VERSION}
266
267 # rm any old libs
268 rm -f ${LIBNAME}.so.${VERSION}
269 rm -f ${LIBNAME}.so.${MAJOR}
270 rm -f ${LIBNAME}.so
271
272 # make lib
273 ${LINK} ${OPTS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
274 # make usual symlinks
275 ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR}
276 ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
277 # finish up
278 FINAL_LIBS="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so"
279 # rm -f exptmp
280 fi
281 ;;
282
283 'SunOS')
284 if [ $STATIC = 1 ] ; then
285 LIBNAME="lib${LIBNAME}.a"
286 echo "mklib: Making SunOS static library: " ${LIBNAME}
287 rm -f ${LIBNAME}
288 ar -ruv ${LIBNAME} ${OBJECTS}
289 FINAL_LIBS=${LIBNAME}
290 else
291 if [ $NOPREFIX = 0 ] ; then
292 LIBNAME="lib${LIBNAME}.so"
293 fi
294 echo "mklib: Making SunOS shared library: " ${LIBNAME}
295
296 if [ "x$LINK" = "x" ] ; then
297 # -linker was not specified, choose default linker now
298 if [ $CPLUSPLUS = 1 ] ; then
299 # determine linker and options for C++ code
300 if [ `which c++` ] ; then
301 # use Sun c++
302 LINK="c++"
303 elif [ `type g++` ] ; then
304 # use g++
305 LINK="g++"
306 else
307 echo "mklib: warning: can't find C++ comiler, trying CC."
308 LINK="CC"
309 fi
310 else
311 # use native Sun linker for C code
312 LINK="ld"
313 fi
314 fi
315
316 # linker options
317 if [ ${LINK} = "ld" -o ${LINK} = "cc" -o ${LINK} = "CC" ] ; then
318 # SunOS tools, -G to make shared libs
319 OPTS="-G"
320 else
321 # gcc linker
322 # Check if objects are 32-bit and we're running in 64-bit
323 # environment. If so, pass -m32 flag to linker.
324 set ${OBJECTS}
325 ABI32=`file $1 | grep 32-bit`
326 if [ "${ABI32}" ] ; then
327 OPTS="-m32 -shared -Wl,-Bdynamic"
328 else
329 OPTS="-m64 -shared -Wl,-Bdynamic"
330 fi
331 fi
332
333 # Check if objects are SPARC v9
334 # file says: ELF 64-bit MSB relocatable SPARCV9 Version 1
335 set ${OBJECTS}
336 SPARCV9=`file $1 | grep SPARCV9`
337 if [ "${SPARCV9}" ] ; then
338 OPTS="${OPTS} -xarch=v9"
339 fi
340
341 # for debug:
342 #echo "mklib: linker is" ${LINK} ${OPTS}
343 if [ $NOPREFIX = 1 ] ; then
344 rm -f ${LIBNAME}
345 ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
346 else
347 rm -f ${LIBNAME}.${MAJOR} ${LIBNAME}
348 ${LINK} ${OPTS} -o ${LIBNAME}.${MAJOR} ${OBJECTS} ${DEPS}
349 ln -s ${LIBNAME}.${MAJOR} ${LIBNAME}
350 fi
351 FINAL_LIBS="${LIBNAME}.${MAJOR} ${LIBNAME}"
352 fi
353 ;;
354
355 'FreeBSD')
356 # we assume gcc
357
358 if [ "x$LINK" = "x" ] ; then
359 # -linker was not specified so set default link command now
360 if [ $CPLUSPLUS = 1 ] ; then
361 LINK=g++
362 else
363 LINK=gcc
364 fi
365 fi
366
367 if [ $NOPREFIX = 1 ] ; then
368 # No "lib" or ".so" part
369 echo "mklib: Making FreeBSD shared library: " ${LIBNAME}
370 OPTS="-shared"
371 rm -f ${LIBNAME}
372 ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
373 FINAL_LIBS=${LIBNAME}
374 elif [ $STATIC = 1 ] ; then
375 STLIB="lib${LIBNAME}.a"
376 echo "mklib: Making FreeBSD static library: " ${STLIB}
377 rm -f ${STLIB}
378 ar cq ${STLIB} ${OBJECTS}
379 ranlib ${STLIB}
380 FINAL_LIBS=${STLIB}
381 else
382 SHLIB="lib${LIBNAME}.so.${MAJOR}"
383 OPTS="-shared -Wl,-soname,${SHLIB}"
384 echo "mklib: Making FreeBSD shared library: " ${SHLIB}
385 rm -f ${SHLIB}
386 ${LINK} ${OPTS} -o ${SHLIB} ${OBJECTS} ${DEPS}
387 ln -sf ${SHLIB} "lib${LIBNAME}.so"
388 FINAL_LIBS="${SHLIB} lib${LIBNAME}.so"
389 fi
390 ;;
391
392 'NetBSD')
393 if [ $STATIC = 1 ] ; then
394 LIBNAME="lib${LIBNAME}_pic.a"
395 echo "mklib: Making NetBSD PIC static library: " ${LIBNAME}
396 rm -f ${LIBNAME}
397 ar cq ${LIBNAME} ${OBJECTS}
398 ranlib ${LIBNAME}
399 FINAL_LIBS=${LIBNAME}
400 else
401 LIBNAME="lib${LIBNAME}.so.${MAJOR}.${MINOR}"
402 echo "mklib: Making NetBSD PIC shared library: " ${LIBNAME}
403 rm -f ${LIBNAME}
404 ld -x -Bshareable -Bforcearchive -o ${LIBNAME} ${OBJECTS}
405 FINAL_LIBS=${LIBNAME}
406 fi
407 ;;
408
409 'IRIX' | 'IRIX64')
410 if [ $STATIC = 1 ] ; then
411 LIBNAME="lib${LIBNAME}.a"
412 rm -f ${LIBNAME}
413 ar rc ${LIBNAME} ${OBJECTS}
414 FINAL_LIBS=${LIBNAME}
415 else
416 LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
417
418 # examine first object to determine ABI
419 set ${OBJECTS}
420 ABI_O32=`file $1 | grep 'ELF 32-bit'`
421 ABI_N32=`file $1 | grep 'ELF N32'`
422 ABI_N64=`file $1 | grep 'ELF 64-bit'`
423 if [ "${ABI_O32}" ] ; then
424 OPTS="-32 -shared -all"
425 ABI="o32-bit"
426 elif [ "${ABI_N32}" ] ; then
427 OPTS="-n32 -shared -all"
428 ABI="n32-bit"
429 elif [ "${ABI_N64}" ] ; then
430 OPTS="-64 -shared -all"
431 ABI="64-bit"
432 else
433 echo "Error: Unexpected IRIX ABI!"
434 exit 1
435 fi
436
437 if [ $CPLUSPLUS = 1 ] ; then
438 LINK="CC"
439 else
440 LINK="ld"
441 fi
442
443 echo "mklib: Making IRIX " ${ABI} " shared library: " ${LIBNAME}
444 ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
445 FINAL_LIBS=${LIBNAME}
446 fi
447 ;;
448
449 'linux-cygwin')
450 LIBNAME="lib${LIBNAME}.a"
451 echo "mklib: Making linux-cygwin library: " ${LIBNAME}
452 rm -f ${LIBNAME}
453 gnuwin32ar ruv ${LIBNAME} ${OBJECTS}
454 FINAL_LIBS=${LIBNAME}
455 ;;
456
457 'HP-UX')
458 if [ $STATIC = 1 ] ; then
459 LIBNAME="lib${LIBNAME}.a"
460 echo "mklib: Making HP-UX static library: " ${LIBNAME}
461 rm -f ${LIBNAME}
462 ar -ruv ${LIBNAME} ${OBJECTS}
463 FINAL_LIBS=${LIBNAME}
464 else
465 # HP uses a .2 for their current GL/GLU libraries
466 if [ ${LIBNAME} = "GL" -o ${LIBNAME} = "GLU" ] ; then
467 MAJOR=2
468 fi
469 RUNLIB="lib${LIBNAME}.${MAJOR}"
470 DEVLIB="lib${LIBNAME}.sl"
471 echo "mklib: Making HP-UX shared library: " ${RUNLIB} ${DEVLIB}
472 ld -b -o ${RUNLIB} +b ${RUNLIB} ${OBJECTS} ${DEPS}
473 ln -s ${RUNLIB} ${DEVLIB}
474 FINAL_LIBS="${RUNLIB} ${DEVLIB}"
475 fi
476 ;;
477
478 'AIX' )
479 # examine first object to determine ABI
480 set ${OBJECTS}
481 ABI_64=`file $1 | grep '64-bit'`
482 if [ "${ABI_64}" ] ; then
483 X64="-X64"
484 Q64="-q64"
485 OFILE=shr_64.o
486 else
487 OFILE=shr.o #Want to be consistent with the IBM libGL.a
488 fi
489
490 if [ $STATIC = 1 ] ; then
491 LIBNAME="lib${LIBNAME}.a"
492 echo "mklib: Making AIX static library: " ${LIBNAME}
493 ar -ruv ${X64} ${LIBNAME} ${OBJECTS}
494 FINAL_LIBS=${LIBNAME}
495 else
496 EXPFILE="lib${LIBNAME}.exp"
497 LIBNAME="lib${LIBNAME}.a" # shared objects are still stored in the .a libraries
498 OPTS="-bE:${EXPFILE} -bM:SRE -bnoentry ${Q64}"
499 rm -f ${EXPFILE} ${OFILE}
500 NM="/bin/nm -eC ${X64}"
501 echo "#! /usr/lib/${LIBNAME}" > ${EXPFILE}
502 ${NM} ${OBJECTS} | awk '{
503 if ((($2 == "T") || ($2 == "D") || ($2 == "B")) \
504 && ( substr($1,1,1) != ".")) {
505 if (substr ($1, 1, 7) != "__sinit" &&
506 substr ($1, 1, 7) != "__sterm") {
507 if (substr ($1, 1, 5) == "__tf1")
508 print (substr ($1, 7))
509 else if (substr ($1, 1, 5) == "__tf9")
510 print (substr ($1, 15))
511 else
512 print $1
513 }
514 }
515 }' | sort -u >> ${EXPFILE}
516
517 # On AIX a shared library is linked differently when
518 # you want to dlopen the file
519 if [ $DLOPEN = "1" ] ; then
520 cc -G ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
521 else
522 cc ${OPTS} -o ${OFILE} ${OBJECTS} ${DEPS}
523 ar ${X64} -r ${LIBNAME} ${OFILE}
524 fi
525
526 FINAL_LIBS="${LIBNAME}"
527 fi
528 ;;
529
530 'OpenSTEP')
531 LIBNAME="lib${LIBNAME}.a"
532 echo "mklib: Making OpenSTEP static library: " ${LIBNAME}
533 libtool -static -o ${LIBNAME} - ${OBJECTS}
534 FINAL_LIBS=${LIBNAME}
535 ;;
536
537 'OSF1')
538 if [ $STATIC = 1 ] ; then
539 LIBNAME="lib${LIBNAME}.a"
540 echo "mklib: Making OSF/1 static library: " ${LIBNAME}
541 rm -f ${LIBNAME}
542 ar -ruv ${LIBNAME} ${OBJECTS}
543 FINAL_LIBS=${LIBNAME}
544 else
545 VERSION="${MAJOR}.${MINOR}"
546 LIBNAME="lib${LIBNAME}.so"
547 echo "mklib: Making OSF/1 shared library: " ${LIBNAME}
548 if [ "x$LINK" = "x" ] ; then
549 if [ $CPLUSPLUS = 1 ] ; then
550 LINK=cxx
551 else
552 LINK=cc
553 fi
554 fi
555 rm -f ${LIBNAME}.${VERSION}
556 ${LINK} -o ${LIBNAME}.${VERSION} -shared -set_version ${VERSION} -soname ${LIBNAME}.${VERSION} -expect_unresolved \* -all ${OBJECTS} ${DEPS}
557 ln -sf ${LIBNAME}.${VERSION} ${LIBNAME}
558 FINAL_LIBS="${LIBNAME} ${LIBNAME}.${VERSION}"
559 fi
560 ;;
561
562 'Darwin')
563 if [ $STATIC = 1 ] ; then
564 LIBNAME="lib${LIBNAME}.a"
565 echo "mklib: Making Darwin static library: " ${LIBNAME}
566 LINK="ar"
567 OPTS="-ruvs"
568 ${LINK} ${OPTS} ${LIBNAME} ${OBJECTS}
569 FINAL_LIBS=${LIBNAME}
570 else
571 # On Darwin a .bundle is used for a library that you want to dlopen
572 if [ $DLOPEN = "1" ] ; then
573 LIBSUFFIX="bundle"
574 OPTS="${ARCHOPT} -bundle -multiply_defined suppress"
575 else
576 LIBSUFFIX="dylib"
577 OPTS="${ARCHOPT} -dynamiclib -multiply_defined suppress -current_version ${MAJOR}.${MINOR}.0 -compatibility_version ${MAJOR}.${MINOR}.0 -install_name lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}"
578 fi
579 LINKNAME="lib${LIBNAME}.${LIBSUFFIX}"
580 LIBNAME="lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}"
581
582 # examine first object to determine ABI
583 set ${OBJECTS}
584 ABI_PPC=`file $1 | grep 'object ppc'`
585 ABI_I386=`file $1 | grep 'object i386'`
586 if [ "${ABI_PPC}" ] ; then
587 OPTS="${OPTS} -arch ppc"
588 fi
589 if [ "${ABI_I386}" ] ; then
590 OPTS="${OPTS} -arch i386"
591 fi
592
593 # XXX can we always add -isysroot /Developer/SDKs/MacOSX10.4u.sdk
594 # to OPTS here?
595
596 # determine linker
597 if [ $CPLUSPLUS = 1 ] ; then
598 LINK="g++"
599 else
600 LINK="cc"
601 fi
602
603 echo "mklib: Making Darwin shared library: " ${LIBNAME}
604 ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
605 ln -s ${LIBNAME} ${LINKNAME}
606 FINAL_LIBS="${LIBNAME} ${LINKNAME}"
607 fi
608 ;;
609
610 'LynxOS')
611 LIBNAME="lib${LIBNAME}.a"
612 echo "mklib: Making LynxOS static library: " ${LIBNAME}
613 rm -f ${LIBNAME}
614 ar ru ${LIBNAME} ${OBJECTS}
615 FINAL_LIBS=${LIBNAME}
616 ;;
617
618 'BeOS')
619 if [ $STATIC = 1 ] ; then
620 LIBNAME="lib${LIBNAME}.a"
621 echo "mklib: Making BeOS static library: " ${LIBNAME}
622 ar -cru "${LIBNAME}" ${OBJECTS}
623 else
624 LIBNAME="lib${LIBNAME}.so"
625 echo "mklib: Making BeOS shared library: " ${LIBNAME}
626 gcc -nostart -Xlinker "-soname=${LIBNAME}" -L/Be/develop/lib/x86 -lbe ${DEPS} ${OBJECTS} -o "${LIBNAME}"
627 mimeset -f "${LIBNAME}"
628 # XXX remove the Mesa3D stuff here since mklib isn't mesa-specific.
629 setversion "${LIBNAME}" -app ${MAJOR} ${MINOR} ${PATCH} -short "Powered by Mesa3D!" -long "Powered by Mesa3D!"
630 fi
631 FINAL_LIBS=${LIBNAME}
632 ;;
633
634 'QNX')
635 LIBNAME="lib${LIBNAME}.a"
636 echo "mklib: Making QNX library: " ${LIBNAME}
637 wlib ${LIBNAME} ${OBJECTS}
638 FINAL_LIBS=${LIBNAME}
639 ;;
640
641 'MorphOS')
642 LIBNAME="lib${LIBNAME}.a"
643 echo "mklib: Making MorphOS library: " ${LIBNAME}
644 ppc-morphos-ar rc ${LIBNAME} ${OBJECTS}
645 FINAL_LIBS="${LIBNAME}"
646 ;;
647
648 'icc' | 'icc-istatic')
649 # Intel C compiler
650 # This should get merged into the Linux code, above, since this isn't
651 # really a different architecture.
652 LIBNAME="lib${LIBNAME}" # prefix with "lib"
653
654 if [ $STATIC = 1 ] ; then
655 echo "mklib: Making Intel ICC static library: " ${LIBNAME}.a
656 LINK="ar"
657 OPTS="-ruv"
658 # make lib
659 ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
660 # finish up
661 FINAL_LIBS="${LIBNAME}.a"
662 else
663 if [ $ARCH = icc-istatic ] ; then
664 OPTS="-shared -i-static -cxxlib-icc"
665 else
666 OPTS="-shared"
667 fi
668 VERSION="${MAJOR}.${MINOR}.${PATCH}"
669 echo "mklib: Making Intel ICC shared library: " ${LIBNAME}.so.${VERSION}
670
671 if [ $CPLUSPLUS = 1 ] ; then
672 LINK="icpc"
673 else
674 LINK="icc"
675 fi
676 # rm any old libs
677 rm -f ${LIBNAME}.so.${VERSION}
678 rm -f ${LIBNAME}.so.${MAJOR}
679 rm -f ${LIBNAME}.so
680 # make lib
681 ${LINK} ${OPTS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
682 # make usual symlinks
683 ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR}
684 ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
685 # finish up
686 FINAL_LIBS="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so"
687 fi
688 ;;
689
690 'aix-gcc')
691 # AIX with gcc
692 if [ $STATIC = 1 ] ; then
693 LIBNAME="lib${LIBNAME}.a"
694 echo "mklib: Making AIX GCC static library: " ${LIBNAME}
695 rm -f ${LIBNAME}
696 ar ru ${LIBNAME} ${OBJECTS}
697 FINAL_LIBS=${LIBNAME}
698 else
699 LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
700 echo "mklib: Making AIX GCC shared library: " ${LIBNAME}
701 # remove old lib
702 rm -f ${LIBNAME}
703 # make the lib
704 gcc -shared -Wl,-G ${OBJECTS} ${DEPS} -o ${LIBNAME}
705 # NOTE: the application linking with this library must specify
706 # the -Wl,-brtl flags to gcc
707 FINAL_LIBS=${LIBNAME}
708 fi
709 ;;
710
711 'ultrix')
712 # XXX untested
713 if [ $STATIC = 0 ] ; then
714 echo "mklib: Warning shared libs not supported on Ultrix"
715 fi
716 LIBNAME="lib${LIBNAME}.a"
717 echo "mklib: Making static library for Ultrix: " ${LIBNAME}
718 rm -f ${LIBNAME}
719 ar ru ${LIBNAME} ${OBJECTS}
720 FINAL_LIBS="${LIBNAME}"
721 ;;
722
723 CYGWIN*)
724 # GCC-based environment
725 CYGNAME="cyg${LIBNAME}" # prefix with "cyg"
726 LIBNAME="lib${LIBNAME}" # prefix with "lib"
727
728 if [ $STATIC = 1 ] ; then
729 echo "mklib: Making" $ARCH "static library: " ${LIBNAME}.a
730 LINK="ar"
731 OPTS="-ru"
732 # make lib
733 ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
734 ranlib ${LIBNAME}.a
735 # finish up
736 FINAL_LIBS=${LIBNAME}.a
737 else
738 OPTS="-shared -Wl,-export-all -Wl,--out-implib=${LIBNAME}-${MAJOR}.dll.a"
739 echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}-${MAJOR}.dll
740
741 if [ $CPLUSPLUS = 1 ] ; then
742 LINK="g++"
743 else
744 LINK="gcc"
745 fi
746
747 # rm any old libs
748 rm -f ${LIBNAME}-${MAJOR}.dll
749 rm -f ${LIBNAME}.dll.a
750 rm -f ${LIBNAME}.a
751
752 # make lib
753 ${LINK} ${OPTS} -o ${CYGNAME}-${MAJOR}.dll ${OBJECTS} ${DEPS}
754 # make usual symlinks
755 ln -s ${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a
756 # finish up
757 FINAL_LIBS="${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a"
758 # special case for installing in bin
759 FINAL_BINS="${CYGNAME}-${MAJOR}.dll"
760 fi
761 ;;
762
763 'example')
764 # If you're adding support for a new architecture, you can
765 # start with this:
766 if [ $STATIC = 1 ] ; then
767 LIBNAME="lib${LIBNAME}.a"
768 echo "mklib: Making static library for example arch: " ${LIBNAME}
769 rm -f ${LIBNAME}
770 ar rv ${LIBNAME} ${OBJECTS}
771 FINAL_LIBS="${LIBNAME}"
772 else
773 LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
774 echo "mklib: Making shared library for example arch: " ${LIBNAME}
775 ld -o ${LIBNAME} ${OBJECTS} ${DEPS}
776 FINAL_LIBS="${LIBNAME}"
777 fi
778 ;;
779
780 *)
781 echo "mklib: ERROR: Don't know how to make a static/shared library for" ${ARCH}
782 echo "mklib: Please add necessary commands to mklib script."
783 ;;
784 esac
785
786
787 #
788 # Put library files into installation directory if specified.
789 #
790 if [ ${INSTALLDIR} != "." ] ; then
791 echo "mklib: Installing" ${FINAL_LIBS} "in" ${INSTALLDIR}
792 mv ${FINAL_LIBS} ${INSTALLDIR}/
793 fi