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.
28 # Given a list of files, look for .a archives and unpack them.
29 # Return the original list of files minus the .a files plus the unpacked files.
30 # first param: name of a temp directory (to be deleted when finished)
31 # remaining params: list of .o and .a files
40 for FILE
in $FILES ; do
43 # extract the .o files from this .a archive
46 *) FILE
="$ORIG_DIR/$FILE" ;;
50 for MEMBER
in $MEMBERS ; do
51 NEWFILES
="$NEWFILES $DIR/$MEMBER"
55 # other file type, just add to list
56 NEWFILES
="$NEWFILES $FILE"
65 # Make static library with 'ar'
68 # 1 or 0 to indicate if ranlib should be run
70 # list of object files
71 # Return name of library we made
72 # Example: "make_ar_static_lib -ru 1 libfoo.a foo.o bar.o"
73 make_ar_static_lib
() {
82 # remove existing lib, if present
86 ar ${OPTS} ${LIBNAME} ${OBJECTS}
89 if [ ${RANLIB} = 1 ] ; then
99 echo 'Usage: mklib [options] objects'
100 echo 'Create a shared library from object files.'
101 echo ' -o LIBRARY specifies the name of the resulting library, without'
102 echo ' the leading "lib" or any suffix.'
103 echo ' (eg: "-o GL" might result in "libGL.so" being made)'
104 echo ' -major N specifies major version number (default is 1)'
105 echo ' -minor N specifies minor version number (default is 0)'
106 echo ' -patch N specifies patch version number (default is 0)'
107 echo ' -lLIBRARY specifies a dependency on LIBRARY'
108 echo ' -LDIR search in DIR for library dependencies at build time'
109 echo ' -RDIR search in DIR for library dependencies at run time'
110 echo ' -linker L explicity specify the linker program to use (eg: gcc, g++)'
111 echo ' Not observed on all systems at this time.'
112 echo ' -ldflags OPT specify any additional linker flags in OPT'
113 echo ' -cplusplus link with C++ runtime'
114 echo ' -static make a static library (default is dynamic/shared)'
115 echo ' -dlopen make a shared library suitable for dynamic loading'
116 echo ' -install DIR put resulting library file(s) in DIR'
117 echo ' -arch ARCH override using `uname` to determine host system'
118 echo ' -archopt OPT specify an extra achitecture-specific option OPT'
119 echo ' -altopts OPTS alternate options to override all others'
120 echo " -noprefix don't prefix library name with 'lib' nor add any suffix"
121 echo ' -exports FILE only export the symbols listed in FILE'
122 echo ' -id NAME Sets the id of the dylib (Darwin)'
123 echo ' -h, --help display this information and exit'
194 # this is a special case (see bugzilla 10876)
198 DEPS
="$DEPS -pthread"
237 echo "mklib: Unknown option: " $1 ;
241 # This should be the first object file, stop parsing
249 if [ ${ARCH} = "auto" ] ; then
254 if [ $STATIC = 1 ]; then
255 # filter out linker options inside object list
257 for OBJ
in $OBJECTS ; do
260 echo "mklib: warning: ignoring $OBJ for static library"
263 NEWOBJECTS
="$NEWOBJECTS $OBJ"
274 if [ "x${LIBNAME}" = "x" ] ; then
275 echo "mklib: Error: no library name specified (-h for help)"
278 if [ "x${OBJECTS}" = "x" ] ; then
279 echo "mklib: Error: no object files specified (-h for help)"
288 echo "-----------------"
290 echo LIBNAME is
$LIBNAME
295 echo "EXPORTS in" $EXPORTS
297 echo "-----------------"
302 # OK, make the library now
306 'Linux' |
'OpenBSD' |
'DragonFly' |
'GNU' | GNU
/*)
309 if [ "x$LINK" = "x" ] ; then
310 # -linker was not specified so set default link command now
311 if [ $CPLUSPLUS = 1 ] ; then
318 if [ $NOPREFIX = 1 ] ; then
319 # No "lib" or ".so" part
320 echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}
321 case $ARCH in 'Linux' |
'GNU' | GNU
/*)
322 OPTS
="-Xlinker -Bsymbolic -shared"
329 # Check if objects are 32-bit and we're running in 64-bit
330 # environment. If so, pass -m32 flag to linker.
332 ABI32
=`file $1 | grep 32-bit`
333 if [ "${ABI32}" -a `uname -m` = "x86_64" ] ; then
337 if [ "${ALTOPTS}" ] ; then
343 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
345 FINAL_LIBS
="${LIBNAME}"
346 elif [ $STATIC = 1 ] ; then
347 # make a static .a library
348 LIBNAME
="lib${LIBNAME}.a" # prefix with "lib", suffix with ".a"
349 echo "mklib: Making" $ARCH "static library: " ${LIBNAME}
351 if [ "${ALTOPTS}" ] ; then
355 # expand .a into .o files
356 NEW_OBJECTS
=`expand_archives ${LIBNAME}.obj $OBJECTS`
359 FINAL_LIBS
=`make_ar_static_lib ${OPTS} 1 ${LIBNAME} ${NEW_OBJECTS}`
361 # remove temporary extracted .o files
362 rm -rf ${LIBNAME}.obj
364 # make dynamic library
365 LIBNAME
="lib${LIBNAME}" # prefix with "lib"
366 case $ARCH in 'Linux' |
'GNU' | GNU
/*)
367 OPTS
="-Xlinker -Bsymbolic -shared -Wl,-soname,${LIBNAME}.so.${MAJOR}"
370 OPTS
="-shared -Wl,-soname,${LIBNAME}.so.${MAJOR}"
373 if [ $EXPORTS ] ; then
374 #OPTS="${OPTS} -Xlinker --retain-symbols-file ${EXPORTS}"
375 # Make the 'exptmp' file for --version-script option
377 echo "global:" >> exptmp
378 sed 's/$/;/' ${EXPORTS} >> exptmp
379 echo "local:" >> exptmp
382 OPTS
="${OPTS} -Xlinker --version-script=exptmp"
383 # exptmp is removed below
386 # Check if objects are 32-bit and we're running in 64-bit
387 # environment. If so, pass -m32 flag to linker.
389 ABI32
=`file $1 | grep 32-bit`
390 if [ "${ABI32}" -a `uname -m` = "x86_64" ] ; then
393 if [ "${ALTOPTS}" ] ; then
397 if [ x
${PATCH} = "x" ] ; then
398 VERSION
="${MAJOR}.${MINOR}"
400 VERSION
="${MAJOR}.${MINOR}.${PATCH}"
403 echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}.so.
${VERSION}
406 rm -f ${LIBNAME}.so.
${VERSION}
407 rm -f ${LIBNAME}.so.
${MAJOR}
411 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
412 # make usual symlinks
413 ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR}
414 ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
416 FINAL_LIBS
="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so"
422 if [ $STATIC = 1 ] ; then
423 LIBNAME
="lib${LIBNAME}.a"
424 echo "mklib: Making SunOS static library: " ${LIBNAME}
425 FINAL_LIBS
=`make_ar_static_lib -ruc 0 ${LIBNAME} ${OBJECTS}`
427 if [ $NOPREFIX = 0 ] ; then
428 LIBNAME
="lib${LIBNAME}.so"
430 echo "mklib: Making SunOS shared library: " ${LIBNAME}
432 if [ "x$LINK" = "x" ] ; then
433 # -linker was not specified, choose default linker now
434 if [ $CPLUSPLUS = 1 ] ; then
435 # determine linker and options for C++ code
436 if [ `which c++` ] ; then
439 elif [ `type g++` ] ; then
443 echo "mklib: warning: can't find C++ compiler, trying CC."
447 # use native Sun linker for C code
453 if [ ${LINK} = "ld" -o ${LINK} = "cc" -o ${LINK} = "CC" ] ; then
454 # SunOS tools, -G to make shared libs
458 # Check if objects are 32-bit and we're running in 64-bit
459 # environment. If so, pass -m32 flag to linker.
461 ABI32
=`file $1 | grep 32-bit`
462 if [ "${ABI32}" ] ; then
463 OPTS
="-m32 -shared -Wl,-Bdynamic"
465 OPTS
="-m64 -shared -Wl,-Bdynamic"
469 # If using Sun C++ compiler, need to tell it not to add runpaths
470 # that are specific to the build machine
471 if [ ${LINK} = "CC" ] ; then
472 OPTS
="${OPTS} -norunpath"
475 # Solaris linker requires explicitly listing the Standard C & C++
476 # libraries in the link path when building shared objects
477 if [ ${LINK} = "CC" ] ; then
478 DEPS
="${DEPS} -lCrun"
482 if [ $EXPORTS ] ; then
483 # Make the 'mapfile.scope' linker mapfile
484 echo "{" > mapfile.scope
485 echo "global:" >> mapfile.scope
486 sed 's/$/;/' ${EXPORTS} >> mapfile.scope
487 echo "local:" >> mapfile.scope
488 echo " *;" >> mapfile.scope
489 echo "};" >> mapfile.scope
490 OPTS
="${OPTS} -Wl,-Mmapfile.scope"
493 # Check if objects are SPARC v9
494 # file says: ELF 64-bit MSB relocatable SPARCV9 Version 1
496 if [ ${LINK} = "cc" -o ${LINK} = "CC" ] ; then
497 SPARCV9
=`file $1 | grep SPARCV9`
498 if [ "${SPARCV9}" ] ; then
499 OPTS
="${OPTS} -xarch=v9"
502 if [ "${ALTOPTS}" ] ; then
507 #echo "mklib: linker is" ${LINK} ${OPTS}
508 if [ $NOPREFIX = 1 ] ; then
510 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
511 FINAL_LIBS
="${LIBNAME}"
513 rm -f ${LIBNAME}.${MAJOR} ${LIBNAME}
514 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.${MAJOR} -h ${LIBNAME}.${MAJOR} ${OBJECTS} ${DEPS}
515 ln -s ${LIBNAME}.${MAJOR} ${LIBNAME}
516 FINAL_LIBS
="${LIBNAME}.${MAJOR} ${LIBNAME}"
524 if [ "x$LINK" = "x" ] ; then
525 # -linker was not specified so set default link command now
526 if [ $CPLUSPLUS = 1 ] ; then
533 if [ $NOPREFIX = 1 ] ; then
534 # No "lib" or ".so" part
535 echo "mklib: Making FreeBSD shared library: " ${LIBNAME}
537 if [ "${ALTOPTS}" ] ; then
541 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
542 FINAL_LIBS
=${LIBNAME}
543 elif [ $STATIC = 1 ] ; then
544 # make a static .a library
545 STLIB
="lib${LIBNAME}.a"
546 echo "mklib: Making FreeBSD static library: " ${STLIB}
548 # expand .a into .o files
549 NEW_OBJECTS
=`expand_archives ${STLIB}.obj $OBJECTS`
551 FINAL_LIBS
=`make_ar_static_lib cq 1 ${STLIB} ${NEW_OBJECTS}`
553 # remove temporary extracted .o files
556 # make dynamic library
557 SHLIB
="lib${LIBNAME}.so.${MAJOR}"
558 OPTS
="-shared -Wl,-soname,${SHLIB}"
559 if [ "${ALTOPTS}" ] ; then
562 echo "mklib: Making FreeBSD shared library: " ${SHLIB}
564 ${LINK} ${OPTS} ${LDFLAGS} -o ${SHLIB} ${OBJECTS} ${DEPS}
565 ln -sf ${SHLIB} "lib${LIBNAME}.so"
566 FINAL_LIBS
="${SHLIB} lib${LIBNAME}.so"
571 if [ $STATIC = 1 ] ; then
572 LIBNAME
="lib${LIBNAME}_pic.a"
573 echo "mklib: Making NetBSD PIC static library: " ${LIBNAME}
574 FINAL_LIBS
=`make_ar_static_lib cq 1 ${LIBNAME} ${OBJECTS}`
576 LIBNAME
="lib${LIBNAME}.so.${MAJOR}.${MINOR}"
577 echo "mklib: Making NetBSD PIC shared library: " ${LIBNAME}
579 ld
-x -Bshareable -Bforcearchive -o ${LIBNAME} ${OBJECTS}
580 FINAL_LIBS
=${LIBNAME}
585 if [ $STATIC = 1 ] ; then
586 LIBNAME
="lib${LIBNAME}.a"
587 FINAL_LIBS
=`make_ar_static_lib rc 0 ${LIBNAME} ${OBJECTS}`
589 LIBNAME
="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
591 # examine first object to determine ABI
593 ABI_O32
=`file $1 | grep 'ELF 32-bit'`
594 ABI_N32
=`file $1 | grep 'ELF N32'`
595 ABI_N64
=`file $1 | grep 'ELF 64-bit'`
596 if [ "${ABI_O32}" ] ; then
597 OPTS
="-32 -shared -all"
599 elif [ "${ABI_N32}" ] ; then
600 OPTS
="-n32 -shared -all"
602 elif [ "${ABI_N64}" ] ; then
603 OPTS
="-64 -shared -all"
606 echo "Error: Unexpected IRIX ABI!"
610 if [ "${ALTOPTS}" ] ; then
614 if [ $CPLUSPLUS = 1 ] ; then
620 echo "mklib: Making IRIX " ${ABI} " shared library: " ${LIBNAME}
621 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
622 FINAL_LIBS
=${LIBNAME}
627 LIBNAME
="lib${LIBNAME}.a"
628 echo "mklib: Making linux-cygwin library: " ${LIBNAME}
630 gnuwin32ar ruv
${LIBNAME} ${OBJECTS}
631 FINAL_LIBS
=${LIBNAME}
635 if [ $STATIC = 1 ] ; then
636 LIBNAME
="lib${LIBNAME}.a"
637 echo "mklib: Making HP-UX static library: " ${LIBNAME}
638 FINAL_LIBS
=`make_ar_static_lib -ruv 0 ${LIBNAME} ${OBJECTS}`
640 # HP uses a .2 for their current GL/GLU libraries
641 if [ ${LIBNAME} = "GL" -o ${LIBNAME} = "GLU" ] ; then
644 RUNLIB
="lib${LIBNAME}.${MAJOR}"
645 DEVLIB
="lib${LIBNAME}.sl"
646 echo "mklib: Making HP-UX shared library: " ${RUNLIB} ${DEVLIB}
647 ld
-b -o ${RUNLIB} +b ${RUNLIB} ${OBJECTS} ${DEPS}
648 ln -s ${RUNLIB} ${DEVLIB}
649 FINAL_LIBS
="${RUNLIB} ${DEVLIB}"
654 # examine first object to determine ABI
656 ABI_64
=`file $1 | grep '64-bit'`
657 if [ "${ABI_64}" ] ; then
662 OFILE
=shr.o
#Want to be consistent with the IBM libGL.a
665 if [ $STATIC = 1 ] ; then
666 LIBNAME
="lib${LIBNAME}.a"
667 echo "mklib: Making AIX static library: " ${LIBNAME}
668 FINAL_LIBS
=`make_ar_static_lib -ruv 0 ${LIBNAME} ${OBJECTS}`
670 EXPFILE
="lib${LIBNAME}.exp"
671 LIBNAME
="lib${LIBNAME}.a" # shared objects are still stored in the .a libraries
672 OPTS
="-bE:${EXPFILE} -bM:SRE -bnoentry ${Q64}"
673 rm -f ${EXPFILE} ${OFILE}
674 NM
="/bin/nm -eC ${X64}"
675 echo "#! /usr/lib/${LIBNAME}" > ${EXPFILE}
676 ${NM} ${OBJECTS} |
awk '{
677 if ((($2 == "T") || ($2 == "D") || ($2 == "B")) \
678 && ( substr($1,1,1) != ".")) {
679 if (substr ($1, 1, 7) != "__sinit" &&
680 substr ($1, 1, 7) != "__sterm") {
681 if (substr ($1, 1, 5) == "__tf1")
682 print (substr ($1, 7))
683 else if (substr ($1, 1, 5) == "__tf9")
684 print (substr ($1, 15))
689 }' |
sort -u >> ${EXPFILE}
691 if [ "${ALTOPTS}" ] ; then
695 # On AIX a shared library is linked differently when
696 # you want to dlopen the file
697 if [ $DLOPEN = "1" ] ; then
698 cc
-G ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
700 cc
${OPTS} ${LDFLAGS} -o ${OFILE} ${OBJECTS} ${DEPS}
701 ar ${X64} -r ${LIBNAME} ${OFILE}
704 FINAL_LIBS
="${LIBNAME}"
709 LIBNAME
="lib${LIBNAME}.a"
710 echo "mklib: Making OpenSTEP static library: " ${LIBNAME}
711 libtool
-static -o ${LIBNAME} - ${OBJECTS}
712 FINAL_LIBS
=${LIBNAME}
716 if [ $STATIC = 1 ] ; then
717 LIBNAME
="lib${LIBNAME}.a"
718 echo "mklib: Making OSF/1 static library: " ${LIBNAME}
719 FINAL_LIBS
=`make_ar_static_lib -ruv 0 ${LIBNAME} ${OBJECTS}`
721 VERSION
="${MAJOR}.${MINOR}"
722 LIBNAME
="lib${LIBNAME}.so"
723 echo "mklib: Making OSF/1 shared library: " ${LIBNAME}
724 if [ "x$LINK" = "x" ] ; then
725 if [ $CPLUSPLUS = 1 ] ; then
731 rm -f ${LIBNAME}.
${VERSION}
732 ${LINK} -o ${LIBNAME}.${VERSION} -shared -set_version ${VERSION} -soname ${LIBNAME}.${VERSION} -expect_unresolved \* -all ${OBJECTS} ${DEPS}
733 ln -sf ${LIBNAME}.${VERSION} ${LIBNAME}
734 FINAL_LIBS
="${LIBNAME} ${LIBNAME}.${VERSION}"
739 if [ $STATIC = 1 ] ; then
740 LIBNAME
="lib${LIBNAME}.a"
741 echo "mklib: Making Darwin static library: " ${LIBNAME}
744 if [ "${ALTOPTS}" ] ; then
747 ${LINK} ${OPTS} ${LIBNAME} ${OBJECTS}
748 FINAL_LIBS
=${LIBNAME}
750 # On Darwin a .bundle is used for a library that you want to dlopen
751 if [ $DLOPEN = "1" ] ; then
753 OPTS
="${ARCHOPT} -bundle -multiply_defined suppress"
756 if [ -z "$ID" ] ; then
757 ID
="lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}"
759 OPTS
="${ARCHOPT} -dynamiclib -multiply_defined suppress -current_version ${MAJOR}.${MINOR}.0 -compatibility_version ${MAJOR}.${MINOR}.0 -install_name ${ID}"
762 if [ ${EXPORTS} ] ; then
763 if [ -f ${EXPORTS}".darwin" ] ; then
764 EXPORTS
=$EXPORTS".darwin"
766 OPTS
="${OPTS} -exported_symbols_list ${EXPORTS}"
769 LINKNAME
="lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}"
770 LINKNAME2
="lib${LIBNAME}.${LIBSUFFIX}"
771 LIBNAME
="lib${LIBNAME}.${MAJOR}.${MINOR}.${LIBSUFFIX}"
773 # examine first object to determine ABI
775 ABIS
=`lipo -info $1 | sed s/.*://`
777 OPTS
="${OPTS} -arch ${ABI}"
780 if [ "${ALTOPTS}" ] ; then
784 # XXX can we always add -isysroot /Developer/SDKs/MacOSX10.4u.sdk
788 if [ $CPLUSPLUS = 1 ] ; then
794 echo "mklib: Making Darwin shared library: " ${LIBNAME}
796 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
797 ln -s ${LIBNAME} ${LINKNAME}
798 ln -s ${LIBNAME} ${LINKNAME2}
799 FINAL_LIBS
="${LIBNAME} ${LINKNAME} ${LINKNAME2}"
804 LIBNAME
="lib${LIBNAME}.a"
805 echo "mklib: Making LynxOS static library: " ${LIBNAME}
806 FINAL_LIBS
=`make_ar_static_lib -ru 0 ${LIBNAME} ${OBJECTS}`
810 if [ $STATIC = 1 ] ; then
811 LIBNAME
="lib${LIBNAME}.a"
812 echo "mklib: Making BeOS static library: " ${LIBNAME}
813 FINAL_LIBS
=`make_ar_static_lib -cru 0 ${LIBNAME} ${OBJECTS}`
815 LIBNAME
="lib${LIBNAME}.so"
816 echo "mklib: Making BeOS shared library: " ${LIBNAME}
817 gcc
-nostart -Xlinker "-soname=${LIBNAME}" -L/Be/develop/lib/x86 -lbe ${DEPS} ${OBJECTS} -o "${LIBNAME}"
818 mimeset
-f "${LIBNAME}"
819 # XXX remove the Mesa3D stuff here since mklib isn't mesa-specific.
820 setversion
"${LIBNAME}" -app ${MAJOR} ${MINOR} ${PATCH} -short "Powered by Mesa3D
!" -long "Powered by Mesa3D
!"
822 FINAL_LIBS=${LIBNAME}
826 LIBNAME="lib
${LIBNAME}.a
"
827 echo "mklib
: Making QNX library
: " ${LIBNAME}
828 wlib ${LIBNAME} ${OBJECTS}
829 FINAL_LIBS=${LIBNAME}
833 LIBNAME="lib
${LIBNAME}.a
"
834 echo "mklib
: Making MorphOS library
: " ${LIBNAME}
835 ppc-morphos-ar rc ${LIBNAME} ${OBJECTS}
836 FINAL_LIBS="${LIBNAME}"
839 'icc' | 'icc-istatic')
841 # This should get merged into the Linux code, above, since this isn't
842 # really a different architecture.
843 LIBNAME="lib
${LIBNAME}" # prefix with "lib
"
845 if [ $STATIC = 1 ] ; then
846 echo "mklib
: Making Intel ICC static library
: " ${LIBNAME}.a
849 if [ "${ALTOPTS}" ] ; then
853 ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
855 FINAL_LIBS="${LIBNAME}.a
"
857 if [ $ARCH = icc-istatic ] ; then
858 OPTS="-shared -i-static -cxxlib-icc"
862 if [ "${ALTOPTS}" ] ; then
865 VERSION="${MAJOR}.${MINOR}.${PATCH}"
866 echo "mklib
: Making Intel ICC shared library
: " ${LIBNAME}.so.${VERSION}
868 if [ $CPLUSPLUS = 1 ] ; then
874 rm -f ${LIBNAME}.so.${VERSION}
875 rm -f ${LIBNAME}.so.${MAJOR}
878 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
879 # make usual symlinks
880 ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR}
881 ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
883 FINAL_LIBS="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
"
889 if [ $STATIC = 1 ] ; then
890 LIBNAME="lib
${LIBNAME}.a
"
891 echo "mklib
: Making AIX GCC static library
: " ${LIBNAME}
892 FINAL_LIBS=`make_ar_static_lib ru 0 ${LIBNAME} ${OBJECTS}`
894 LIBNAME="lib
${LIBNAME}.so
" # prefix with "lib
", suffix with ".so
"
895 echo "mklib
: Making AIX GCC shared library
: " ${LIBNAME}
899 gcc -shared -Wl,-G ${OBJECTS} ${DEPS} -o ${LIBNAME}
900 # NOTE: the application linking with this library must specify
901 # the -Wl,-brtl flags to gcc
902 FINAL_LIBS=${LIBNAME}
908 if [ $STATIC = 0 ] ; then
909 echo "mklib
: Warning shared libs not supported on Ultrix
"
911 LIBNAME="lib
${LIBNAME}.a
"
912 echo "mklib
: Making static library
for Ultrix
: " ${LIBNAME}
913 FINAL_LIBS=`make_ar_static_lib ru 0 ${LIBNAME} ${OBJECTS}`
917 # GCC-based environment
918 if [ $NOPREFIX = 1 ] ; then
919 # No "lib
" or ".so
" part
920 echo "mklib
: Making CYGWIN shared library
: " ${LIBNAME}
921 OPTS="-shared -Wl,--enable-auto-image-base"
922 if [ "${ALTOPTS}" ] ; then
926 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
927 FINAL_LIBS=${LIBNAME}
929 CYGNAME="cyg
${LIBNAME}" # prefix with "cyg
"
930 LIBNAME="lib
${LIBNAME}" # prefix with "lib
"
932 if [ $STATIC = 1 ] ; then
934 echo "mklib
: Making
" $ARCH "static library
: " ${LIBNAME}
936 if [ "${ALTOPTS}" ] ; then
940 # expand .a into .o files
941 NEW_OBJECTS=`expand_archives ${LIBNAME}.obj $OBJECTS`
943 FINAL_LIBS=`make_ar_static_lib ${OPTS} 1 ${LIBNAME} ${NEW_OBJECTS}`
945 # remove temporary extracted .o files
946 rm -rf ${LIBNAME}.obj
948 OPTS="-shared -Wl,--enable-auto-image-base -Wl,-export-all -Wl,--out-implib=${LIBNAME}-${MAJOR}.dll.a
"
949 if [ "${ALTOPTS}" ] ; then
952 echo "mklib
: Making
" $ARCH "shared library
: " ${CYGNAME}-${MAJOR}.dll
954 if [ $CPLUSPLUS = 1 ] ; then
961 rm -f ${CYGNAME}-${MAJOR}.dll
962 rm -f ${LIBNAME}-${MAJOR}.dll.a
963 rm -f ${LIBNAME}.dll.a
967 ${LINK} ${OPTS} ${LDFLAGS} -o ${CYGNAME}-${MAJOR}.dll ${OBJECTS} ${DEPS}
968 # make build fail if link failed
970 if [ "$es" -ne "0" ]; then
973 # make usual symlinks
974 ln -s ${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a
976 FINAL_LIBS="${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a
"
977 # special case for installing in bin
978 FINAL_BINS="${CYGNAME}-${MAJOR}.dll
"
984 # If you're adding support for a new architecture, you can
986 if [ $STATIC = 1 ] ; then
987 LIBNAME="lib
${LIBNAME}.a
"
988 echo "mklib
: Making static library
for example arch
: " ${LIBNAME}
989 FINAL_LIBS=`make_ar_static_lib rv 0 ${LIBNAME} ${OBJECTS}`
991 LIBNAME="lib
${LIBNAME}.so
" # prefix with "lib
", suffix with ".so
"
992 echo "mklib
: Making shared library
for example arch
: " ${LIBNAME}
993 ld -o ${LIBNAME} ${OBJECTS} ${DEPS}
994 FINAL_LIBS="${LIBNAME}"
999 echo "mklib
: ERROR
: Don
't know how to make a static/shared library for" ${ARCH}
1000 echo "mklib: Please add necessary commands to mklib script."
1006 # Put library files into installation directory if specified.
1008 if [ ${INSTALLDIR} != "." ] ; then
1009 echo "mklib: Installing" ${FINAL_LIBS} "in" ${INSTALLDIR}
1010 test -d ${INSTALLDIR} || mkdir -p ${INSTALLDIR}
1011 mv ${FINAL_LIBS} ${INSTALLDIR}/