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
74 echo 'Usage: mklib [options] objects'
75 echo 'Create a shared library from object files.'
76 echo ' -o LIBRARY specifies the name of the resulting library, without'
77 echo ' the leading "lib" or any suffix.'
78 echo ' (eg: "-o GL" might result in "libGL.so" being made)'
79 echo ' -major N specifies major version number (default is 1)'
80 echo ' -minor N specifies minor version number (default is 0)'
81 echo ' -patch N specifies patch version number (default is 0)'
82 echo ' -lLIBRARY specifies a dependency on LIBRARY'
83 echo ' -LDIR search in DIR for library dependencies at build time'
84 echo ' -RDIR search in DIR for library dependencies at run time'
85 echo ' -linker L explicity specify the linker program to use (eg: gcc, g++)'
86 echo ' Not observed on all systems at this time.'
87 echo ' -ldflags OPT specify any additional linker flags in OPT'
88 echo ' -cplusplus link with C++ runtime'
89 echo ' -static make a static library (default is dynamic/shared)'
90 echo ' -dlopen make a shared library suitable for dynamic loading'
91 echo ' -install DIR put resulting library file(s) in DIR'
92 echo ' -arch ARCH override using `uname` to determine host system'
93 echo ' -archopt OPT specify an extra achitecture-specific option OPT'
94 echo ' -altopts OPTS alternate options to override all others'
95 echo " -noprefix don't prefix library name with 'lib' nor add any suffix"
96 echo ' -exports FILE only export the symbols listed in FILE'
97 echo ' -id NAME Sets the id of the dylib (Darwin)'
98 echo ' -h, --help display this information and exit'
169 # this is a special case (see bugzilla 10876)
173 DEPS
="$DEPS -pthread"
212 echo "mklib: Unknown option: " $1 ;
216 # This should be the first object file, stop parsing
224 if [ ${ARCH} = "auto" ] ; then
229 if [ $STATIC = 1 ]; then
230 # filter out linker options inside object list
232 for OBJ
in $OBJECTS ; do
235 echo "mklib: warning: ignoring $OBJ for static library"
238 NEWOBJECTS
="$NEWOBJECTS $OBJ"
249 if [ "x${LIBNAME}" = "x" ] ; then
250 echo "mklib: Error: no library name specified (-h for help)"
253 if [ "x${OBJECTS}" = "x" ] ; then
254 echo "mklib: Error: no object files specified (-h for help)"
263 echo "-----------------"
265 echo LIBNAME is
$LIBNAME
270 echo "EXPORTS in" $EXPORTS
272 echo "-----------------"
277 # OK, make the library now
281 'Linux' |
'OpenBSD' |
'DragonFly' |
'GNU' | GNU
/*)
284 if [ "x$LINK" = "x" ] ; then
285 # -linker was not specified so set default link command now
286 if [ $CPLUSPLUS = 1 ] ; then
293 if [ $NOPREFIX = 1 ] ; then
294 # No "lib" or ".so" part
295 echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}
296 case $ARCH in 'Linux' |
'GNU' | GNU
/*)
297 OPTS
="-Xlinker -Bsymbolic -shared"
304 # Check if objects are 32-bit and we're running in 64-bit
305 # environment. If so, pass -m32 flag to linker.
307 ABI32
=`file $1 | grep 32-bit`
308 if [ "${ABI32}" -a `uname -m` = "x86_64" ] ; then
312 if [ "${ALTOPTS}" ] ; then
318 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
320 FINAL_LIBS
="${LIBNAME}"
321 elif [ $STATIC = 1 ] ; then
322 # make a static .a library
323 LIBNAME
="lib${LIBNAME}.a" # prefix with "lib", suffix with ".a"
324 echo "mklib: Making" $ARCH "static library: " ${LIBNAME}
326 if [ "${ALTOPTS}" ] ; then
330 # expand .a into .o files
331 NEW_OBJECTS
=`expand_archives $OBJECTS`
335 ar ${OPTS} ${LIBNAME} ${NEW_OBJECTS}
338 # remove temporary extracted .o files
339 rm -f `contents_of_archives $OBJECTS`
342 FINAL_LIBS
=${LIBNAME}
344 # make dynamic library
345 LIBNAME
="lib${LIBNAME}" # prefix with "lib"
346 case $ARCH in 'Linux' |
'GNU' | GNU
/*)
347 OPTS
="-Xlinker -Bsymbolic -shared -Wl,-soname,${LIBNAME}.so.${MAJOR}"
350 OPTS
="-shared -Wl,-soname,${LIBNAME}.so.${MAJOR}"
353 if [ $EXPORTS ] ; then
354 #OPTS="${OPTS} -Xlinker --retain-symbols-file ${EXPORTS}"
355 # Make the 'exptmp' file for --version-script option
357 echo "global:" >> exptmp
358 sed 's/$/;/' ${EXPORTS} >> exptmp
359 echo "local:" >> exptmp
362 OPTS
="${OPTS} -Xlinker --version-script=exptmp"
363 # exptmp is removed below
366 # Check if objects are 32-bit and we're running in 64-bit
367 # environment. If so, pass -m32 flag to linker.
369 ABI32
=`file $1 | grep 32-bit`
370 if [ "${ABI32}" -a `uname -m` = "x86_64" ] ; then
373 if [ "${ALTOPTS}" ] ; then
377 if [ x
${PATCH} = "x" ] ; then
378 VERSION
="${MAJOR}.${MINOR}"
380 VERSION
="${MAJOR}.${MINOR}.${PATCH}"
383 echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}.so.
${VERSION}
386 rm -f ${LIBNAME}.so.
${VERSION}
387 rm -f ${LIBNAME}.so.
${MAJOR}
391 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
392 # make usual symlinks
393 ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR}
394 ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
396 FINAL_LIBS
="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so"
402 if [ $STATIC = 1 ] ; then
403 LIBNAME
="lib${LIBNAME}.a"
404 echo "mklib: Making SunOS static library: " ${LIBNAME}
406 ar -ruv ${LIBNAME} ${OBJECTS}
407 FINAL_LIBS
=${LIBNAME}
409 if [ $NOPREFIX = 0 ] ; then
410 LIBNAME
="lib${LIBNAME}.so"
412 echo "mklib: Making SunOS shared library: " ${LIBNAME}
414 if [ "x$LINK" = "x" ] ; then
415 # -linker was not specified, choose default linker now
416 if [ $CPLUSPLUS = 1 ] ; then
417 # determine linker and options for C++ code
418 if [ `which c++` ] ; then
421 elif [ `type g++` ] ; then
425 echo "mklib: warning: can't find C++ compiler, trying CC."
429 # use native Sun linker for C code
435 if [ ${LINK} = "ld" -o ${LINK} = "cc" -o ${LINK} = "CC" ] ; then
436 # SunOS tools, -G to make shared libs
440 # Check if objects are 32-bit and we're running in 64-bit
441 # environment. If so, pass -m32 flag to linker.
443 ABI32
=`file $1 | grep 32-bit`
444 if [ "${ABI32}" ] ; then
445 OPTS
="-m32 -shared -Wl,-Bdynamic"
447 OPTS
="-m64 -shared -Wl,-Bdynamic"
451 # If using Sun C++ compiler, need to tell it not to add runpaths
452 # that are specific to the build machine
453 if [ ${LINK} = "CC" ] ; then
454 OPTS
="${OPTS} -norunpath"
457 # Solaris linker requires explicitly listing the Standard C & C++
458 # libraries in the link path when building shared objects
459 if [ ${LINK} = "CC" ] ; then
460 DEPS
="${DEPS} -lCrun"
464 if [ $EXPORTS ] ; then
465 # Make the 'mapfile.scope' linker mapfile
466 echo "{" > mapfile.scope
467 echo "global:" >> mapfile.scope
468 sed 's/$/;/' ${EXPORTS} >> mapfile.scope
469 echo "local:" >> mapfile.scope
470 echo " *;" >> mapfile.scope
471 echo "};" >> mapfile.scope
472 OPTS
="${OPTS} -Wl,-Mmapfile.scope"
475 # Check if objects are SPARC v9
476 # file says: ELF 64-bit MSB relocatable SPARCV9 Version 1
478 if [ ${LINK} = "cc" -o ${LINK} = "CC" ] ; then
479 SPARCV9
=`file $1 | grep SPARCV9`
480 if [ "${SPARCV9}" ] ; then
481 OPTS
="${OPTS} -xarch=v9"
484 if [ "${ALTOPTS}" ] ; then
489 #echo "mklib: linker is" ${LINK} ${OPTS}
490 if [ $NOPREFIX = 1 ] ; then
492 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
493 FINAL_LIBS
="${LIBNAME}"
495 rm -f ${LIBNAME}.${MAJOR} ${LIBNAME}
496 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.${MAJOR} -h ${LIBNAME}.${MAJOR} ${OBJECTS} ${DEPS}
497 ln -s ${LIBNAME}.${MAJOR} ${LIBNAME}
498 FINAL_LIBS
="${LIBNAME}.${MAJOR} ${LIBNAME}"
506 if [ "x$LINK" = "x" ] ; then
507 # -linker was not specified so set default link command now
508 if [ $CPLUSPLUS = 1 ] ; then
515 if [ $NOPREFIX = 1 ] ; then
516 # No "lib" or ".so" part
517 echo "mklib: Making FreeBSD shared library: " ${LIBNAME}
519 if [ "${ALTOPTS}" ] ; then
523 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
524 FINAL_LIBS
=${LIBNAME}
525 elif [ $STATIC = 1 ] ; then
526 # make a static .a library
527 STLIB
="lib${LIBNAME}.a"
528 echo "mklib: Making FreeBSD static library: " ${STLIB}
530 # expand .a into .o files
531 NEW_OBJECTS
=`expand_archives $OBJECTS`
535 ar cq
${STLIB} ${NEW_OBJECTS}
538 # remove temporary extracted .o files
539 rm -f `contents_of_archives $OBJECTS`
543 # make dynamic library
544 SHLIB
="lib${LIBNAME}.so.${MAJOR}"
545 OPTS
="-shared -Wl,-soname,${SHLIB}"
546 if [ "${ALTOPTS}" ] ; then
549 echo "mklib: Making FreeBSD shared library: " ${SHLIB}
551 ${LINK} ${OPTS} ${LDFLAGS} -o ${SHLIB} ${OBJECTS} ${DEPS}
552 ln -sf ${SHLIB} "lib${LIBNAME}.so"
553 FINAL_LIBS
="${SHLIB} lib${LIBNAME}.so"
558 if [ $STATIC = 1 ] ; then
559 LIBNAME
="lib${LIBNAME}_pic.a"
560 echo "mklib: Making NetBSD PIC static library: " ${LIBNAME}
562 ar cq
${LIBNAME} ${OBJECTS}
564 FINAL_LIBS
=${LIBNAME}
566 LIBNAME
="lib${LIBNAME}.so.${MAJOR}.${MINOR}"
567 echo "mklib: Making NetBSD PIC shared library: " ${LIBNAME}
569 ld
-x -Bshareable -Bforcearchive -o ${LIBNAME} ${OBJECTS}
570 FINAL_LIBS
=${LIBNAME}
575 if [ $STATIC = 1 ] ; then
576 LIBNAME
="lib${LIBNAME}.a"
578 ar rc
${LIBNAME} ${OBJECTS}
579 FINAL_LIBS
=${LIBNAME}
581 LIBNAME
="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
583 # examine first object to determine ABI
585 ABI_O32
=`file $1 | grep 'ELF 32-bit'`
586 ABI_N32
=`file $1 | grep 'ELF N32'`
587 ABI_N64
=`file $1 | grep 'ELF 64-bit'`
588 if [ "${ABI_O32}" ] ; then
589 OPTS
="-32 -shared -all"
591 elif [ "${ABI_N32}" ] ; then
592 OPTS
="-n32 -shared -all"
594 elif [ "${ABI_N64}" ] ; then
595 OPTS
="-64 -shared -all"
598 echo "Error: Unexpected IRIX ABI!"
602 if [ "${ALTOPTS}" ] ; then
606 if [ $CPLUSPLUS = 1 ] ; then
612 echo "mklib: Making IRIX " ${ABI} " shared library: " ${LIBNAME}
613 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
614 FINAL_LIBS
=${LIBNAME}
619 LIBNAME
="lib${LIBNAME}.a"
620 echo "mklib: Making linux-cygwin library: " ${LIBNAME}
622 gnuwin32ar ruv
${LIBNAME} ${OBJECTS}
623 FINAL_LIBS
=${LIBNAME}
627 if [ $STATIC = 1 ] ; then
628 LIBNAME
="lib${LIBNAME}.a"
629 echo "mklib: Making HP-UX static library: " ${LIBNAME}
631 ar -ruv ${LIBNAME} ${OBJECTS}
632 FINAL_LIBS
=${LIBNAME}
634 # HP uses a .2 for their current GL/GLU libraries
635 if [ ${LIBNAME} = "GL" -o ${LIBNAME} = "GLU" ] ; then
638 RUNLIB
="lib${LIBNAME}.${MAJOR}"
639 DEVLIB
="lib${LIBNAME}.sl"
640 echo "mklib: Making HP-UX shared library: " ${RUNLIB} ${DEVLIB}
641 ld
-b -o ${RUNLIB} +b ${RUNLIB} ${OBJECTS} ${DEPS}
642 ln -s ${RUNLIB} ${DEVLIB}
643 FINAL_LIBS
="${RUNLIB} ${DEVLIB}"
648 # examine first object to determine ABI
650 ABI_64
=`file $1 | grep '64-bit'`
651 if [ "${ABI_64}" ] ; then
656 OFILE
=shr.o
#Want to be consistent with the IBM libGL.a
659 if [ $STATIC = 1 ] ; then
660 LIBNAME
="lib${LIBNAME}.a"
661 echo "mklib: Making AIX static library: " ${LIBNAME}
662 ar -ruv ${X64} ${LIBNAME} ${OBJECTS}
663 FINAL_LIBS
=${LIBNAME}
665 EXPFILE
="lib${LIBNAME}.exp"
666 LIBNAME
="lib${LIBNAME}.a" # shared objects are still stored in the .a libraries
667 OPTS
="-bE:${EXPFILE} -bM:SRE -bnoentry ${Q64}"
668 rm -f ${EXPFILE} ${OFILE}
669 NM
="/bin/nm -eC ${X64}"
670 echo "#! /usr/lib/${LIBNAME}" > ${EXPFILE}
671 ${NM} ${OBJECTS} |
awk '{
672 if ((($2 == "T") || ($2 == "D") || ($2 == "B")) \
673 && ( substr($1,1,1) != ".")) {
674 if (substr ($1, 1, 7) != "__sinit" &&
675 substr ($1, 1, 7) != "__sterm") {
676 if (substr ($1, 1, 5) == "__tf1")
677 print (substr ($1, 7))
678 else if (substr ($1, 1, 5) == "__tf9")
679 print (substr ($1, 15))
684 }' |
sort -u >> ${EXPFILE}
686 if [ "${ALTOPTS}" ] ; then
690 # On AIX a shared library is linked differently when
691 # you want to dlopen the file
692 if [ $DLOPEN = "1" ] ; then
693 cc
-G ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
695 cc
${OPTS} ${LDFLAGS} -o ${OFILE} ${OBJECTS} ${DEPS}
696 ar ${X64} -r ${LIBNAME} ${OFILE}
699 FINAL_LIBS
="${LIBNAME}"
704 LIBNAME
="lib${LIBNAME}.a"
705 echo "mklib: Making OpenSTEP static library: " ${LIBNAME}
706 libtool
-static -o ${LIBNAME} - ${OBJECTS}
707 FINAL_LIBS
=${LIBNAME}
711 if [ $STATIC = 1 ] ; then
712 LIBNAME
="lib${LIBNAME}.a"
713 echo "mklib: Making OSF/1 static library: " ${LIBNAME}
715 ar -ruv ${LIBNAME} ${OBJECTS}
716 FINAL_LIBS
=${LIBNAME}
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}
741 if [ "${ALTOPTS}" ] ; then
744 ${LINK} ${OPTS} ${LIBNAME} ${OBJECTS}
745 FINAL_LIBS
=${LIBNAME}
747 # On Darwin a .bundle is used for a library that you want to dlopen
748 if [ $DLOPEN = "1" ] ; then
750 OPTS
="${ARCHOPT} -bundle -multiply_defined suppress"
753 if [ -z "$ID" ] ; then
754 ID
="lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}"
756 OPTS
="${ARCHOPT} -dynamiclib -multiply_defined suppress -current_version ${MAJOR}.${MINOR}.0 -compatibility_version ${MAJOR}.${MINOR}.0 -install_name ${ID}"
759 if [ ${EXPORTS} ] ; then
760 if [ -f ${EXPORTS}".darwin" ] ; then
761 EXPORTS
=$EXPORTS".darwin"
763 OPTS
="${OPTS} -exported_symbols_list ${EXPORTS}"
766 LINKNAME
="lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}"
767 LINKNAME2
="lib${LIBNAME}.${LIBSUFFIX}"
768 LIBNAME
="lib${LIBNAME}.${MAJOR}.${MINOR}.${LIBSUFFIX}"
770 # examine first object to determine ABI
772 ABIS
=`lipo -info $1 | sed s/.*://`
774 OPTS
="${OPTS} -arch ${ABI}"
777 if [ "${ALTOPTS}" ] ; then
781 # XXX can we always add -isysroot /Developer/SDKs/MacOSX10.4u.sdk
785 if [ $CPLUSPLUS = 1 ] ; then
791 echo "mklib: Making Darwin shared library: " ${LIBNAME}
793 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
794 ln -s ${LIBNAME} ${LINKNAME}
795 ln -s ${LIBNAME} ${LINKNAME2}
796 FINAL_LIBS
="${LIBNAME} ${LINKNAME} ${LINKNAME2}"
801 LIBNAME
="lib${LIBNAME}.a"
802 echo "mklib: Making LynxOS static library: " ${LIBNAME}
804 ar ru
${LIBNAME} ${OBJECTS}
805 FINAL_LIBS
=${LIBNAME}
809 if [ $STATIC = 1 ] ; then
810 LIBNAME
="lib${LIBNAME}.a"
811 echo "mklib: Making BeOS static library: " ${LIBNAME}
812 ar -cru "${LIBNAME}" ${OBJECTS}
814 LIBNAME
="lib${LIBNAME}.so"
815 echo "mklib: Making BeOS shared library: " ${LIBNAME}
816 gcc
-nostart -Xlinker "-soname=${LIBNAME}" -L/Be/develop/lib/x86 -lbe ${DEPS} ${OBJECTS} -o "${LIBNAME}"
817 mimeset
-f "${LIBNAME}"
818 # XXX remove the Mesa3D stuff here since mklib isn't mesa-specific.
819 setversion
"${LIBNAME}" -app ${MAJOR} ${MINOR} ${PATCH} -short "Powered by Mesa3D
!" -long "Powered by Mesa3D
!"
821 FINAL_LIBS=${LIBNAME}
825 LIBNAME="lib
${LIBNAME}.a
"
826 echo "mklib
: Making QNX library
: " ${LIBNAME}
827 wlib ${LIBNAME} ${OBJECTS}
828 FINAL_LIBS=${LIBNAME}
832 LIBNAME="lib
${LIBNAME}.a
"
833 echo "mklib
: Making MorphOS library
: " ${LIBNAME}
834 ppc-morphos-ar rc ${LIBNAME} ${OBJECTS}
835 FINAL_LIBS="${LIBNAME}"
838 'icc' | 'icc-istatic')
840 # This should get merged into the Linux code, above, since this isn't
841 # really a different architecture.
842 LIBNAME="lib
${LIBNAME}" # prefix with "lib
"
844 if [ $STATIC = 1 ] ; then
845 echo "mklib
: Making Intel ICC static library
: " ${LIBNAME}.a
848 if [ "${ALTOPTS}" ] ; then
852 ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
854 FINAL_LIBS="${LIBNAME}.a
"
856 if [ $ARCH = icc-istatic ] ; then
857 OPTS="-shared -i-static -cxxlib-icc"
861 if [ "${ALTOPTS}" ] ; then
864 VERSION="${MAJOR}.${MINOR}.${PATCH}"
865 echo "mklib
: Making Intel ICC shared library
: " ${LIBNAME}.so.${VERSION}
867 if [ $CPLUSPLUS = 1 ] ; then
873 rm -f ${LIBNAME}.so.${VERSION}
874 rm -f ${LIBNAME}.so.${MAJOR}
877 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
878 # make usual symlinks
879 ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR}
880 ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
882 FINAL_LIBS="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
"
888 if [ $STATIC = 1 ] ; then
889 LIBNAME="lib
${LIBNAME}.a
"
890 echo "mklib
: Making AIX GCC static library
: " ${LIBNAME}
892 ar ru ${LIBNAME} ${OBJECTS}
893 FINAL_LIBS=${LIBNAME}
895 LIBNAME="lib
${LIBNAME}.so
" # prefix with "lib
", suffix with ".so
"
896 echo "mklib
: Making AIX GCC shared library
: " ${LIBNAME}
900 gcc -shared -Wl,-G ${OBJECTS} ${DEPS} -o ${LIBNAME}
901 # NOTE: the application linking with this library must specify
902 # the -Wl,-brtl flags to gcc
903 FINAL_LIBS=${LIBNAME}
909 if [ $STATIC = 0 ] ; then
910 echo "mklib
: Warning shared libs not supported on Ultrix
"
912 LIBNAME="lib
${LIBNAME}.a
"
913 echo "mklib
: Making static library
for Ultrix
: " ${LIBNAME}
915 ar ru ${LIBNAME} ${OBJECTS}
916 FINAL_LIBS="${LIBNAME}"
920 # GCC-based environment
921 if [ $NOPREFIX = 1 ] ; then
922 # No "lib
" or ".so
" part
923 echo "mklib
: Making CYGWIN shared library
: " ${LIBNAME}
924 OPTS="-shared -Wl,--enable-auto-image-base"
925 if [ "${ALTOPTS}" ] ; then
929 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
930 FINAL_LIBS=${LIBNAME}
932 CYGNAME="cyg
${LIBNAME}" # prefix with "cyg
"
933 LIBNAME="lib
${LIBNAME}" # prefix with "lib
"
935 if [ $STATIC = 1 ] ; then
936 echo "mklib
: Making
" $ARCH "static library
: " ${LIBNAME}.a
939 if [ "${ALTOPTS}" ] ; then
943 ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
946 FINAL_LIBS=${LIBNAME}.a
948 OPTS="-shared -Wl,--enable-auto-image-base -Wl,-export-all -Wl,--out-implib=${LIBNAME}-${MAJOR}.dll.a
"
949 if [ "${ALTOPTS}" ] ; then
952 echo "mklib
: Making
" $ARCH "shared library
: " ${CYGNAME}-${MAJOR}.dll
954 if [ $CPLUSPLUS = 1 ] ; then
961 rm -f ${CYGNAME}-${MAJOR}.dll
962 rm -f ${LIBNAME}-${MAJOR}.dll.a
963 rm -f ${LIBNAME}.dll.a
967 ${LINK} ${OPTS} ${LDFLAGS} -o ${CYGNAME}-${MAJOR}.dll ${OBJECTS} ${DEPS}
968 # make usual symlinks
969 ln -s ${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a
971 FINAL_LIBS="${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a
"
972 # special case for installing in bin
973 FINAL_BINS="${CYGNAME}-${MAJOR}.dll
"
979 # If you're adding support for a new architecture, you can
981 if [ $STATIC = 1 ] ; then
982 LIBNAME="lib
${LIBNAME}.a
"
983 echo "mklib
: Making static library
for example arch
: " ${LIBNAME}
985 ar rv ${LIBNAME} ${OBJECTS}
986 FINAL_LIBS="${LIBNAME}"
988 LIBNAME="lib
${LIBNAME}.so
" # prefix with "lib
", suffix with ".so
"
989 echo "mklib
: Making shared library
for example arch
: " ${LIBNAME}
990 ld -o ${LIBNAME} ${OBJECTS} ${DEPS}
991 FINAL_LIBS="${LIBNAME}"
996 echo "mklib
: ERROR
: Don
't know how to make a static/shared library for" ${ARCH}
997 echo "mklib: Please add necessary commands to mklib script."
1003 # Put library files into installation directory if specified.
1005 if [ ${INSTALLDIR} != "." ] ; then
1006 echo "mklib: Installing" ${FINAL_LIBS} "in" ${INSTALLDIR}
1007 test -d ${INSTALLDIR} || mkdir -p ${INSTALLDIR}
1008 mv ${FINAL_LIBS} ${INSTALLDIR}/