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.
55 echo 'Usage: mklib [options] objects'
56 echo 'Create a shared library from object files.'
57 echo ' -o LIBRARY specifies the name of the resulting library, without'
58 echo ' the leading "lib" or any suffix.'
59 echo ' (eg: "-o GL" might result in "libGL.so" being made)'
60 echo ' -major N specifies major version number (default is 1)'
61 echo ' -minor N specifies minor version number (default is 0)'
62 echo ' -patch N specifies patch version number (default is 0)'
63 echo ' -lLIBRARY specifies a dependency on LIBRARY'
64 echo ' -LDIR search in DIR for library dependencies at build time'
65 echo ' -RDIR search in DIR for library dependencies at run time'
66 echo ' -linker L explicity specify the linker program to use (eg: gcc, g++)'
67 echo ' Not observed on all systems at this time.'
68 echo ' -ldflags OPT specify any additional linker flags in OPT'
69 echo ' -cplusplus link with C++ runtime'
70 echo ' -static make a static library (default is dynamic/shared)'
71 echo ' -dlopen make a shared library suitable for dynamic loading'
72 echo ' -install DIR put resulting library file(s) in DIR'
73 echo ' -arch ARCH override using `uname` to determine host system'
74 echo ' -archopt OPT specify an extra achitecture-specific option OPT'
75 echo ' -altopts OPTS alternate options to override all others'
76 echo " -noprefix don't prefix library name with 'lib' nor add any suffix"
77 echo ' -exports FILE only export the symbols listed in FILE'
78 echo ' -id NAME Sets the id of the dylib (Darwin)'
79 echo ' -h, --help display this information and exit'
119 # this is a special case (see bugzilla 10876)
123 DEPS
="$DEPS -pthread"
162 echo "mklib: Unknown option: " $1 ;
166 # This should be the first object file, stop parsing
174 if [ ${ARCH} = "auto" ] ; then
179 if [ $STATIC = 1 ]; then
180 # filter out linker options inside object list
182 for OBJ
in $OBJECTS ; do
185 echo "mklib: warning: ignoring $OBJ for static library"
188 NEWOBJECTS
="$NEWOBJECTS $OBJ"
199 if [ "x${LIBNAME}" = "x" ] ; then
200 echo "mklib: Error: no library name specified"
203 if [ "x${OBJECTS}" = "x" ] ; then
204 echo "mklib: Error: no object files specified"
213 echo "-----------------"
215 echo LIBNAME is
$LIBNAME
220 echo "EXPORTS in" $EXPORTS
222 echo "-----------------"
227 # OK, make the library now
231 'Linux' |
'OpenBSD' |
'DragonFly' |
'GNU' | GNU
/*)
234 if [ "x$LINK" = "x" ] ; then
235 # -linker was not specified so set default link command now
236 if [ $CPLUSPLUS = 1 ] ; then
243 if [ $NOPREFIX = 1 ] ; then
244 # No "lib" or ".so" part
245 echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}
246 case $ARCH in 'Linux' |
'GNU' | GNU
/*)
247 OPTS
="-Xlinker -Bsymbolic -shared"
254 # Check if objects are 32-bit and we're running in 64-bit
255 # environment. If so, pass -m32 flag to linker.
257 ABI32
=`file $1 | grep 32-bit`
258 if [ "${ABI32}" -a `uname -m` = "x86_64" ] ; then
262 if [ "${ALTOPTS}" ] ; then
268 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
270 FINAL_LIBS
="${LIBNAME}"
271 elif [ $STATIC = 1 ] ; then
272 LIBNAME
="lib${LIBNAME}.a" # prefix with "lib", suffix with ".a"
273 echo "mklib: Making" $ARCH "static library: " ${LIBNAME}
276 if [ "${ALTOPTS}" ] ; then
281 # expand any .a objects into constituent .o files.
284 for OBJ
in ${OBJECTS} ; do
285 if [ `expr match $OBJ '.*\.a'` -gt 0 ] ; then
286 # extract the .o files from this .a archive
289 NEWOBJECTS
="$NEWOBJECTS $FILES"
290 # keep track of temporary .o files and delete them below
291 DELETIA
="$DELETIA $FILES"
294 NEWOBJECTS
="$NEWOBJECTS $OBJ"
299 ${LINK} ${OPTS} ${LIBNAME} ${NEWOBJECTS}
302 # remove temporary extracted .o files
306 FINAL_LIBS
=${LIBNAME}
308 LIBNAME
="lib${LIBNAME}" # prefix with "lib"
309 case $ARCH in 'Linux' |
'GNU' | GNU
/*)
310 OPTS
="-Xlinker -Bsymbolic -shared -Wl,-soname,${LIBNAME}.so.${MAJOR}"
313 OPTS
="-shared -Wl,-soname,${LIBNAME}.so.${MAJOR}"
316 if [ $EXPORTS ] ; then
317 #OPTS="${OPTS} -Xlinker --retain-symbols-file ${EXPORTS}"
318 # Make the 'exptmp' file for --version-script option
320 echo "global:" >> exptmp
321 sed 's/$/;/' ${EXPORTS} >> exptmp
322 echo "local:" >> exptmp
325 OPTS
="${OPTS} -Xlinker --version-script=exptmp"
326 # exptmp is removed below
329 # Check if objects are 32-bit and we're running in 64-bit
330 # environment. If so, pass -m32 flag to linker.
332 ABI32
=`file $1 | grep 32-bit`
333 if [ "${ABI32}" -a `uname -m` = "x86_64" ] ; then
336 if [ "${ALTOPTS}" ] ; then
340 if [ x
${PATCH} = "x" ] ; then
341 VERSION
="${MAJOR}.${MINOR}"
343 VERSION
="${MAJOR}.${MINOR}.${PATCH}"
346 echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}.so.
${VERSION}
349 rm -f ${LIBNAME}.so.
${VERSION}
350 rm -f ${LIBNAME}.so.
${MAJOR}
354 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
355 # make usual symlinks
356 ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR}
357 ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
359 FINAL_LIBS
="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so"
365 if [ $STATIC = 1 ] ; then
366 LIBNAME
="lib${LIBNAME}.a"
367 echo "mklib: Making SunOS static library: " ${LIBNAME}
369 ar -ruv ${LIBNAME} ${OBJECTS}
370 FINAL_LIBS
=${LIBNAME}
372 if [ $NOPREFIX = 0 ] ; then
373 LIBNAME
="lib${LIBNAME}.so"
375 echo "mklib: Making SunOS shared library: " ${LIBNAME}
377 if [ "x$LINK" = "x" ] ; then
378 # -linker was not specified, choose default linker now
379 if [ $CPLUSPLUS = 1 ] ; then
380 # determine linker and options for C++ code
381 if [ `which c++` ] ; then
384 elif [ `type g++` ] ; then
388 echo "mklib: warning: can't find C++ compiler, trying CC."
392 # use native Sun linker for C code
398 if [ ${LINK} = "ld" -o ${LINK} = "cc" -o ${LINK} = "CC" ] ; then
399 # SunOS tools, -G to make shared libs
403 # Check if objects are 32-bit and we're running in 64-bit
404 # environment. If so, pass -m32 flag to linker.
406 ABI32
=`file $1 | grep 32-bit`
407 if [ "${ABI32}" ] ; then
408 OPTS
="-m32 -shared -Wl,-Bdynamic"
410 OPTS
="-m64 -shared -Wl,-Bdynamic"
414 # If using Sun C++ compiler, need to tell it not to add runpaths
415 # that are specific to the build machine
416 if [ ${LINK} = "CC" ] ; then
417 OPTS
="${OPTS} -norunpath"
420 # Solaris linker requires explicitly listing the Standard C & C++
421 # libraries in the link path when building shared objects
422 if [ ${LINK} = "CC" ] ; then
423 DEPS
="${DEPS} -lCrun"
427 if [ $EXPORTS ] ; then
428 # Make the 'mapfile.scope' linker mapfile
429 echo "{" > mapfile.scope
430 echo "global:" >> mapfile.scope
431 sed 's/$/;/' ${EXPORTS} >> mapfile.scope
432 echo "local:" >> mapfile.scope
433 echo " *;" >> mapfile.scope
434 echo "};" >> mapfile.scope
435 OPTS
="${OPTS} -Wl,-Mmapfile.scope"
438 # Check if objects are SPARC v9
439 # file says: ELF 64-bit MSB relocatable SPARCV9 Version 1
441 if [ ${LINK} = "cc" -o ${LINK} = "CC" ] ; then
442 SPARCV9
=`file $1 | grep SPARCV9`
443 if [ "${SPARCV9}" ] ; then
444 OPTS
="${OPTS} -xarch=v9"
447 if [ "${ALTOPTS}" ] ; then
452 #echo "mklib: linker is" ${LINK} ${OPTS}
453 if [ $NOPREFIX = 1 ] ; then
455 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
456 FINAL_LIBS
="${LIBNAME}"
458 rm -f ${LIBNAME}.${MAJOR} ${LIBNAME}
459 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.${MAJOR} -h ${LIBNAME}.${MAJOR} ${OBJECTS} ${DEPS}
460 ln -s ${LIBNAME}.${MAJOR} ${LIBNAME}
461 FINAL_LIBS
="${LIBNAME}.${MAJOR} ${LIBNAME}"
469 if [ "x$LINK" = "x" ] ; then
470 # -linker was not specified so set default link command now
471 if [ $CPLUSPLUS = 1 ] ; then
478 if [ $NOPREFIX = 1 ] ; then
479 # No "lib" or ".so" part
480 echo "mklib: Making FreeBSD shared library: " ${LIBNAME}
482 if [ "${ALTOPTS}" ] ; then
486 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
487 FINAL_LIBS
=${LIBNAME}
488 elif [ $STATIC = 1 ] ; then
489 STLIB
="lib${LIBNAME}.a"
490 echo "mklib: Making FreeBSD static library: " ${STLIB}
492 ar cq
${STLIB} ${OBJECTS}
496 SHLIB
="lib${LIBNAME}.so.${MAJOR}"
497 OPTS
="-shared -Wl,-soname,${SHLIB}"
498 if [ "${ALTOPTS}" ] ; then
501 echo "mklib: Making FreeBSD shared library: " ${SHLIB}
503 ${LINK} ${OPTS} ${LDFLAGS} -o ${SHLIB} ${OBJECTS} ${DEPS}
504 ln -sf ${SHLIB} "lib${LIBNAME}.so"
505 FINAL_LIBS
="${SHLIB} lib${LIBNAME}.so"
510 if [ $STATIC = 1 ] ; then
511 LIBNAME
="lib${LIBNAME}_pic.a"
512 echo "mklib: Making NetBSD PIC static library: " ${LIBNAME}
514 ar cq
${LIBNAME} ${OBJECTS}
516 FINAL_LIBS
=${LIBNAME}
518 LIBNAME
="lib${LIBNAME}.so.${MAJOR}.${MINOR}"
519 echo "mklib: Making NetBSD PIC shared library: " ${LIBNAME}
521 ld
-x -Bshareable -Bforcearchive -o ${LIBNAME} ${OBJECTS}
522 FINAL_LIBS
=${LIBNAME}
527 if [ $STATIC = 1 ] ; then
528 LIBNAME
="lib${LIBNAME}.a"
530 ar rc
${LIBNAME} ${OBJECTS}
531 FINAL_LIBS
=${LIBNAME}
533 LIBNAME
="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
535 # examine first object to determine ABI
537 ABI_O32
=`file $1 | grep 'ELF 32-bit'`
538 ABI_N32
=`file $1 | grep 'ELF N32'`
539 ABI_N64
=`file $1 | grep 'ELF 64-bit'`
540 if [ "${ABI_O32}" ] ; then
541 OPTS
="-32 -shared -all"
543 elif [ "${ABI_N32}" ] ; then
544 OPTS
="-n32 -shared -all"
546 elif [ "${ABI_N64}" ] ; then
547 OPTS
="-64 -shared -all"
550 echo "Error: Unexpected IRIX ABI!"
554 if [ "${ALTOPTS}" ] ; then
558 if [ $CPLUSPLUS = 1 ] ; then
564 echo "mklib: Making IRIX " ${ABI} " shared library: " ${LIBNAME}
565 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
566 FINAL_LIBS
=${LIBNAME}
571 LIBNAME
="lib${LIBNAME}.a"
572 echo "mklib: Making linux-cygwin library: " ${LIBNAME}
574 gnuwin32ar ruv
${LIBNAME} ${OBJECTS}
575 FINAL_LIBS
=${LIBNAME}
579 if [ $STATIC = 1 ] ; then
580 LIBNAME
="lib${LIBNAME}.a"
581 echo "mklib: Making HP-UX static library: " ${LIBNAME}
583 ar -ruv ${LIBNAME} ${OBJECTS}
584 FINAL_LIBS
=${LIBNAME}
586 # HP uses a .2 for their current GL/GLU libraries
587 if [ ${LIBNAME} = "GL" -o ${LIBNAME} = "GLU" ] ; then
590 RUNLIB
="lib${LIBNAME}.${MAJOR}"
591 DEVLIB
="lib${LIBNAME}.sl"
592 echo "mklib: Making HP-UX shared library: " ${RUNLIB} ${DEVLIB}
593 ld
-b -o ${RUNLIB} +b ${RUNLIB} ${OBJECTS} ${DEPS}
594 ln -s ${RUNLIB} ${DEVLIB}
595 FINAL_LIBS
="${RUNLIB} ${DEVLIB}"
600 # examine first object to determine ABI
602 ABI_64
=`file $1 | grep '64-bit'`
603 if [ "${ABI_64}" ] ; then
608 OFILE
=shr.o
#Want to be consistent with the IBM libGL.a
611 if [ $STATIC = 1 ] ; then
612 LIBNAME
="lib${LIBNAME}.a"
613 echo "mklib: Making AIX static library: " ${LIBNAME}
614 ar -ruv ${X64} ${LIBNAME} ${OBJECTS}
615 FINAL_LIBS
=${LIBNAME}
617 EXPFILE
="lib${LIBNAME}.exp"
618 LIBNAME
="lib${LIBNAME}.a" # shared objects are still stored in the .a libraries
619 OPTS
="-bE:${EXPFILE} -bM:SRE -bnoentry ${Q64}"
620 rm -f ${EXPFILE} ${OFILE}
621 NM
="/bin/nm -eC ${X64}"
622 echo "#! /usr/lib/${LIBNAME}" > ${EXPFILE}
623 ${NM} ${OBJECTS} |
awk '{
624 if ((($2 == "T") || ($2 == "D") || ($2 == "B")) \
625 && ( substr($1,1,1) != ".")) {
626 if (substr ($1, 1, 7) != "__sinit" &&
627 substr ($1, 1, 7) != "__sterm") {
628 if (substr ($1, 1, 5) == "__tf1")
629 print (substr ($1, 7))
630 else if (substr ($1, 1, 5) == "__tf9")
631 print (substr ($1, 15))
636 }' |
sort -u >> ${EXPFILE}
638 if [ "${ALTOPTS}" ] ; then
642 # On AIX a shared library is linked differently when
643 # you want to dlopen the file
644 if [ $DLOPEN = "1" ] ; then
645 cc
-G ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
647 cc
${OPTS} ${LDFLAGS} -o ${OFILE} ${OBJECTS} ${DEPS}
648 ar ${X64} -r ${LIBNAME} ${OFILE}
651 FINAL_LIBS
="${LIBNAME}"
656 LIBNAME
="lib${LIBNAME}.a"
657 echo "mklib: Making OpenSTEP static library: " ${LIBNAME}
658 libtool
-static -o ${LIBNAME} - ${OBJECTS}
659 FINAL_LIBS
=${LIBNAME}
663 if [ $STATIC = 1 ] ; then
664 LIBNAME
="lib${LIBNAME}.a"
665 echo "mklib: Making OSF/1 static library: " ${LIBNAME}
667 ar -ruv ${LIBNAME} ${OBJECTS}
668 FINAL_LIBS
=${LIBNAME}
670 VERSION
="${MAJOR}.${MINOR}"
671 LIBNAME
="lib${LIBNAME}.so"
672 echo "mklib: Making OSF/1 shared library: " ${LIBNAME}
673 if [ "x$LINK" = "x" ] ; then
674 if [ $CPLUSPLUS = 1 ] ; then
680 rm -f ${LIBNAME}.
${VERSION}
681 ${LINK} -o ${LIBNAME}.${VERSION} -shared -set_version ${VERSION} -soname ${LIBNAME}.${VERSION} -expect_unresolved \* -all ${OBJECTS} ${DEPS}
682 ln -sf ${LIBNAME}.${VERSION} ${LIBNAME}
683 FINAL_LIBS
="${LIBNAME} ${LIBNAME}.${VERSION}"
688 if [ $STATIC = 1 ] ; then
689 LIBNAME
="lib${LIBNAME}.a"
690 echo "mklib: Making Darwin static library: " ${LIBNAME}
693 if [ "${ALTOPTS}" ] ; then
696 ${LINK} ${OPTS} ${LIBNAME} ${OBJECTS}
697 FINAL_LIBS
=${LIBNAME}
699 # On Darwin a .bundle is used for a library that you want to dlopen
700 if [ $DLOPEN = "1" ] ; then
702 OPTS
="${ARCHOPT} -bundle -multiply_defined suppress"
705 if [ -z "$ID" ] ; then
706 ID
="lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}"
708 OPTS
="${ARCHOPT} -dynamiclib -multiply_defined suppress -current_version ${MAJOR}.${MINOR}.0 -compatibility_version ${MAJOR}.${MINOR}.0 -install_name ${ID}"
711 if [ ${EXPORTS} ] ; then
712 if [ -f ${EXPORTS}".darwin" ] ; then
713 EXPORTS
=$EXPORTS".darwin"
715 OPTS
="${OPTS} -exported_symbols_list ${EXPORTS}"
718 LINKNAME
="lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}"
719 LINKNAME2
="lib${LIBNAME}.${LIBSUFFIX}"
720 LIBNAME
="lib${LIBNAME}.${MAJOR}.${MINOR}.${LIBSUFFIX}"
722 # examine first object to determine ABI
724 ABI_PPC
=`file $1 | grep ' ppc'`
725 ABI_I386
=`file $1 | grep ' i386'`
726 ABI_PPC64
=`file $1 | grep ' ppc64'`
727 ABI_X86_64
=`file $1 | grep ' x86_64'`
728 if [ "${ABI_PPC}" ] ; then
729 OPTS
="${OPTS} -arch ppc"
731 if [ "${ABI_I386}" ] ; then
732 OPTS
="${OPTS} -arch i386"
734 if [ "${ABI_PPC64}" ] ; then
735 OPTS
="${OPTS} -arch ppc64"
737 if [ "${ABI_X86_64}" ] ; then
738 OPTS
="${OPTS} -arch x86_64"
741 if [ "${ALTOPTS}" ] ; then
745 # XXX can we always add -isysroot /Developer/SDKs/MacOSX10.4u.sdk
749 if [ $CPLUSPLUS = 1 ] ; then
755 echo "mklib: Making Darwin shared library: " ${LIBNAME}
757 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
758 ln -s ${LIBNAME} ${LINKNAME}
759 ln -s ${LIBNAME} ${LINKNAME2}
760 FINAL_LIBS
="${LIBNAME} ${LINKNAME} ${LINKNAME2}"
765 LIBNAME
="lib${LIBNAME}.a"
766 echo "mklib: Making LynxOS static library: " ${LIBNAME}
768 ar ru
${LIBNAME} ${OBJECTS}
769 FINAL_LIBS
=${LIBNAME}
773 if [ $STATIC = 1 ] ; then
774 LIBNAME
="lib${LIBNAME}.a"
775 echo "mklib: Making BeOS static library: " ${LIBNAME}
776 ar -cru "${LIBNAME}" ${OBJECTS}
778 LIBNAME
="lib${LIBNAME}.so"
779 echo "mklib: Making BeOS shared library: " ${LIBNAME}
780 gcc
-nostart -Xlinker "-soname=${LIBNAME}" -L/Be/develop/lib/x86 -lbe ${DEPS} ${OBJECTS} -o "${LIBNAME}"
781 mimeset
-f "${LIBNAME}"
782 # XXX remove the Mesa3D stuff here since mklib isn't mesa-specific.
783 setversion
"${LIBNAME}" -app ${MAJOR} ${MINOR} ${PATCH} -short "Powered by Mesa3D
!" -long "Powered by Mesa3D
!"
785 FINAL_LIBS=${LIBNAME}
789 LIBNAME="lib
${LIBNAME}.a
"
790 echo "mklib
: Making QNX library
: " ${LIBNAME}
791 wlib ${LIBNAME} ${OBJECTS}
792 FINAL_LIBS=${LIBNAME}
796 LIBNAME="lib
${LIBNAME}.a
"
797 echo "mklib
: Making MorphOS library
: " ${LIBNAME}
798 ppc-morphos-ar rc ${LIBNAME} ${OBJECTS}
799 FINAL_LIBS="${LIBNAME}"
802 'icc' | 'icc-istatic')
804 # This should get merged into the Linux code, above, since this isn't
805 # really a different architecture.
806 LIBNAME="lib
${LIBNAME}" # prefix with "lib
"
808 if [ $STATIC = 1 ] ; then
809 echo "mklib
: Making Intel ICC static library
: " ${LIBNAME}.a
812 if [ "${ALTOPTS}" ] ; then
816 ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
818 FINAL_LIBS="${LIBNAME}.a
"
820 if [ $ARCH = icc-istatic ] ; then
821 OPTS="-shared -i-static -cxxlib-icc"
825 if [ "${ALTOPTS}" ] ; then
828 VERSION="${MAJOR}.${MINOR}.${PATCH}"
829 echo "mklib
: Making Intel ICC shared library
: " ${LIBNAME}.so.${VERSION}
831 if [ $CPLUSPLUS = 1 ] ; then
837 rm -f ${LIBNAME}.so.${VERSION}
838 rm -f ${LIBNAME}.so.${MAJOR}
841 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
842 # make usual symlinks
843 ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR}
844 ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
846 FINAL_LIBS="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
"
852 if [ $STATIC = 1 ] ; then
853 LIBNAME="lib
${LIBNAME}.a
"
854 echo "mklib
: Making AIX GCC static library
: " ${LIBNAME}
856 ar ru ${LIBNAME} ${OBJECTS}
857 FINAL_LIBS=${LIBNAME}
859 LIBNAME="lib
${LIBNAME}.so
" # prefix with "lib
", suffix with ".so
"
860 echo "mklib
: Making AIX GCC shared library
: " ${LIBNAME}
864 gcc -shared -Wl,-G ${OBJECTS} ${DEPS} -o ${LIBNAME}
865 # NOTE: the application linking with this library must specify
866 # the -Wl,-brtl flags to gcc
867 FINAL_LIBS=${LIBNAME}
873 if [ $STATIC = 0 ] ; then
874 echo "mklib
: Warning shared libs not supported on Ultrix
"
876 LIBNAME="lib
${LIBNAME}.a
"
877 echo "mklib
: Making static library
for Ultrix
: " ${LIBNAME}
879 ar ru ${LIBNAME} ${OBJECTS}
880 FINAL_LIBS="${LIBNAME}"
884 # GCC-based environment
885 CYGNAME="cyg
${LIBNAME}" # prefix with "cyg
"
886 LIBNAME="lib
${LIBNAME}" # prefix with "lib
"
888 if [ $STATIC = 1 ] ; then
889 echo "mklib
: Making
" $ARCH "static library
: " ${LIBNAME}.a
892 if [ "${ALTOPTS}" ] ; then
896 ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
899 FINAL_LIBS=${LIBNAME}.a
901 OPTS="-shared -Wl,-export-all -Wl,--out-implib=${LIBNAME}-${MAJOR}.dll.a
"
902 if [ "${ALTOPTS}" ] ; then
905 echo "mklib
: Making
" $ARCH "shared library
: " ${LIBNAME}-${MAJOR}.dll
907 if [ $CPLUSPLUS = 1 ] ; then
914 rm -f ${LIBNAME}-${MAJOR}.dll
915 rm -f ${LIBNAME}.dll.a
919 ${LINK} ${OPTS} ${LDFLAGS} -o ${CYGNAME}-${MAJOR}.dll ${OBJECTS} ${DEPS}
920 # make usual symlinks
921 ln -s ${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a
923 FINAL_LIBS="${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a
"
924 # special case for installing in bin
925 FINAL_BINS="${CYGNAME}-${MAJOR}.dll
"
930 # If you're adding support for a new architecture, you can
932 if [ $STATIC = 1 ] ; then
933 LIBNAME="lib
${LIBNAME}.a
"
934 echo "mklib
: Making static library
for example arch
: " ${LIBNAME}
936 ar rv ${LIBNAME} ${OBJECTS}
937 FINAL_LIBS="${LIBNAME}"
939 LIBNAME="lib
${LIBNAME}.so
" # prefix with "lib
", suffix with ".so
"
940 echo "mklib
: Making shared library
for example arch
: " ${LIBNAME}
941 ld -o ${LIBNAME} ${OBJECTS} ${DEPS}
942 FINAL_LIBS="${LIBNAME}"
947 echo "mklib
: ERROR
: Don
't know how to make a static/shared library for" ${ARCH}
948 echo "mklib: Please add necessary commands to mklib script."
954 # Put library files into installation directory if specified.
956 if [ ${INSTALLDIR} != "." ] ; then
957 echo "mklib: Installing" ${FINAL_LIBS} "in" ${INSTALLDIR}
958 mv ${FINAL_LIBS} ${INSTALLDIR}/