3 # Make a shared library.
4 # This script should be useful for projects other than Mesa.
5 # Improvements/fixes are welcome.
8 # Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
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:
17 # The above copyright notice and this permission notice shall be included
18 # in all copies or substantial portions of the Software.
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.
55 echo 'Usage: mklib [options] objects'
56 echo 'Create a shared library from object files.'
57 echo ' -o LIBRARY specifies the name of the resulting library, without'
58 echo ' the leading "lib" or any suffix.'
59 echo ' (eg: "-o GL" might result in "libGL.so" being made)'
60 echo ' -major N specifies major version number (default is 1)'
61 echo ' -minor N specifies minor version number (default is 0)'
62 echo ' -patch N specifies patch version number (default is 0)'
63 echo ' -lLIBRARY specifies a dependency on LIBRARY'
64 echo ' -LDIR search in DIR for library dependencies'
65 echo ' -linker L explicity specify the linker program to use (eg: gcc, g++)'
66 echo ' Not observed on all systems at this time.'
67 echo ' -ldflags OPT specify any additional linker flags in OPT'
68 echo ' -cplusplus link with C++ runtime'
69 echo ' -static make a static library (default is dynamic/shared)'
70 echo ' -dlopen make a shared library suitable for dynamic loading'
71 echo ' -install DIR put resulting library file(s) in DIR'
72 echo ' -arch ARCH override using `uname` to determine host system'
73 echo ' -archopt OPT specify an extra achitecture-specific option OPT'
74 echo ' -altopts OPTS alternate options to override all others'
75 echo " -noprefix don't prefix library name with 'lib' nor add any suffix"
76 echo ' -exports FILE only export the symbols listed in FILE'
77 echo ' -h, --help display this information and exit'
114 # this is a special case (see bugzilla 10876)
118 DEPS
="$DEPS -pthread"
153 echo "mklib: Unknown option: " $1 ;
157 # This should be the first object file, stop parsing
165 if [ ${ARCH} = "auto" ] ; then
173 if [ "x${LIBNAME}" = "x" ] ; then
174 echo "mklib: Error: no library name specified"
177 if [ "x${OBJECTS}" = "x" ] ; then
178 echo "mklib: Error: no object files specified"
187 echo "-----------------"
189 echo LIBNAME is
$LIBNAME
194 echo "EXPORTS in" $EXPORTS
195 echo "-----------------"
200 # OK, make the library now
204 'Linux' |
'OpenBSD' |
'DragonFly' |
'GNU' | GNU
/*)
207 if [ "x$LINK" = "x" ] ; then
208 # -linker was not specified so set default link command now
209 if [ $CPLUSPLUS = 1 ] ; then
216 if [ $NOPREFIX = 1 ] ; then
217 # No "lib" or ".so" part
218 echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}
219 case $ARCH in 'Linux' |
'GNU' | GNU
/*)
220 OPTS
="-Xlinker -Bsymbolic -shared"
227 # Check if objects are 32-bit and we're running in 64-bit
228 # environment. If so, pass -m32 flag to linker.
230 ABI32
=`file $1 | grep 32-bit`
231 if [ "${ABI32}" -a `uname -m` = "x86_64" ] ; then
235 if [ "${ALTOPTS}" ] ; then
241 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
243 FINAL_LIBS
="${LIBNAME}"
244 elif [ $STATIC = 1 ] ; then
245 LIBNAME
="lib${LIBNAME}.a" # prefix with "lib", suffix with ".a"
246 echo "mklib: Making" $ARCH "static library: " ${LIBNAME}
249 if [ "${ALTOPTS}" ] ; then
254 ${LINK} ${OPTS} ${LIBNAME} ${OBJECTS}
257 FINAL_LIBS
=${LIBNAME}
259 LIBNAME
="lib${LIBNAME}" # prefix with "lib"
260 case $ARCH in 'Linux' |
'GNU' | GNU
/*)
261 OPTS
="-Xlinker -Bsymbolic -shared -Wl,-soname,${LIBNAME}.so.${MAJOR}"
264 OPTS
="-shared -Wl,-soname,${LIBNAME}.so.${MAJOR}"
267 if [ $EXPORTS ] ; then
268 #OPTS="${OPTS} -Xlinker --retain-symbols-file ${EXPORTS}"
269 # Make the 'exptmp' file for --version-script option
270 echo "VERSION_${MAJOR}.${MINOR} {" > exptmp
271 echo "global:" >> exptmp
272 sed 's/$/;/' ${EXPORTS} >> exptmp
273 echo "local:" >> exptmp
276 OPTS
="${OPTS} -Xlinker --version-script=exptmp"
277 # exptmp is removed below
280 # Check if objects are 32-bit and we're running in 64-bit
281 # environment. If so, pass -m32 flag to linker.
283 ABI32
=`file $1 | grep 32-bit`
284 if [ "${ABI32}" -a `uname -m` = "x86_64" ] ; then
287 if [ "${ALTOPTS}" ] ; then
291 if [ x
${PATCH} = "x" ] ; then
292 VERSION
="${MAJOR}.${MINOR}"
294 VERSION
="${MAJOR}.${MINOR}.${PATCH}"
297 echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}.so.
${VERSION}
300 rm -f ${LIBNAME}.so.
${VERSION}
301 rm -f ${LIBNAME}.so.
${MAJOR}
305 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
306 # make usual symlinks
307 ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR}
308 ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
310 FINAL_LIBS
="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so"
316 if [ $STATIC = 1 ] ; then
317 LIBNAME
="lib${LIBNAME}.a"
318 echo "mklib: Making SunOS static library: " ${LIBNAME}
320 ar -ruv ${LIBNAME} ${OBJECTS}
321 FINAL_LIBS
=${LIBNAME}
323 if [ $NOPREFIX = 0 ] ; then
324 LIBNAME
="lib${LIBNAME}.so"
326 echo "mklib: Making SunOS shared library: " ${LIBNAME}
328 if [ "x$LINK" = "x" ] ; then
329 # -linker was not specified, choose default linker now
330 if [ $CPLUSPLUS = 1 ] ; then
331 # determine linker and options for C++ code
332 if [ `which c++` ] ; then
335 elif [ `type g++` ] ; then
339 echo "mklib: warning: can't find C++ comiler, trying CC."
343 # use native Sun linker for C code
349 if [ ${LINK} = "ld" -o ${LINK} = "cc" -o ${LINK} = "CC" ] ; then
350 # SunOS tools, -G to make shared libs
354 # Check if objects are 32-bit and we're running in 64-bit
355 # environment. If so, pass -m32 flag to linker.
357 ABI32
=`file $1 | grep 32-bit`
358 if [ "${ABI32}" ] ; then
359 OPTS
="-m32 -shared -Wl,-Bdynamic"
361 OPTS
="-m64 -shared -Wl,-Bdynamic"
365 # Check if objects are SPARC v9
366 # file says: ELF 64-bit MSB relocatable SPARCV9 Version 1
368 SPARCV9
=`file $1 | grep SPARCV9`
369 if [ "${SPARCV9}" ] ; then
370 OPTS
="${OPTS} -xarch=v9"
372 if [ "${ALTOPTS}" ] ; then
376 #echo "mklib: linker is" ${LINK} ${OPTS}
377 if [ $NOPREFIX = 1 ] ; then
379 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
381 rm -f ${LIBNAME}.${MAJOR} ${LIBNAME}
382 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.${MAJOR} ${OBJECTS} ${DEPS}
383 ln -s ${LIBNAME}.${MAJOR} ${LIBNAME}
385 FINAL_LIBS
="${LIBNAME}.${MAJOR} ${LIBNAME}"
392 if [ "x$LINK" = "x" ] ; then
393 # -linker was not specified so set default link command now
394 if [ $CPLUSPLUS = 1 ] ; then
401 if [ $NOPREFIX = 1 ] ; then
402 # No "lib" or ".so" part
403 echo "mklib: Making FreeBSD shared library: " ${LIBNAME}
405 if [ "${ALTOPTS}" ] ; then
409 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
410 FINAL_LIBS
=${LIBNAME}
411 elif [ $STATIC = 1 ] ; then
412 STLIB
="lib${LIBNAME}.a"
413 echo "mklib: Making FreeBSD static library: " ${STLIB}
415 ar cq
${STLIB} ${OBJECTS}
419 SHLIB
="lib${LIBNAME}.so.${MAJOR}"
420 OPTS
="-shared -Wl,-soname,${SHLIB}"
421 if [ "${ALTOPTS}" ] ; then
424 echo "mklib: Making FreeBSD shared library: " ${SHLIB}
426 ${LINK} ${OPTS} ${LDFLAGS} -o ${SHLIB} ${OBJECTS} ${DEPS}
427 ln -sf ${SHLIB} "lib${LIBNAME}.so"
428 FINAL_LIBS
="${SHLIB} lib${LIBNAME}.so"
433 if [ $STATIC = 1 ] ; then
434 LIBNAME
="lib${LIBNAME}_pic.a"
435 echo "mklib: Making NetBSD PIC static library: " ${LIBNAME}
437 ar cq
${LIBNAME} ${OBJECTS}
439 FINAL_LIBS
=${LIBNAME}
441 LIBNAME
="lib${LIBNAME}.so.${MAJOR}.${MINOR}"
442 echo "mklib: Making NetBSD PIC shared library: " ${LIBNAME}
444 ld
-x -Bshareable -Bforcearchive -o ${LIBNAME} ${OBJECTS}
445 FINAL_LIBS
=${LIBNAME}
450 if [ $STATIC = 1 ] ; then
451 LIBNAME
="lib${LIBNAME}.a"
453 ar rc
${LIBNAME} ${OBJECTS}
454 FINAL_LIBS
=${LIBNAME}
456 LIBNAME
="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
458 # examine first object to determine ABI
460 ABI_O32
=`file $1 | grep 'ELF 32-bit'`
461 ABI_N32
=`file $1 | grep 'ELF N32'`
462 ABI_N64
=`file $1 | grep 'ELF 64-bit'`
463 if [ "${ABI_O32}" ] ; then
464 OPTS
="-32 -shared -all"
466 elif [ "${ABI_N32}" ] ; then
467 OPTS
="-n32 -shared -all"
469 elif [ "${ABI_N64}" ] ; then
470 OPTS
="-64 -shared -all"
473 echo "Error: Unexpected IRIX ABI!"
477 if [ "${ALTOPTS}" ] ; then
481 if [ $CPLUSPLUS = 1 ] ; then
487 echo "mklib: Making IRIX " ${ABI} " shared library: " ${LIBNAME}
488 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
489 FINAL_LIBS
=${LIBNAME}
494 LIBNAME
="lib${LIBNAME}.a"
495 echo "mklib: Making linux-cygwin library: " ${LIBNAME}
497 gnuwin32ar ruv
${LIBNAME} ${OBJECTS}
498 FINAL_LIBS
=${LIBNAME}
502 if [ $STATIC = 1 ] ; then
503 LIBNAME
="lib${LIBNAME}.a"
504 echo "mklib: Making HP-UX static library: " ${LIBNAME}
506 ar -ruv ${LIBNAME} ${OBJECTS}
507 FINAL_LIBS
=${LIBNAME}
509 # HP uses a .2 for their current GL/GLU libraries
510 if [ ${LIBNAME} = "GL" -o ${LIBNAME} = "GLU" ] ; then
513 RUNLIB
="lib${LIBNAME}.${MAJOR}"
514 DEVLIB
="lib${LIBNAME}.sl"
515 echo "mklib: Making HP-UX shared library: " ${RUNLIB} ${DEVLIB}
516 ld
-b -o ${RUNLIB} +b ${RUNLIB} ${OBJECTS} ${DEPS}
517 ln -s ${RUNLIB} ${DEVLIB}
518 FINAL_LIBS
="${RUNLIB} ${DEVLIB}"
523 # examine first object to determine ABI
525 ABI_64
=`file $1 | grep '64-bit'`
526 if [ "${ABI_64}" ] ; then
531 OFILE
=shr.o
#Want to be consistent with the IBM libGL.a
534 if [ $STATIC = 1 ] ; then
535 LIBNAME
="lib${LIBNAME}.a"
536 echo "mklib: Making AIX static library: " ${LIBNAME}
537 ar -ruv ${X64} ${LIBNAME} ${OBJECTS}
538 FINAL_LIBS
=${LIBNAME}
540 EXPFILE
="lib${LIBNAME}.exp"
541 LIBNAME
="lib${LIBNAME}.a" # shared objects are still stored in the .a libraries
542 OPTS
="-bE:${EXPFILE} -bM:SRE -bnoentry ${Q64}"
543 rm -f ${EXPFILE} ${OFILE}
544 NM
="/bin/nm -eC ${X64}"
545 echo "#! /usr/lib/${LIBNAME}" > ${EXPFILE}
546 ${NM} ${OBJECTS} |
awk '{
547 if ((($2 == "T") || ($2 == "D") || ($2 == "B")) \
548 && ( substr($1,1,1) != ".")) {
549 if (substr ($1, 1, 7) != "__sinit" &&
550 substr ($1, 1, 7) != "__sterm") {
551 if (substr ($1, 1, 5) == "__tf1")
552 print (substr ($1, 7))
553 else if (substr ($1, 1, 5) == "__tf9")
554 print (substr ($1, 15))
559 }' |
sort -u >> ${EXPFILE}
561 if [ "${ALTOPTS}" ] ; then
565 # On AIX a shared library is linked differently when
566 # you want to dlopen the file
567 if [ $DLOPEN = "1" ] ; then
568 cc
-G ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
570 cc
${OPTS} ${LDFLAGS} -o ${OFILE} ${OBJECTS} ${DEPS}
571 ar ${X64} -r ${LIBNAME} ${OFILE}
574 FINAL_LIBS
="${LIBNAME}"
579 LIBNAME
="lib${LIBNAME}.a"
580 echo "mklib: Making OpenSTEP static library: " ${LIBNAME}
581 libtool
-static -o ${LIBNAME} - ${OBJECTS}
582 FINAL_LIBS
=${LIBNAME}
586 if [ $STATIC = 1 ] ; then
587 LIBNAME
="lib${LIBNAME}.a"
588 echo "mklib: Making OSF/1 static library: " ${LIBNAME}
590 ar -ruv ${LIBNAME} ${OBJECTS}
591 FINAL_LIBS
=${LIBNAME}
593 VERSION
="${MAJOR}.${MINOR}"
594 LIBNAME
="lib${LIBNAME}.so"
595 echo "mklib: Making OSF/1 shared library: " ${LIBNAME}
596 if [ "x$LINK" = "x" ] ; then
597 if [ $CPLUSPLUS = 1 ] ; then
603 rm -f ${LIBNAME}.
${VERSION}
604 ${LINK} -o ${LIBNAME}.${VERSION} -shared -set_version ${VERSION} -soname ${LIBNAME}.${VERSION} -expect_unresolved \* -all ${OBJECTS} ${DEPS}
605 ln -sf ${LIBNAME}.${VERSION} ${LIBNAME}
606 FINAL_LIBS
="${LIBNAME} ${LIBNAME}.${VERSION}"
611 if [ $STATIC = 1 ] ; then
612 LIBNAME
="lib${LIBNAME}.a"
613 echo "mklib: Making Darwin static library: " ${LIBNAME}
616 if [ "${ALTOPTS}" ] ; then
619 ${LINK} ${OPTS} ${LIBNAME} ${OBJECTS}
620 FINAL_LIBS
=${LIBNAME}
622 # On Darwin a .bundle is used for a library that you want to dlopen
623 if [ $DLOPEN = "1" ] ; then
625 OPTS
="${ARCHOPT} -bundle -multiply_defined suppress"
628 OPTS
="${ARCHOPT} -dynamiclib -multiply_defined suppress -current_version ${MAJOR}.${MINOR}.0 -compatibility_version ${MAJOR}.${MINOR}.0 -install_name lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}"
631 if [ ${EXPORTS} ] ; then
632 OPTS
="${OPTS} -exported_symbols_list ${EXPORTS}"
635 LINKNAME
="lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}"
636 LINKNAME2
="lib${LIBNAME}.${LIBSUFFIX}"
637 LIBNAME
="lib${LIBNAME}.${MAJOR}.${MINOR}.${LIBSUFFIX}"
639 # examine first object to determine ABI
641 ABI_PPC
=`file $1 | grep ' ppc'`
642 ABI_I386
=`file $1 | grep ' i386'`
643 ABI_PPC64
=`file $1 | grep ' ppc64'`
644 ABI_X86_64
=`file $1 | grep ' x86_64'`
645 if [ "${ABI_PPC}" ] ; then
646 OPTS
="${OPTS} -arch ppc"
648 if [ "${ABI_I386}" ] ; then
649 OPTS
="${OPTS} -arch i386"
651 if [ "${ABI_PPC64}" ] ; then
652 OPTS
="${OPTS} -arch ppc64"
654 if [ "${ABI_X86_64}" ] ; then
655 OPTS
="${OPTS} -arch x86_64"
658 if [ "${ALTOPTS}" ] ; then
662 # XXX can we always add -isysroot /Developer/SDKs/MacOSX10.4u.sdk
666 if [ $CPLUSPLUS = 1 ] ; then
672 echo "mklib: Making Darwin shared library: " ${LIBNAME}
674 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
675 ln -s ${LIBNAME} ${LINKNAME}
676 ln -s ${LIBNAME} ${LINKNAME2}
677 FINAL_LIBS
="${LIBNAME} ${LINKNAME} ${LINKNAME2}"
682 LIBNAME
="lib${LIBNAME}.a"
683 echo "mklib: Making LynxOS static library: " ${LIBNAME}
685 ar ru
${LIBNAME} ${OBJECTS}
686 FINAL_LIBS
=${LIBNAME}
690 if [ $STATIC = 1 ] ; then
691 LIBNAME
="lib${LIBNAME}.a"
692 echo "mklib: Making BeOS static library: " ${LIBNAME}
693 ar -cru "${LIBNAME}" ${OBJECTS}
695 LIBNAME
="lib${LIBNAME}.so"
696 echo "mklib: Making BeOS shared library: " ${LIBNAME}
697 gcc
-nostart -Xlinker "-soname=${LIBNAME}" -L/Be/develop/lib/x86 -lbe ${DEPS} ${OBJECTS} -o "${LIBNAME}"
698 mimeset
-f "${LIBNAME}"
699 # XXX remove the Mesa3D stuff here since mklib isn't mesa-specific.
700 setversion
"${LIBNAME}" -app ${MAJOR} ${MINOR} ${PATCH} -short "Powered by Mesa3D
!" -long "Powered by Mesa3D
!"
702 FINAL_LIBS=${LIBNAME}
706 LIBNAME="lib
${LIBNAME}.a
"
707 echo "mklib
: Making QNX library
: " ${LIBNAME}
708 wlib ${LIBNAME} ${OBJECTS}
709 FINAL_LIBS=${LIBNAME}
713 LIBNAME="lib
${LIBNAME}.a
"
714 echo "mklib
: Making MorphOS library
: " ${LIBNAME}
715 ppc-morphos-ar rc ${LIBNAME} ${OBJECTS}
716 FINAL_LIBS="${LIBNAME}"
719 'icc' | 'icc-istatic')
721 # This should get merged into the Linux code, above, since this isn't
722 # really a different architecture.
723 LIBNAME="lib
${LIBNAME}" # prefix with "lib
"
725 if [ $STATIC = 1 ] ; then
726 echo "mklib
: Making Intel ICC static library
: " ${LIBNAME}.a
729 if [ "${ALTOPTS}" ] ; then
733 ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
735 FINAL_LIBS="${LIBNAME}.a
"
737 if [ $ARCH = icc-istatic ] ; then
738 OPTS="-shared -i-static -cxxlib-icc"
742 if [ "${ALTOPTS}" ] ; then
745 VERSION="${MAJOR}.${MINOR}.${PATCH}"
746 echo "mklib
: Making Intel ICC shared library
: " ${LIBNAME}.so.${VERSION}
748 if [ $CPLUSPLUS = 1 ] ; then
754 rm -f ${LIBNAME}.so.${VERSION}
755 rm -f ${LIBNAME}.so.${MAJOR}
758 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
759 # make usual symlinks
760 ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR}
761 ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
763 FINAL_LIBS="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
"
769 if [ $STATIC = 1 ] ; then
770 LIBNAME="lib
${LIBNAME}.a
"
771 echo "mklib
: Making AIX GCC static library
: " ${LIBNAME}
773 ar ru ${LIBNAME} ${OBJECTS}
774 FINAL_LIBS=${LIBNAME}
776 LIBNAME="lib
${LIBNAME}.so
" # prefix with "lib
", suffix with ".so
"
777 echo "mklib
: Making AIX GCC shared library
: " ${LIBNAME}
781 gcc -shared -Wl,-G ${OBJECTS} ${DEPS} -o ${LIBNAME}
782 # NOTE: the application linking with this library must specify
783 # the -Wl,-brtl flags to gcc
784 FINAL_LIBS=${LIBNAME}
790 if [ $STATIC = 0 ] ; then
791 echo "mklib
: Warning shared libs not supported on Ultrix
"
793 LIBNAME="lib
${LIBNAME}.a
"
794 echo "mklib
: Making static library
for Ultrix
: " ${LIBNAME}
796 ar ru ${LIBNAME} ${OBJECTS}
797 FINAL_LIBS="${LIBNAME}"
801 # GCC-based environment
802 CYGNAME="cyg
${LIBNAME}" # prefix with "cyg
"
803 LIBNAME="lib
${LIBNAME}" # prefix with "lib
"
805 if [ $STATIC = 1 ] ; then
806 echo "mklib
: Making
" $ARCH "static library
: " ${LIBNAME}.a
809 if [ "${ALTOPTS}" ] ; then
813 ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
816 FINAL_LIBS=${LIBNAME}.a
818 OPTS="-shared -Wl,-export-all -Wl,--out-implib=${LIBNAME}-${MAJOR}.dll.a
"
819 if [ "${ALTOPTS}" ] ; then
822 echo "mklib
: Making
" $ARCH "shared library
: " ${LIBNAME}-${MAJOR}.dll
824 if [ $CPLUSPLUS = 1 ] ; then
831 rm -f ${LIBNAME}-${MAJOR}.dll
832 rm -f ${LIBNAME}.dll.a
836 ${LINK} ${OPTS} ${LDFLAGS} -o ${CYGNAME}-${MAJOR}.dll ${OBJECTS} ${DEPS}
837 # make usual symlinks
838 ln -s ${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a
840 FINAL_LIBS="${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a
"
841 # special case for installing in bin
842 FINAL_BINS="${CYGNAME}-${MAJOR}.dll
"
847 # If you're adding support for a new architecture, you can
849 if [ $STATIC = 1 ] ; then
850 LIBNAME="lib
${LIBNAME}.a
"
851 echo "mklib
: Making static library
for example arch
: " ${LIBNAME}
853 ar rv ${LIBNAME} ${OBJECTS}
854 FINAL_LIBS="${LIBNAME}"
856 LIBNAME="lib
${LIBNAME}.so
" # prefix with "lib
", suffix with ".so
"
857 echo "mklib
: Making shared library
for example arch
: " ${LIBNAME}
858 ld -o ${LIBNAME} ${OBJECTS} ${DEPS}
859 FINAL_LIBS="${LIBNAME}"
864 echo "mklib
: ERROR
: Don
't know how to make a static/shared library for" ${ARCH}
865 echo "mklib: Please add necessary commands to mklib script."
871 # Put library files into installation directory if specified.
873 if [ ${INSTALLDIR} != "." ] ; then
874 echo "mklib: Installing" ${FINAL_LIBS} "in" ${INSTALLDIR}
875 mv ${FINAL_LIBS} ${INSTALLDIR}/