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.
38 for FILE in $FILES ; do
41 # extract the .o files from this .a archive
44 *) FILE="$ORIG_DIR/$FILE" ;;
48 for MEMBER in $MEMBERS ; do
49 NEWFILES="$NEWFILES $DIR/$MEMBER"
53 # other file type, just add to list
54 NEWFILES="$NEWFILES $FILE"
63 # Given a list of files, look for .a archives and return a list of all objects
65 contents_of_archives() {
68 for FILE in $FILES ; do
71 # get list of members in this .a archive
73 NEWFILES="$NEWFILES $MEMBERS"
76 # skip other file types
84 # Make static library with 'ar'
87 # 1 or 0 to indicate if ranlib should be run
89 # list of object files
90 # Return name of library we made
91 # Example: "make_ar_static_lib -ru 1 libfoo.a foo.o bar.o"
92 make_ar_static_lib() {
101 # remove existing lib, if present
105 ar ${OPTS} ${LIBNAME} ${OBJECTS}
108 if [ ${RANLIB} = 1 ] ; then
118 echo 'Usage: mklib [options] objects'
119 echo 'Create a shared library from object files.'
120 echo ' -o LIBRARY specifies the name of the resulting library, without'
121 echo ' the leading "lib" or any suffix.'
122 echo ' (eg: "-o GL" might result in "libGL.so" being made)'
123 echo ' -major N specifies major version number (default is 1)'
124 echo ' -minor N specifies minor version number (default is 0)'
125 echo ' -patch N specifies patch version number (default is 0)'
126 echo ' -lLIBRARY specifies a dependency on LIBRARY'
127 echo ' -LDIR search in DIR for library dependencies at build time'
128 echo ' -RDIR search in DIR for library dependencies at run time'
129 echo ' -linker L explicity specify the linker program to use (eg: gcc, g++)'
130 echo ' Not observed on all systems at this time.'
131 echo ' -ldflags OPT specify any additional linker flags in OPT'
132 echo ' -cplusplus link with C++ runtime'
133 echo ' -static make a static library (default is dynamic/shared)'
134 echo ' -dlopen make a shared library suitable for dynamic loading'
135 echo ' -install DIR put resulting library file(s) in DIR'
136 echo ' -arch ARCH override using `uname` to determine host system'
137 echo ' -archopt OPT specify an extra achitecture-specific option OPT'
138 echo ' -altopts OPTS alternate options to override all others'
139 echo " -noprefix don't prefix library name with 'lib' nor add any suffix"
140 echo ' -exports FILE only export the symbols listed in FILE'
141 echo ' -id NAME Sets the id of the dylib (Darwin)'
142 echo ' -h, --help display this information and exit'
213 # this is a special case (see bugzilla 10876)
217 DEPS="$DEPS -pthread"
256 echo "mklib: Unknown option: " $1 ;
260 # This should be the first object file, stop parsing
268 if [ ${ARCH} = "auto" ] ; then
273 if [ $STATIC = 1 ]; then
274 # filter out linker options inside object list
276 for OBJ in $OBJECTS ; do
279 echo "mklib: warning: ignoring $OBJ for static library"
282 NEWOBJECTS="$NEWOBJECTS $OBJ"
293 if [ "x${LIBNAME}" = "x" ] ; then
294 echo "mklib: Error: no library name specified (-h for help)"
297 if [ "x${OBJECTS}" = "x" ] ; then
298 echo "mklib: Error: no object files specified (-h for help)"
307 echo "-----------------"
309 echo LIBNAME is $LIBNAME
314 echo "EXPORTS in" $EXPORTS
316 echo "-----------------"
321 # OK, make the library now
325 'Linux' | 'OpenBSD' | 'DragonFly' | 'GNU' | GNU/*)
328 if [ "x$LINK" = "x" ] ; then
329 # -linker was not specified so set default link command now
330 if [ $CPLUSPLUS = 1 ] ; then
337 if [ $NOPREFIX = 1 ] ; then
338 # No "lib" or ".so" part
339 echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}
340 case $ARCH in 'Linux' | 'GNU' | GNU/*)
341 OPTS="-Xlinker -Bsymbolic -shared"
348 # Check if objects are 32-bit and we're running in 64-bit
349 # environment. If so, pass -m32 flag to linker.
351 ABI32=`file $1 | grep 32-bit`
352 if [ "${ABI32}" -a `uname -m` = "x86_64" ] ; then
356 if [ "${ALTOPTS}" ] ; then
362 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
364 FINAL_LIBS="${LIBNAME}"
365 elif [ $STATIC = 1 ] ; then
366 # make a static .a library
367 LIBNAME="lib${LIBNAME}.a" # prefix with "lib", suffix with ".a"
368 echo "mklib: Making" $ARCH "static library: " ${LIBNAME}
370 if [ "${ALTOPTS}" ] ; then
374 # expand .a into .o files
375 NEW_OBJECTS=`expand_archives ${LIBNAME}.obj $OBJECTS`
378 FINAL_LIBS=`make_ar_static_lib ${OPTS} 1 ${LIBNAME} ${NEW_OBJECTS}`
380 # remove temporary extracted .o files
381 rm -rf ${LIBNAME}.obj
383 # make dynamic library
384 LIBNAME="lib${LIBNAME}" # prefix with "lib"
385 case $ARCH in 'Linux' | 'GNU' | GNU/*)
386 OPTS="-Xlinker -Bsymbolic -shared -Wl,-soname,${LIBNAME}.so.${MAJOR}"
389 OPTS="-shared -Wl,-soname,${LIBNAME}.so.${MAJOR}"
392 if [ $EXPORTS ] ; then
393 #OPTS="${OPTS} -Xlinker --retain-symbols-file ${EXPORTS}"
394 # Make the 'exptmp' file for --version-script option
396 echo "global:" >> exptmp
397 sed 's/$/;/' ${EXPORTS} >> exptmp
398 echo "local:" >> exptmp
401 OPTS="${OPTS} -Xlinker --version-script=exptmp"
402 # exptmp is removed below
405 # Check if objects are 32-bit and we're running in 64-bit
406 # environment. If so, pass -m32 flag to linker.
408 ABI32=`file $1 | grep 32-bit`
409 if [ "${ABI32}" -a `uname -m` = "x86_64" ] ; then
412 if [ "${ALTOPTS}" ] ; then
416 if [ x${PATCH} = "x" ] ; then
417 VERSION="${MAJOR}.${MINOR}"
419 VERSION="${MAJOR}.${MINOR}.${PATCH}"
422 echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}.so.${VERSION}
425 rm -f ${LIBNAME}.so.${VERSION}
426 rm -f ${LIBNAME}.so.${MAJOR}
430 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
431 # make usual symlinks
432 ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR}
433 ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
435 FINAL_LIBS="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so"
441 if [ $STATIC = 1 ] ; then
442 LIBNAME="lib${LIBNAME}.a"
443 echo "mklib: Making SunOS static library: " ${LIBNAME}
444 FINAL_LIBS=`make_ar_static_lib -ruv 0 ${LIBNAME} ${OBJECTS}`
446 if [ $NOPREFIX = 0 ] ; then
447 LIBNAME="lib${LIBNAME}.so"
449 echo "mklib: Making SunOS shared library: " ${LIBNAME}
451 if [ "x$LINK" = "x" ] ; then
452 # -linker was not specified, choose default linker now
453 if [ $CPLUSPLUS = 1 ] ; then
454 # determine linker and options for C++ code
455 if [ `which c++` ] ; then
458 elif [ `type g++` ] ; then
462 echo "mklib: warning: can't find C++ compiler, trying CC."
466 # use native Sun linker for C code
472 if [ ${LINK} = "ld" -o ${LINK} = "cc" -o ${LINK} = "CC" ] ; then
473 # SunOS tools, -G to make shared libs
477 # Check if objects are 32-bit and we're running in 64-bit
478 # environment. If so, pass -m32 flag to linker.
480 ABI32=`file $1 | grep 32-bit`
481 if [ "${ABI32}" ] ; then
482 OPTS="-m32 -shared -Wl,-Bdynamic"
484 OPTS="-m64 -shared -Wl,-Bdynamic"
488 # If using Sun C++ compiler, need to tell it not to add runpaths
489 # that are specific to the build machine
490 if [ ${LINK} = "CC" ] ; then
491 OPTS="${OPTS} -norunpath"
494 # Solaris linker requires explicitly listing the Standard C & C++
495 # libraries in the link path when building shared objects
496 if [ ${LINK} = "CC" ] ; then
497 DEPS="${DEPS} -lCrun"
501 if [ $EXPORTS ] ; then
502 # Make the 'mapfile.scope' linker mapfile
503 echo "{" > mapfile.scope
504 echo "global:" >> mapfile.scope
505 sed 's/$/;/' ${EXPORTS} >> mapfile.scope
506 echo "local:" >> mapfile.scope
507 echo " *;" >> mapfile.scope
508 echo "};" >> mapfile.scope
509 OPTS="${OPTS} -Wl,-Mmapfile.scope"
512 # Check if objects are SPARC v9
513 # file says: ELF 64-bit MSB relocatable SPARCV9 Version 1
515 if [ ${LINK} = "cc" -o ${LINK} = "CC" ] ; then
516 SPARCV9=`file $1 | grep SPARCV9`
517 if [ "${SPARCV9}" ] ; then
518 OPTS="${OPTS} -xarch=v9"
521 if [ "${ALTOPTS}" ] ; then
526 #echo "mklib: linker is" ${LINK} ${OPTS}
527 if [ $NOPREFIX = 1 ] ; then
529 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
530 FINAL_LIBS="${LIBNAME}"
532 rm -f ${LIBNAME}.${MAJOR} ${LIBNAME}
533 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.${MAJOR} -h ${LIBNAME}.${MAJOR} ${OBJECTS} ${DEPS}
534 ln -s ${LIBNAME}.${MAJOR} ${LIBNAME}
535 FINAL_LIBS="${LIBNAME}.${MAJOR} ${LIBNAME}"
543 if [ "x$LINK" = "x" ] ; then
544 # -linker was not specified so set default link command now
545 if [ $CPLUSPLUS = 1 ] ; then
552 if [ $NOPREFIX = 1 ] ; then
553 # No "lib" or ".so" part
554 echo "mklib: Making FreeBSD shared library: " ${LIBNAME}
556 if [ "${ALTOPTS}" ] ; then
560 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
561 FINAL_LIBS=${LIBNAME}
562 elif [ $STATIC = 1 ] ; then
563 # make a static .a library
564 STLIB="lib${LIBNAME}.a"
565 echo "mklib: Making FreeBSD static library: " ${STLIB}
567 # expand .a into .o files
568 NEW_OBJECTS=`expand_archives ${STLIB}.obj $OBJECTS`
570 FINAL_LIBS=`make_ar_static_lib cq 1 ${STLIB} ${NEW_OBJECTS}`
572 # remove temporary extracted .o files
575 # make dynamic library
576 SHLIB="lib${LIBNAME}.so.${MAJOR}"
577 OPTS="-shared -Wl,-soname,${SHLIB}"
578 if [ "${ALTOPTS}" ] ; then
581 echo "mklib: Making FreeBSD shared library: " ${SHLIB}
583 ${LINK} ${OPTS} ${LDFLAGS} -o ${SHLIB} ${OBJECTS} ${DEPS}
584 ln -sf ${SHLIB} "lib${LIBNAME}.so"
585 FINAL_LIBS="${SHLIB} lib${LIBNAME}.so"
590 if [ $STATIC = 1 ] ; then
591 LIBNAME="lib${LIBNAME}_pic.a"
592 echo "mklib: Making NetBSD PIC static library: " ${LIBNAME}
593 FINAL_LIBS=`make_ar_static_lib cq 1 ${LIBNAME} ${OBJECTS}`
595 LIBNAME="lib${LIBNAME}.so.${MAJOR}.${MINOR}"
596 echo "mklib: Making NetBSD PIC shared library: " ${LIBNAME}
598 ld -x -Bshareable -Bforcearchive -o ${LIBNAME} ${OBJECTS}
599 FINAL_LIBS=${LIBNAME}
604 if [ $STATIC = 1 ] ; then
605 LIBNAME="lib${LIBNAME}.a"
606 FINAL_LIBS=`make_ar_static_lib rc 0 ${LIBNAME} ${OBJECTS}`
608 LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
610 # examine first object to determine ABI
612 ABI_O32=`file $1 | grep 'ELF 32-bit'`
613 ABI_N32=`file $1 | grep 'ELF N32'`
614 ABI_N64=`file $1 | grep 'ELF 64-bit'`
615 if [ "${ABI_O32}" ] ; then
616 OPTS="-32 -shared -all"
618 elif [ "${ABI_N32}" ] ; then
619 OPTS="-n32 -shared -all"
621 elif [ "${ABI_N64}" ] ; then
622 OPTS="-64 -shared -all"
625 echo "Error: Unexpected IRIX ABI!"
629 if [ "${ALTOPTS}" ] ; then
633 if [ $CPLUSPLUS = 1 ] ; then
639 echo "mklib: Making IRIX " ${ABI} " shared library: " ${LIBNAME}
640 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
641 FINAL_LIBS=${LIBNAME}
646 LIBNAME="lib${LIBNAME}.a"
647 echo "mklib: Making linux-cygwin library: " ${LIBNAME}
649 gnuwin32ar ruv ${LIBNAME} ${OBJECTS}
650 FINAL_LIBS=${LIBNAME}
654 if [ $STATIC = 1 ] ; then
655 LIBNAME="lib${LIBNAME}.a"
656 echo "mklib: Making HP-UX static library: " ${LIBNAME}
657 FINAL_LIBS=`make_ar_static_lib -ruv 0 ${LIBNAME} ${OBJECTS}`
659 # HP uses a .2 for their current GL/GLU libraries
660 if [ ${LIBNAME} = "GL" -o ${LIBNAME} = "GLU" ] ; then
663 RUNLIB="lib${LIBNAME}.${MAJOR}"
664 DEVLIB="lib${LIBNAME}.sl"
665 echo "mklib: Making HP-UX shared library: " ${RUNLIB} ${DEVLIB}
666 ld -b -o ${RUNLIB} +b ${RUNLIB} ${OBJECTS} ${DEPS}
667 ln -s ${RUNLIB} ${DEVLIB}
668 FINAL_LIBS="${RUNLIB} ${DEVLIB}"
673 # examine first object to determine ABI
675 ABI_64=`file $1 | grep '64-bit'`
676 if [ "${ABI_64}" ] ; then
681 OFILE=shr.o #Want to be consistent with the IBM libGL.a
684 if [ $STATIC = 1 ] ; then
685 LIBNAME="lib${LIBNAME}.a"
686 echo "mklib: Making AIX static library: " ${LIBNAME}
687 FINAL_LIBS=`make_ar_static_lib -ruv 0 ${LIBNAME} ${OBJECTS}`
689 EXPFILE="lib${LIBNAME}.exp"
690 LIBNAME="lib${LIBNAME}.a" # shared objects are still stored in the .a libraries
691 OPTS="-bE:${EXPFILE} -bM:SRE -bnoentry ${Q64}"
692 rm -f ${EXPFILE} ${OFILE}
693 NM="/bin/nm -eC ${X64}"
694 echo "#! /usr/lib/${LIBNAME}" > ${EXPFILE}
695 ${NM} ${OBJECTS} | awk '{
696 if ((($2 == "T") || ($2 == "D") || ($2 == "B")) \
697 && ( substr($1,1,1) != ".")) {
698 if (substr ($1, 1, 7) != "__sinit" &&
699 substr ($1, 1, 7) != "__sterm") {
700 if (substr ($1, 1, 5) == "__tf1")
701 print (substr ($1, 7))
702 else if (substr ($1, 1, 5) == "__tf9")
703 print (substr ($1, 15))
708 }' | sort -u >> ${EXPFILE}
710 if [ "${ALTOPTS}" ] ; then
714 # On AIX a shared library is linked differently when
715 # you want to dlopen the file
716 if [ $DLOPEN = "1" ] ; then
717 cc -G ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
719 cc ${OPTS} ${LDFLAGS} -o ${OFILE} ${OBJECTS} ${DEPS}
720 ar ${X64} -r ${LIBNAME} ${OFILE}
723 FINAL_LIBS="${LIBNAME}"
728 LIBNAME="lib${LIBNAME}.a"
729 echo "mklib: Making OpenSTEP static library: " ${LIBNAME}
730 libtool -static -o ${LIBNAME} - ${OBJECTS}
731 FINAL_LIBS=${LIBNAME}
735 if [ $STATIC = 1 ] ; then
736 LIBNAME="lib${LIBNAME}.a"
737 echo "mklib: Making OSF/1 static library: " ${LIBNAME}
738 FINAL_LIBS=`make_ar_static_lib -ruv 0 ${LIBNAME} ${OBJECTS}`
740 VERSION="${MAJOR}.${MINOR}"
741 LIBNAME="lib${LIBNAME}.so"
742 echo "mklib: Making OSF/1 shared library: " ${LIBNAME}
743 if [ "x$LINK" = "x" ] ; then
744 if [ $CPLUSPLUS = 1 ] ; then
750 rm -f ${LIBNAME}.${VERSION}
751 ${LINK} -o ${LIBNAME}.${VERSION} -shared -set_version ${VERSION} -soname ${LIBNAME}.${VERSION} -expect_unresolved \* -all ${OBJECTS} ${DEPS}
752 ln -sf ${LIBNAME}.${VERSION} ${LIBNAME}
753 FINAL_LIBS="${LIBNAME} ${LIBNAME}.${VERSION}"
758 if [ $STATIC = 1 ] ; then
759 LIBNAME="lib${LIBNAME}.a"
760 echo "mklib: Making Darwin static library: " ${LIBNAME}
763 if [ "${ALTOPTS}" ] ; then
766 ${LINK} ${OPTS} ${LIBNAME} ${OBJECTS}
767 FINAL_LIBS=${LIBNAME}
769 # On Darwin a .bundle is used for a library that you want to dlopen
770 if [ $DLOPEN = "1" ] ; then
772 OPTS="${ARCHOPT} -bundle -multiply_defined suppress"
775 if [ -z "$ID" ] ; then
776 ID="lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}"
778 OPTS="${ARCHOPT} -dynamiclib -multiply_defined suppress -current_version ${MAJOR}.${MINOR}.0 -compatibility_version ${MAJOR}.${MINOR}.0 -install_name ${ID}"
781 if [ ${EXPORTS} ] ; then
782 if [ -f ${EXPORTS}".darwin" ] ; then
783 EXPORTS=$EXPORTS".darwin"
785 OPTS="${OPTS} -exported_symbols_list ${EXPORTS}"
788 LINKNAME="lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}"
789 LINKNAME2="lib${LIBNAME}.${LIBSUFFIX}"
790 LIBNAME="lib${LIBNAME}.${MAJOR}.${MINOR}.${LIBSUFFIX}"
792 # examine first object to determine ABI
794 ABIS=`lipo -info $1 | sed s/.*://`
796 OPTS="${OPTS} -arch ${ABI}"
799 if [ "${ALTOPTS}" ] ; then
803 # XXX can we always add -isysroot /Developer/SDKs/MacOSX10.4u.sdk
807 if [ $CPLUSPLUS = 1 ] ; then
813 echo "mklib: Making Darwin shared library: " ${LIBNAME}
815 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
816 ln -s ${LIBNAME} ${LINKNAME}
817 ln -s ${LIBNAME} ${LINKNAME2}
818 FINAL_LIBS="${LIBNAME} ${LINKNAME} ${LINKNAME2}"
823 LIBNAME="lib${LIBNAME}.a"
824 echo "mklib: Making LynxOS static library: " ${LIBNAME}
825 FINAL_LIBS=`make_ar_static_lib -ru 0 ${LIBNAME} ${OBJECTS}`
829 if [ $STATIC = 1 ] ; then
830 LIBNAME="lib${LIBNAME}.a"
831 echo "mklib: Making BeOS static library: " ${LIBNAME}
832 FINAL_LIBS=`make_ar_static_lib -cru 0 ${LIBNAME} ${OBJECTS}`
834 LIBNAME="lib${LIBNAME}.so"
835 echo "mklib: Making BeOS shared library: " ${LIBNAME}
836 gcc -nostart -Xlinker "-soname=${LIBNAME}" -L/Be/develop/lib/x86 -lbe ${DEPS} ${OBJECTS} -o "${LIBNAME}"
837 mimeset -f "${LIBNAME}"
838 # XXX remove the Mesa3D stuff here since mklib isn't mesa-specific.
839 setversion "${LIBNAME}" -app ${MAJOR} ${MINOR} ${PATCH} -short "Powered by Mesa3D!" -long "Powered by Mesa3D!"
841 FINAL_LIBS=${LIBNAME}
845 LIBNAME="lib${LIBNAME}.a"
846 echo "mklib: Making QNX library: " ${LIBNAME}
847 wlib ${LIBNAME} ${OBJECTS}
848 FINAL_LIBS=${LIBNAME}
852 LIBNAME="lib${LIBNAME}.a"
853 echo "mklib: Making MorphOS library: " ${LIBNAME}
854 ppc-morphos-ar rc ${LIBNAME} ${OBJECTS}
855 FINAL_LIBS="${LIBNAME}"
858 'icc' | 'icc-istatic')
860 # This should get merged into the Linux code, above, since this isn't
861 # really a different architecture.
862 LIBNAME="lib${LIBNAME}" # prefix with "lib"
864 if [ $STATIC = 1 ] ; then
865 echo "mklib: Making Intel ICC static library: " ${LIBNAME}.a
868 if [ "${ALTOPTS}" ] ; then
872 ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
874 FINAL_LIBS="${LIBNAME}.a"
876 if [ $ARCH = icc-istatic ] ; then
877 OPTS="-shared -i-static -cxxlib-icc"
881 if [ "${ALTOPTS}" ] ; then
884 VERSION="${MAJOR}.${MINOR}.${PATCH}"
885 echo "mklib: Making Intel ICC shared library: " ${LIBNAME}.so.${VERSION}
887 if [ $CPLUSPLUS = 1 ] ; then
893 rm -f ${LIBNAME}.so.${VERSION}
894 rm -f ${LIBNAME}.so.${MAJOR}
897 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
898 # make usual symlinks
899 ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR}
900 ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
902 FINAL_LIBS="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so"
908 if [ $STATIC = 1 ] ; then
909 LIBNAME="lib${LIBNAME}.a"
910 echo "mklib: Making AIX GCC static library: " ${LIBNAME}
911 FINAL_LIBS=`make_ar_static_lib ru 0 ${LIBNAME} ${OBJECTS}`
913 LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
914 echo "mklib: Making AIX GCC shared library: " ${LIBNAME}
918 gcc -shared -Wl,-G ${OBJECTS} ${DEPS} -o ${LIBNAME}
919 # NOTE: the application linking with this library must specify
920 # the -Wl,-brtl flags to gcc
921 FINAL_LIBS=${LIBNAME}
927 if [ $STATIC = 0 ] ; then
928 echo "mklib: Warning shared libs not supported on Ultrix"
930 LIBNAME="lib${LIBNAME}.a"
931 echo "mklib: Making static library for Ultrix: " ${LIBNAME}
932 FINAL_LIBS=`make_ar_static_lib ru 0 ${LIBNAME} ${OBJECTS}`
936 # GCC-based environment
937 if [ $NOPREFIX = 1 ] ; then
938 # No "lib" or ".so" part
939 echo "mklib: Making CYGWIN shared library: " ${LIBNAME}
940 OPTS="-shared -Wl,--enable-auto-image-base"
941 if [ "${ALTOPTS}" ] ; then
945 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
946 FINAL_LIBS=${LIBNAME}
948 CYGNAME="cyg${LIBNAME}" # prefix with "cyg"
949 LIBNAME="lib${LIBNAME}" # prefix with "lib"
951 if [ $STATIC = 1 ] ; then
953 echo "mklib: Making" $ARCH "static library: " ${LIBNAME}
955 if [ "${ALTOPTS}" ] ; then
958 FINAL_LIBS=`make_ar_static_lib ${OPTS} 1 ${LIBNAME} ${OBJECTS}`
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 usual symlinks
981 ln -s ${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a
983 FINAL_LIBS="${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a"
984 # special case for installing in bin
985 FINAL_BINS="${CYGNAME}-${MAJOR}.dll"
991 # If you're adding support for a new architecture, you can
993 if [ $STATIC = 1 ] ; then
994 LIBNAME="lib${LIBNAME}.a"
995 echo "mklib: Making static library for example arch: " ${LIBNAME}
996 FINAL_LIBS=`make_ar_static_lib rv 0 ${LIBNAME} ${OBJECTS}`
998 LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
999 echo "mklib: Making shared library for example arch: " ${LIBNAME}
1000 ld -o ${LIBNAME} ${OBJECTS} ${DEPS}
1001 FINAL_LIBS="${LIBNAME}"
1006 echo "mklib: ERROR: Don't know how to make a static/shared library for" ${ARCH}
1007 echo "mklib: Please add necessary commands to mklib script."
1013 # Put library files into installation directory if specified.
1015 if [ ${INSTALLDIR} != "." ] ; then
1016 echo "mklib: Installing" ${FINAL_LIBS} "in" ${INSTALLDIR}
1017 test -d ${INSTALLDIR} || mkdir -p ${INSTALLDIR}
1018 mv ${FINAL_LIBS} ${INSTALLDIR}/