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.
33 for FILE
in $FILES ; do
36 # extract the .o files from this .a archive
39 NEWFILES
="$NEWFILES $MEMBERS"
42 # other file type, just add to list
43 NEWFILES
="$NEWFILES $FILE"
51 # Given a list of files, look for .a archives and return a list of all objects
53 contents_of_archives
() {
56 for FILE
in $FILES ; do
59 # get list of members in this .a archive
61 NEWFILES
="$NEWFILES $MEMBERS"
64 # skip other file types
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'
163 # this is a special case (see bugzilla 10876)
167 DEPS
="$DEPS -pthread"
206 echo "mklib: Unknown option: " $1 ;
210 # This should be the first object file, stop parsing
218 if [ ${ARCH} = "auto" ] ; then
223 if [ $STATIC = 1 ]; then
224 # filter out linker options inside object list
226 for OBJ
in $OBJECTS ; do
229 echo "mklib: warning: ignoring $OBJ for static library"
232 NEWOBJECTS
="$NEWOBJECTS $OBJ"
243 if [ "x${LIBNAME}" = "x" ] ; then
244 echo "mklib: Error: no library name specified"
247 if [ "x${OBJECTS}" = "x" ] ; then
248 echo "mklib: Error: no object files specified"
257 echo "-----------------"
259 echo LIBNAME is
$LIBNAME
264 echo "EXPORTS in" $EXPORTS
266 echo "-----------------"
271 # OK, make the library now
275 'Linux' |
'OpenBSD' |
'DragonFly' |
'GNU' | GNU
/*)
278 if [ "x$LINK" = "x" ] ; then
279 # -linker was not specified so set default link command now
280 if [ $CPLUSPLUS = 1 ] ; then
287 if [ $NOPREFIX = 1 ] ; then
288 # No "lib" or ".so" part
289 echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}
290 case $ARCH in 'Linux' |
'GNU' | GNU
/*)
291 OPTS
="-Xlinker -Bsymbolic -shared"
298 # Check if objects are 32-bit and we're running in 64-bit
299 # environment. If so, pass -m32 flag to linker.
301 ABI32
=`file $1 | grep 32-bit`
302 if [ "${ABI32}" -a `uname -m` = "x86_64" ] ; then
306 if [ "${ALTOPTS}" ] ; then
312 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
314 FINAL_LIBS
="${LIBNAME}"
315 elif [ $STATIC = 1 ] ; then
316 # make a static .a library
317 LIBNAME
="lib${LIBNAME}.a" # prefix with "lib", suffix with ".a"
318 echo "mklib: Making" $ARCH "static library: " ${LIBNAME}
320 if [ "${ALTOPTS}" ] ; then
324 # expand .a into .o files
325 NEW_OBJECTS
=`expand_archives $OBJECTS`
329 ar ${OPTS} ${LIBNAME} ${NEW_OBJECTS}
332 # remove temporary extracted .o files
333 rm -f `contents_of_archives $OBJECTS`
336 FINAL_LIBS
=${LIBNAME}
338 # make dynamic library
339 LIBNAME
="lib${LIBNAME}" # prefix with "lib"
340 case $ARCH in 'Linux' |
'GNU' | GNU
/*)
341 OPTS
="-Xlinker -Bsymbolic -shared -Wl,-soname,${LIBNAME}.so.${MAJOR}"
344 OPTS
="-shared -Wl,-soname,${LIBNAME}.so.${MAJOR}"
347 if [ $EXPORTS ] ; then
348 #OPTS="${OPTS} -Xlinker --retain-symbols-file ${EXPORTS}"
349 # Make the 'exptmp' file for --version-script option
351 echo "global:" >> exptmp
352 sed 's/$/;/' ${EXPORTS} >> exptmp
353 echo "local:" >> exptmp
356 OPTS
="${OPTS} -Xlinker --version-script=exptmp"
357 # exptmp is removed below
360 # Check if objects are 32-bit and we're running in 64-bit
361 # environment. If so, pass -m32 flag to linker.
363 ABI32
=`file $1 | grep 32-bit`
364 if [ "${ABI32}" -a `uname -m` = "x86_64" ] ; then
367 if [ "${ALTOPTS}" ] ; then
371 if [ x
${PATCH} = "x" ] ; then
372 VERSION
="${MAJOR}.${MINOR}"
374 VERSION
="${MAJOR}.${MINOR}.${PATCH}"
377 echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}.so.
${VERSION}
380 rm -f ${LIBNAME}.so.
${VERSION}
381 rm -f ${LIBNAME}.so.
${MAJOR}
385 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
386 # make usual symlinks
387 ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR}
388 ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
390 FINAL_LIBS
="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so"
396 if [ $STATIC = 1 ] ; then
397 LIBNAME
="lib${LIBNAME}.a"
398 echo "mklib: Making SunOS static library: " ${LIBNAME}
400 ar -ruv ${LIBNAME} ${OBJECTS}
401 FINAL_LIBS
=${LIBNAME}
403 if [ $NOPREFIX = 0 ] ; then
404 LIBNAME
="lib${LIBNAME}.so"
406 echo "mklib: Making SunOS shared library: " ${LIBNAME}
408 if [ "x$LINK" = "x" ] ; then
409 # -linker was not specified, choose default linker now
410 if [ $CPLUSPLUS = 1 ] ; then
411 # determine linker and options for C++ code
412 if [ `which c++` ] ; then
415 elif [ `type g++` ] ; then
419 echo "mklib: warning: can't find C++ compiler, trying CC."
423 # use native Sun linker for C code
429 if [ ${LINK} = "ld" -o ${LINK} = "cc" -o ${LINK} = "CC" ] ; then
430 # SunOS tools, -G to make shared libs
434 # Check if objects are 32-bit and we're running in 64-bit
435 # environment. If so, pass -m32 flag to linker.
437 ABI32
=`file $1 | grep 32-bit`
438 if [ "${ABI32}" ] ; then
439 OPTS
="-m32 -shared -Wl,-Bdynamic"
441 OPTS
="-m64 -shared -Wl,-Bdynamic"
445 # If using Sun C++ compiler, need to tell it not to add runpaths
446 # that are specific to the build machine
447 if [ ${LINK} = "CC" ] ; then
448 OPTS
="${OPTS} -norunpath"
451 # Solaris linker requires explicitly listing the Standard C & C++
452 # libraries in the link path when building shared objects
453 if [ ${LINK} = "CC" ] ; then
454 DEPS
="${DEPS} -lCrun"
458 if [ $EXPORTS ] ; then
459 # Make the 'mapfile.scope' linker mapfile
460 echo "{" > mapfile.scope
461 echo "global:" >> mapfile.scope
462 sed 's/$/;/' ${EXPORTS} >> mapfile.scope
463 echo "local:" >> mapfile.scope
464 echo " *;" >> mapfile.scope
465 echo "};" >> mapfile.scope
466 OPTS
="${OPTS} -Wl,-Mmapfile.scope"
469 # Check if objects are SPARC v9
470 # file says: ELF 64-bit MSB relocatable SPARCV9 Version 1
472 if [ ${LINK} = "cc" -o ${LINK} = "CC" ] ; then
473 SPARCV9
=`file $1 | grep SPARCV9`
474 if [ "${SPARCV9}" ] ; then
475 OPTS
="${OPTS} -xarch=v9"
478 if [ "${ALTOPTS}" ] ; then
483 #echo "mklib: linker is" ${LINK} ${OPTS}
484 if [ $NOPREFIX = 1 ] ; then
486 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
487 FINAL_LIBS
="${LIBNAME}"
489 rm -f ${LIBNAME}.${MAJOR} ${LIBNAME}
490 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.${MAJOR} -h ${LIBNAME}.${MAJOR} ${OBJECTS} ${DEPS}
491 ln -s ${LIBNAME}.${MAJOR} ${LIBNAME}
492 FINAL_LIBS
="${LIBNAME}.${MAJOR} ${LIBNAME}"
500 if [ "x$LINK" = "x" ] ; then
501 # -linker was not specified so set default link command now
502 if [ $CPLUSPLUS = 1 ] ; then
509 if [ $NOPREFIX = 1 ] ; then
510 # No "lib" or ".so" part
511 echo "mklib: Making FreeBSD shared library: " ${LIBNAME}
513 if [ "${ALTOPTS}" ] ; then
517 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
518 FINAL_LIBS
=${LIBNAME}
519 elif [ $STATIC = 1 ] ; then
520 # make a static .a library
521 STLIB
="lib${LIBNAME}.a"
522 echo "mklib: Making FreeBSD static library: " ${STLIB}
524 # expand .a into .o files
525 NEW_OBJECTS
=`expand_archives $OBJECTS`
529 ar cq
${STLIB} ${NEW_OBJECTS}
532 # remove temporary extracted .o files
533 rm -f `contents_of_archives $OBJECTS`
537 # make dynamic library
538 SHLIB
="lib${LIBNAME}.so.${MAJOR}"
539 OPTS
="-shared -Wl,-soname,${SHLIB}"
540 if [ "${ALTOPTS}" ] ; then
543 echo "mklib: Making FreeBSD shared library: " ${SHLIB}
545 ${LINK} ${OPTS} ${LDFLAGS} -o ${SHLIB} ${OBJECTS} ${DEPS}
546 ln -sf ${SHLIB} "lib${LIBNAME}.so"
547 FINAL_LIBS
="${SHLIB} lib${LIBNAME}.so"
552 if [ $STATIC = 1 ] ; then
553 LIBNAME
="lib${LIBNAME}_pic.a"
554 echo "mklib: Making NetBSD PIC static library: " ${LIBNAME}
556 ar cq
${LIBNAME} ${OBJECTS}
558 FINAL_LIBS
=${LIBNAME}
560 LIBNAME
="lib${LIBNAME}.so.${MAJOR}.${MINOR}"
561 echo "mklib: Making NetBSD PIC shared library: " ${LIBNAME}
563 ld
-x -Bshareable -Bforcearchive -o ${LIBNAME} ${OBJECTS}
564 FINAL_LIBS
=${LIBNAME}
569 if [ $STATIC = 1 ] ; then
570 LIBNAME
="lib${LIBNAME}.a"
572 ar rc
${LIBNAME} ${OBJECTS}
573 FINAL_LIBS
=${LIBNAME}
575 LIBNAME
="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
577 # examine first object to determine ABI
579 ABI_O32
=`file $1 | grep 'ELF 32-bit'`
580 ABI_N32
=`file $1 | grep 'ELF N32'`
581 ABI_N64
=`file $1 | grep 'ELF 64-bit'`
582 if [ "${ABI_O32}" ] ; then
583 OPTS
="-32 -shared -all"
585 elif [ "${ABI_N32}" ] ; then
586 OPTS
="-n32 -shared -all"
588 elif [ "${ABI_N64}" ] ; then
589 OPTS
="-64 -shared -all"
592 echo "Error: Unexpected IRIX ABI!"
596 if [ "${ALTOPTS}" ] ; then
600 if [ $CPLUSPLUS = 1 ] ; then
606 echo "mklib: Making IRIX " ${ABI} " shared library: " ${LIBNAME}
607 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
608 FINAL_LIBS
=${LIBNAME}
613 LIBNAME
="lib${LIBNAME}.a"
614 echo "mklib: Making linux-cygwin library: " ${LIBNAME}
616 gnuwin32ar ruv
${LIBNAME} ${OBJECTS}
617 FINAL_LIBS
=${LIBNAME}
621 if [ $STATIC = 1 ] ; then
622 LIBNAME
="lib${LIBNAME}.a"
623 echo "mklib: Making HP-UX static library: " ${LIBNAME}
625 ar -ruv ${LIBNAME} ${OBJECTS}
626 FINAL_LIBS
=${LIBNAME}
628 # HP uses a .2 for their current GL/GLU libraries
629 if [ ${LIBNAME} = "GL" -o ${LIBNAME} = "GLU" ] ; then
632 RUNLIB
="lib${LIBNAME}.${MAJOR}"
633 DEVLIB
="lib${LIBNAME}.sl"
634 echo "mklib: Making HP-UX shared library: " ${RUNLIB} ${DEVLIB}
635 ld
-b -o ${RUNLIB} +b ${RUNLIB} ${OBJECTS} ${DEPS}
636 ln -s ${RUNLIB} ${DEVLIB}
637 FINAL_LIBS
="${RUNLIB} ${DEVLIB}"
642 # examine first object to determine ABI
644 ABI_64
=`file $1 | grep '64-bit'`
645 if [ "${ABI_64}" ] ; then
650 OFILE
=shr.o
#Want to be consistent with the IBM libGL.a
653 if [ $STATIC = 1 ] ; then
654 LIBNAME
="lib${LIBNAME}.a"
655 echo "mklib: Making AIX static library: " ${LIBNAME}
656 ar -ruv ${X64} ${LIBNAME} ${OBJECTS}
657 FINAL_LIBS
=${LIBNAME}
659 EXPFILE
="lib${LIBNAME}.exp"
660 LIBNAME
="lib${LIBNAME}.a" # shared objects are still stored in the .a libraries
661 OPTS
="-bE:${EXPFILE} -bM:SRE -bnoentry ${Q64}"
662 rm -f ${EXPFILE} ${OFILE}
663 NM
="/bin/nm -eC ${X64}"
664 echo "#! /usr/lib/${LIBNAME}" > ${EXPFILE}
665 ${NM} ${OBJECTS} |
awk '{
666 if ((($2 == "T") || ($2 == "D") || ($2 == "B")) \
667 && ( substr($1,1,1) != ".")) {
668 if (substr ($1, 1, 7) != "__sinit" &&
669 substr ($1, 1, 7) != "__sterm") {
670 if (substr ($1, 1, 5) == "__tf1")
671 print (substr ($1, 7))
672 else if (substr ($1, 1, 5) == "__tf9")
673 print (substr ($1, 15))
678 }' |
sort -u >> ${EXPFILE}
680 if [ "${ALTOPTS}" ] ; then
684 # On AIX a shared library is linked differently when
685 # you want to dlopen the file
686 if [ $DLOPEN = "1" ] ; then
687 cc
-G ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
689 cc
${OPTS} ${LDFLAGS} -o ${OFILE} ${OBJECTS} ${DEPS}
690 ar ${X64} -r ${LIBNAME} ${OFILE}
693 FINAL_LIBS
="${LIBNAME}"
698 LIBNAME
="lib${LIBNAME}.a"
699 echo "mklib: Making OpenSTEP static library: " ${LIBNAME}
700 libtool
-static -o ${LIBNAME} - ${OBJECTS}
701 FINAL_LIBS
=${LIBNAME}
705 if [ $STATIC = 1 ] ; then
706 LIBNAME
="lib${LIBNAME}.a"
707 echo "mklib: Making OSF/1 static library: " ${LIBNAME}
709 ar -ruv ${LIBNAME} ${OBJECTS}
710 FINAL_LIBS
=${LIBNAME}
712 VERSION
="${MAJOR}.${MINOR}"
713 LIBNAME
="lib${LIBNAME}.so"
714 echo "mklib: Making OSF/1 shared library: " ${LIBNAME}
715 if [ "x$LINK" = "x" ] ; then
716 if [ $CPLUSPLUS = 1 ] ; then
722 rm -f ${LIBNAME}.
${VERSION}
723 ${LINK} -o ${LIBNAME}.${VERSION} -shared -set_version ${VERSION} -soname ${LIBNAME}.${VERSION} -expect_unresolved \* -all ${OBJECTS} ${DEPS}
724 ln -sf ${LIBNAME}.${VERSION} ${LIBNAME}
725 FINAL_LIBS
="${LIBNAME} ${LIBNAME}.${VERSION}"
730 if [ $STATIC = 1 ] ; then
731 LIBNAME
="lib${LIBNAME}.a"
732 echo "mklib: Making Darwin static library: " ${LIBNAME}
735 if [ "${ALTOPTS}" ] ; then
738 ${LINK} ${OPTS} ${LIBNAME} ${OBJECTS}
739 FINAL_LIBS
=${LIBNAME}
741 # On Darwin a .bundle is used for a library that you want to dlopen
742 if [ $DLOPEN = "1" ] ; then
744 OPTS
="${ARCHOPT} -bundle -multiply_defined suppress"
747 if [ -z "$ID" ] ; then
748 ID
="lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}"
750 OPTS
="${ARCHOPT} -dynamiclib -multiply_defined suppress -current_version ${MAJOR}.${MINOR}.0 -compatibility_version ${MAJOR}.${MINOR}.0 -install_name ${ID}"
753 if [ ${EXPORTS} ] ; then
754 if [ -f ${EXPORTS}".darwin" ] ; then
755 EXPORTS
=$EXPORTS".darwin"
757 OPTS
="${OPTS} -exported_symbols_list ${EXPORTS}"
760 LINKNAME
="lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}"
761 LINKNAME2
="lib${LIBNAME}.${LIBSUFFIX}"
762 LIBNAME
="lib${LIBNAME}.${MAJOR}.${MINOR}.${LIBSUFFIX}"
764 # examine first object to determine ABI
766 ABIS
=`lipo -info $1 | sed s/.*://`
768 OPTS
="${OPTS} -arch ${ABI}"
771 if [ "${ALTOPTS}" ] ; then
775 # XXX can we always add -isysroot /Developer/SDKs/MacOSX10.4u.sdk
779 if [ $CPLUSPLUS = 1 ] ; then
785 echo "mklib: Making Darwin shared library: " ${LIBNAME}
787 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
788 ln -s ${LIBNAME} ${LINKNAME}
789 ln -s ${LIBNAME} ${LINKNAME2}
790 FINAL_LIBS
="${LIBNAME} ${LINKNAME} ${LINKNAME2}"
795 LIBNAME
="lib${LIBNAME}.a"
796 echo "mklib: Making LynxOS static library: " ${LIBNAME}
798 ar ru
${LIBNAME} ${OBJECTS}
799 FINAL_LIBS
=${LIBNAME}
803 if [ $STATIC = 1 ] ; then
804 LIBNAME
="lib${LIBNAME}.a"
805 echo "mklib: Making BeOS static library: " ${LIBNAME}
806 ar -cru "${LIBNAME}" ${OBJECTS}
808 LIBNAME
="lib${LIBNAME}.so"
809 echo "mklib: Making BeOS shared library: " ${LIBNAME}
810 gcc
-nostart -Xlinker "-soname=${LIBNAME}" -L/Be/develop/lib/x86 -lbe ${DEPS} ${OBJECTS} -o "${LIBNAME}"
811 mimeset
-f "${LIBNAME}"
812 # XXX remove the Mesa3D stuff here since mklib isn't mesa-specific.
813 setversion
"${LIBNAME}" -app ${MAJOR} ${MINOR} ${PATCH} -short "Powered by Mesa3D
!" -long "Powered by Mesa3D
!"
815 FINAL_LIBS=${LIBNAME}
819 LIBNAME="lib
${LIBNAME}.a
"
820 echo "mklib
: Making QNX library
: " ${LIBNAME}
821 wlib ${LIBNAME} ${OBJECTS}
822 FINAL_LIBS=${LIBNAME}
826 LIBNAME="lib
${LIBNAME}.a
"
827 echo "mklib
: Making MorphOS library
: " ${LIBNAME}
828 ppc-morphos-ar rc ${LIBNAME} ${OBJECTS}
829 FINAL_LIBS="${LIBNAME}"
832 'icc' | 'icc-istatic')
834 # This should get merged into the Linux code, above, since this isn't
835 # really a different architecture.
836 LIBNAME="lib
${LIBNAME}" # prefix with "lib
"
838 if [ $STATIC = 1 ] ; then
839 echo "mklib
: Making Intel ICC static library
: " ${LIBNAME}.a
842 if [ "${ALTOPTS}" ] ; then
846 ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
848 FINAL_LIBS="${LIBNAME}.a
"
850 if [ $ARCH = icc-istatic ] ; then
851 OPTS="-shared -i-static -cxxlib-icc"
855 if [ "${ALTOPTS}" ] ; then
858 VERSION="${MAJOR}.${MINOR}.${PATCH}"
859 echo "mklib
: Making Intel ICC shared library
: " ${LIBNAME}.so.${VERSION}
861 if [ $CPLUSPLUS = 1 ] ; then
867 rm -f ${LIBNAME}.so.${VERSION}
868 rm -f ${LIBNAME}.so.${MAJOR}
871 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
872 # make usual symlinks
873 ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR}
874 ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
876 FINAL_LIBS="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
"
882 if [ $STATIC = 1 ] ; then
883 LIBNAME="lib
${LIBNAME}.a
"
884 echo "mklib
: Making AIX GCC static library
: " ${LIBNAME}
886 ar ru ${LIBNAME} ${OBJECTS}
887 FINAL_LIBS=${LIBNAME}
889 LIBNAME="lib
${LIBNAME}.so
" # prefix with "lib
", suffix with ".so
"
890 echo "mklib
: Making AIX GCC shared library
: " ${LIBNAME}
894 gcc -shared -Wl,-G ${OBJECTS} ${DEPS} -o ${LIBNAME}
895 # NOTE: the application linking with this library must specify
896 # the -Wl,-brtl flags to gcc
897 FINAL_LIBS=${LIBNAME}
903 if [ $STATIC = 0 ] ; then
904 echo "mklib
: Warning shared libs not supported on Ultrix
"
906 LIBNAME="lib
${LIBNAME}.a
"
907 echo "mklib
: Making static library
for Ultrix
: " ${LIBNAME}
909 ar ru ${LIBNAME} ${OBJECTS}
910 FINAL_LIBS="${LIBNAME}"
914 # GCC-based environment
915 if [ $NOPREFIX = 1 ] ; then
916 # No "lib
" or ".so
" part
917 echo "mklib
: Making CYGWIN shared library
: " ${LIBNAME}
918 OPTS="-shared -Wl,--enable-auto-image-base"
919 if [ "${ALTOPTS}" ] ; then
923 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
924 FINAL_LIBS=${LIBNAME}
926 CYGNAME="cyg
${LIBNAME}" # prefix with "cyg
"
927 LIBNAME="lib
${LIBNAME}" # prefix with "lib
"
929 if [ $STATIC = 1 ] ; then
930 echo "mklib
: Making
" $ARCH "static library
: " ${LIBNAME}.a
933 if [ "${ALTOPTS}" ] ; then
937 ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
940 FINAL_LIBS=${LIBNAME}.a
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
" $ARCH "shared library
: " ${CYGNAME}-${MAJOR}.dll
948 if [ $CPLUSPLUS = 1 ] ; then
955 rm -f ${CYGNAME}-${MAJOR}.dll
956 rm -f ${LIBNAME}-${MAJOR}.dll.a
957 rm -f ${LIBNAME}.dll.a
961 ${LINK} ${OPTS} ${LDFLAGS} -o ${CYGNAME}-${MAJOR}.dll ${OBJECTS} ${DEPS}
962 # make usual symlinks
963 ln -s ${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a
965 FINAL_LIBS="${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a
"
966 # special case for installing in bin
967 FINAL_BINS="${CYGNAME}-${MAJOR}.dll
"
973 # If you're adding support for a new architecture, you can
975 if [ $STATIC = 1 ] ; then
976 LIBNAME="lib
${LIBNAME}.a
"
977 echo "mklib
: Making static library
for example arch
: " ${LIBNAME}
979 ar rv ${LIBNAME} ${OBJECTS}
980 FINAL_LIBS="${LIBNAME}"
982 LIBNAME="lib
${LIBNAME}.so
" # prefix with "lib
", suffix with ".so
"
983 echo "mklib
: Making shared library
for example arch
: " ${LIBNAME}
984 ld -o ${LIBNAME} ${OBJECTS} ${DEPS}
985 FINAL_LIBS="${LIBNAME}"
990 echo "mklib
: ERROR
: Don
't know how to make a static/shared library for" ${ARCH}
991 echo "mklib: Please add necessary commands to mklib script."
997 # Put library files into installation directory if specified.
999 if [ ${INSTALLDIR} != "." ] ; then
1000 echo "mklib: Installing" ${FINAL_LIBS} "in" ${INSTALLDIR}
1001 test -d ${INSTALLDIR} || mkdir -p ${INSTALLDIR}
1002 mv ${FINAL_LIBS} ${INSTALLDIR}/