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