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
182 if [ "x${LIBNAME}" = "x" ] ; then
183 echo "mklib: Error: no library name specified"
186 if [ "x${OBJECTS}" = "x" ] ; then
187 echo "mklib: Error: no object files specified"
196 echo "-----------------"
198 echo LIBNAME is
$LIBNAME
203 echo "EXPORTS in" $EXPORTS
205 echo "-----------------"
210 # OK, make the library now
214 'Linux' |
'OpenBSD' |
'DragonFly' |
'GNU' | GNU
/*)
217 if [ "x$LINK" = "x" ] ; then
218 # -linker was not specified so set default link command now
219 if [ $CPLUSPLUS = 1 ] ; then
226 if [ $NOPREFIX = 1 ] ; then
227 # No "lib" or ".so" part
228 echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}
229 case $ARCH in 'Linux' |
'GNU' | GNU
/*)
230 OPTS
="-Xlinker -Bsymbolic -shared"
237 # Check if objects are 32-bit and we're running in 64-bit
238 # environment. If so, pass -m32 flag to linker.
240 ABI32
=`file $1 | grep 32-bit`
241 if [ "${ABI32}" -a `uname -m` = "x86_64" ] ; then
245 if [ "${ALTOPTS}" ] ; then
251 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
253 FINAL_LIBS
="${LIBNAME}"
254 elif [ $STATIC = 1 ] ; then
255 LIBNAME
="lib${LIBNAME}.a" # prefix with "lib", suffix with ".a"
256 echo "mklib: Making" $ARCH "static library: " ${LIBNAME}
259 if [ "${ALTOPTS}" ] ; then
264 # expand any .a objects into constituent .o files.
267 for OBJ
in ${OBJECTS} ; do
268 if [ `expr match $OBJ '.*\.a'` -gt 0 ] ; then
269 # extract the .o files from this .a archive
272 NEWOBJECTS
="$NEWOBJECTS $FILES"
273 # keep track of temporary .o files and delete them below
274 DELETIA
="$DELETIA $FILES"
277 NEWOBJECTS
="$NEWOBJECTS $OBJ"
282 ${LINK} ${OPTS} ${LIBNAME} ${NEWOBJECTS}
285 # remove temporary extracted .o files
289 FINAL_LIBS
=${LIBNAME}
291 LIBNAME
="lib${LIBNAME}" # prefix with "lib"
292 case $ARCH in 'Linux' |
'GNU' | GNU
/*)
293 OPTS
="-Xlinker -Bsymbolic -shared -Wl,-soname,${LIBNAME}.so.${MAJOR}"
296 OPTS
="-shared -Wl,-soname,${LIBNAME}.so.${MAJOR}"
299 if [ $EXPORTS ] ; then
300 #OPTS="${OPTS} -Xlinker --retain-symbols-file ${EXPORTS}"
301 # Make the 'exptmp' file for --version-script option
303 echo "global:" >> exptmp
304 sed 's/$/;/' ${EXPORTS} >> exptmp
305 echo "local:" >> exptmp
308 OPTS
="${OPTS} -Xlinker --version-script=exptmp"
309 # exptmp is removed below
312 # Check if objects are 32-bit and we're running in 64-bit
313 # environment. If so, pass -m32 flag to linker.
315 ABI32
=`file $1 | grep 32-bit`
316 if [ "${ABI32}" -a `uname -m` = "x86_64" ] ; then
319 if [ "${ALTOPTS}" ] ; then
323 if [ x
${PATCH} = "x" ] ; then
324 VERSION
="${MAJOR}.${MINOR}"
326 VERSION
="${MAJOR}.${MINOR}.${PATCH}"
329 echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}.so.
${VERSION}
332 rm -f ${LIBNAME}.so.
${VERSION}
333 rm -f ${LIBNAME}.so.
${MAJOR}
337 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
338 # make usual symlinks
339 ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR}
340 ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
342 FINAL_LIBS
="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so"
348 if [ $STATIC = 1 ] ; then
349 LIBNAME
="lib${LIBNAME}.a"
350 echo "mklib: Making SunOS static library: " ${LIBNAME}
352 ar -ruv ${LIBNAME} ${OBJECTS}
353 FINAL_LIBS
=${LIBNAME}
355 if [ $NOPREFIX = 0 ] ; then
356 LIBNAME
="lib${LIBNAME}.so"
358 echo "mklib: Making SunOS shared library: " ${LIBNAME}
360 if [ "x$LINK" = "x" ] ; then
361 # -linker was not specified, choose default linker now
362 if [ $CPLUSPLUS = 1 ] ; then
363 # determine linker and options for C++ code
364 if [ `which c++` ] ; then
367 elif [ `type g++` ] ; then
371 echo "mklib: warning: can't find C++ compiler, trying CC."
375 # use native Sun linker for C code
381 if [ ${LINK} = "ld" -o ${LINK} = "cc" -o ${LINK} = "CC" ] ; then
382 # SunOS tools, -G to make shared libs
386 # Check if objects are 32-bit and we're running in 64-bit
387 # environment. If so, pass -m32 flag to linker.
389 ABI32
=`file $1 | grep 32-bit`
390 if [ "${ABI32}" ] ; then
391 OPTS
="-m32 -shared -Wl,-Bdynamic"
393 OPTS
="-m64 -shared -Wl,-Bdynamic"
397 # If using Sun C++ compiler, need to tell it not to add runpaths
398 # that are specific to the build machine
399 if [ ${LINK} = "CC" ] ; then
400 OPTS
="${OPTS} -norunpath"
403 # Solaris linker requires explicitly listing the Standard C & C++
404 # libraries in the link path when building shared objects
405 if [ ${LINK} = "CC" ] ; then
406 DEPS
="${DEPS} -lCrun"
410 if [ $EXPORTS ] ; then
411 # Make the 'mapfile.scope' linker mapfile
412 echo "{" > mapfile.scope
413 echo "global:" >> mapfile.scope
414 sed 's/$/;/' ${EXPORTS} >> mapfile.scope
415 echo "local:" >> mapfile.scope
416 echo " *;" >> mapfile.scope
417 echo "};" >> mapfile.scope
418 OPTS
="${OPTS} -Wl,-Mmapfile.scope"
421 # Check if objects are SPARC v9
422 # file says: ELF 64-bit MSB relocatable SPARCV9 Version 1
424 if [ ${LINK} = "cc" -o ${LINK} = "CC" ] ; then
425 SPARCV9
=`file $1 | grep SPARCV9`
426 if [ "${SPARCV9}" ] ; then
427 OPTS
="${OPTS} -xarch=v9"
430 if [ "${ALTOPTS}" ] ; then
435 #echo "mklib: linker is" ${LINK} ${OPTS}
436 if [ $NOPREFIX = 1 ] ; then
438 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
439 FINAL_LIBS
="${LIBNAME}"
441 rm -f ${LIBNAME}.${MAJOR} ${LIBNAME}
442 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.${MAJOR} -h ${LIBNAME}.${MAJOR} ${OBJECTS} ${DEPS}
443 ln -s ${LIBNAME}.${MAJOR} ${LIBNAME}
444 FINAL_LIBS
="${LIBNAME}.${MAJOR} ${LIBNAME}"
452 if [ "x$LINK" = "x" ] ; then
453 # -linker was not specified so set default link command now
454 if [ $CPLUSPLUS = 1 ] ; then
461 if [ $NOPREFIX = 1 ] ; then
462 # No "lib" or ".so" part
463 echo "mklib: Making FreeBSD shared library: " ${LIBNAME}
465 if [ "${ALTOPTS}" ] ; then
469 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
470 FINAL_LIBS
=${LIBNAME}
471 elif [ $STATIC = 1 ] ; then
472 STLIB
="lib${LIBNAME}.a"
473 echo "mklib: Making FreeBSD static library: " ${STLIB}
475 ar cq
${STLIB} ${OBJECTS}
479 SHLIB
="lib${LIBNAME}.so.${MAJOR}"
480 OPTS
="-shared -Wl,-soname,${SHLIB}"
481 if [ "${ALTOPTS}" ] ; then
484 echo "mklib: Making FreeBSD shared library: " ${SHLIB}
486 ${LINK} ${OPTS} ${LDFLAGS} -o ${SHLIB} ${OBJECTS} ${DEPS}
487 ln -sf ${SHLIB} "lib${LIBNAME}.so"
488 FINAL_LIBS
="${SHLIB} lib${LIBNAME}.so"
493 if [ $STATIC = 1 ] ; then
494 LIBNAME
="lib${LIBNAME}_pic.a"
495 echo "mklib: Making NetBSD PIC static library: " ${LIBNAME}
497 ar cq
${LIBNAME} ${OBJECTS}
499 FINAL_LIBS
=${LIBNAME}
501 LIBNAME
="lib${LIBNAME}.so.${MAJOR}.${MINOR}"
502 echo "mklib: Making NetBSD PIC shared library: " ${LIBNAME}
504 ld
-x -Bshareable -Bforcearchive -o ${LIBNAME} ${OBJECTS}
505 FINAL_LIBS
=${LIBNAME}
510 if [ $STATIC = 1 ] ; then
511 LIBNAME
="lib${LIBNAME}.a"
513 ar rc
${LIBNAME} ${OBJECTS}
514 FINAL_LIBS
=${LIBNAME}
516 LIBNAME
="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
518 # examine first object to determine ABI
520 ABI_O32
=`file $1 | grep 'ELF 32-bit'`
521 ABI_N32
=`file $1 | grep 'ELF N32'`
522 ABI_N64
=`file $1 | grep 'ELF 64-bit'`
523 if [ "${ABI_O32}" ] ; then
524 OPTS
="-32 -shared -all"
526 elif [ "${ABI_N32}" ] ; then
527 OPTS
="-n32 -shared -all"
529 elif [ "${ABI_N64}" ] ; then
530 OPTS
="-64 -shared -all"
533 echo "Error: Unexpected IRIX ABI!"
537 if [ "${ALTOPTS}" ] ; then
541 if [ $CPLUSPLUS = 1 ] ; then
547 echo "mklib: Making IRIX " ${ABI} " shared library: " ${LIBNAME}
548 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
549 FINAL_LIBS
=${LIBNAME}
554 LIBNAME
="lib${LIBNAME}.a"
555 echo "mklib: Making linux-cygwin library: " ${LIBNAME}
557 gnuwin32ar ruv
${LIBNAME} ${OBJECTS}
558 FINAL_LIBS
=${LIBNAME}
562 if [ $STATIC = 1 ] ; then
563 LIBNAME
="lib${LIBNAME}.a"
564 echo "mklib: Making HP-UX static library: " ${LIBNAME}
566 ar -ruv ${LIBNAME} ${OBJECTS}
567 FINAL_LIBS
=${LIBNAME}
569 # HP uses a .2 for their current GL/GLU libraries
570 if [ ${LIBNAME} = "GL" -o ${LIBNAME} = "GLU" ] ; then
573 RUNLIB
="lib${LIBNAME}.${MAJOR}"
574 DEVLIB
="lib${LIBNAME}.sl"
575 echo "mklib: Making HP-UX shared library: " ${RUNLIB} ${DEVLIB}
576 ld
-b -o ${RUNLIB} +b ${RUNLIB} ${OBJECTS} ${DEPS}
577 ln -s ${RUNLIB} ${DEVLIB}
578 FINAL_LIBS
="${RUNLIB} ${DEVLIB}"
583 # examine first object to determine ABI
585 ABI_64
=`file $1 | grep '64-bit'`
586 if [ "${ABI_64}" ] ; then
591 OFILE
=shr.o
#Want to be consistent with the IBM libGL.a
594 if [ $STATIC = 1 ] ; then
595 LIBNAME
="lib${LIBNAME}.a"
596 echo "mklib: Making AIX static library: " ${LIBNAME}
597 ar -ruv ${X64} ${LIBNAME} ${OBJECTS}
598 FINAL_LIBS
=${LIBNAME}
600 EXPFILE
="lib${LIBNAME}.exp"
601 LIBNAME
="lib${LIBNAME}.a" # shared objects are still stored in the .a libraries
602 OPTS
="-bE:${EXPFILE} -bM:SRE -bnoentry ${Q64}"
603 rm -f ${EXPFILE} ${OFILE}
604 NM
="/bin/nm -eC ${X64}"
605 echo "#! /usr/lib/${LIBNAME}" > ${EXPFILE}
606 ${NM} ${OBJECTS} |
awk '{
607 if ((($2 == "T") || ($2 == "D") || ($2 == "B")) \
608 && ( substr($1,1,1) != ".")) {
609 if (substr ($1, 1, 7) != "__sinit" &&
610 substr ($1, 1, 7) != "__sterm") {
611 if (substr ($1, 1, 5) == "__tf1")
612 print (substr ($1, 7))
613 else if (substr ($1, 1, 5) == "__tf9")
614 print (substr ($1, 15))
619 }' |
sort -u >> ${EXPFILE}
621 if [ "${ALTOPTS}" ] ; then
625 # On AIX a shared library is linked differently when
626 # you want to dlopen the file
627 if [ $DLOPEN = "1" ] ; then
628 cc
-G ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
630 cc
${OPTS} ${LDFLAGS} -o ${OFILE} ${OBJECTS} ${DEPS}
631 ar ${X64} -r ${LIBNAME} ${OFILE}
634 FINAL_LIBS
="${LIBNAME}"
639 LIBNAME
="lib${LIBNAME}.a"
640 echo "mklib: Making OpenSTEP static library: " ${LIBNAME}
641 libtool
-static -o ${LIBNAME} - ${OBJECTS}
642 FINAL_LIBS
=${LIBNAME}
646 if [ $STATIC = 1 ] ; then
647 LIBNAME
="lib${LIBNAME}.a"
648 echo "mklib: Making OSF/1 static library: " ${LIBNAME}
650 ar -ruv ${LIBNAME} ${OBJECTS}
651 FINAL_LIBS
=${LIBNAME}
653 VERSION
="${MAJOR}.${MINOR}"
654 LIBNAME
="lib${LIBNAME}.so"
655 echo "mklib: Making OSF/1 shared library: " ${LIBNAME}
656 if [ "x$LINK" = "x" ] ; then
657 if [ $CPLUSPLUS = 1 ] ; then
663 rm -f ${LIBNAME}.
${VERSION}
664 ${LINK} -o ${LIBNAME}.${VERSION} -shared -set_version ${VERSION} -soname ${LIBNAME}.${VERSION} -expect_unresolved \* -all ${OBJECTS} ${DEPS}
665 ln -sf ${LIBNAME}.${VERSION} ${LIBNAME}
666 FINAL_LIBS
="${LIBNAME} ${LIBNAME}.${VERSION}"
671 if [ $STATIC = 1 ] ; then
672 LIBNAME
="lib${LIBNAME}.a"
673 echo "mklib: Making Darwin static library: " ${LIBNAME}
676 if [ "${ALTOPTS}" ] ; then
679 ${LINK} ${OPTS} ${LIBNAME} ${OBJECTS}
680 FINAL_LIBS
=${LIBNAME}
682 # On Darwin a .bundle is used for a library that you want to dlopen
683 if [ $DLOPEN = "1" ] ; then
685 OPTS
="${ARCHOPT} -bundle -multiply_defined suppress"
688 if [ -z "$ID" ] ; then
689 ID
="lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}"
691 OPTS
="${ARCHOPT} -dynamiclib -multiply_defined suppress -current_version ${MAJOR}.${MINOR}.0 -compatibility_version ${MAJOR}.${MINOR}.0 -install_name ${ID}"
694 if [ ${EXPORTS} ] ; then
695 if [ -f ${EXPORTS}".darwin" ] ; then
696 EXPORTS
=$EXPORTS".darwin"
698 OPTS
="${OPTS} -exported_symbols_list ${EXPORTS}"
701 LINKNAME
="lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}"
702 LINKNAME2
="lib${LIBNAME}.${LIBSUFFIX}"
703 LIBNAME
="lib${LIBNAME}.${MAJOR}.${MINOR}.${LIBSUFFIX}"
705 # examine first object to determine ABI
707 ABI_PPC
=`file $1 | grep ' ppc'`
708 ABI_I386
=`file $1 | grep ' i386'`
709 ABI_PPC64
=`file $1 | grep ' ppc64'`
710 ABI_X86_64
=`file $1 | grep ' x86_64'`
711 if [ "${ABI_PPC}" ] ; then
712 OPTS
="${OPTS} -arch ppc"
714 if [ "${ABI_I386}" ] ; then
715 OPTS
="${OPTS} -arch i386"
717 if [ "${ABI_PPC64}" ] ; then
718 OPTS
="${OPTS} -arch ppc64"
720 if [ "${ABI_X86_64}" ] ; then
721 OPTS
="${OPTS} -arch x86_64"
724 if [ "${ALTOPTS}" ] ; then
728 # XXX can we always add -isysroot /Developer/SDKs/MacOSX10.4u.sdk
732 if [ $CPLUSPLUS = 1 ] ; then
738 echo "mklib: Making Darwin shared library: " ${LIBNAME}
740 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
741 ln -s ${LIBNAME} ${LINKNAME}
742 ln -s ${LIBNAME} ${LINKNAME2}
743 FINAL_LIBS
="${LIBNAME} ${LINKNAME} ${LINKNAME2}"
748 LIBNAME
="lib${LIBNAME}.a"
749 echo "mklib: Making LynxOS static library: " ${LIBNAME}
751 ar ru
${LIBNAME} ${OBJECTS}
752 FINAL_LIBS
=${LIBNAME}
756 if [ $STATIC = 1 ] ; then
757 LIBNAME
="lib${LIBNAME}.a"
758 echo "mklib: Making BeOS static library: " ${LIBNAME}
759 ar -cru "${LIBNAME}" ${OBJECTS}
761 LIBNAME
="lib${LIBNAME}.so"
762 echo "mklib: Making BeOS shared library: " ${LIBNAME}
763 gcc
-nostart -Xlinker "-soname=${LIBNAME}" -L/Be/develop/lib/x86 -lbe ${DEPS} ${OBJECTS} -o "${LIBNAME}"
764 mimeset
-f "${LIBNAME}"
765 # XXX remove the Mesa3D stuff here since mklib isn't mesa-specific.
766 setversion
"${LIBNAME}" -app ${MAJOR} ${MINOR} ${PATCH} -short "Powered by Mesa3D
!" -long "Powered by Mesa3D
!"
768 FINAL_LIBS=${LIBNAME}
772 LIBNAME="lib
${LIBNAME}.a
"
773 echo "mklib
: Making QNX library
: " ${LIBNAME}
774 wlib ${LIBNAME} ${OBJECTS}
775 FINAL_LIBS=${LIBNAME}
779 LIBNAME="lib
${LIBNAME}.a
"
780 echo "mklib
: Making MorphOS library
: " ${LIBNAME}
781 ppc-morphos-ar rc ${LIBNAME} ${OBJECTS}
782 FINAL_LIBS="${LIBNAME}"
785 'icc' | 'icc-istatic')
787 # This should get merged into the Linux code, above, since this isn't
788 # really a different architecture.
789 LIBNAME="lib
${LIBNAME}" # prefix with "lib
"
791 if [ $STATIC = 1 ] ; then
792 echo "mklib
: Making Intel ICC static library
: " ${LIBNAME}.a
795 if [ "${ALTOPTS}" ] ; then
799 ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
801 FINAL_LIBS="${LIBNAME}.a
"
803 if [ $ARCH = icc-istatic ] ; then
804 OPTS="-shared -i-static -cxxlib-icc"
808 if [ "${ALTOPTS}" ] ; then
811 VERSION="${MAJOR}.${MINOR}.${PATCH}"
812 echo "mklib
: Making Intel ICC shared library
: " ${LIBNAME}.so.${VERSION}
814 if [ $CPLUSPLUS = 1 ] ; then
820 rm -f ${LIBNAME}.so.${VERSION}
821 rm -f ${LIBNAME}.so.${MAJOR}
824 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
825 # make usual symlinks
826 ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR}
827 ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
829 FINAL_LIBS="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
"
835 if [ $STATIC = 1 ] ; then
836 LIBNAME="lib
${LIBNAME}.a
"
837 echo "mklib
: Making AIX GCC static library
: " ${LIBNAME}
839 ar ru ${LIBNAME} ${OBJECTS}
840 FINAL_LIBS=${LIBNAME}
842 LIBNAME="lib
${LIBNAME}.so
" # prefix with "lib
", suffix with ".so
"
843 echo "mklib
: Making AIX GCC shared library
: " ${LIBNAME}
847 gcc -shared -Wl,-G ${OBJECTS} ${DEPS} -o ${LIBNAME}
848 # NOTE: the application linking with this library must specify
849 # the -Wl,-brtl flags to gcc
850 FINAL_LIBS=${LIBNAME}
856 if [ $STATIC = 0 ] ; then
857 echo "mklib
: Warning shared libs not supported on Ultrix
"
859 LIBNAME="lib
${LIBNAME}.a
"
860 echo "mklib
: Making static library
for Ultrix
: " ${LIBNAME}
862 ar ru ${LIBNAME} ${OBJECTS}
863 FINAL_LIBS="${LIBNAME}"
867 # GCC-based environment
868 CYGNAME="cyg
${LIBNAME}" # prefix with "cyg
"
869 LIBNAME="lib
${LIBNAME}" # prefix with "lib
"
871 if [ $STATIC = 1 ] ; then
872 echo "mklib
: Making
" $ARCH "static library
: " ${LIBNAME}.a
875 if [ "${ALTOPTS}" ] ; then
879 ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
882 FINAL_LIBS=${LIBNAME}.a
884 OPTS="-shared -Wl,-export-all -Wl,--out-implib=${LIBNAME}-${MAJOR}.dll.a
"
885 if [ "${ALTOPTS}" ] ; then
888 echo "mklib
: Making
" $ARCH "shared library
: " ${LIBNAME}-${MAJOR}.dll
890 if [ $CPLUSPLUS = 1 ] ; then
897 rm -f ${LIBNAME}-${MAJOR}.dll
898 rm -f ${LIBNAME}.dll.a
902 ${LINK} ${OPTS} ${LDFLAGS} -o ${CYGNAME}-${MAJOR}.dll ${OBJECTS} ${DEPS}
903 # make usual symlinks
904 ln -s ${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a
906 FINAL_LIBS="${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a
"
907 # special case for installing in bin
908 FINAL_BINS="${CYGNAME}-${MAJOR}.dll
"
913 # If you're adding support for a new architecture, you can
915 if [ $STATIC = 1 ] ; then
916 LIBNAME="lib
${LIBNAME}.a
"
917 echo "mklib
: Making static library
for example arch
: " ${LIBNAME}
919 ar rv ${LIBNAME} ${OBJECTS}
920 FINAL_LIBS="${LIBNAME}"
922 LIBNAME="lib
${LIBNAME}.so
" # prefix with "lib
", suffix with ".so
"
923 echo "mklib
: Making shared library
for example arch
: " ${LIBNAME}
924 ld -o ${LIBNAME} ${OBJECTS} ${DEPS}
925 FINAL_LIBS="${LIBNAME}"
930 echo "mklib
: ERROR
: Don
't know how to make a static/shared library for" ${ARCH}
931 echo "mklib: Please add necessary commands to mklib script."
937 # Put library files into installation directory if specified.
939 if [ ${INSTALLDIR} != "." ] ; then
940 echo "mklib: Installing" ${FINAL_LIBS} "in" ${INSTALLDIR}
941 mv ${FINAL_LIBS} ${INSTALLDIR}/