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 at build time'
65 echo ' -RDIR search in DIR for library dependencies at run time'
66 echo ' -linker L explicity specify the linker program to use (eg: gcc, g++)'
67 echo ' Not observed on all systems at this time.'
68 echo ' -ldflags OPT specify any additional linker flags in OPT'
69 echo ' -cplusplus link with C++ runtime'
70 echo ' -static make a static library (default is dynamic/shared)'
71 echo ' -dlopen make a shared library suitable for dynamic loading'
72 echo ' -install DIR put resulting library file(s) in DIR'
73 echo ' -arch ARCH override using `uname` to determine host system'
74 echo ' -archopt OPT specify an extra achitecture-specific option OPT'
75 echo ' -altopts OPTS alternate options to override all others'
76 echo " -noprefix don't prefix library name with 'lib' nor add any suffix"
77 echo ' -exports FILE only export the symbols listed in FILE'
78 echo ' -id NAME Sets the id of the dylib (Darwin)'
79 echo ' -h, --help display this information and exit'
119 # this is a special case (see bugzilla 10876)
123 DEPS
="$DEPS -pthread"
162 echo "mklib: Unknown option: " $1 ;
166 # This should be the first object file, stop parsing
174 if [ ${ARCH} = "auto" ] ; then
179 if [ $STATIC = 1 ]; then
180 # filter out linker options inside object list
182 for OBJ
in $OBJECTS ; do
185 echo "mklib: warning: ignoring $OBJ for static library"
188 NEWOBJECTS
="$NEWOBJECTS $OBJ"
199 if [ "x${LIBNAME}" = "x" ] ; then
200 echo "mklib: Error: no library name specified"
203 if [ "x${OBJECTS}" = "x" ] ; then
204 echo "mklib: Error: no object files specified"
213 echo "-----------------"
215 echo LIBNAME is
$LIBNAME
220 echo "EXPORTS in" $EXPORTS
222 echo "-----------------"
227 # OK, make the library now
231 'Linux' |
'OpenBSD' |
'DragonFly' |
'GNU' | GNU
/*)
234 if [ "x$LINK" = "x" ] ; then
235 # -linker was not specified so set default link command now
236 if [ $CPLUSPLUS = 1 ] ; then
243 if [ $NOPREFIX = 1 ] ; then
244 # No "lib" or ".so" part
245 echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}
246 case $ARCH in 'Linux' |
'GNU' | GNU
/*)
247 OPTS
="-Xlinker -Bsymbolic -shared"
254 # Check if objects are 32-bit and we're running in 64-bit
255 # environment. If so, pass -m32 flag to linker.
257 ABI32
=`file $1 | grep 32-bit`
258 if [ "${ABI32}" -a `uname -m` = "x86_64" ] ; then
262 if [ "${ALTOPTS}" ] ; then
268 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
270 FINAL_LIBS
="${LIBNAME}"
271 elif [ $STATIC = 1 ] ; then
272 LIBNAME
="lib${LIBNAME}.a" # prefix with "lib", suffix with ".a"
273 echo "mklib: Making" $ARCH "static library: " ${LIBNAME}
276 if [ "${ALTOPTS}" ] ; then
281 # expand any .a objects into constituent .o files.
284 for OBJ
in $OBJECTS ; do
287 # extract the .o files from this .a archive
290 NEWOBJECTS
="$NEWOBJECTS $FILES"
291 # keep track of temporary .o files and delete them below
292 DELETIA
="$DELETIA $FILES"
296 NEWOBJECTS
="$NEWOBJECTS $OBJ"
302 ${LINK} ${OPTS} ${LIBNAME} ${NEWOBJECTS}
305 # remove temporary extracted .o files
309 FINAL_LIBS
=${LIBNAME}
311 LIBNAME
="lib${LIBNAME}" # prefix with "lib"
312 case $ARCH in 'Linux' |
'GNU' | GNU
/*)
313 OPTS
="-Xlinker -Bsymbolic -shared -Wl,-soname,${LIBNAME}.so.${MAJOR}"
316 OPTS
="-shared -Wl,-soname,${LIBNAME}.so.${MAJOR}"
319 if [ $EXPORTS ] ; then
320 #OPTS="${OPTS} -Xlinker --retain-symbols-file ${EXPORTS}"
321 # Make the 'exptmp' file for --version-script option
323 echo "global:" >> exptmp
324 sed 's/$/;/' ${EXPORTS} >> exptmp
325 echo "local:" >> exptmp
328 OPTS
="${OPTS} -Xlinker --version-script=exptmp"
329 # exptmp is removed below
332 # Check if objects are 32-bit and we're running in 64-bit
333 # environment. If so, pass -m32 flag to linker.
335 ABI32
=`file $1 | grep 32-bit`
336 if [ "${ABI32}" -a `uname -m` = "x86_64" ] ; then
339 if [ "${ALTOPTS}" ] ; then
343 if [ x
${PATCH} = "x" ] ; then
344 VERSION
="${MAJOR}.${MINOR}"
346 VERSION
="${MAJOR}.${MINOR}.${PATCH}"
349 echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}.so.
${VERSION}
352 rm -f ${LIBNAME}.so.
${VERSION}
353 rm -f ${LIBNAME}.so.
${MAJOR}
357 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
358 # make usual symlinks
359 ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR}
360 ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
362 FINAL_LIBS
="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so"
368 if [ $STATIC = 1 ] ; then
369 LIBNAME
="lib${LIBNAME}.a"
370 echo "mklib: Making SunOS static library: " ${LIBNAME}
372 ar -ruv ${LIBNAME} ${OBJECTS}
373 FINAL_LIBS
=${LIBNAME}
375 if [ $NOPREFIX = 0 ] ; then
376 LIBNAME
="lib${LIBNAME}.so"
378 echo "mklib: Making SunOS shared library: " ${LIBNAME}
380 if [ "x$LINK" = "x" ] ; then
381 # -linker was not specified, choose default linker now
382 if [ $CPLUSPLUS = 1 ] ; then
383 # determine linker and options for C++ code
384 if [ `which c++` ] ; then
387 elif [ `type g++` ] ; then
391 echo "mklib: warning: can't find C++ compiler, trying CC."
395 # use native Sun linker for C code
401 if [ ${LINK} = "ld" -o ${LINK} = "cc" -o ${LINK} = "CC" ] ; then
402 # SunOS tools, -G to make shared libs
406 # Check if objects are 32-bit and we're running in 64-bit
407 # environment. If so, pass -m32 flag to linker.
409 ABI32
=`file $1 | grep 32-bit`
410 if [ "${ABI32}" ] ; then
411 OPTS
="-m32 -shared -Wl,-Bdynamic"
413 OPTS
="-m64 -shared -Wl,-Bdynamic"
417 # If using Sun C++ compiler, need to tell it not to add runpaths
418 # that are specific to the build machine
419 if [ ${LINK} = "CC" ] ; then
420 OPTS
="${OPTS} -norunpath"
423 # Solaris linker requires explicitly listing the Standard C & C++
424 # libraries in the link path when building shared objects
425 if [ ${LINK} = "CC" ] ; then
426 DEPS
="${DEPS} -lCrun"
430 if [ $EXPORTS ] ; then
431 # Make the 'mapfile.scope' linker mapfile
432 echo "{" > mapfile.scope
433 echo "global:" >> mapfile.scope
434 sed 's/$/;/' ${EXPORTS} >> mapfile.scope
435 echo "local:" >> mapfile.scope
436 echo " *;" >> mapfile.scope
437 echo "};" >> mapfile.scope
438 OPTS
="${OPTS} -Wl,-Mmapfile.scope"
441 # Check if objects are SPARC v9
442 # file says: ELF 64-bit MSB relocatable SPARCV9 Version 1
444 if [ ${LINK} = "cc" -o ${LINK} = "CC" ] ; then
445 SPARCV9
=`file $1 | grep SPARCV9`
446 if [ "${SPARCV9}" ] ; then
447 OPTS
="${OPTS} -xarch=v9"
450 if [ "${ALTOPTS}" ] ; then
455 #echo "mklib: linker is" ${LINK} ${OPTS}
456 if [ $NOPREFIX = 1 ] ; then
458 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
459 FINAL_LIBS
="${LIBNAME}"
461 rm -f ${LIBNAME}.${MAJOR} ${LIBNAME}
462 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.${MAJOR} -h ${LIBNAME}.${MAJOR} ${OBJECTS} ${DEPS}
463 ln -s ${LIBNAME}.${MAJOR} ${LIBNAME}
464 FINAL_LIBS
="${LIBNAME}.${MAJOR} ${LIBNAME}"
472 if [ "x$LINK" = "x" ] ; then
473 # -linker was not specified so set default link command now
474 if [ $CPLUSPLUS = 1 ] ; then
481 if [ $NOPREFIX = 1 ] ; then
482 # No "lib" or ".so" part
483 echo "mklib: Making FreeBSD shared library: " ${LIBNAME}
485 if [ "${ALTOPTS}" ] ; then
489 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
490 FINAL_LIBS
=${LIBNAME}
491 elif [ $STATIC = 1 ] ; then
492 STLIB
="lib${LIBNAME}.a"
493 echo "mklib: Making FreeBSD static library: " ${STLIB}
495 ar cq
${STLIB} ${OBJECTS}
499 SHLIB
="lib${LIBNAME}.so.${MAJOR}"
500 OPTS
="-shared -Wl,-soname,${SHLIB}"
501 if [ "${ALTOPTS}" ] ; then
504 echo "mklib: Making FreeBSD shared library: " ${SHLIB}
506 ${LINK} ${OPTS} ${LDFLAGS} -o ${SHLIB} ${OBJECTS} ${DEPS}
507 ln -sf ${SHLIB} "lib${LIBNAME}.so"
508 FINAL_LIBS
="${SHLIB} lib${LIBNAME}.so"
513 if [ $STATIC = 1 ] ; then
514 LIBNAME
="lib${LIBNAME}_pic.a"
515 echo "mklib: Making NetBSD PIC static library: " ${LIBNAME}
517 ar cq
${LIBNAME} ${OBJECTS}
519 FINAL_LIBS
=${LIBNAME}
521 LIBNAME
="lib${LIBNAME}.so.${MAJOR}.${MINOR}"
522 echo "mklib: Making NetBSD PIC shared library: " ${LIBNAME}
524 ld
-x -Bshareable -Bforcearchive -o ${LIBNAME} ${OBJECTS}
525 FINAL_LIBS
=${LIBNAME}
530 if [ $STATIC = 1 ] ; then
531 LIBNAME
="lib${LIBNAME}.a"
533 ar rc
${LIBNAME} ${OBJECTS}
534 FINAL_LIBS
=${LIBNAME}
536 LIBNAME
="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
538 # examine first object to determine ABI
540 ABI_O32
=`file $1 | grep 'ELF 32-bit'`
541 ABI_N32
=`file $1 | grep 'ELF N32'`
542 ABI_N64
=`file $1 | grep 'ELF 64-bit'`
543 if [ "${ABI_O32}" ] ; then
544 OPTS
="-32 -shared -all"
546 elif [ "${ABI_N32}" ] ; then
547 OPTS
="-n32 -shared -all"
549 elif [ "${ABI_N64}" ] ; then
550 OPTS
="-64 -shared -all"
553 echo "Error: Unexpected IRIX ABI!"
557 if [ "${ALTOPTS}" ] ; then
561 if [ $CPLUSPLUS = 1 ] ; then
567 echo "mklib: Making IRIX " ${ABI} " shared library: " ${LIBNAME}
568 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
569 FINAL_LIBS
=${LIBNAME}
574 LIBNAME
="lib${LIBNAME}.a"
575 echo "mklib: Making linux-cygwin library: " ${LIBNAME}
577 gnuwin32ar ruv
${LIBNAME} ${OBJECTS}
578 FINAL_LIBS
=${LIBNAME}
582 if [ $STATIC = 1 ] ; then
583 LIBNAME
="lib${LIBNAME}.a"
584 echo "mklib: Making HP-UX static library: " ${LIBNAME}
586 ar -ruv ${LIBNAME} ${OBJECTS}
587 FINAL_LIBS
=${LIBNAME}
589 # HP uses a .2 for their current GL/GLU libraries
590 if [ ${LIBNAME} = "GL" -o ${LIBNAME} = "GLU" ] ; then
593 RUNLIB
="lib${LIBNAME}.${MAJOR}"
594 DEVLIB
="lib${LIBNAME}.sl"
595 echo "mklib: Making HP-UX shared library: " ${RUNLIB} ${DEVLIB}
596 ld
-b -o ${RUNLIB} +b ${RUNLIB} ${OBJECTS} ${DEPS}
597 ln -s ${RUNLIB} ${DEVLIB}
598 FINAL_LIBS
="${RUNLIB} ${DEVLIB}"
603 # examine first object to determine ABI
605 ABI_64
=`file $1 | grep '64-bit'`
606 if [ "${ABI_64}" ] ; then
611 OFILE
=shr.o
#Want to be consistent with the IBM libGL.a
614 if [ $STATIC = 1 ] ; then
615 LIBNAME
="lib${LIBNAME}.a"
616 echo "mklib: Making AIX static library: " ${LIBNAME}
617 ar -ruv ${X64} ${LIBNAME} ${OBJECTS}
618 FINAL_LIBS
=${LIBNAME}
620 EXPFILE
="lib${LIBNAME}.exp"
621 LIBNAME
="lib${LIBNAME}.a" # shared objects are still stored in the .a libraries
622 OPTS
="-bE:${EXPFILE} -bM:SRE -bnoentry ${Q64}"
623 rm -f ${EXPFILE} ${OFILE}
624 NM
="/bin/nm -eC ${X64}"
625 echo "#! /usr/lib/${LIBNAME}" > ${EXPFILE}
626 ${NM} ${OBJECTS} |
awk '{
627 if ((($2 == "T") || ($2 == "D") || ($2 == "B")) \
628 && ( substr($1,1,1) != ".")) {
629 if (substr ($1, 1, 7) != "__sinit" &&
630 substr ($1, 1, 7) != "__sterm") {
631 if (substr ($1, 1, 5) == "__tf1")
632 print (substr ($1, 7))
633 else if (substr ($1, 1, 5) == "__tf9")
634 print (substr ($1, 15))
639 }' |
sort -u >> ${EXPFILE}
641 if [ "${ALTOPTS}" ] ; then
645 # On AIX a shared library is linked differently when
646 # you want to dlopen the file
647 if [ $DLOPEN = "1" ] ; then
648 cc
-G ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
650 cc
${OPTS} ${LDFLAGS} -o ${OFILE} ${OBJECTS} ${DEPS}
651 ar ${X64} -r ${LIBNAME} ${OFILE}
654 FINAL_LIBS
="${LIBNAME}"
659 LIBNAME
="lib${LIBNAME}.a"
660 echo "mklib: Making OpenSTEP static library: " ${LIBNAME}
661 libtool
-static -o ${LIBNAME} - ${OBJECTS}
662 FINAL_LIBS
=${LIBNAME}
666 if [ $STATIC = 1 ] ; then
667 LIBNAME
="lib${LIBNAME}.a"
668 echo "mklib: Making OSF/1 static library: " ${LIBNAME}
670 ar -ruv ${LIBNAME} ${OBJECTS}
671 FINAL_LIBS
=${LIBNAME}
673 VERSION
="${MAJOR}.${MINOR}"
674 LIBNAME
="lib${LIBNAME}.so"
675 echo "mklib: Making OSF/1 shared library: " ${LIBNAME}
676 if [ "x$LINK" = "x" ] ; then
677 if [ $CPLUSPLUS = 1 ] ; then
683 rm -f ${LIBNAME}.
${VERSION}
684 ${LINK} -o ${LIBNAME}.${VERSION} -shared -set_version ${VERSION} -soname ${LIBNAME}.${VERSION} -expect_unresolved \* -all ${OBJECTS} ${DEPS}
685 ln -sf ${LIBNAME}.${VERSION} ${LIBNAME}
686 FINAL_LIBS
="${LIBNAME} ${LIBNAME}.${VERSION}"
691 if [ $STATIC = 1 ] ; then
692 LIBNAME
="lib${LIBNAME}.a"
693 echo "mklib: Making Darwin static library: " ${LIBNAME}
696 if [ "${ALTOPTS}" ] ; then
699 ${LINK} ${OPTS} ${LIBNAME} ${OBJECTS}
700 FINAL_LIBS
=${LIBNAME}
702 # On Darwin a .bundle is used for a library that you want to dlopen
703 if [ $DLOPEN = "1" ] ; then
705 OPTS
="${ARCHOPT} -bundle -multiply_defined suppress"
708 if [ -z "$ID" ] ; then
709 ID
="lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}"
711 OPTS
="${ARCHOPT} -dynamiclib -multiply_defined suppress -current_version ${MAJOR}.${MINOR}.0 -compatibility_version ${MAJOR}.${MINOR}.0 -install_name ${ID}"
714 if [ ${EXPORTS} ] ; then
715 if [ -f ${EXPORTS}".darwin" ] ; then
716 EXPORTS
=$EXPORTS".darwin"
718 OPTS
="${OPTS} -exported_symbols_list ${EXPORTS}"
721 LINKNAME
="lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}"
722 LINKNAME2
="lib${LIBNAME}.${LIBSUFFIX}"
723 LIBNAME
="lib${LIBNAME}.${MAJOR}.${MINOR}.${LIBSUFFIX}"
725 # examine first object to determine ABI
727 ABI_PPC
=`file $1 | grep ' ppc'`
728 ABI_I386
=`file $1 | grep ' i386'`
729 ABI_PPC64
=`file $1 | grep ' ppc64'`
730 ABI_X86_64
=`file $1 | grep ' x86_64'`
731 if [ "${ABI_PPC}" ] ; then
732 OPTS
="${OPTS} -arch ppc"
734 if [ "${ABI_I386}" ] ; then
735 OPTS
="${OPTS} -arch i386"
737 if [ "${ABI_PPC64}" ] ; then
738 OPTS
="${OPTS} -arch ppc64"
740 if [ "${ABI_X86_64}" ] ; then
741 OPTS
="${OPTS} -arch x86_64"
744 if [ "${ALTOPTS}" ] ; then
748 # XXX can we always add -isysroot /Developer/SDKs/MacOSX10.4u.sdk
752 if [ $CPLUSPLUS = 1 ] ; then
758 echo "mklib: Making Darwin shared library: " ${LIBNAME}
760 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
761 ln -s ${LIBNAME} ${LINKNAME}
762 ln -s ${LIBNAME} ${LINKNAME2}
763 FINAL_LIBS
="${LIBNAME} ${LINKNAME} ${LINKNAME2}"
768 LIBNAME
="lib${LIBNAME}.a"
769 echo "mklib: Making LynxOS static library: " ${LIBNAME}
771 ar ru
${LIBNAME} ${OBJECTS}
772 FINAL_LIBS
=${LIBNAME}
776 if [ $STATIC = 1 ] ; then
777 LIBNAME
="lib${LIBNAME}.a"
778 echo "mklib: Making BeOS static library: " ${LIBNAME}
779 ar -cru "${LIBNAME}" ${OBJECTS}
781 LIBNAME
="lib${LIBNAME}.so"
782 echo "mklib: Making BeOS shared library: " ${LIBNAME}
783 gcc
-nostart -Xlinker "-soname=${LIBNAME}" -L/Be/develop/lib/x86 -lbe ${DEPS} ${OBJECTS} -o "${LIBNAME}"
784 mimeset
-f "${LIBNAME}"
785 # XXX remove the Mesa3D stuff here since mklib isn't mesa-specific.
786 setversion
"${LIBNAME}" -app ${MAJOR} ${MINOR} ${PATCH} -short "Powered by Mesa3D
!" -long "Powered by Mesa3D
!"
788 FINAL_LIBS=${LIBNAME}
792 LIBNAME="lib
${LIBNAME}.a
"
793 echo "mklib
: Making QNX library
: " ${LIBNAME}
794 wlib ${LIBNAME} ${OBJECTS}
795 FINAL_LIBS=${LIBNAME}
799 LIBNAME="lib
${LIBNAME}.a
"
800 echo "mklib
: Making MorphOS library
: " ${LIBNAME}
801 ppc-morphos-ar rc ${LIBNAME} ${OBJECTS}
802 FINAL_LIBS="${LIBNAME}"
805 'icc' | 'icc-istatic')
807 # This should get merged into the Linux code, above, since this isn't
808 # really a different architecture.
809 LIBNAME="lib
${LIBNAME}" # prefix with "lib
"
811 if [ $STATIC = 1 ] ; then
812 echo "mklib
: Making Intel ICC static library
: " ${LIBNAME}.a
815 if [ "${ALTOPTS}" ] ; then
819 ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
821 FINAL_LIBS="${LIBNAME}.a
"
823 if [ $ARCH = icc-istatic ] ; then
824 OPTS="-shared -i-static -cxxlib-icc"
828 if [ "${ALTOPTS}" ] ; then
831 VERSION="${MAJOR}.${MINOR}.${PATCH}"
832 echo "mklib
: Making Intel ICC shared library
: " ${LIBNAME}.so.${VERSION}
834 if [ $CPLUSPLUS = 1 ] ; then
840 rm -f ${LIBNAME}.so.${VERSION}
841 rm -f ${LIBNAME}.so.${MAJOR}
844 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
845 # make usual symlinks
846 ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR}
847 ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
849 FINAL_LIBS="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
"
855 if [ $STATIC = 1 ] ; then
856 LIBNAME="lib
${LIBNAME}.a
"
857 echo "mklib
: Making AIX GCC static library
: " ${LIBNAME}
859 ar ru ${LIBNAME} ${OBJECTS}
860 FINAL_LIBS=${LIBNAME}
862 LIBNAME="lib
${LIBNAME}.so
" # prefix with "lib
", suffix with ".so
"
863 echo "mklib
: Making AIX GCC shared library
: " ${LIBNAME}
867 gcc -shared -Wl,-G ${OBJECTS} ${DEPS} -o ${LIBNAME}
868 # NOTE: the application linking with this library must specify
869 # the -Wl,-brtl flags to gcc
870 FINAL_LIBS=${LIBNAME}
876 if [ $STATIC = 0 ] ; then
877 echo "mklib
: Warning shared libs not supported on Ultrix
"
879 LIBNAME="lib
${LIBNAME}.a
"
880 echo "mklib
: Making static library
for Ultrix
: " ${LIBNAME}
882 ar ru ${LIBNAME} ${OBJECTS}
883 FINAL_LIBS="${LIBNAME}"
887 # GCC-based environment
888 CYGNAME="cyg
${LIBNAME}" # prefix with "cyg
"
889 LIBNAME="lib
${LIBNAME}" # prefix with "lib
"
891 if [ $STATIC = 1 ] ; then
892 echo "mklib
: Making
" $ARCH "static library
: " ${LIBNAME}.a
895 if [ "${ALTOPTS}" ] ; then
899 ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
902 FINAL_LIBS=${LIBNAME}.a
904 OPTS="-shared -Wl,-export-all -Wl,--out-implib=${LIBNAME}-${MAJOR}.dll.a
"
905 if [ "${ALTOPTS}" ] ; then
908 echo "mklib
: Making
" $ARCH "shared library
: " ${LIBNAME}-${MAJOR}.dll
910 if [ $CPLUSPLUS = 1 ] ; then
917 rm -f ${LIBNAME}-${MAJOR}.dll
918 rm -f ${LIBNAME}.dll.a
922 ${LINK} ${OPTS} ${LDFLAGS} -o ${CYGNAME}-${MAJOR}.dll ${OBJECTS} ${DEPS}
923 # make usual symlinks
924 ln -s ${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a
926 FINAL_LIBS="${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a
"
927 # special case for installing in bin
928 FINAL_BINS="${CYGNAME}-${MAJOR}.dll
"
933 # If you're adding support for a new architecture, you can
935 if [ $STATIC = 1 ] ; then
936 LIBNAME="lib
${LIBNAME}.a
"
937 echo "mklib
: Making static library
for example arch
: " ${LIBNAME}
939 ar rv ${LIBNAME} ${OBJECTS}
940 FINAL_LIBS="${LIBNAME}"
942 LIBNAME="lib
${LIBNAME}.so
" # prefix with "lib
", suffix with ".so
"
943 echo "mklib
: Making shared library
for example arch
: " ${LIBNAME}
944 ld -o ${LIBNAME} ${OBJECTS} ${DEPS}
945 FINAL_LIBS="${LIBNAME}"
950 echo "mklib
: ERROR
: Don
't know how to make a static/shared library for" ${ARCH}
951 echo "mklib: Please add necessary commands to mklib script."
957 # Put library files into installation directory if specified.
959 if [ ${INSTALLDIR} != "." ] ; then
960 echo "mklib: Installing" ${FINAL_LIBS} "in" ${INSTALLDIR}
961 mv ${FINAL_LIBS} ${INSTALLDIR}/