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.
27 # propagate any errors
34 # Given a list of files, look for .a archives and unpack them.
35 # Return the original list of files minus the .a files plus the unpacked 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 # Given a list of files, look for .a archives and return a list of all objects
71 contents_of_archives() {
74 for FILE in $FILES ; do
77 # get list of members in this .a archive
79 NEWFILES="$NEWFILES $MEMBERS"
82 # skip other file types
90 # Make static library with 'ar'
93 # 1 or 0 to indicate if ranlib should be run
95 # list of object files
96 # Return name of library we made
97 # Example: "make_ar_static_lib -ru 1 libfoo.a foo.o bar.o"
98 make_ar_static_lib() {
107 # remove existing lib, if present
111 ar ${OPTS} ${LIBNAME} ${OBJECTS}
114 if [ ${RANLIB} = 1 ] ; then
124 echo 'Usage: mklib [options] objects'
125 echo 'Create a shared library from object files.'
126 echo ' -o LIBRARY specifies the name of the resulting library, without'
127 echo ' the leading "lib" or any suffix.'
128 echo ' (eg: "-o GL" might result in "libGL.so" being made)'
129 echo ' -major N specifies major version number (default is 1)'
130 echo ' -minor N specifies minor version number (default is 0)'
131 echo ' -patch N specifies patch version number (default is 0)'
132 echo ' -lLIBRARY specifies a dependency on LIBRARY'
133 echo ' -LDIR search in DIR for library dependencies at build time'
134 echo ' -RDIR search in DIR for library dependencies at run time'
135 echo ' -linker L explicity specify the linker program to use (eg: gcc, g++)'
136 echo ' Not observed on all systems at this time.'
137 echo ' -ldflags OPT specify any additional linker flags in OPT'
138 echo ' -cplusplus link with C++ runtime'
139 echo ' -static make a static library (default is dynamic/shared)'
140 echo ' -dlopen make a shared library suitable for dynamic loading'
141 echo ' -install DIR put resulting library file(s) in DIR'
142 echo ' -arch ARCH override using `uname` to determine host system'
143 echo ' -archopt OPT specify an extra achitecture-specific option OPT'
144 echo ' -altopts OPTS alternate options to override all others'
145 echo " -noprefix don't prefix library name with 'lib' nor add any suffix"
146 echo ' -exports FILE only export the symbols listed in FILE'
147 echo ' -id NAME Sets the id of the dylib (Darwin)'
148 echo ' -h, --help display this information and exit'
219 # this is a special case (see bugzilla 10876)
223 DEPS="$DEPS -pthread"
262 echo "mklib: Unknown option: " $1 ;
266 # This should be the first object file, stop parsing
274 if [ ${ARCH} = "auto" ] ; then
279 if [ $STATIC = 1 ]; then
280 # filter out linker options inside object list
282 for OBJ in $OBJECTS ; do
285 echo "mklib: warning: ignoring $OBJ for static library"
288 NEWOBJECTS="$NEWOBJECTS $OBJ"
299 if [ "x${LIBNAME}" = "x" ] ; then
300 echo "mklib: Error: no library name specified (-h for help)"
303 if [ "x${OBJECTS}" = "x" ] ; then
304 echo "mklib: Error: no object files specified (-h for help)"
313 echo "-----------------"
315 echo LIBNAME is $LIBNAME
320 echo "EXPORTS in" $EXPORTS
322 echo "-----------------"
327 # OK, make the library now
331 'Linux' | 'OpenBSD' | 'DragonFly' | 'GNU' | GNU/*)
334 if [ "x$LINK" = "x" ] ; then
335 # -linker was not specified so set default link command now
336 if [ $CPLUSPLUS = 1 ] ; then
343 if [ $NOPREFIX = 1 ] ; then
344 # No "lib" or ".so" part
345 echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}
346 case $ARCH in 'Linux' | 'GNU' | GNU/*)
347 OPTS="-Xlinker -Bsymbolic -shared"
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}" -a `uname -m` = "x86_64" ] ; then
362 if [ "${ALTOPTS}" ] ; then
368 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
370 FINAL_LIBS="${LIBNAME}"
371 elif [ $STATIC = 1 ] ; then
372 # make a static .a library
373 LIBNAME="lib${LIBNAME}.a" # prefix with "lib", suffix with ".a"
374 echo "mklib: Making" $ARCH "static library: " ${LIBNAME}
376 if [ "${ALTOPTS}" ] ; then
380 # expand .a into .o files
381 NEW_OBJECTS=`expand_archives ${LIBNAME}.obj $OBJECTS`
384 FINAL_LIBS=`make_ar_static_lib ${OPTS} 1 ${LIBNAME} ${NEW_OBJECTS}`
386 # remove temporary extracted .o files
387 rm -rf ${LIBNAME}.obj
389 # make dynamic library
390 LIBNAME="lib${LIBNAME}" # prefix with "lib"
391 case $ARCH in 'Linux' | 'GNU' | GNU/*)
392 OPTS="-Xlinker -Bsymbolic -shared -Wl,-soname,${LIBNAME}.so.${MAJOR}"
395 OPTS="-shared -Wl,-soname,${LIBNAME}.so.${MAJOR}"
398 if [ $EXPORTS ] ; then
399 #OPTS="${OPTS} -Xlinker --retain-symbols-file ${EXPORTS}"
400 # Make the 'exptmp' file for --version-script option
402 echo "global:" >> exptmp
403 sed 's/$/;/' ${EXPORTS} >> exptmp
404 echo "local:" >> exptmp
407 OPTS="${OPTS} -Xlinker --version-script=exptmp"
408 # exptmp is removed below
411 # Check if objects are 32-bit and we're running in 64-bit
412 # environment. If so, pass -m32 flag to linker.
414 ABI32=`file $1 | grep 32-bit`
415 if [ "${ABI32}" -a `uname -m` = "x86_64" ] ; then
418 if [ "${ALTOPTS}" ] ; then
422 if [ x${PATCH} = "x" ] ; then
423 VERSION="${MAJOR}.${MINOR}"
425 VERSION="${MAJOR}.${MINOR}.${PATCH}"
428 echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}.so.${VERSION}
431 rm -f ${LIBNAME}.so.${VERSION}
432 rm -f ${LIBNAME}.so.${MAJOR}
436 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
437 # make usual symlinks
438 ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR}
439 ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
441 FINAL_LIBS="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so"
447 if [ $STATIC = 1 ] ; then
448 LIBNAME="lib${LIBNAME}.a"
449 echo "mklib: Making SunOS static library: " ${LIBNAME}
450 FINAL_LIBS=`make_ar_static_lib -ruc 0 ${LIBNAME} ${OBJECTS}`
452 if [ $NOPREFIX = 0 ] ; then
453 LIBNAME="lib${LIBNAME}.so"
455 echo "mklib: Making SunOS shared library: " ${LIBNAME}
457 if [ "x$LINK" = "x" ] ; then
458 # -linker was not specified, choose default linker now
459 if [ $CPLUSPLUS = 1 ] ; then
460 # determine linker and options for C++ code
461 if [ `which c++` ] ; then
464 elif [ `type g++` ] ; then
468 echo "mklib: warning: can't find C++ compiler, trying CC."
472 # use native Sun linker for C code
478 if [ ${LINK} = "ld" -o ${LINK} = "cc" -o ${LINK} = "CC" ] ; then
479 # SunOS tools, -G to make shared libs
483 # Check if objects are 32-bit and we're running in 64-bit
484 # environment. If so, pass -m32 flag to linker.
486 ABI32=`file $1 | grep 32-bit`
487 if [ "${ABI32}" ] ; then
488 OPTS="-m32 -shared -Wl,-Bdynamic"
490 OPTS="-m64 -shared -Wl,-Bdynamic"
494 # If using Sun C++ compiler, need to tell it not to add runpaths
495 # that are specific to the build machine
496 if [ ${LINK} = "CC" ] ; then
497 OPTS="${OPTS} -norunpath"
500 # Solaris linker requires explicitly listing the Standard C & C++
501 # libraries in the link path when building shared objects
502 if [ ${LINK} = "CC" ] ; then
503 DEPS="${DEPS} -lCrun"
507 if [ $EXPORTS ] ; then
508 # Make the 'mapfile.scope' linker mapfile
509 echo "{" > mapfile.scope
510 echo "global:" >> mapfile.scope
511 sed 's/$/;/' ${EXPORTS} >> mapfile.scope
512 echo "local:" >> mapfile.scope
513 echo " *;" >> mapfile.scope
514 echo "};" >> mapfile.scope
515 OPTS="${OPTS} -Wl,-Mmapfile.scope"
518 # Check if objects are SPARC v9
519 # file says: ELF 64-bit MSB relocatable SPARCV9 Version 1
521 if [ ${LINK} = "cc" -o ${LINK} = "CC" ] ; then
522 SPARCV9=`file $1 | grep SPARCV9`
523 if [ "${SPARCV9}" ] ; then
524 OPTS="${OPTS} -xarch=v9"
527 if [ "${ALTOPTS}" ] ; then
532 #echo "mklib: linker is" ${LINK} ${OPTS}
533 if [ $NOPREFIX = 1 ] ; then
535 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
536 FINAL_LIBS="${LIBNAME}"
538 rm -f ${LIBNAME}.${MAJOR} ${LIBNAME}
539 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.${MAJOR} -h ${LIBNAME}.${MAJOR} ${OBJECTS} ${DEPS}
540 ln -s ${LIBNAME}.${MAJOR} ${LIBNAME}
541 FINAL_LIBS="${LIBNAME}.${MAJOR} ${LIBNAME}"
549 if [ "x$LINK" = "x" ] ; then
550 # -linker was not specified so set default link command now
551 if [ $CPLUSPLUS = 1 ] ; then
558 if [ $NOPREFIX = 1 ] ; then
559 # No "lib" or ".so" part
560 echo "mklib: Making FreeBSD shared library: " ${LIBNAME}
562 if [ "${ALTOPTS}" ] ; then
566 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
567 FINAL_LIBS=${LIBNAME}
568 elif [ $STATIC = 1 ] ; then
569 # make a static .a library
570 STLIB="lib${LIBNAME}.a"
571 echo "mklib: Making FreeBSD static library: " ${STLIB}
573 # expand .a into .o files
574 NEW_OBJECTS=`expand_archives ${STLIB}.obj $OBJECTS`
576 FINAL_LIBS=`make_ar_static_lib cq 1 ${STLIB} ${NEW_OBJECTS}`
578 # remove temporary extracted .o files
581 # make dynamic library
582 SHLIB="lib${LIBNAME}.so.${MAJOR}"
583 OPTS="-shared -Wl,-soname,${SHLIB}"
584 if [ "${ALTOPTS}" ] ; then
587 echo "mklib: Making FreeBSD shared library: " ${SHLIB}
589 ${LINK} ${OPTS} ${LDFLAGS} -o ${SHLIB} ${OBJECTS} ${DEPS}
590 ln -sf ${SHLIB} "lib${LIBNAME}.so"
591 FINAL_LIBS="${SHLIB} lib${LIBNAME}.so"
596 if [ $STATIC = 1 ] ; then
597 LIBNAME="lib${LIBNAME}_pic.a"
598 echo "mklib: Making NetBSD PIC static library: " ${LIBNAME}
599 FINAL_LIBS=`make_ar_static_lib cq 1 ${LIBNAME} ${OBJECTS}`
601 LIBNAME="lib${LIBNAME}.so.${MAJOR}.${MINOR}"
602 echo "mklib: Making NetBSD PIC shared library: " ${LIBNAME}
604 ld -x -Bshareable -Bforcearchive -o ${LIBNAME} ${OBJECTS}
605 FINAL_LIBS=${LIBNAME}
610 if [ $STATIC = 1 ] ; then
611 LIBNAME="lib${LIBNAME}.a"
612 FINAL_LIBS=`make_ar_static_lib rc 0 ${LIBNAME} ${OBJECTS}`
614 LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
616 # examine first object to determine ABI
618 ABI_O32=`file $1 | grep 'ELF 32-bit'`
619 ABI_N32=`file $1 | grep 'ELF N32'`
620 ABI_N64=`file $1 | grep 'ELF 64-bit'`
621 if [ "${ABI_O32}" ] ; then
622 OPTS="-32 -shared -all"
624 elif [ "${ABI_N32}" ] ; then
625 OPTS="-n32 -shared -all"
627 elif [ "${ABI_N64}" ] ; then
628 OPTS="-64 -shared -all"
631 echo "Error: Unexpected IRIX ABI!"
635 if [ "${ALTOPTS}" ] ; then
639 if [ $CPLUSPLUS = 1 ] ; then
645 echo "mklib: Making IRIX " ${ABI} " shared library: " ${LIBNAME}
646 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
647 FINAL_LIBS=${LIBNAME}
652 LIBNAME="lib${LIBNAME}.a"
653 echo "mklib: Making linux-cygwin library: " ${LIBNAME}
655 gnuwin32ar ruv ${LIBNAME} ${OBJECTS}
656 FINAL_LIBS=${LIBNAME}
660 if [ $STATIC = 1 ] ; then
661 LIBNAME="lib${LIBNAME}.a"
662 echo "mklib: Making HP-UX static library: " ${LIBNAME}
663 FINAL_LIBS=`make_ar_static_lib -ruv 0 ${LIBNAME} ${OBJECTS}`
665 # HP uses a .2 for their current GL/GLU libraries
666 if [ ${LIBNAME} = "GL" -o ${LIBNAME} = "GLU" ] ; then
669 RUNLIB="lib${LIBNAME}.${MAJOR}"
670 DEVLIB="lib${LIBNAME}.sl"
671 echo "mklib: Making HP-UX shared library: " ${RUNLIB} ${DEVLIB}
672 ld -b -o ${RUNLIB} +b ${RUNLIB} ${OBJECTS} ${DEPS}
673 ln -s ${RUNLIB} ${DEVLIB}
674 FINAL_LIBS="${RUNLIB} ${DEVLIB}"
679 # examine first object to determine ABI
681 ABI_64=`file $1 | grep '64-bit'`
682 if [ "${ABI_64}" ] ; then
687 OFILE=shr.o #Want to be consistent with the IBM libGL.a
690 if [ $STATIC = 1 ] ; then
691 LIBNAME="lib${LIBNAME}.a"
692 echo "mklib: Making AIX static library: " ${LIBNAME}
693 FINAL_LIBS=`make_ar_static_lib -ruv 0 ${LIBNAME} ${OBJECTS}`
695 EXPFILE="lib${LIBNAME}.exp"
696 LIBNAME="lib${LIBNAME}.a" # shared objects are still stored in the .a libraries
697 OPTS="-bE:${EXPFILE} -bM:SRE -bnoentry ${Q64}"
698 rm -f ${EXPFILE} ${OFILE}
699 NM="/bin/nm -eC ${X64}"
700 echo "#! /usr/lib/${LIBNAME}" > ${EXPFILE}
701 ${NM} ${OBJECTS} | awk '{
702 if ((($2 == "T") || ($2 == "D") || ($2 == "B")) \
703 && ( substr($1,1,1) != ".")) {
704 if (substr ($1, 1, 7) != "__sinit" &&
705 substr ($1, 1, 7) != "__sterm") {
706 if (substr ($1, 1, 5) == "__tf1")
707 print (substr ($1, 7))
708 else if (substr ($1, 1, 5) == "__tf9")
709 print (substr ($1, 15))
714 }' | sort -u >> ${EXPFILE}
716 if [ "${ALTOPTS}" ] ; then
720 # On AIX a shared library is linked differently when
721 # you want to dlopen the file
722 if [ $DLOPEN = "1" ] ; then
723 cc -G ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
725 cc ${OPTS} ${LDFLAGS} -o ${OFILE} ${OBJECTS} ${DEPS}
726 ar ${X64} -r ${LIBNAME} ${OFILE}
729 FINAL_LIBS="${LIBNAME}"
734 LIBNAME="lib${LIBNAME}.a"
735 echo "mklib: Making OpenSTEP static library: " ${LIBNAME}
736 libtool -static -o ${LIBNAME} - ${OBJECTS}
737 FINAL_LIBS=${LIBNAME}
741 if [ $STATIC = 1 ] ; then
742 LIBNAME="lib${LIBNAME}.a"
743 echo "mklib: Making OSF/1 static library: " ${LIBNAME}
744 FINAL_LIBS=`make_ar_static_lib -ruv 0 ${LIBNAME} ${OBJECTS}`
746 VERSION="${MAJOR}.${MINOR}"
747 LIBNAME="lib${LIBNAME}.so"
748 echo "mklib: Making OSF/1 shared library: " ${LIBNAME}
749 if [ "x$LINK" = "x" ] ; then
750 if [ $CPLUSPLUS = 1 ] ; then
756 rm -f ${LIBNAME}.${VERSION}
757 ${LINK} -o ${LIBNAME}.${VERSION} -shared -set_version ${VERSION} -soname ${LIBNAME}.${VERSION} -expect_unresolved \* -all ${OBJECTS} ${DEPS}
758 ln -sf ${LIBNAME}.${VERSION} ${LIBNAME}
759 FINAL_LIBS="${LIBNAME} ${LIBNAME}.${VERSION}"
764 if [ $STATIC = 1 ] ; then
765 LIBNAME="lib${LIBNAME}.a"
766 echo "mklib: Making Darwin static library: " ${LIBNAME}
769 if [ "${ALTOPTS}" ] ; then
772 ${LINK} ${OPTS} ${LIBNAME} ${OBJECTS}
773 FINAL_LIBS=${LIBNAME}
775 # On Darwin a .bundle is used for a library that you want to dlopen
776 if [ $DLOPEN = "1" ] ; then
778 OPTS="${ARCHOPT} -bundle -multiply_defined suppress"
781 if [ -z "$ID" ] ; then
782 ID="lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}"
784 OPTS="${ARCHOPT} -dynamiclib -multiply_defined suppress -current_version ${MAJOR}.${MINOR}.0 -compatibility_version ${MAJOR}.${MINOR}.0 -install_name ${ID}"
787 if [ ${EXPORTS} ] ; then
788 if [ -f ${EXPORTS}".darwin" ] ; then
789 EXPORTS=$EXPORTS".darwin"
791 OPTS="${OPTS} -exported_symbols_list ${EXPORTS}"
794 LINKNAME="lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}"
795 LINKNAME2="lib${LIBNAME}.${LIBSUFFIX}"
796 LIBNAME="lib${LIBNAME}.${MAJOR}.${MINOR}.${LIBSUFFIX}"
798 # examine first object to determine ABI
800 ABIS=`lipo -info $1 | sed s/.*://`
802 OPTS="${OPTS} -arch ${ABI}"
805 if [ "${ALTOPTS}" ] ; then
809 # XXX can we always add -isysroot /Developer/SDKs/MacOSX10.4u.sdk
813 if [ $CPLUSPLUS = 1 ] ; then
819 echo "mklib: Making Darwin shared library: " ${LIBNAME}
821 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
822 ln -s ${LIBNAME} ${LINKNAME}
823 ln -s ${LIBNAME} ${LINKNAME2}
824 FINAL_LIBS="${LIBNAME} ${LINKNAME} ${LINKNAME2}"
829 LIBNAME="lib${LIBNAME}.a"
830 echo "mklib: Making LynxOS static library: " ${LIBNAME}
831 FINAL_LIBS=`make_ar_static_lib -ru 0 ${LIBNAME} ${OBJECTS}`
835 if [ $STATIC = 1 ] ; then
836 LIBNAME="lib${LIBNAME}.a"
837 echo "mklib: Making BeOS static library: " ${LIBNAME}
838 FINAL_LIBS=`make_ar_static_lib -cru 0 ${LIBNAME} ${OBJECTS}`
840 LIBNAME="lib${LIBNAME}.so"
841 echo "mklib: Making BeOS shared library: " ${LIBNAME}
842 gcc -nostart -Xlinker "-soname=${LIBNAME}" -L/Be/develop/lib/x86 -lbe ${DEPS} ${OBJECTS} -o "${LIBNAME}"
843 mimeset -f "${LIBNAME}"
844 # XXX remove the Mesa3D stuff here since mklib isn't mesa-specific.
845 setversion "${LIBNAME}" -app ${MAJOR} ${MINOR} ${PATCH} -short "Powered by Mesa3D!" -long "Powered by Mesa3D!"
847 FINAL_LIBS=${LIBNAME}
851 LIBNAME="lib${LIBNAME}.a"
852 echo "mklib: Making QNX library: " ${LIBNAME}
853 wlib ${LIBNAME} ${OBJECTS}
854 FINAL_LIBS=${LIBNAME}
858 LIBNAME="lib${LIBNAME}.a"
859 echo "mklib: Making MorphOS library: " ${LIBNAME}
860 ppc-morphos-ar rc ${LIBNAME} ${OBJECTS}
861 FINAL_LIBS="${LIBNAME}"
864 'icc' | 'icc-istatic')
866 # This should get merged into the Linux code, above, since this isn't
867 # really a different architecture.
868 LIBNAME="lib${LIBNAME}" # prefix with "lib"
870 if [ $STATIC = 1 ] ; then
871 echo "mklib: Making Intel ICC static library: " ${LIBNAME}.a
874 if [ "${ALTOPTS}" ] ; then
878 ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
880 FINAL_LIBS="${LIBNAME}.a"
882 if [ $ARCH = icc-istatic ] ; then
883 OPTS="-shared -i-static -cxxlib-icc"
887 if [ "${ALTOPTS}" ] ; then
890 VERSION="${MAJOR}.${MINOR}.${PATCH}"
891 echo "mklib: Making Intel ICC shared library: " ${LIBNAME}.so.${VERSION}
893 if [ $CPLUSPLUS = 1 ] ; then
899 rm -f ${LIBNAME}.so.${VERSION}
900 rm -f ${LIBNAME}.so.${MAJOR}
903 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
904 # make usual symlinks
905 ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR}
906 ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
908 FINAL_LIBS="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so"
914 if [ $STATIC = 1 ] ; then
915 LIBNAME="lib${LIBNAME}.a"
916 echo "mklib: Making AIX GCC static library: " ${LIBNAME}
917 FINAL_LIBS=`make_ar_static_lib ru 0 ${LIBNAME} ${OBJECTS}`
919 LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
920 echo "mklib: Making AIX GCC shared library: " ${LIBNAME}
924 gcc -shared -Wl,-G ${OBJECTS} ${DEPS} -o ${LIBNAME}
925 # NOTE: the application linking with this library must specify
926 # the -Wl,-brtl flags to gcc
927 FINAL_LIBS=${LIBNAME}
933 if [ $STATIC = 0 ] ; then
934 echo "mklib: Warning shared libs not supported on Ultrix"
936 LIBNAME="lib${LIBNAME}.a"
937 echo "mklib: Making static library for Ultrix: " ${LIBNAME}
938 FINAL_LIBS=`make_ar_static_lib ru 0 ${LIBNAME} ${OBJECTS}`
942 # GCC-based environment
943 if [ $NOPREFIX = 1 ] ; then
944 # No "lib" or ".so" part
945 echo "mklib: Making CYGWIN shared library: " ${LIBNAME}
946 OPTS="-shared -Wl,--enable-auto-image-base"
947 if [ "${ALTOPTS}" ] ; then
951 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
952 FINAL_LIBS=${LIBNAME}
954 CYGNAME="cyg${LIBNAME}" # prefix with "cyg"
955 LIBNAME="lib${LIBNAME}" # prefix with "lib"
957 if [ $STATIC = 1 ] ; then
959 echo "mklib: Making" $ARCH "static library: " ${LIBNAME}
961 if [ "${ALTOPTS}" ] ; then
964 FINAL_LIBS=`make_ar_static_lib ${OPTS} 1 ${LIBNAME} ${OBJECTS}`
966 OPTS="-shared -Wl,--enable-auto-image-base -Wl,-export-all -Wl,--out-implib=${LIBNAME}-${MAJOR}.dll.a"
967 if [ "${ALTOPTS}" ] ; then
970 echo "mklib: Making" $ARCH "shared library: " ${CYGNAME}-${MAJOR}.dll
972 if [ $CPLUSPLUS = 1 ] ; then
979 rm -f ${CYGNAME}-${MAJOR}.dll
980 rm -f ${LIBNAME}-${MAJOR}.dll.a
981 rm -f ${LIBNAME}.dll.a
985 ${LINK} ${OPTS} ${LDFLAGS} -o ${CYGNAME}-${MAJOR}.dll ${OBJECTS} ${DEPS}
986 # make build fail if link failed
988 if [ "$es" -ne "0" ]; then
991 # make usual symlinks
992 ln -s ${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a
994 FINAL_LIBS="${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a"
995 # special case for installing in bin
996 FINAL_BINS="${CYGNAME}-${MAJOR}.dll"
1002 # If you're adding support for a new architecture, you can
1004 if [ $STATIC = 1 ] ; then
1005 LIBNAME="lib${LIBNAME}.a"
1006 echo "mklib: Making static library for example arch: " ${LIBNAME}
1007 FINAL_LIBS=`make_ar_static_lib rv 0 ${LIBNAME} ${OBJECTS}`
1009 LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
1010 echo "mklib: Making shared library for example arch: " ${LIBNAME}
1011 ld -o ${LIBNAME} ${OBJECTS} ${DEPS}
1012 FINAL_LIBS="${LIBNAME}"
1017 echo "mklib: ERROR: Don't know how to make a static/shared library for" ${ARCH}
1018 echo "mklib: Please add necessary commands to mklib script."
1024 # Put library files into installation directory if specified.
1026 if [ ${INSTALLDIR} != "." ] ; then
1027 echo "mklib: Installing" ${FINAL_LIBS} "in" ${INSTALLDIR}
1028 test -d ${INSTALLDIR} || mkdir -p ${INSTALLDIR}
1029 mv ${FINAL_LIBS} ${INSTALLDIR}/