version bump
[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 LIBNAME="lib${LIBNAME}.so"
287 echo "mklib: Making SunOS shared library: " ${LIBNAME}
288
289 if [ "x$LINK" = "x" ] ; then
290 # -linker was not specified, choose default linker now
291 if [ $CPLUSPLUS = 1 ] ; then
292 # determine linker and options for C++ code
293 if [ `which c++` ] ; then
294 # use Sun c++
295 LINK="c++"
296 elif [ `type g++` ] ; then
297 # use g++
298 LINK="g++"
299 else
300 echo "mklib: warning: can't find C++ comiler, trying CC."
301 LINK="CC"
302 fi
303 else
304 # use native Sun linker for C code
305 LINK="ld"
306 fi
307 fi
308
309 # linker options
310 if [ ${LINK} = "ld" -o ${LINK} = "cc" -o ${LINK} = "CC" ] ; then
311 # SunOS tools, -G to make shared libs
312 OPTS="-G"
313 else
314 # gcc linker
315 # Check if objects are 32-bit and we're running in 64-bit
316 # environment. If so, pass -m32 flag to linker.
317 set ${OBJECTS}
318 ABI32=`file $1 | grep 32-bit`
319 if [ "${ABI32}" ] ; then
320 OPTS="-m32 -shared -Wl,-Bdynamic"
321 else
322 OPTS="-m64 -shared -Wl,-Bdynamic"
323 fi
324 fi
325
326 # Check if objects are SPARC v9
327 # file says: ELF 64-bit MSB relocatable SPARCV9 Version 1
328 set ${OBJECTS}
329 SPARCV9=`file $1 | grep SPARCV9`
330 if [ "${SPARCV9}" ] ; then
331 OPTS="${OPTS} -xarch=v9"
332 fi
333
334 # for debug:
335 #echo "mklib: linker is" ${LINK} ${OPTS}
336 rm -f ${LIBNAME}.${MAJOR} ${LIBNAME}
337 ${LINK} ${OPTS} -o ${LIBNAME}.${MAJOR} ${OBJECTS} ${DEPS}
338 ln -s ${LIBNAME}.${MAJOR} ${LIBNAME}
339 FINAL_LIBS="${LIBNAME}.${MAJOR} ${LIBNAME}"
340 fi
341 ;;
342
343 'FreeBSD')
344 # we assume gcc
345
346 if [ "x$LINK" = "x" ] ; then
347 # -linker was not specified so set default link command now
348 if [ $CPLUSPLUS = 1 ] ; then
349 LINK=g++
350 else
351 LINK=gcc
352 fi
353 fi
354
355 if [ $NOPREFIX = 1 ] ; then
356 # No "lib" or ".so" part
357 echo "mklib: Making FreeBSD shared library: " ${LIBNAME}
358 OPTS="-shared"
359 rm -f ${LIBNAME}
360 ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
361 FINAL_LIBS=${LIBNAME}
362 elif [ $STATIC = 1 ] ; then
363 STLIB="lib${LIBNAME}.a"
364 echo "mklib: Making FreeBSD static library: " ${STLIB}
365 rm -f ${STLIB}
366 ar cq ${STLIB} ${OBJECTS}
367 ranlib ${STLIB}
368 FINAL_LIBS=${STLIB}
369 else
370 SHLIB="lib${LIBNAME}.so.${MAJOR}"
371 OPTS="-shared -Wl,-soname,${SHLIB}"
372 echo "mklib: Making FreeBSD shared library: " ${SHLIB}
373 rm -f ${SHLIB}
374 ${LINK} ${OPTS} -o ${SHLIB} ${OBJECTS} ${DEPS}
375 ln -sf ${SHLIB} "lib${LIBNAME}.so"
376 FINAL_LIBS="${SHLIB} lib${LIBNAME}.so"
377 fi
378 ;;
379
380 'NetBSD')
381 if [ $STATIC = 1 ] ; then
382 LIBNAME="lib${LIBNAME}_pic.a"
383 echo "mklib: Making NetBSD PIC static library: " ${LIBNAME}
384 rm -f ${LIBNAME}
385 ar cq ${LIBNAME} ${OBJECTS}
386 ranlib ${LIBNAME}
387 FINAL_LIBS=${LIBNAME}
388 else
389 LIBNAME="lib${LIBNAME}.so.${MAJOR}.${MINOR}"
390 echo "mklib: Making NetBSD PIC shared library: " ${LIBNAME}
391 rm -f ${LIBNAME}
392 ld -x -Bshareable -Bforcearchive -o ${LIBNAME} ${OBJECTS}
393 FINAL_LIBS=${LIBNAME}
394 fi
395 ;;
396
397 'IRIX' | 'IRIX64')
398 if [ $STATIC = 1 ] ; then
399 LIBNAME="lib${LIBNAME}.a"
400 rm -f ${LIBNAME}
401 ar rc ${LIBNAME} ${OBJECTS}
402 FINAL_LIBS=${LIBNAME}
403 else
404 LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
405
406 # examine first object to determine ABI
407 set ${OBJECTS}
408 ABI_O32=`file $1 | grep 'ELF 32-bit'`
409 ABI_N32=`file $1 | grep 'ELF N32'`
410 ABI_N64=`file $1 | grep 'ELF 64-bit'`
411 if [ "${ABI_O32}" ] ; then
412 OPTS="-32 -shared -all"
413 ABI="o32-bit"
414 elif [ "${ABI_N32}" ] ; then
415 OPTS="-n32 -shared -all"
416 ABI="n32-bit"
417 elif [ "${ABI_N64}" ] ; then
418 OPTS="-64 -shared -all"
419 ABI="64-bit"
420 else
421 echo "Error: Unexpected IRIX ABI!"
422 exit 1
423 fi
424
425 if [ $CPLUSPLUS = 1 ] ; then
426 LINK="CC"
427 else
428 LINK="ld"
429 fi
430
431 echo "mklib: Making IRIX " ${ABI} " shared library: " ${LIBNAME}
432 ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
433 FINAL_LIBS=${LIBNAME}
434 fi
435 ;;
436
437 'linux-cygwin')
438 LIBNAME="lib${LIBNAME}.a"
439 echo "mklib: Making linux-cygwin library: " ${LIBNAME}
440 rm -f ${LIBNAME}
441 gnuwin32ar ruv ${LIBNAME} ${OBJECTS}
442 FINAL_LIBS=${LIBNAME}
443 ;;
444
445 'HP-UX')
446 if [ $STATIC = 1 ] ; then
447 LIBNAME="lib${LIBNAME}.a"
448 echo "mklib: Making HP-UX static library: " ${LIBNAME}
449 rm -f ${LIBNAME}
450 ar -ruv ${LIBNAME} ${OBJECTS}
451 FINAL_LIBS=${LIBNAME}
452 else
453 # HP uses a .2 for their current GL/GLU libraries
454 if [ ${LIBNAME} = "GL" -o ${LIBNAME} = "GLU" ] ; then
455 MAJOR=2
456 fi
457 RUNLIB="lib${LIBNAME}.${MAJOR}"
458 DEVLIB="lib${LIBNAME}.sl"
459 echo "mklib: Making HP-UX shared library: " ${RUNLIB} ${DEVLIB}
460 ld -b -o ${RUNLIB} +b ${RUNLIB} ${OBJECTS} ${DEPS}
461 ln -s ${RUNLIB} ${DEVLIB}
462 FINAL_LIBS="${RUNLIB} ${DEVLIB}"
463 fi
464 ;;
465
466 'AIX' )
467 # examine first object to determine ABI
468 set ${OBJECTS}
469 ABI_64=`file $1 | grep '64-bit'`
470 if [ "${ABI_64}" ] ; then
471 X64="-X64"
472 Q64="-q64"
473 OFILE=shr_64.o
474 else
475 OFILE=shr.o #Want to be consistent with the IBM libGL.a
476 fi
477
478 if [ $STATIC = 1 ] ; then
479 LIBNAME="lib${LIBNAME}.a"
480 echo "mklib: Making AIX static library: " ${LIBNAME}
481 ar -ruv ${X64} ${LIBNAME} ${OBJECTS}
482 FINAL_LIBS=${LIBNAME}
483 else
484 EXPFILE="lib${LIBNAME}.exp"
485 LIBNAME="lib${LIBNAME}.a" # shared objects are still stored in the .a libraries
486 OPTS="-bE:${EXPFILE} -bM:SRE -bnoentry ${Q64}"
487 rm -f ${EXPFILE} ${OFILE}
488 NM="/bin/nm -eC ${X64}"
489 echo "#! /usr/lib/${LIBNAME}" > ${EXPFILE}
490 ${NM} ${OBJECTS} | awk '{
491 if ((($2 == "T") || ($2 == "D") || ($2 == "B")) \
492 && ( substr($1,1,1) != ".")) {
493 if (substr ($1, 1, 7) != "__sinit" &&
494 substr ($1, 1, 7) != "__sterm") {
495 if (substr ($1, 1, 5) == "__tf1")
496 print (substr ($1, 7))
497 else if (substr ($1, 1, 5) == "__tf9")
498 print (substr ($1, 15))
499 else
500 print $1
501 }
502 }
503 }' | sort -u >> ${EXPFILE}
504
505 # On AIX a shared library is linked differently when
506 # you want to dlopen the file
507 if [ $DLOPEN = "1" ] ; then
508 cc -G ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
509 else
510 cc ${OPTS} -o ${OFILE} ${OBJECTS} ${DEPS}
511 ar ${X64} -r ${LIBNAME} ${OFILE}
512 fi
513
514 FINAL_LIBS="${LIBNAME}"
515 fi
516 ;;
517
518 'OpenSTEP')
519 LIBNAME="lib${LIBNAME}.a"
520 echo "mklib: Making OpenSTEP static library: " ${LIBNAME}
521 libtool -static -o ${LIBNAME} - ${OBJECTS}
522 FINAL_LIBS=${LIBNAME}
523 ;;
524
525 'OSF1')
526 if [ $STATIC = 1 ] ; then
527 LIBNAME="lib${LIBNAME}.a"
528 echo "mklib: Making OSF/1 static library: " ${LIBNAME}
529 rm -f ${LIBNAME}
530 ar -ruv ${LIBNAME} ${OBJECTS}
531 FINAL_LIBS=${LIBNAME}
532 else
533 VERSION="${MAJOR}.${MINOR}"
534 LIBNAME="lib${LIBNAME}.so"
535 echo "mklib: Making OSF/1 shared library: " ${LIBNAME}
536 if [ "x$LINK" = "x" ] ; then
537 if [ $CPLUSPLUS = 1 ] ; then
538 LINK=cxx
539 else
540 LINK=cc
541 fi
542 fi
543 rm -f ${LIBNAME}.${VERSION}
544 ${LINK} -o ${LIBNAME}.${VERSION} -shared -set_version ${VERSION} -soname ${LIBNAME}.${VERSION} -expect_unresolved \* -all ${OBJECTS} ${DEPS}
545 ln -sf ${LIBNAME}.${VERSION} ${LIBNAME}
546 FINAL_LIBS="${LIBNAME} ${LIBNAME}.${VERSION}"
547 fi
548 ;;
549
550 'Darwin')
551 if [ $STATIC = 1 ] ; then
552 LIBNAME="lib${LIBNAME}.a"
553 echo "mklib: Making Darwin static library: " ${LIBNAME}
554 LINK="ar"
555 OPTS="-ruvs"
556 ${LINK} ${OPTS} ${LIBNAME} ${OBJECTS}
557 FINAL_LIBS=${LIBNAME}
558 else
559 # On Darwin a .bundle is used for a library that you want to dlopen
560 if [ $DLOPEN = "1" ] ; then
561 LIBSUFFIX="bundle"
562 OPTS="${ARCHOPT} -bundle -multiply_defined suppress"
563 else
564 LIBSUFFIX="dylib"
565 OPTS="${ARCHOPT} -dynamiclib -multiply_defined suppress -current_version ${MAJOR}.${MINOR}.0 -compatibility_version ${MAJOR}.${MINOR}.0 -install_name lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}"
566 fi
567 LINKNAME="lib${LIBNAME}.${LIBSUFFIX}"
568 LIBNAME="lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}"
569
570 # examine first object to determine ABI
571 set ${OBJECTS}
572 ABI_PPC=`file $1 | grep 'object ppc'`
573 ABI_I386=`file $1 | grep 'object i386'`
574 if [ "${ABI_PPC}" ] ; then
575 OPTS="${OPTS} -arch ppc"
576 fi
577 if [ "${ABI_I386}" ] ; then
578 OPTS="${OPTS} -arch i386"
579 fi
580
581 # XXX can we always add -isysroot /Developer/SDKs/MacOSX10.4u.sdk
582 # to OPTS here?
583
584 # determine linker
585 if [ $CPLUSPLUS = 1 ] ; then
586 LINK="g++"
587 else
588 LINK="cc"
589 fi
590
591 echo "mklib: Making Darwin shared library: " ${LIBNAME}
592 ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
593 ln -s ${LIBNAME} ${LINKNAME}
594 FINAL_LIBS="${LIBNAME} ${LINKNAME}"
595 fi
596 ;;
597
598 'LynxOS')
599 LIBNAME="lib${LIBNAME}.a"
600 echo "mklib: Making LynxOS static library: " ${LIBNAME}
601 rm -f ${LIBNAME}
602 ar ru ${LIBNAME} ${OBJECTS}
603 FINAL_LIBS=${LIBNAME}
604 ;;
605
606 'BeOS')
607 if [ $STATIC = 1 ] ; then
608 LIBNAME="lib${LIBNAME}.a"
609 echo "mklib: Making BeOS static library: " ${LIBNAME}
610 ar -cru "${LIBNAME}" ${OBJECTS}
611 else
612 LIBNAME="lib${LIBNAME}.so"
613 echo "mklib: Making BeOS shared library: " ${LIBNAME}
614 gcc -nostart -Xlinker "-soname=${LIBNAME}" -L/Be/develop/lib/x86 -lbe ${DEPS} ${OBJECTS} -o "${LIBNAME}"
615 mimeset -f "${LIBNAME}"
616 # XXX remove the Mesa3D stuff here since mklib isn't mesa-specific.
617 setversion "${LIBNAME}" -app ${MAJOR} ${MINOR} ${PATCH} -short "Powered by Mesa3D!" -long "Powered by Mesa3D!"
618 fi
619 FINAL_LIBS=${LIBNAME}
620 ;;
621
622 'QNX')
623 LIBNAME="lib${LIBNAME}.a"
624 echo "mklib: Making QNX library: " ${LIBNAME}
625 wlib ${LIBNAME} ${OBJECTS}
626 FINAL_LIBS=${LIBNAME}
627 ;;
628
629 'MorphOS')
630 LIBNAME="lib${LIBNAME}.a"
631 echo "mklib: Making MorphOS library: " ${LIBNAME}
632 ppc-morphos-ar rc ${LIBNAME} ${OBJECTS}
633 FINAL_LIBS="${LIBNAME}"
634 ;;
635
636 'icc' | 'icc-istatic')
637 # Intel C compiler
638 # This should get merged into the Linux code, above, since this isn't
639 # really a different architecture.
640 LIBNAME="lib${LIBNAME}" # prefix with "lib"
641
642 if [ $STATIC = 1 ] ; then
643 echo "mklib: Making Intel ICC static library: " ${LIBNAME}.a
644 LINK="ar"
645 OPTS="-ruv"
646 # make lib
647 ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
648 # finish up
649 FINAL_LIBS="${LIBNAME}.a"
650 else
651 if [ $ARCH = icc-istatic ] ; then
652 OPTS="-shared -i-static -cxxlib-icc"
653 else
654 OPTS="-shared"
655 fi
656 VERSION="${MAJOR}.${MINOR}.${PATCH}"
657 echo "mklib: Making Intel ICC shared library: " ${LIBNAME}.so.${VERSION}
658
659 if [ $CPLUSPLUS = 1 ] ; then
660 LINK="icpc"
661 else
662 LINK="icc"
663 fi
664 # rm any old libs
665 rm -f ${LIBNAME}.so.${VERSION}
666 rm -f ${LIBNAME}.so.${MAJOR}
667 rm -f ${LIBNAME}.so
668 # make lib
669 ${LINK} ${OPTS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
670 # make usual symlinks
671 ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR}
672 ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
673 # finish up
674 FINAL_LIBS="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so"
675 fi
676 ;;
677
678 'aix-gcc')
679 # AIX with gcc
680 if [ $STATIC = 1 ] ; then
681 LIBNAME="lib${LIBNAME}.a"
682 echo "mklib: Making AIX GCC static library: " ${LIBNAME}
683 rm -f ${LIBNAME}
684 ar ru ${LIBNAME} ${OBJECTS}
685 FINAL_LIBS=${LIBNAME}
686 else
687 LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
688 echo "mklib: Making AIX GCC shared library: " ${LIBNAME}
689 # remove old lib
690 rm -f ${LIBNAME}
691 # make the lib
692 gcc -shared -Wl,-G ${OBJECTS} ${DEPS} -o ${LIBNAME}
693 # NOTE: the application linking with this library must specify
694 # the -Wl,-brtl flags to gcc
695 FINAL_LIBS=${LIBNAME}
696 fi
697 ;;
698
699 'ultrix')
700 # XXX untested
701 if [ $STATIC = 0 ] ; then
702 echo "mklib: Warning shared libs not supported on Ultrix"
703 fi
704 LIBNAME="lib${LIBNAME}.a"
705 echo "mklib: Making static library for Ultrix: " ${LIBNAME}
706 rm -f ${LIBNAME}
707 ar ru ${LIBNAME} ${OBJECTS}
708 FINAL_LIBS="${LIBNAME}"
709 ;;
710
711 CYGWIN*)
712 # GCC-based environment
713 CYGNAME="cyg${LIBNAME}" # prefix with "cyg"
714 LIBNAME="lib${LIBNAME}" # prefix with "lib"
715
716 if [ $STATIC = 1 ] ; then
717 echo "mklib: Making" $ARCH "static library: " ${LIBNAME}.a
718 LINK="ar"
719 OPTS="-ru"
720 # make lib
721 ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
722 ranlib ${LIBNAME}.a
723 # finish up
724 FINAL_LIBS=${LIBNAME}.a
725 else
726 OPTS="-shared -Wl,-export-all -Wl,--out-implib=${LIBNAME}-${MAJOR}.dll.a"
727 echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}-${MAJOR}.dll
728
729 if [ $CPLUSPLUS = 1 ] ; then
730 LINK="g++"
731 else
732 LINK="gcc"
733 fi
734
735 # rm any old libs
736 rm -f ${LIBNAME}-${MAJOR}.dll
737 rm -f ${LIBNAME}.dll.a
738 rm -f ${LIBNAME}.a
739
740 # make lib
741 ${LINK} ${OPTS} -o ${CYGNAME}-${MAJOR}.dll ${OBJECTS} ${DEPS}
742 # make usual symlinks
743 ln -s ${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a
744 # finish up
745 FINAL_LIBS="${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a"
746 # special case for installing in bin
747 FINAL_BINS="${CYGNAME}-${MAJOR}.dll"
748 fi
749 ;;
750
751 'example')
752 # If you're adding support for a new architecture, you can
753 # start with this:
754 if [ $STATIC = 1 ] ; then
755 LIBNAME="lib${LIBNAME}.a"
756 echo "mklib: Making static library for example arch: " ${LIBNAME}
757 rm -f ${LIBNAME}
758 ar rv ${LIBNAME} ${OBJECTS}
759 FINAL_LIBS="${LIBNAME}"
760 else
761 LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
762 echo "mklib: Making shared library for example arch: " ${LIBNAME}
763 ld -o ${LIBNAME} ${OBJECTS} ${DEPS}
764 FINAL_LIBS="${LIBNAME}"
765 fi
766 ;;
767
768 *)
769 echo "mklib: ERROR: Don't know how to make a static/shared library for" ${ARCH}
770 echo "mklib: Please add necessary commands to mklib script."
771 ;;
772 esac
773
774
775 #
776 # Put library files into installation directory if specified.
777 #
778 if [ ${INSTALLDIR} != "." ] ; then
779 echo "mklib: Installing" ${FINAL_LIBS} "in" ${INSTALLDIR}
780 mv ${FINAL_LIBS} ${INSTALLDIR}/
781 fi