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
/* |
'NetBSD')
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 ARM
=`file $1 | grep ARM`
338 # Do not add "-m32" option for arm.
339 if [ -z "$ARM" -a "${ABI32}" -a `uname -m` = "x86_64" ] ; then
343 if [ "${ALTOPTS}" ] ; then
349 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
351 FINAL_LIBS
="${LIBNAME}"
352 elif [ $STATIC = 1 ] ; then
353 # make a static .a library
354 LIBNAME
="lib${LIBNAME}.a" # prefix with "lib", suffix with ".a"
355 echo "mklib: Making" $ARCH "static library: " ${LIBNAME}
357 if [ "${ALTOPTS}" ] ; then
361 # expand .a into .o files
362 NEW_OBJECTS
=`expand_archives ${LIBNAME}.obj $OBJECTS`
365 FINAL_LIBS
=`make_ar_static_lib ${OPTS} 1 ${LIBNAME} ${NEW_OBJECTS}`
367 # remove temporary extracted .o files
368 rm -rf ${LIBNAME}.obj
370 # make dynamic library
371 LIBNAME
="lib${LIBNAME}" # prefix with "lib"
372 case $ARCH in 'Linux' |
'GNU' | GNU
/*)
373 OPTS
="-Xlinker -Bsymbolic -shared -Wl,-soname,${LIBNAME}.so.${MAJOR}"
376 OPTS
="-shared -Wl,-soname,${LIBNAME}.so.${MAJOR}"
379 if [ $EXPORTS ] ; then
380 #OPTS="${OPTS} -Xlinker --retain-symbols-file ${EXPORTS}"
381 # Make the 'exptmp' file for --version-script option
383 echo "global:" >> exptmp
384 sed 's/$/;/' ${EXPORTS} >> exptmp
385 echo "local:" >> exptmp
388 OPTS
="${OPTS} -Xlinker --version-script=exptmp"
389 # exptmp is removed below
392 # Check if objects are 32-bit and we're running in 64-bit
393 # environment. If so, pass -m32 flag to linker.
395 ABI32
=`file $1 | grep 32-bit`
396 ARM
=`file $1 | grep ARM`
397 # Do not add "-m32" option for arm.
398 if [ -z "$ARM" -a "${ABI32}" -a `uname -m` = "x86_64" ] ; then
401 if [ "${ALTOPTS}" ] ; then
405 if [ x
${PATCH} = "x" ] ; then
406 VERSION
="${MAJOR}.${MINOR}"
408 VERSION
="${MAJOR}.${MINOR}.${PATCH}"
411 echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}.so.
${VERSION}
414 rm -f ${LIBNAME}.so.
${VERSION}
415 rm -f ${LIBNAME}.so.
${MAJOR}
419 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
420 # make usual symlinks
421 ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR}
422 ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
424 FINAL_LIBS
="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so"
430 if [ $STATIC = 1 ] ; then
431 LIBNAME
="lib${LIBNAME}.a"
432 echo "mklib: Making SunOS static library: " ${LIBNAME}
433 FINAL_LIBS
=`make_ar_static_lib -ruc 0 ${LIBNAME} ${OBJECTS}`
435 if [ $NOPREFIX = 0 ] ; then
436 LIBNAME
="lib${LIBNAME}.so"
438 echo "mklib: Making SunOS shared library: " ${LIBNAME}
440 if [ "x$LINK" = "x" ] ; then
441 # -linker was not specified, choose default linker now
442 if [ $CPLUSPLUS = 1 ] ; then
443 # determine linker and options for C++ code
444 if [ `which c++` ] ; then
447 elif [ `type g++` ] ; then
451 echo "mklib: warning: can't find C++ compiler, trying CC."
455 # use native Sun linker for C code
461 if [ ${LINK} = "ld" -o ${LINK} = "cc" -o ${LINK} = "CC" ] ; then
462 # SunOS tools, -G to make shared libs
466 # Check if objects are 32-bit and we're running in 64-bit
467 # environment. If so, pass -m32 flag to linker.
469 ABI32
=`file $1 | grep 32-bit`
470 if [ "${ABI32}" ] ; then
471 OPTS
="-m32 -shared -Wl,-Bdynamic"
473 OPTS
="-m64 -shared -Wl,-Bdynamic"
477 # If using Sun C++ compiler, need to tell it not to add runpaths
478 # that are specific to the build machine
479 if [ ${LINK} = "CC" ] ; then
480 OPTS
="${OPTS} -norunpath"
483 # Solaris linker requires explicitly listing the Standard C & C++
484 # libraries in the link path when building shared objects
485 if [ ${LINK} = "CC" ] ; then
486 DEPS
="${DEPS} -lCrun"
490 if [ $EXPORTS ] ; then
491 # Make the 'mapfile.scope' linker mapfile
492 echo "{" > mapfile.scope
493 echo "global:" >> mapfile.scope
494 sed 's/$/;/' ${EXPORTS} >> mapfile.scope
495 echo "local:" >> mapfile.scope
496 echo " *;" >> mapfile.scope
497 echo "};" >> mapfile.scope
498 OPTS
="${OPTS} -Wl,-Mmapfile.scope"
501 # Check if objects are 64-bit
502 # file says: ELF 64-bit MSB relocatable SPARCV9 Version 1
504 if [ ${LINK} = "cc" -o ${LINK} = "CC" ] ; then
505 ABI64
=`file $1 | grep "ELF 64-bit"`
506 if [ "${ABI64}" ] ; then
508 sparc
) OPTS
="${OPTS} -xarch=v9" ;;
509 i386
) OPTS
="${OPTS} -xarch=amd64" ;;
513 if [ "${ALTOPTS}" ] ; then
518 #echo "mklib: linker is" ${LINK} ${OPTS}
519 if [ $NOPREFIX = 1 ] ; then
521 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
522 FINAL_LIBS
="${LIBNAME}"
524 rm -f ${LIBNAME}.${MAJOR} ${LIBNAME}
525 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.${MAJOR} -h ${LIBNAME}.${MAJOR} ${OBJECTS} ${DEPS}
526 ln -s ${LIBNAME}.${MAJOR} ${LIBNAME}
527 FINAL_LIBS
="${LIBNAME}.${MAJOR} ${LIBNAME}"
535 if [ "x$LINK" = "x" ] ; then
536 # -linker was not specified so set default link command now
537 if [ $CPLUSPLUS = 1 ] ; then
544 if [ $NOPREFIX = 1 ] ; then
545 # No "lib" or ".so" part
546 echo "mklib: Making FreeBSD shared library: " ${LIBNAME}
548 if [ "${ALTOPTS}" ] ; then
552 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
553 FINAL_LIBS
=${LIBNAME}
554 elif [ $STATIC = 1 ] ; then
555 # make a static .a library
556 STLIB
="lib${LIBNAME}.a"
557 echo "mklib: Making FreeBSD static library: " ${STLIB}
559 # expand .a into .o files
560 NEW_OBJECTS
=`expand_archives ${STLIB}.obj $OBJECTS`
562 FINAL_LIBS
=`make_ar_static_lib cq 1 ${STLIB} ${NEW_OBJECTS}`
564 # remove temporary extracted .o files
567 # make dynamic library
568 SHLIB
="lib${LIBNAME}.so.${MAJOR}"
569 OPTS
="-shared -Wl,-soname,${SHLIB}"
570 if [ "${ALTOPTS}" ] ; then
573 echo "mklib: Making FreeBSD shared library: " ${SHLIB}
575 ${LINK} ${OPTS} ${LDFLAGS} -o ${SHLIB} ${OBJECTS} ${DEPS}
576 ln -sf ${SHLIB} "lib${LIBNAME}.so"
577 FINAL_LIBS
="${SHLIB} lib${LIBNAME}.so"
582 if [ $STATIC = 1 ] ; then
583 LIBNAME
="lib${LIBNAME}.a"
584 FINAL_LIBS
=`make_ar_static_lib rc 0 ${LIBNAME} ${OBJECTS}`
586 LIBNAME
="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
588 # examine first object to determine ABI
590 ABI_O32
=`file $1 | grep 'ELF 32-bit'`
591 ABI_N32
=`file $1 | grep 'ELF N32'`
592 ABI_N64
=`file $1 | grep 'ELF 64-bit'`
593 if [ "${ABI_O32}" ] ; then
594 OPTS
="-32 -shared -all"
596 elif [ "${ABI_N32}" ] ; then
597 OPTS
="-n32 -shared -all"
599 elif [ "${ABI_N64}" ] ; then
600 OPTS
="-64 -shared -all"
603 echo "Error: Unexpected IRIX ABI!"
607 if [ "${ALTOPTS}" ] ; then
611 if [ $CPLUSPLUS = 1 ] ; then
617 echo "mklib: Making IRIX " ${ABI} " shared library: " ${LIBNAME}
618 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
619 FINAL_LIBS
=${LIBNAME}
624 LIBNAME
="lib${LIBNAME}.a"
625 echo "mklib: Making linux-cygwin library: " ${LIBNAME}
627 gnuwin32ar ruv
${LIBNAME} ${OBJECTS}
628 FINAL_LIBS
=${LIBNAME}
632 if [ $STATIC = 1 ] ; then
633 LIBNAME
="lib${LIBNAME}.a"
634 echo "mklib: Making HP-UX static library: " ${LIBNAME}
635 FINAL_LIBS
=`make_ar_static_lib -ruv 0 ${LIBNAME} ${OBJECTS}`
637 # HP uses a .2 for their current GL/GLU libraries
638 if [ ${LIBNAME} = "GL" -o ${LIBNAME} = "GLU" ] ; then
641 RUNLIB
="lib${LIBNAME}.${MAJOR}"
642 DEVLIB
="lib${LIBNAME}.sl"
643 echo "mklib: Making HP-UX shared library: " ${RUNLIB} ${DEVLIB}
644 ld
-b -o ${RUNLIB} +b ${RUNLIB} ${OBJECTS} ${DEPS}
645 ln -s ${RUNLIB} ${DEVLIB}
646 FINAL_LIBS
="${RUNLIB} ${DEVLIB}"
651 # examine first object to determine ABI
653 ABI_64
=`file $1 | grep '64-bit'`
654 if [ "${ABI_64}" ] ; then
659 OFILE
=shr.o
#Want to be consistent with the IBM libGL.a
662 if [ $STATIC = 1 ] ; then
663 LIBNAME
="lib${LIBNAME}.a"
664 echo "mklib: Making AIX static library: " ${LIBNAME}
665 FINAL_LIBS
=`make_ar_static_lib -ruv 0 ${LIBNAME} ${OBJECTS}`
667 EXPFILE
="lib${LIBNAME}.exp"
668 LIBNAME
="lib${LIBNAME}.a" # shared objects are still stored in the .a libraries
669 OPTS
="-bE:${EXPFILE} -bM:SRE -bnoentry ${Q64}"
670 rm -f ${EXPFILE} ${OFILE}
671 NM
="/bin/nm -eC ${X64}"
672 echo "#! /usr/lib/${LIBNAME}" > ${EXPFILE}
673 ${NM} ${OBJECTS} |
awk '{
674 if ((($2 == "T") || ($2 == "D") || ($2 == "B")) \
675 && ( substr($1,1,1) != ".")) {
676 if (substr ($1, 1, 7) != "__sinit" &&
677 substr ($1, 1, 7) != "__sterm") {
678 if (substr ($1, 1, 5) == "__tf1")
679 print (substr ($1, 7))
680 else if (substr ($1, 1, 5) == "__tf9")
681 print (substr ($1, 15))
686 }' |
sort -u >> ${EXPFILE}
688 if [ "${ALTOPTS}" ] ; then
692 # On AIX a shared library is linked differently when
693 # you want to dlopen the file
694 if [ $DLOPEN = "1" ] ; then
695 cc
-G ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
697 cc
${OPTS} ${LDFLAGS} -o ${OFILE} ${OBJECTS} ${DEPS}
698 ar ${X64} -r ${LIBNAME} ${OFILE}
701 FINAL_LIBS
="${LIBNAME}"
706 LIBNAME
="lib${LIBNAME}.a"
707 echo "mklib: Making OpenSTEP static library: " ${LIBNAME}
708 libtool
-static -o ${LIBNAME} - ${OBJECTS}
709 FINAL_LIBS
=${LIBNAME}
713 if [ $STATIC = 1 ] ; then
714 LIBNAME
="lib${LIBNAME}.a"
715 echo "mklib: Making OSF/1 static library: " ${LIBNAME}
716 FINAL_LIBS
=`make_ar_static_lib -ruv 0 ${LIBNAME} ${OBJECTS}`
718 VERSION
="${MAJOR}.${MINOR}"
719 LIBNAME
="lib${LIBNAME}.so"
720 echo "mklib: Making OSF/1 shared library: " ${LIBNAME}
721 if [ "x$LINK" = "x" ] ; then
722 if [ $CPLUSPLUS = 1 ] ; then
728 rm -f ${LIBNAME}.
${VERSION}
729 ${LINK} -o ${LIBNAME}.${VERSION} -shared -set_version ${VERSION} -soname ${LIBNAME}.${VERSION} -expect_unresolved \* -all ${OBJECTS} ${DEPS}
730 ln -sf ${LIBNAME}.${VERSION} ${LIBNAME}
731 FINAL_LIBS
="${LIBNAME} ${LIBNAME}.${VERSION}"
736 if [ $STATIC = 1 ] ; then
737 LIBNAME
="lib${LIBNAME}.a"
738 echo "mklib: Making Darwin static library: " ${LIBNAME}
740 if [ "${ALTOPTS}" ] ; then
744 # expand .a into .o files
745 NEW_OBJECTS
=`expand_archives ${LIBNAME}.obj $OBJECTS`
748 FINAL_LIBS
=`make_ar_static_lib ${OPTS} 1 ${LIBNAME} ${NEW_OBJECTS}`
750 # remove temporary extracted .o files
751 rm -rf ${LIBNAME}.obj
753 FINAL_LIBS
=${LIBNAME}
755 # On Darwin a .bundle is used for a library that you want to dlopen
756 if [ $DLOPEN = "1" ] ; then
758 OPTS
="${ARCHOPT} -bundle -multiply_defined suppress"
761 if [ -z "$ID" ] ; then
762 ID
="lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}"
764 OPTS
="${ARCHOPT} -dynamiclib -multiply_defined suppress -current_version ${MAJOR}.${MINOR}.0 -compatibility_version ${MAJOR}.${MINOR}.0 -install_name ${ID}"
767 if [ ${EXPORTS} ] ; then
768 if [ -f ${EXPORTS}".darwin" ] ; then
769 EXPORTS
=$EXPORTS".darwin"
771 OPTS
="${OPTS} -exported_symbols_list ${EXPORTS}"
774 LINKNAME
="lib${LIBNAME}.${LIBSUFFIX}"
775 LIBNAME
="lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}"
777 # examine first object to determine ABI
779 ABIS
=`lipo -info $1 | sed s/.*://`
781 OPTS
="${OPTS} -arch ${ABI}"
784 if [ "${ALTOPTS}" ] ; then
789 if [ $CPLUSPLUS = 1 ] ; then
795 echo "mklib: Making Darwin shared library: " ${LIBNAME}
797 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
798 ln -s ${LIBNAME} ${LINKNAME}
799 FINAL_LIBS
="${LIBNAME} ${LINKNAME}"
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 LIBNAME
="lib${LIBNAME}.a"
811 echo "mklib: Making QNX library: " ${LIBNAME}
812 wlib
${LIBNAME} ${OBJECTS}
813 FINAL_LIBS
=${LIBNAME}
817 LIBNAME
="lib${LIBNAME}.a"
818 echo "mklib: Making MorphOS library: " ${LIBNAME}
819 ppc-morphos-ar rc
${LIBNAME} ${OBJECTS}
820 FINAL_LIBS
="${LIBNAME}"
823 'icc' |
'icc-istatic')
825 # This should get merged into the Linux code, above, since this isn't
826 # really a different architecture.
827 LIBNAME
="lib${LIBNAME}" # prefix with "lib"
829 if [ $STATIC = 1 ] ; then
830 echo "mklib: Making Intel ICC static library: " ${LIBNAME}.a
833 if [ "${ALTOPTS}" ] ; then
837 ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
839 FINAL_LIBS
="${LIBNAME}.a"
841 if [ $ARCH = icc-istatic
] ; then
842 OPTS
="-shared -i-static -cxxlib-icc"
846 if [ "${ALTOPTS}" ] ; then
849 VERSION
="${MAJOR}.${MINOR}.${PATCH}"
850 echo "mklib: Making Intel ICC shared library: " ${LIBNAME}.so.
${VERSION}
852 if [ $CPLUSPLUS = 1 ] ; then
858 rm -f ${LIBNAME}.so.
${VERSION}
859 rm -f ${LIBNAME}.so.
${MAJOR}
862 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
863 # make usual symlinks
864 ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR}
865 ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
867 FINAL_LIBS
="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so"
873 if [ $STATIC = 1 ] ; then
874 LIBNAME
="lib${LIBNAME}.a"
875 echo "mklib: Making AIX GCC static library: " ${LIBNAME}
876 FINAL_LIBS
=`make_ar_static_lib ru 0 ${LIBNAME} ${OBJECTS}`
878 LIBNAME
="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
879 echo "mklib: Making AIX GCC shared library: " ${LIBNAME}
883 gcc
-shared -Wl,-G ${OBJECTS} ${DEPS} -o ${LIBNAME}
884 # NOTE: the application linking with this library must specify
885 # the -Wl,-brtl flags to gcc
886 FINAL_LIBS
=${LIBNAME}
892 if [ $STATIC = 0 ] ; then
893 echo "mklib: Warning shared libs not supported on Ultrix"
895 LIBNAME
="lib${LIBNAME}.a"
896 echo "mklib: Making static library for Ultrix: " ${LIBNAME}
897 FINAL_LIBS
=`make_ar_static_lib ru 0 ${LIBNAME} ${OBJECTS}`
901 # GCC-based environment
903 if [ "x$LINK" = "x" ] ; then
904 # -linker was not specified so set default link command now
905 if [ $CPLUSPLUS = 1 ] ; then
912 if [ $NOPREFIX = 1 ] ; then
913 # No "lib" or ".so" part
914 echo "mklib: Making CYGWIN shared library: " ${LIBNAME}
915 OPTS
="-shared -Wl,--enable-auto-image-base"
916 if [ "${ALTOPTS}" ] ; then
920 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS} ||
exit $?
921 FINAL_LIBS
=${LIBNAME}
923 CYGNAME
="cyg${LIBNAME}" # prefix with "cyg"
924 LIBNAME
="lib${LIBNAME}" # prefix with "lib"
926 if [ $STATIC = 1 ] ; then
928 echo "mklib: Making CYGWIN static library: " ${LIBNAME}
930 if [ "${ALTOPTS}" ] ; then
934 # expand .a into .o files
935 NEW_OBJECTS
=`expand_archives ${LIBNAME}.obj $OBJECTS`
937 FINAL_LIBS
=`make_ar_static_lib ${OPTS} 1 ${LIBNAME} ${NEW_OBJECTS}`
939 # remove temporary extracted .o files
940 rm -rf ${LIBNAME}.obj
942 OPTS
="-shared -Wl,--enable-auto-image-base -Wl,-export-all -Wl,--out-implib=${LIBNAME}-${MAJOR}.dll.a"
943 if [ "${ALTOPTS}" ] ; then
946 echo "mklib: Making CYGWIN shared library: " ${CYGNAME}-${MAJOR}.dll
949 rm -f ${CYGNAME}-${MAJOR}.dll
950 rm -f ${LIBNAME}-${MAJOR}.dll.a
951 rm -f ${LIBNAME}.dll.a
955 ${LINK} ${OPTS} ${LDFLAGS} -o ${CYGNAME}-${MAJOR}.dll ${OBJECTS} ${DEPS} ||
exit $?
956 # make usual symlinks
957 ln -s ${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a
959 FINAL_LIBS
="${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a"
960 # special case for installing in bin
961 FINAL_BINS
="${CYGNAME}-${MAJOR}.dll"
967 if [ $STATIC = 1 ] ; then
968 LIBNAME
="lib${LIBNAME}.a"
969 if [ "x$LINK" = "x" ] ; then
970 # -linker was not specified so set default link command now
971 if [ $CPLUSPLUS = 1 ] ; then
979 if [ "${ALTOPTS}" ] ; then
983 echo "mklib: Making static library for Haiku: " ${LIBNAME}
985 # expand .a into .o files
986 NEW_OBJECTS
=`expand_archives ${LIBNAME}.obj $OBJECTS`
989 FINAL_LIBS
=`make_ar_static_lib ${OPTS} 1 ${LIBNAME} ${NEW_OBJECTS}`
991 # remove temporary extracted .o files
992 rm -rf ${LIBNAME}.obj
994 LIBNAME
="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
997 echo "mklib: Making shared library for Haiku: " ${LIBNAME}
998 ${LINK} ${OPTS} ${LDFLAGS} ${OBJECTS} ${DEPS} -o ${LIBNAME}
999 FINAL_LIBS
="${LIBNAME}"
1004 # If you're adding support for a new architecture, you can
1006 if [ $STATIC = 1 ] ; then
1007 LIBNAME
="lib${LIBNAME}.a"
1008 echo "mklib: Making static library for example arch: " ${LIBNAME}
1009 FINAL_LIBS
=`make_ar_static_lib rv 0 ${LIBNAME} ${OBJECTS}`
1011 LIBNAME
="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
1012 echo "mklib: Making shared library for example arch: " ${LIBNAME}
1013 ld
-o ${LIBNAME} ${OBJECTS} ${DEPS}
1014 FINAL_LIBS
="${LIBNAME}"
1019 echo "mklib: ERROR: Don't know how to make a static/shared library for" ${ARCH}
1020 echo "mklib: Please add necessary commands to mklib script."
1026 # Put library files into installation directory if specified.
1028 if [ ${INSTALLDIR} != "." ] ; then
1029 echo "mklib: Installing" ${FINAL_LIBS} "in" ${INSTALLDIR}
1030 test -d ${INSTALLDIR} || mkdir
-p ${INSTALLDIR}
1031 mv ${FINAL_LIBS} ${INSTALLDIR}/
1033 if [ "x${FINAL_BINS}" != "x" ] ; then
1034 echo "mklib: Installing" ${FINAL_BINS} "in" ${INSTALLDIR}
1035 mv ${FINAL_BINS} ${INSTALLDIR}/