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 # Clear CDPATH as the 'cd' command will echo stuff
29 # to stdout if it is set
32 # Given a list of files, look for .a archives and unpack them.
33 # Return the original list of files minus the .a files plus the unpacked files.
34 # first param: name of a temp directory (to be deleted when finished)
35 # remaining params: list of .o and .a files
44 for FILE
in $FILES ; do
47 # extract the .o files from this .a archive
50 *) FILE
="$ORIG_DIR/$FILE" ;;
54 for MEMBER
in $MEMBERS ; do
55 NEWFILES
="$NEWFILES $DIR/$MEMBER"
59 # other file type, just add to list
60 NEWFILES
="$NEWFILES $FILE"
69 # Make static library with 'ar'
72 # 1 or 0 to indicate if ranlib should be run
74 # list of object files
75 # Return name of library we made
76 # Example: "make_ar_static_lib -ru 1 libfoo.a foo.o bar.o"
77 make_ar_static_lib
() {
86 # remove existing lib, if present
90 ar ${OPTS} ${LIBNAME} ${OBJECTS}
93 if [ ${RANLIB} = 1 ] ; then
103 echo 'Usage: mklib [options] objects'
104 echo 'Create a shared library from object files.'
105 echo ' -o LIBRARY specifies the name of the resulting library, without'
106 echo ' the leading "lib" or any suffix.'
107 echo ' (eg: "-o GL" might result in "libGL.so" being made)'
108 echo ' -major N specifies major version number (default is 1)'
109 echo ' -minor N specifies minor version number (default is 0)'
110 echo ' -patch N specifies patch version number (default is 0)'
111 echo ' -lLIBRARY specifies a dependency on LIBRARY'
112 echo ' -LDIR search in DIR for library dependencies at build time'
113 echo ' -RDIR search in DIR for library dependencies at run time'
114 echo ' -linker L explicity specify the linker program to use (eg: gcc, g++)'
115 echo ' Not observed on all systems at this time.'
116 echo ' -ldflags OPT specify any additional linker flags in OPT'
117 echo ' -cplusplus link with C++ runtime'
118 echo ' -static make a static library (default is dynamic/shared)'
119 echo ' -dlopen make a shared library suitable for dynamic loading'
120 echo ' -install DIR put resulting library file(s) in DIR'
121 echo ' -arch ARCH override using `uname` to determine host system'
122 echo ' -archopt OPT specify an extra achitecture-specific option OPT'
123 echo ' -altopts OPTS alternate options to override all others'
124 echo " -noprefix don't prefix library name with 'lib' nor add any suffix"
125 echo ' -exports FILE only export the symbols listed in FILE'
126 echo ' -id NAME Sets the id of the dylib (Darwin)'
127 echo ' -h, --help display this information and exit'
198 # this is a special case (see bugzilla 10876)
202 DEPS
="$DEPS -pthread"
241 echo "mklib: Unknown option: " $1 ;
245 # This should be the first object file, stop parsing
253 if [ ${ARCH} = "auto" ] ; then
258 if [ $STATIC = 1 ]; then
259 # filter out linker options inside object list
261 for OBJ
in $OBJECTS ; do
264 echo "mklib: warning: ignoring $OBJ for static library"
267 NEWOBJECTS
="$NEWOBJECTS $OBJ"
278 if [ "x${LIBNAME}" = "x" ] ; then
279 echo "mklib: Error: no library name specified (-h for help)"
282 if [ "x${OBJECTS}" = "x" ] ; then
283 echo "mklib: Error: no object files specified (-h for help)"
292 echo "-----------------"
294 echo LIBNAME is
$LIBNAME
299 echo "EXPORTS in" $EXPORTS
301 echo "-----------------"
306 # OK, make the library now
310 'Linux' |
'OpenBSD' |
'DragonFly' |
'GNU' | GNU
/*)
313 if [ "x$LINK" = "x" ] ; then
314 # -linker was not specified so set default link command now
315 if [ $CPLUSPLUS = 1 ] ; then
322 if [ $NOPREFIX = 1 ] ; then
323 # No "lib" or ".so" part
324 echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}
325 case $ARCH in 'Linux' |
'GNU' | GNU
/*)
326 OPTS
="-Xlinker -Bsymbolic -shared"
333 # Check if objects are 32-bit and we're running in 64-bit
334 # environment. If so, pass -m32 flag to linker.
336 ABI32
=`file $1 | grep 32-bit`
337 if [ "${ABI32}" -a `uname -m` = "x86_64" ] ; then
341 if [ "${ALTOPTS}" ] ; then
347 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
349 FINAL_LIBS
="${LIBNAME}"
350 elif [ $STATIC = 1 ] ; then
351 # make a static .a library
352 LIBNAME
="lib${LIBNAME}.a" # prefix with "lib", suffix with ".a"
353 echo "mklib: Making" $ARCH "static library: " ${LIBNAME}
355 if [ "${ALTOPTS}" ] ; then
359 # expand .a into .o files
360 NEW_OBJECTS
=`expand_archives ${LIBNAME}.obj $OBJECTS`
363 FINAL_LIBS
=`make_ar_static_lib ${OPTS} 1 ${LIBNAME} ${NEW_OBJECTS}`
365 # remove temporary extracted .o files
366 rm -rf ${LIBNAME}.obj
368 # make dynamic library
369 LIBNAME
="lib${LIBNAME}" # prefix with "lib"
370 case $ARCH in 'Linux' |
'GNU' | GNU
/*)
371 OPTS
="-Xlinker -Bsymbolic -shared -Wl,-soname,${LIBNAME}.so.${MAJOR}"
374 OPTS
="-shared -Wl,-soname,${LIBNAME}.so.${MAJOR}"
377 if [ $EXPORTS ] ; then
378 #OPTS="${OPTS} -Xlinker --retain-symbols-file ${EXPORTS}"
379 # Make the 'exptmp' file for --version-script option
381 echo "global:" >> exptmp
382 sed 's/$/;/' ${EXPORTS} >> exptmp
383 echo "local:" >> exptmp
386 OPTS
="${OPTS} -Xlinker --version-script=exptmp"
387 # exptmp is removed below
390 # Check if objects are 32-bit and we're running in 64-bit
391 # environment. If so, pass -m32 flag to linker.
393 ABI32
=`file $1 | grep 32-bit`
394 if [ "${ABI32}" -a `uname -m` = "x86_64" ] ; then
397 if [ "${ALTOPTS}" ] ; then
401 if [ x
${PATCH} = "x" ] ; then
402 VERSION
="${MAJOR}.${MINOR}"
404 VERSION
="${MAJOR}.${MINOR}.${PATCH}"
407 echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}.so.
${VERSION}
410 rm -f ${LIBNAME}.so.
${VERSION}
411 rm -f ${LIBNAME}.so.
${MAJOR}
415 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
416 # make usual symlinks
417 ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR}
418 ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
420 FINAL_LIBS
="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so"
426 if [ $STATIC = 1 ] ; then
427 LIBNAME
="lib${LIBNAME}.a"
428 echo "mklib: Making SunOS static library: " ${LIBNAME}
429 FINAL_LIBS
=`make_ar_static_lib -ruc 0 ${LIBNAME} ${OBJECTS}`
431 if [ $NOPREFIX = 0 ] ; then
432 LIBNAME
="lib${LIBNAME}.so"
434 echo "mklib: Making SunOS shared library: " ${LIBNAME}
436 if [ "x$LINK" = "x" ] ; then
437 # -linker was not specified, choose default linker now
438 if [ $CPLUSPLUS = 1 ] ; then
439 # determine linker and options for C++ code
440 if [ `which c++` ] ; then
443 elif [ `type g++` ] ; then
447 echo "mklib: warning: can't find C++ compiler, trying CC."
451 # use native Sun linker for C code
457 if [ ${LINK} = "ld" -o ${LINK} = "cc" -o ${LINK} = "CC" ] ; then
458 # SunOS tools, -G to make shared libs
462 # Check if objects are 32-bit and we're running in 64-bit
463 # environment. If so, pass -m32 flag to linker.
465 ABI32
=`file $1 | grep 32-bit`
466 if [ "${ABI32}" ] ; then
467 OPTS
="-m32 -shared -Wl,-Bdynamic"
469 OPTS
="-m64 -shared -Wl,-Bdynamic"
473 # If using Sun C++ compiler, need to tell it not to add runpaths
474 # that are specific to the build machine
475 if [ ${LINK} = "CC" ] ; then
476 OPTS
="${OPTS} -norunpath"
479 # Solaris linker requires explicitly listing the Standard C & C++
480 # libraries in the link path when building shared objects
481 if [ ${LINK} = "CC" ] ; then
482 DEPS
="${DEPS} -lCrun"
486 if [ $EXPORTS ] ; then
487 # Make the 'mapfile.scope' linker mapfile
488 echo "{" > mapfile.scope
489 echo "global:" >> mapfile.scope
490 sed 's/$/;/' ${EXPORTS} >> mapfile.scope
491 echo "local:" >> mapfile.scope
492 echo " *;" >> mapfile.scope
493 echo "};" >> mapfile.scope
494 OPTS
="${OPTS} -Wl,-Mmapfile.scope"
497 # Check if objects are SPARC v9
498 # file says: ELF 64-bit MSB relocatable SPARCV9 Version 1
500 if [ ${LINK} = "cc" -o ${LINK} = "CC" ] ; then
501 SPARCV9
=`file $1 | grep SPARCV9`
502 if [ "${SPARCV9}" ] ; then
503 OPTS
="${OPTS} -xarch=v9"
506 if [ "${ALTOPTS}" ] ; then
511 #echo "mklib: linker is" ${LINK} ${OPTS}
512 if [ $NOPREFIX = 1 ] ; then
514 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
515 FINAL_LIBS
="${LIBNAME}"
517 rm -f ${LIBNAME}.${MAJOR} ${LIBNAME}
518 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.${MAJOR} -h ${LIBNAME}.${MAJOR} ${OBJECTS} ${DEPS}
519 ln -s ${LIBNAME}.${MAJOR} ${LIBNAME}
520 FINAL_LIBS
="${LIBNAME}.${MAJOR} ${LIBNAME}"
528 if [ "x$LINK" = "x" ] ; then
529 # -linker was not specified so set default link command now
530 if [ $CPLUSPLUS = 1 ] ; then
537 if [ $NOPREFIX = 1 ] ; then
538 # No "lib" or ".so" part
539 echo "mklib: Making FreeBSD shared library: " ${LIBNAME}
541 if [ "${ALTOPTS}" ] ; then
545 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
546 FINAL_LIBS
=${LIBNAME}
547 elif [ $STATIC = 1 ] ; then
548 # make a static .a library
549 STLIB
="lib${LIBNAME}.a"
550 echo "mklib: Making FreeBSD static library: " ${STLIB}
552 # expand .a into .o files
553 NEW_OBJECTS
=`expand_archives ${STLIB}.obj $OBJECTS`
555 FINAL_LIBS
=`make_ar_static_lib cq 1 ${STLIB} ${NEW_OBJECTS}`
557 # remove temporary extracted .o files
560 # make dynamic library
561 SHLIB
="lib${LIBNAME}.so.${MAJOR}"
562 OPTS
="-shared -Wl,-soname,${SHLIB}"
563 if [ "${ALTOPTS}" ] ; then
566 echo "mklib: Making FreeBSD shared library: " ${SHLIB}
568 ${LINK} ${OPTS} ${LDFLAGS} -o ${SHLIB} ${OBJECTS} ${DEPS}
569 ln -sf ${SHLIB} "lib${LIBNAME}.so"
570 FINAL_LIBS
="${SHLIB} lib${LIBNAME}.so"
575 if [ $STATIC = 1 ] ; then
576 LIBNAME
="lib${LIBNAME}_pic.a"
577 echo "mklib: Making NetBSD PIC static library: " ${LIBNAME}
578 FINAL_LIBS
=`make_ar_static_lib cq 1 ${LIBNAME} ${OBJECTS}`
580 LIBNAME
="lib${LIBNAME}.so.${MAJOR}.${MINOR}"
581 echo "mklib: Making NetBSD PIC shared library: " ${LIBNAME}
583 ld
-x -Bshareable -Bforcearchive -o ${LIBNAME} ${OBJECTS}
584 FINAL_LIBS
=${LIBNAME}
589 if [ $STATIC = 1 ] ; then
590 LIBNAME
="lib${LIBNAME}.a"
591 FINAL_LIBS
=`make_ar_static_lib rc 0 ${LIBNAME} ${OBJECTS}`
593 LIBNAME
="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
595 # examine first object to determine ABI
597 ABI_O32
=`file $1 | grep 'ELF 32-bit'`
598 ABI_N32
=`file $1 | grep 'ELF N32'`
599 ABI_N64
=`file $1 | grep 'ELF 64-bit'`
600 if [ "${ABI_O32}" ] ; then
601 OPTS
="-32 -shared -all"
603 elif [ "${ABI_N32}" ] ; then
604 OPTS
="-n32 -shared -all"
606 elif [ "${ABI_N64}" ] ; then
607 OPTS
="-64 -shared -all"
610 echo "Error: Unexpected IRIX ABI!"
614 if [ "${ALTOPTS}" ] ; then
618 if [ $CPLUSPLUS = 1 ] ; then
624 echo "mklib: Making IRIX " ${ABI} " shared library: " ${LIBNAME}
625 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
626 FINAL_LIBS
=${LIBNAME}
631 LIBNAME
="lib${LIBNAME}.a"
632 echo "mklib: Making linux-cygwin library: " ${LIBNAME}
634 gnuwin32ar ruv
${LIBNAME} ${OBJECTS}
635 FINAL_LIBS
=${LIBNAME}
639 if [ $STATIC = 1 ] ; then
640 LIBNAME
="lib${LIBNAME}.a"
641 echo "mklib: Making HP-UX static library: " ${LIBNAME}
642 FINAL_LIBS
=`make_ar_static_lib -ruv 0 ${LIBNAME} ${OBJECTS}`
644 # HP uses a .2 for their current GL/GLU libraries
645 if [ ${LIBNAME} = "GL" -o ${LIBNAME} = "GLU" ] ; then
648 RUNLIB
="lib${LIBNAME}.${MAJOR}"
649 DEVLIB
="lib${LIBNAME}.sl"
650 echo "mklib: Making HP-UX shared library: " ${RUNLIB} ${DEVLIB}
651 ld
-b -o ${RUNLIB} +b ${RUNLIB} ${OBJECTS} ${DEPS}
652 ln -s ${RUNLIB} ${DEVLIB}
653 FINAL_LIBS
="${RUNLIB} ${DEVLIB}"
658 # examine first object to determine ABI
660 ABI_64
=`file $1 | grep '64-bit'`
661 if [ "${ABI_64}" ] ; then
666 OFILE
=shr.o
#Want to be consistent with the IBM libGL.a
669 if [ $STATIC = 1 ] ; then
670 LIBNAME
="lib${LIBNAME}.a"
671 echo "mklib: Making AIX static library: " ${LIBNAME}
672 FINAL_LIBS
=`make_ar_static_lib -ruv 0 ${LIBNAME} ${OBJECTS}`
674 EXPFILE
="lib${LIBNAME}.exp"
675 LIBNAME
="lib${LIBNAME}.a" # shared objects are still stored in the .a libraries
676 OPTS
="-bE:${EXPFILE} -bM:SRE -bnoentry ${Q64}"
677 rm -f ${EXPFILE} ${OFILE}
678 NM
="/bin/nm -eC ${X64}"
679 echo "#! /usr/lib/${LIBNAME}" > ${EXPFILE}
680 ${NM} ${OBJECTS} |
awk '{
681 if ((($2 == "T") || ($2 == "D") || ($2 == "B")) \
682 && ( substr($1,1,1) != ".")) {
683 if (substr ($1, 1, 7) != "__sinit" &&
684 substr ($1, 1, 7) != "__sterm") {
685 if (substr ($1, 1, 5) == "__tf1")
686 print (substr ($1, 7))
687 else if (substr ($1, 1, 5) == "__tf9")
688 print (substr ($1, 15))
693 }' |
sort -u >> ${EXPFILE}
695 if [ "${ALTOPTS}" ] ; then
699 # On AIX a shared library is linked differently when
700 # you want to dlopen the file
701 if [ $DLOPEN = "1" ] ; then
702 cc
-G ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
704 cc
${OPTS} ${LDFLAGS} -o ${OFILE} ${OBJECTS} ${DEPS}
705 ar ${X64} -r ${LIBNAME} ${OFILE}
708 FINAL_LIBS
="${LIBNAME}"
713 LIBNAME
="lib${LIBNAME}.a"
714 echo "mklib: Making OpenSTEP static library: " ${LIBNAME}
715 libtool
-static -o ${LIBNAME} - ${OBJECTS}
716 FINAL_LIBS
=${LIBNAME}
720 if [ $STATIC = 1 ] ; then
721 LIBNAME
="lib${LIBNAME}.a"
722 echo "mklib: Making OSF/1 static library: " ${LIBNAME}
723 FINAL_LIBS
=`make_ar_static_lib -ruv 0 ${LIBNAME} ${OBJECTS}`
725 VERSION
="${MAJOR}.${MINOR}"
726 LIBNAME
="lib${LIBNAME}.so"
727 echo "mklib: Making OSF/1 shared library: " ${LIBNAME}
728 if [ "x$LINK" = "x" ] ; then
729 if [ $CPLUSPLUS = 1 ] ; then
735 rm -f ${LIBNAME}.
${VERSION}
736 ${LINK} -o ${LIBNAME}.${VERSION} -shared -set_version ${VERSION} -soname ${LIBNAME}.${VERSION} -expect_unresolved \* -all ${OBJECTS} ${DEPS}
737 ln -sf ${LIBNAME}.${VERSION} ${LIBNAME}
738 FINAL_LIBS
="${LIBNAME} ${LIBNAME}.${VERSION}"
743 if [ $STATIC = 1 ] ; then
744 LIBNAME
="lib${LIBNAME}.a"
745 echo "mklib: Making Darwin static library: " ${LIBNAME}
747 if [ "${ALTOPTS}" ] ; then
751 # expand .a into .o files
752 NEW_OBJECTS
=`expand_archives ${LIBNAME}.obj $OBJECTS`
755 FINAL_LIBS
=`make_ar_static_lib ${OPTS} 1 ${LIBNAME} ${NEW_OBJECTS}`
757 # remove temporary extracted .o files
758 rm -rf ${LIBNAME}.obj
760 FINAL_LIBS
=${LIBNAME}
762 # On Darwin a .bundle is used for a library that you want to dlopen
763 if [ $DLOPEN = "1" ] ; then
765 OPTS
="${ARCHOPT} -bundle -multiply_defined suppress"
768 if [ -z "$ID" ] ; then
769 ID
="lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}"
771 OPTS
="${ARCHOPT} -dynamiclib -multiply_defined suppress -current_version ${MAJOR}.${MINOR}.0 -compatibility_version ${MAJOR}.${MINOR}.0 -install_name ${ID}"
774 if [ ${EXPORTS} ] ; then
775 if [ -f ${EXPORTS}".darwin" ] ; then
776 EXPORTS
=$EXPORTS".darwin"
778 OPTS
="${OPTS} -exported_symbols_list ${EXPORTS}"
781 LINKNAME
="lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}"
782 LINKNAME2
="lib${LIBNAME}.${LIBSUFFIX}"
783 LIBNAME
="lib${LIBNAME}.${MAJOR}.${MINOR}.${LIBSUFFIX}"
785 # examine first object to determine ABI
787 ABIS
=`lipo -info $1 | sed s/.*://`
789 OPTS
="${OPTS} -arch ${ABI}"
792 if [ "${ALTOPTS}" ] ; then
796 # XXX can we always add -isysroot /Developer/SDKs/MacOSX10.4u.sdk
800 if [ $CPLUSPLUS = 1 ] ; then
806 echo "mklib: Making Darwin shared library: " ${LIBNAME}
808 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
809 ln -s ${LIBNAME} ${LINKNAME}
810 ln -s ${LIBNAME} ${LINKNAME2}
811 FINAL_LIBS
="${LIBNAME} ${LINKNAME} ${LINKNAME2}"
816 LIBNAME
="lib${LIBNAME}.a"
817 echo "mklib: Making LynxOS static library: " ${LIBNAME}
818 FINAL_LIBS
=`make_ar_static_lib -ru 0 ${LIBNAME} ${OBJECTS}`
822 if [ $STATIC = 1 ] ; then
823 LIBNAME
="lib${LIBNAME}.a"
824 echo "mklib: Making BeOS static library: " ${LIBNAME}
825 FINAL_LIBS
=`make_ar_static_lib -cru 0 ${LIBNAME} ${OBJECTS}`
827 LIBNAME
="lib${LIBNAME}.so"
828 echo "mklib: Making BeOS shared library: " ${LIBNAME}
829 gcc
-nostart -Xlinker "-soname=${LIBNAME}" -L/Be/develop/lib/x86 -lbe ${DEPS} ${OBJECTS} -o "${LIBNAME}"
830 mimeset
-f "${LIBNAME}"
831 # XXX remove the Mesa3D stuff here since mklib isn't mesa-specific.
832 setversion
"${LIBNAME}" -app ${MAJOR} ${MINOR} ${PATCH} -short "Powered by Mesa3D
!" -long "Powered by Mesa3D
!"
834 FINAL_LIBS=${LIBNAME}
838 LIBNAME="lib
${LIBNAME}.a
"
839 echo "mklib
: Making QNX library
: " ${LIBNAME}
840 wlib ${LIBNAME} ${OBJECTS}
841 FINAL_LIBS=${LIBNAME}
845 LIBNAME="lib
${LIBNAME}.a
"
846 echo "mklib
: Making MorphOS library
: " ${LIBNAME}
847 ppc-morphos-ar rc ${LIBNAME} ${OBJECTS}
848 FINAL_LIBS="${LIBNAME}"
851 'icc' | 'icc-istatic')
853 # This should get merged into the Linux code, above, since this isn't
854 # really a different architecture.
855 LIBNAME="lib
${LIBNAME}" # prefix with "lib
"
857 if [ $STATIC = 1 ] ; then
858 echo "mklib
: Making Intel ICC static library
: " ${LIBNAME}.a
861 if [ "${ALTOPTS}" ] ; then
865 ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
867 FINAL_LIBS="${LIBNAME}.a
"
869 if [ $ARCH = icc-istatic ] ; then
870 OPTS="-shared -i-static -cxxlib-icc"
874 if [ "${ALTOPTS}" ] ; then
877 VERSION="${MAJOR}.${MINOR}.${PATCH}"
878 echo "mklib
: Making Intel ICC shared library
: " ${LIBNAME}.so.${VERSION}
880 if [ $CPLUSPLUS = 1 ] ; then
886 rm -f ${LIBNAME}.so.${VERSION}
887 rm -f ${LIBNAME}.so.${MAJOR}
890 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
891 # make usual symlinks
892 ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR}
893 ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
895 FINAL_LIBS="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
"
901 if [ $STATIC = 1 ] ; then
902 LIBNAME="lib
${LIBNAME}.a
"
903 echo "mklib
: Making AIX GCC static library
: " ${LIBNAME}
904 FINAL_LIBS=`make_ar_static_lib ru 0 ${LIBNAME} ${OBJECTS}`
906 LIBNAME="lib
${LIBNAME}.so
" # prefix with "lib
", suffix with ".so
"
907 echo "mklib
: Making AIX GCC shared library
: " ${LIBNAME}
911 gcc -shared -Wl,-G ${OBJECTS} ${DEPS} -o ${LIBNAME}
912 # NOTE: the application linking with this library must specify
913 # the -Wl,-brtl flags to gcc
914 FINAL_LIBS=${LIBNAME}
920 if [ $STATIC = 0 ] ; then
921 echo "mklib
: Warning shared libs not supported on Ultrix
"
923 LIBNAME="lib
${LIBNAME}.a
"
924 echo "mklib
: Making static library
for Ultrix
: " ${LIBNAME}
925 FINAL_LIBS=`make_ar_static_lib ru 0 ${LIBNAME} ${OBJECTS}`
929 # GCC-based environment
930 if [ $NOPREFIX = 1 ] ; then
931 # No "lib
" or ".so
" part
932 echo "mklib
: Making CYGWIN shared library
: " ${LIBNAME}
933 OPTS="-shared -Wl,--enable-auto-image-base"
934 if [ "${ALTOPTS}" ] ; then
938 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
939 FINAL_LIBS=${LIBNAME}
941 CYGNAME="cyg
${LIBNAME}" # prefix with "cyg
"
942 LIBNAME="lib
${LIBNAME}" # prefix with "lib
"
944 if [ $STATIC = 1 ] ; then
946 echo "mklib
: Making
" $ARCH "static library
: " ${LIBNAME}
948 if [ "${ALTOPTS}" ] ; then
952 # expand .a into .o files
953 NEW_OBJECTS=`expand_archives ${LIBNAME}.obj $OBJECTS`
955 FINAL_LIBS=`make_ar_static_lib ${OPTS} 1 ${LIBNAME} ${NEW_OBJECTS}`
957 # remove temporary extracted .o files
958 rm -rf ${LIBNAME}.obj
960 OPTS="-shared -Wl,--enable-auto-image-base -Wl,-export-all -Wl,--out-implib=${LIBNAME}-${MAJOR}.dll.a
"
961 if [ "${ALTOPTS}" ] ; then
964 echo "mklib
: Making
" $ARCH "shared library
: " ${CYGNAME}-${MAJOR}.dll
966 if [ $CPLUSPLUS = 1 ] ; then
973 rm -f ${CYGNAME}-${MAJOR}.dll
974 rm -f ${LIBNAME}-${MAJOR}.dll.a
975 rm -f ${LIBNAME}.dll.a
979 ${LINK} ${OPTS} ${LDFLAGS} -o ${CYGNAME}-${MAJOR}.dll ${OBJECTS} ${DEPS}
980 # make build fail if link failed
982 if [ "$es" -ne "0" ]; then
985 # make usual symlinks
986 ln -s ${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a
988 FINAL_LIBS="${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a
"
989 # special case for installing in bin
990 FINAL_BINS="${CYGNAME}-${MAJOR}.dll
"
996 # If you're adding support for a new architecture, you can
998 if [ $STATIC = 1 ] ; then
999 LIBNAME="lib
${LIBNAME}.a
"
1000 echo "mklib
: Making static library
for example arch
: " ${LIBNAME}
1001 FINAL_LIBS=`make_ar_static_lib rv 0 ${LIBNAME} ${OBJECTS}`
1003 LIBNAME="lib
${LIBNAME}.so
" # prefix with "lib
", suffix with ".so
"
1004 echo "mklib
: Making shared library
for example arch
: " ${LIBNAME}
1005 ld -o ${LIBNAME} ${OBJECTS} ${DEPS}
1006 FINAL_LIBS="${LIBNAME}"
1011 echo "mklib
: ERROR
: Don
't know how to make a static/shared library for" ${ARCH}
1012 echo "mklib: Please add necessary commands to mklib script."
1018 # Put library files into installation directory if specified.
1020 if [ ${INSTALLDIR} != "." ] ; then
1021 echo "mklib: Installing" ${FINAL_LIBS} "in" ${INSTALLDIR}
1022 test -d ${INSTALLDIR} || mkdir -p ${INSTALLDIR}
1023 mv ${FINAL_LIBS} ${INSTALLDIR}/