SetBuffer, renderbuffer changes
[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-2005 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 INSTALLDIR="."
40 ARCH="auto"
41 ARCHOPT=""
42 NOPREFIX=0
43 EXPORTS=""
44
45
46 #
47 # Parse arguments
48 #
49 while true
50 do
51 case $1 in
52 '-h' | '--help')
53 echo 'Usage: mklib [options] objects'
54 echo 'Create a shared library from object files.'
55 echo ' -o LIBRARY specifies the name of the resulting library, without'
56 echo ' the leading "lib" or any suffix.'
57 echo ' (eg: "-o GL" might result in "libGL.so" being made)'
58 echo ' -major N specifies major version number (default is 1)'
59 echo ' -minor N specifies minor version number (default is 0)'
60 echo ' -patch N specifies patch version number (default is 0)'
61 echo ' -lLIBRARY specifies a dependency on LIBRARY'
62 echo ' -LDIR search in DIR for library dependencies'
63 echo ' -linker L explicity specify the linker program to use (eg: gcc, g++)'
64 echo ' Not observed on all systems at this time.'
65 echo ' -cplusplus link with C++ runtime'
66 echo ' -static make a static library (default is dynamic/shared)'
67 echo ' -install DIR put resulting library file(s) in DIR'
68 echo ' -arch ARCH override using `uname` to determine host system'
69 echo ' -archopt OPT specify an extra achitecture-specific option OPT'
70 echo " -noprefix don't prefix library name with 'lib' nor add any suffix"
71 echo ' -exports FILE only export the symbols listed in FILE'
72 echo ' -h, --help display this information and exit'
73 exit 1
74 ;;
75 '-o')
76 shift 1;
77 LIBNAME=$1
78 ;;
79 '-major')
80 shift 1;
81 MAJOR=$1
82 ;;
83 '-minor')
84 shift 1;
85 MINOR=$1
86 ;;
87 '-patch')
88 shift 1;
89 PATCH=$1
90 ;;
91 '-linker')
92 shift 1;
93 LINK=$1
94 ;;
95 -l*)
96 DEPS="$DEPS $1"
97 ;;
98 -L*)
99 DEPS="$DEPS $1"
100 ;;
101 '-cplusplus')
102 CPLUSPLUS=1
103 ;;
104 '-static')
105 STATIC=1
106 ;;
107 '-install')
108 shift 1;
109 INSTALLDIR=$1
110 ;;
111 '-arch')
112 shift 1;
113 ARCH=$1
114 ;;
115 '-archopt')
116 shift 1;
117 ARCHOPT=$1
118 ;;
119 '-noprefix')
120 NOPREFIX=1
121 ;;
122 '-exports')
123 shift 1;
124 EXPORTS=$1
125 ;;
126 -*)
127 echo "mklib: Unknown option: " $1 ;
128 exit 1
129 ;;
130 *)
131 # This should be the first object file, stop parsing
132 break
133 esac
134 shift 1
135 done
136 OBJECTS=$@
137
138
139 if [ ${ARCH} = "auto" ] ; then
140 ARCH=`uname`
141 fi
142
143
144 #
145 # Error checking
146 #
147 if [ "x${LIBNAME}" = "x" ] ; then
148 echo "mklib: Error: no library name specified"
149 exit 1
150 fi
151 if [ "x${OBJECTS}" = "x" ] ; then
152 echo "mklib: Error: no object files specified"
153 exit 1
154 fi
155
156
157 #
158 # Debugging info
159 #
160 if [ ] ; then
161 echo "-----------------"
162 echo ARCH is $ARCH
163 echo LIBNAME is $LIBNAME
164 echo MAJOR is $MAJOR
165 echo MINOR is $MINOR
166 echo PATCH is $PATCH
167 echo DEPS are $DEPS
168 echo "EXPORTS in" $EXPORTS
169 echo "-----------------"
170 fi
171
172
173 #
174 # OK, make the library now
175 #
176 case $ARCH in
177
178 'Linux' | 'OpenBSD')
179 # we assume gcc
180
181 if [ "x$LINK" = "x" ] ; then
182 # -linker was not specified so set default link command now
183 if [ $CPLUSPLUS = 1 ] ; then
184 LINK=g++
185 else
186 LINK=gcc
187 fi
188 fi
189
190 if [ $NOPREFIX = 1 ] ; then
191 # No "lib" or ".so" part
192 echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}
193 #OPTS="-shared -Wl,-soname,${LIBNAME}" # soname???
194 OPTS="-shared"
195
196 # Check if objects are 32-bit and we're running in 64-bit
197 # environment. If so, pass -m32 flag to linker.
198 set ${OBJECTS}
199 ABI32=`file $1 | grep 32-bit`
200 if [ "${ABI32}" -a `uname -m` = "x86_64" ] ; then
201 OPTS="-m32 ${OPTS}"
202 fi
203
204 rm -f ${LIBNAME}
205 # make lib
206 ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
207 # finish up
208 FINAL_LIBS="${LIBNAME}"
209 elif [ $STATIC = 1 ] ; then
210 LIBNAME="lib${LIBNAME}" # prefix with "lib"
211 echo "mklib: Making" $ARCH "static library: " ${LIBNAME}.a
212 LINK="ar"
213 OPTS="-ru"
214 # make lib
215 ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
216 ranlib ${LIBNAME}.a
217 # finish up
218 FINAL_LIBS=${LIBNAME}.a
219 else
220 LIBNAME="lib${LIBNAME}" # prefix with "lib"
221 if [ $ARCH = 'Linux' ] ; then
222 OPTS="-Xlinker -Bsymbolic -shared -Wl,-soname,${LIBNAME}.so.${MAJOR}"
223 else
224 OPTS="-shared -Wl,-soname,${LIBNAME}.so.${MAJOR}"
225 fi
226 if [ $EXPORTS ] ; then
227 #OPTS="${OPTS} -Xlinker --retain-symbols-file ${EXPORTS}"
228 # Make the 'exptmp' file for --version-script option
229 echo "VERSION_${MAJOR}.${MINOR} {" > exptmp
230 echo "global:" >> exptmp
231 sed 's/$/;/' ${EXPORTS} >> exptmp
232 echo "local:" >> exptmp
233 echo "*;" >> exptmp
234 echo "};" >> exptmp
235 OPTS="${OPTS} -Xlinker --version-script=exptmp"
236 # exptmp is removed below
237 fi
238
239 # Check if objects are 32-bit and we're running in 64-bit
240 # environment. If so, pass -m32 flag to linker.
241 set ${OBJECTS}
242 ABI32=`file $1 | grep 32-bit`
243 if [ "${ABI32}" -a `uname -m` = "x86_64" ] ; then
244 OPTS="-m32 ${OPTS}"
245 fi
246
247 if [ x${PATCH} = "x" ] ; then
248 VERSION="${MAJOR}.${MINOR}"
249 else
250 VERSION="${MAJOR}.${MINOR}.${PATCH}"
251 fi
252
253 echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}.so.${VERSION}
254
255 # rm any old libs
256 rm -f ${LIBNAME}.so.${VERSION}
257 rm -f ${LIBNAME}.so.${MAJOR}
258 rm -f ${LIBNAME}.so
259
260 # make lib
261 ${LINK} ${OPTS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
262 # make usual symlinks
263 ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR}
264 ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
265 # finish up
266 FINAL_LIBS="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so"
267 # rm -f exptmp
268 fi
269 ;;
270
271 'SunOS')
272 if [ $STATIC = 1 ] ; then
273 LIBNAME="lib${LIBNAME}.a"
274 echo "mklib: Making SunOS static library: " ${LIBNAME}
275 rm -f ${LIBNAME}
276 ar -ruv ${LIBNAME} ${OBJECTS}
277 FINAL_LIBS=${LIBNAME}
278 else
279 LIBNAME="lib${LIBNAME}.so"
280 echo "mklib: Making SunOS shared library: " ${LIBNAME}
281 # XXX OPTS for gcc should be -shared, but that doesn't work.
282 # Using -G does work though.
283 OPTS="-G"
284 if [ "x$LINK" = "x" ] ; then
285 # -linker was not specified, choose default linker now
286 if [ $CPLUSPLUS = 1 ] ; then
287 # determine linker and options for C++ code
288 if [ `which c++` ] ; then
289 # use Sun c++
290 LINK="c++"
291 elif [ `type g++` ] ; then
292 # use g++
293 LINK="g++"
294 else
295 echo "mklib: warning: can't find C++ comiler, trying CC."
296 LINK="CC"
297 fi
298 else
299 # use native Sun linker for C code
300 LINK="ld"
301 fi
302 fi
303 echo "mklib: linker is" ${LINK} ${OPTS}
304 rm -f ${LIBNAME}.${MAJOR} ${LIBNAME}
305 ${LINK} ${OPTS} -o ${LIBNAME}.${MAJOR} ${OBJECTS} ${DEPS}
306 ln -s ${LIBNAME}.${MAJOR} ${LIBNAME}
307 FINAL_LIBS="${LIBNAME}.${MAJOR} ${LIBNAME}"
308 fi
309 ;;
310
311 'FreeBSD')
312 if [ $NOPREFIX = 1 ] ; then
313 # No "lib" or ".so" part
314 echo "mklib: Making FreeBSD shared library: " ${LIBNAME}
315 rm -f ${LIBNAME}
316 ld -Bshareable -o ${LIBNAME} ${OBJECTS}
317 FINAL_LIBS=${LIBNAME}
318 elif [ $STATIC = 1 ] ; then
319 STLIB="lib${LIBNAME}.a"
320 echo "mklib: Making FreeBSD static library: " ${STLIB}
321 rm -f ${STLIB}
322 ar cq ${STLIB} ${OBJECTS}
323 ranlib ${STLIB}
324 FINAL_LIBS=${STLIB}
325 else
326 SHLIB="lib${LIBNAME}.so.${MAJOR}.${MINOR}"
327 echo "mklib: Making FreeBSD shared library: " ${SHLIB}
328 rm -f ${SHLIB}
329 ld -Bshareable -o ${SHLIB} ${OBJECTS}
330 # XXX make lib${LIBNAME}.so.${MAJOR} symlink?
331 FINAL_LIBS=${SHLIB}
332 fi
333 ;;
334
335 'NetBSD')
336 if [ $STATIC = 1 ] ; then
337 LIBNAME="lib${LIBNAME}_pic.a"
338 echo "mklib: Making NetBSD PIC static library: " ${LIBNAME}
339 rm -f ${LIBNAME}
340 ar cq ${LIBNAME} ${OBJECTS}
341 ranlib ${LIBNAME}
342 FINAL_LIBS=${LIBNAME}
343 else
344 LIBNAME="lib${LIBNAME}.so.${MAJOR}.${MINOR}"
345 echo "mklib: Making NetBSD PIC shared library: " ${LIBNAME}
346 rm -f ${LIBNAME}
347 ld -x -Bshareable -Bforcearchive -o ${LIBNAME} ${OBJECTS}
348 FINAL_LIBS=${LIBNAME}
349 fi
350 ;;
351
352 'IRIX' | 'IRIX64')
353 if [ $STATIC = 1 ] ; then
354 LIBNAME="lib${LIBNAME}.a"
355 rm -f ${LIBNAME}
356 ar rc ${LIBNAME} ${OBJECTS}
357 FINAL_LIBS=${LIBNAME}
358 else
359 LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
360 # XXX we should run 'file' on the first object file to determine
361 # if it's o32, n32 or 64 format, as we do for Linux above.
362 if [ $ARCHOPT = "64" ] ; then
363 # 64-bit ABI
364 OPTS="-64 -shared -all"
365 echo "mklib: Making IRIX 64-bit shared library: " ${LIBNAME}
366 elif [ $ARCHOPT = "o32" ] ; then
367 # old 32-bit ABI
368 OPTS="-32 -shared -all"
369 echo "mklib: Making IRIX o32-bit shared library: " ${LIBNAME}
370 else
371 # new 32-bit ABI
372 OPTS="-n32 -shared -all"
373 echo "mklib: Making IRIX n32-bit shared library: " ${LIBNAME}
374 fi
375 if [ $CPLUSPLUS = 1 ] ; then
376 LINK="CC"
377 else
378 LINK="ld"
379 fi
380 ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
381 FINAL_LIBS=${LIBNAME}
382 fi
383 ;;
384
385 'linux-cygwin')
386 LIBNAME="lib${LIBNAME}.a"
387 echo "mklib: Making linux-cygwin library: " ${LIBNAME}
388 rm -f ${LIBNAME}
389 gnuwin32ar ruv ${LIBNAME} ${OBJECTS}
390 FINAL_LIBS=${LIBNAME}
391 ;;
392
393 'HP-UX')
394 if [ $STATIC = 1 ] ; then
395 LIBNAME="lib${LIBNAME}.a"
396 echo "mklib: Making HP-UX static library: " ${LIBNAME}
397 rm -f ${LIBNAME}
398 ar -ruv ${LIBNAME} ${OBJECTS}
399 FINAL_LIBS=${LIBNAME}
400 else
401 RUNLIB="lib${LIBNAME}.${MAJOR}"
402 DEVLIB="lib${LIBNAME}.sl"
403 echo "mklib: Making HP-UX shared library: " ${RUNLIB} ${DEVLIB}
404 ld -b -o ${RUNLIB} +b ${RUNLIB} ${OBJECTS} ${DEPS}
405 ln -s ${RUNLIB} ${DEVLIB}
406 FINAL_LIBS="${RUNLIB} ${DEVLIB}"
407 fi
408 ;;
409
410 'AIX' | 'AIX64')
411 if [ $ARCH = "AIX64" ] ; then
412 X64="-X64"
413 fi
414
415 if [ $STATIC = 1 ] ; then
416 LIBNAME="lib${LIBNAME}.a"
417 echo "mklib: Making AIX static library: " ${LIBNAME}
418 ar -ruv ${X64} ${LIBNAME} ${OBJECTS}
419 FINAL_LIBS=${LIBNAME}
420 else
421 EXPFILE="lib${LIBNAME}.exp"
422 OFILE=shr.o #Want to be consistent with the IBM libGL.a
423 LIBNAME="lib${LIBNAME}.a" # shared objects are still stored in the .a libraries
424 if [ $ARCH = "AIX64" ] ; then
425 OPTS="-bE:${EXPFILE} -bM:SRE -bnoentry -q64"
426 else
427 OPTS="-bE:${EXPFILE} -bM:SRE -bnoentry"
428 fi
429 rm -f ${EXPFILE} ${OFILE}
430 NM="/bin/nm -eC ${X64}"
431 echo "#! /usr/lib/${LIBNAME}" > ${EXPFILE}
432 ${NM} ${OBJECTS} | awk '{
433 if ((($2 == "T") || ($2 == "D") || ($2 == "B")) \
434 && ( substr($1,1,1) != ".")) {
435 if (substr ($1, 1, 7) != "__sinit" &&
436 substr ($1, 1, 7) != "__sterm") {
437 if (substr ($1, 1, 5) == "__tf1")
438 print (substr ($1, 7))
439 else if (substr ($1, 1, 5) == "__tf9")
440 print (substr ($1, 15))
441 else
442 print $1
443 }
444 }
445 }' | sort -u >> ${EXPFILE}
446 cc ${OPTS} -o ${OFILE} ${OBJECTS} ${DEPS}
447 ar ${X64} -r ${LIBNAME} ${OFILE}
448 FINAL_LIBS="${LIBNAME}"
449 fi
450 ;;
451
452 'OpenSTEP')
453 LIBNAME="lib${LIBNAME}.a"
454 echo "mklib: Making OpenSTEP static library: " ${LIBNAME}
455 libtool -static -o ${LIBNAME} - ${OBJECTS}
456 FINAL_LIBS=${LIBNAME}
457 ;;
458
459 'OSF1')
460 if [ $STATIC = 1 ] ; then
461 LIBNAME="lib${LIBNAME}.a"
462 echo "mklib: Making OSF/1 static library: " ${LIBNAME}
463 rm -f ${LIBNAME}
464 ar -ruv ${LIBNAME} ${OBJECTS}
465 FINAL_LIBS=${LIBNAME}
466 else
467 VERSION="${MAJOR}.${MINOR}"
468 LIBNAME="lib${LIBNAME}.so"
469 echo "mklib: Making OSF/1 shared library: " ${LIBNAME}
470 if [ "x$LINK" = "x" ] ; then
471 if [ $CPLUSPLUS = 1 ] ; then
472 LINK=cxx
473 else
474 LINK=cc
475 fi
476 fi
477 rm -f ${LIBNAME}.${VERSION}
478 ${LINK} -o ${LIBNAME}.${VERSION} -shared -set_version ${VERSION} -soname ${LIBNAME}.${VERSION} -expect_unresolved \* -all ${OBJECTS} ${DEPS}
479 ln -sf ${LIBNAME}.${VERSION} ${LIBNAME}
480 FINAL_LIBS="${LIBNAME} ${LIBNAME}.${VERSION}"
481 fi
482 ;;
483
484 'Darwin')
485 if [ $STATIC = 1 ] ; then
486 LIBNAME="lib${LIBNAME}.a"
487 echo "mklib: Making Darwin static library: " ${LIBNAME}
488 LINK="ar"
489 OPTS="-ruv"
490 ${LINK} ${OPTS} ${LIBNAME} ${OBJECTS}
491 FINAL_LIBS=${LIBNAME}
492 else
493 LIBNAME="lib${LIBNAME}.dylib"
494 echo "mklib: Making Darwin shared library: " ${LIBNAME}
495 FLAGS="-dynamiclib -multiply_defined suppress"
496 if [ $CPLUSPLUS = 1 ] ; then
497 LINK="g++"
498 else
499 LINK="cc"
500 fi
501 ${LINK} ${FLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
502 FINAL_LIBS=${LIBNAME}
503 fi
504 ;;
505
506 'LynxOS')
507 LIBNAME="lib${LIBNAME}.a"
508 echo "mklib: Making LynxOS static library: " ${LIBNAME}
509 rm -f ${LIBNAME}
510 ar ru ${LIBNAME} ${OBJECTS}
511 FINAL_LIBS=${LIBNAME}
512 ;;
513
514 'BeOS')
515 if [ $STATIC = 1 ] ; then
516 LIBNAME="lib${LIBNAME}.a"
517 echo "mklib: Making BeOS static library: " ${LIBNAME}
518 ar -cru "${LIBNAME}" ${OBJECTS}
519 else
520 LIBNAME="lib${LIBNAME}.so"
521 echo "mklib: Making BeOS shared library: " ${LIBNAME}
522 gcc -nostart -Xlinker "-soname=${LIBNAME}" -L/Be/develop/lib/x86 -lbe ${DEPS} ${OBJECTS} -o "${LIBNAME}"
523 mimeset -f "${LIBNAME}"
524 # XXX remove the Mesa3D stuff here since mklib isn't mesa-specific.
525 setversion "${LIBNAME}" -app ${MAJOR} ${MINOR} ${PATCH} -short "Powered by Mesa3D!" -long "Powered by Mesa3D!"
526 fi
527 FINAL_LIBS=${LIBNAME}
528 ;;
529
530 'QNX')
531 LIBNAME="lib${LIBNAME}.a"
532 echo "mklib: Making QNX library: " ${LIBNAME}
533 wlib ${LIBNAME} ${OBJECTS}
534 FINAL_LIBS=${LIBNAME}
535 ;;
536
537 'MorphOS')
538 LIBNAME="lib${LIBNAME}.a"
539 echo "mklib: Making MorphOS library: " ${LIBNAME}
540 ppc-morphos-ar rc ${LIBNAME} ${OBJECTS}
541 FINAL_LIBS="${LIBNAME}"
542 ;;
543
544 'icc')
545 # Intel C compiler
546 # This should get merged into the Linux code, above, since this isn't
547 # really a different architecture.
548 LIBNAME="lib${LIBNAME}" # prefix with "lib"
549
550 if [ $STATIC = 1 ] ; then
551 echo "mklib: Making Intel ICC static library: " ${LIBNAME}.a
552 LINK="ar"
553 OPTS="-ruv"
554 # make lib
555 ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
556 # finish up
557 FINAL_LIBS="${LIBNAME}.a"
558 else
559 OPTS="-shared"
560 VERSION="${MAJOR}.${MINOR}.${PATCH}"
561 echo "mklib: Making Intel ICC shared library: " ${LIBNAME}.so.${VERSION}
562
563 if [ $CPLUSPLUS = 1 ] ; then
564 LINK="icc"
565 else
566 LINK="icc"
567 fi
568 # rm any old libs
569 rm -f ${LIBNAME}.so.${VERSION}
570 rm -f ${LIBNAME}.so.${MAJOR}
571 rm -f ${LIBNAME}.so
572 # make lib
573 ${LINK} ${OPTS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
574 # make usual symlinks
575 ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR}
576 ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
577 # finish up
578 FINAL_LIBS="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so"
579 fi
580 ;;
581
582 'aix-gcc')
583 # AIX with gcc
584 if [ $STATIC = 1 ] ; then
585 LIBNAME="lib${LIBNAME}.a"
586 echo "mklib: Making AIX GCC static library: " ${LIBNAME}
587 rm -f ${LIBNAME}
588 ar ru ${LIBNAME} ${OBJECTS}
589 FINAL_LIBS=${LIBNAME}
590 else
591 LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
592 echo "mklib: Making AIX GCC shared library: " ${LIBNAME}
593 # remove old lib
594 rm -f ${LIBNAME}
595 # make the lib
596 gcc -shared -Wl,-G ${OBJECTS} ${DEPS} -o ${LIBNAME}
597 # NOTE: the application linking with this library must specify
598 # the -Wl,-brtl flags to gcc
599 FINAL_LIBS=${LIBNAME}
600 fi
601 ;;
602
603 'ultrix')
604 # XXX untested
605 if [ $STATIC = 0 ] ; then
606 echo "mklib: Warning shared libs not supported on Ultrix"
607 fi
608 LIBNAME="lib${LIBNAME}.a"
609 echo "mklib: Making static library for Ultrix: " ${LIBNAME}
610 rm -f ${LIBNAME}
611 ar ru ${LIBNAME} ${OBJECTS}
612 FINAL_LIBS="${LIBNAME}"
613 ;;
614
615 CYGWIN*)
616 # GCC-based environment
617 CYGNAME="cyg${LIBNAME}" # prefix with "cyg"
618 LIBNAME="lib${LIBNAME}" # prefix with "lib"
619
620 if [ $STATIC = 1 ] ; then
621 echo "mklib: Making" $ARCH "static library: " ${LIBNAME}.a
622 LINK="ar"
623 OPTS="-ru"
624 # make lib
625 ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
626 ranlib ${LIBNAME}.a
627 # finish up
628 FINAL_LIBS=${LIBNAME}.a
629 else
630 OPTS="-shared -Wl,-export-all -Wl,--out-implib=${LIBNAME}-${MAJOR}.dll.a"
631 echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}-${MAJOR}.dll
632
633 if [ $CPLUSPLUS = 1 ] ; then
634 LINK="g++"
635 else
636 LINK="gcc"
637 fi
638
639 # rm any old libs
640 rm -f ${LIBNAME}-${MAJOR}.dll
641 rm -f ${LIBNAME}.dll.a
642 rm -f ${LIBNAME}.a
643
644 # make lib
645 ${LINK} ${OPTS} -o ${CYGNAME}-${MAJOR}.dll ${OBJECTS} ${DEPS}
646 # make usual symlinks
647 ln -s ${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a
648 # finish up
649 FINAL_LIBS="${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a"
650 # special case for installing in bin
651 FINAL_BINS="${CYGNAME}-${MAJOR}.dll"
652 fi
653 ;;
654
655 'example')
656 # If you're adding support for a new architecture, you can
657 # start with this:
658 if [ $STATIC = 1 ] ; then
659 LIBNAME="lib${LIBNAME}.a"
660 echo "mklib: Making static library for example arch: " ${LIBNAME}
661 rm -f ${LIBNAME}
662 ar rv ${LIBNAME} ${OBJECTS}
663 FINAL_LIBS="${LIBNAME}"
664 else
665 LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
666 echo "mklib: Making shared library for example arch: " ${LIBNAME}
667 ld -o ${LIBNAME} ${OBJECTS} ${DEPS}
668 FINAL_LIBS="${LIBNAME}"
669 fi
670 ;;
671
672 *)
673 echo "mklib: ERROR: Don't know how to make a static/shared library for" ${ARCH}
674 echo "mklib: Please add necessary commands to mklib script."
675 ;;
676 esac
677
678
679 #
680 # Put library files into installation directory if specified.
681 #
682 if [ ${INSTALLDIR} != "." ] ; then
683 echo "mklib: Installing" ${FINAL_LIBS} "in" ${INSTALLDIR}
684 mv ${FINAL_LIBS} ${INSTALLDIR}/
685 fi