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 ${LINK} ${OPTS} ${LIBNAME} ${OBJECTS}
267 FINAL_LIBS
=${LIBNAME}
269 LIBNAME
="lib${LIBNAME}" # prefix with "lib"
270 case $ARCH in 'Linux' |
'GNU' | GNU
/*)
271 OPTS
="-Xlinker -Bsymbolic -shared -Wl,-soname,${LIBNAME}.so.${MAJOR}"
274 OPTS
="-shared -Wl,-soname,${LIBNAME}.so.${MAJOR}"
277 if [ $EXPORTS ] ; then
278 #OPTS="${OPTS} -Xlinker --retain-symbols-file ${EXPORTS}"
279 # Make the 'exptmp' file for --version-script option
281 echo "global:" >> exptmp
282 sed 's/$/;/' ${EXPORTS} >> exptmp
283 echo "local:" >> exptmp
286 OPTS
="${OPTS} -Xlinker --version-script=exptmp"
287 # exptmp is removed below
290 # Check if objects are 32-bit and we're running in 64-bit
291 # environment. If so, pass -m32 flag to linker.
293 ABI32
=`file $1 | grep 32-bit`
294 if [ "${ABI32}" -a `uname -m` = "x86_64" ] ; then
297 if [ "${ALTOPTS}" ] ; then
301 if [ x
${PATCH} = "x" ] ; then
302 VERSION
="${MAJOR}.${MINOR}"
304 VERSION
="${MAJOR}.${MINOR}.${PATCH}"
307 echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}.so.
${VERSION}
310 rm -f ${LIBNAME}.so.
${VERSION}
311 rm -f ${LIBNAME}.so.
${MAJOR}
315 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
316 # make usual symlinks
317 ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR}
318 ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
320 FINAL_LIBS
="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so"
326 if [ $STATIC = 1 ] ; then
327 LIBNAME
="lib${LIBNAME}.a"
328 echo "mklib: Making SunOS static library: " ${LIBNAME}
330 ar -ruv ${LIBNAME} ${OBJECTS}
331 FINAL_LIBS
=${LIBNAME}
333 if [ $NOPREFIX = 0 ] ; then
334 LIBNAME
="lib${LIBNAME}.so"
336 echo "mklib: Making SunOS shared library: " ${LIBNAME}
338 if [ "x$LINK" = "x" ] ; then
339 # -linker was not specified, choose default linker now
340 if [ $CPLUSPLUS = 1 ] ; then
341 # determine linker and options for C++ code
342 if [ `which c++` ] ; then
345 elif [ `type g++` ] ; then
349 echo "mklib: warning: can't find C++ compiler, trying CC."
353 # use native Sun linker for C code
359 if [ ${LINK} = "ld" -o ${LINK} = "cc" -o ${LINK} = "CC" ] ; then
360 # SunOS tools, -G to make shared libs
364 # Check if objects are 32-bit and we're running in 64-bit
365 # environment. If so, pass -m32 flag to linker.
367 ABI32
=`file $1 | grep 32-bit`
368 if [ "${ABI32}" ] ; then
369 OPTS
="-m32 -shared -Wl,-Bdynamic"
371 OPTS
="-m64 -shared -Wl,-Bdynamic"
375 # Check if objects are SPARC v9
376 # file says: ELF 64-bit MSB relocatable SPARCV9 Version 1
378 if [ ${LINK} = "cc" -o ${LINK} = "CC" ] ; then
379 SPARCV9
=`file $1 | grep SPARCV9`
380 if [ "${SPARCV9}" ] ; then
381 OPTS
="${OPTS} -xarch=v9"
384 if [ "${ALTOPTS}" ] ; then
388 #echo "mklib: linker is" ${LINK} ${OPTS}
389 if [ $NOPREFIX = 1 ] ; then
391 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
393 rm -f ${LIBNAME}.${MAJOR} ${LIBNAME}
394 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.${MAJOR} -h ${LIBNAME}.${MAJOR} ${OBJECTS} ${DEPS}
395 ln -s ${LIBNAME}.${MAJOR} ${LIBNAME}
397 FINAL_LIBS
="${LIBNAME}.${MAJOR} ${LIBNAME}"
404 if [ "x$LINK" = "x" ] ; then
405 # -linker was not specified so set default link command now
406 if [ $CPLUSPLUS = 1 ] ; then
413 if [ $NOPREFIX = 1 ] ; then
414 # No "lib" or ".so" part
415 echo "mklib: Making FreeBSD shared library: " ${LIBNAME}
417 if [ "${ALTOPTS}" ] ; then
421 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
422 FINAL_LIBS
=${LIBNAME}
423 elif [ $STATIC = 1 ] ; then
424 STLIB
="lib${LIBNAME}.a"
425 echo "mklib: Making FreeBSD static library: " ${STLIB}
427 ar cq
${STLIB} ${OBJECTS}
431 SHLIB
="lib${LIBNAME}.so.${MAJOR}"
432 OPTS
="-shared -Wl,-soname,${SHLIB}"
433 if [ "${ALTOPTS}" ] ; then
436 echo "mklib: Making FreeBSD shared library: " ${SHLIB}
438 ${LINK} ${OPTS} ${LDFLAGS} -o ${SHLIB} ${OBJECTS} ${DEPS}
439 ln -sf ${SHLIB} "lib${LIBNAME}.so"
440 FINAL_LIBS
="${SHLIB} lib${LIBNAME}.so"
445 if [ $STATIC = 1 ] ; then
446 LIBNAME
="lib${LIBNAME}_pic.a"
447 echo "mklib: Making NetBSD PIC static library: " ${LIBNAME}
449 ar cq
${LIBNAME} ${OBJECTS}
451 FINAL_LIBS
=${LIBNAME}
453 LIBNAME
="lib${LIBNAME}.so.${MAJOR}.${MINOR}"
454 echo "mklib: Making NetBSD PIC shared library: " ${LIBNAME}
456 ld
-x -Bshareable -Bforcearchive -o ${LIBNAME} ${OBJECTS}
457 FINAL_LIBS
=${LIBNAME}
462 if [ $STATIC = 1 ] ; then
463 LIBNAME
="lib${LIBNAME}.a"
465 ar rc
${LIBNAME} ${OBJECTS}
466 FINAL_LIBS
=${LIBNAME}
468 LIBNAME
="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
470 # examine first object to determine ABI
472 ABI_O32
=`file $1 | grep 'ELF 32-bit'`
473 ABI_N32
=`file $1 | grep 'ELF N32'`
474 ABI_N64
=`file $1 | grep 'ELF 64-bit'`
475 if [ "${ABI_O32}" ] ; then
476 OPTS
="-32 -shared -all"
478 elif [ "${ABI_N32}" ] ; then
479 OPTS
="-n32 -shared -all"
481 elif [ "${ABI_N64}" ] ; then
482 OPTS
="-64 -shared -all"
485 echo "Error: Unexpected IRIX ABI!"
489 if [ "${ALTOPTS}" ] ; then
493 if [ $CPLUSPLUS = 1 ] ; then
499 echo "mklib: Making IRIX " ${ABI} " shared library: " ${LIBNAME}
500 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
501 FINAL_LIBS
=${LIBNAME}
506 LIBNAME
="lib${LIBNAME}.a"
507 echo "mklib: Making linux-cygwin library: " ${LIBNAME}
509 gnuwin32ar ruv
${LIBNAME} ${OBJECTS}
510 FINAL_LIBS
=${LIBNAME}
514 if [ $STATIC = 1 ] ; then
515 LIBNAME
="lib${LIBNAME}.a"
516 echo "mklib: Making HP-UX static library: " ${LIBNAME}
518 ar -ruv ${LIBNAME} ${OBJECTS}
519 FINAL_LIBS
=${LIBNAME}
521 # HP uses a .2 for their current GL/GLU libraries
522 if [ ${LIBNAME} = "GL" -o ${LIBNAME} = "GLU" ] ; then
525 RUNLIB
="lib${LIBNAME}.${MAJOR}"
526 DEVLIB
="lib${LIBNAME}.sl"
527 echo "mklib: Making HP-UX shared library: " ${RUNLIB} ${DEVLIB}
528 ld
-b -o ${RUNLIB} +b ${RUNLIB} ${OBJECTS} ${DEPS}
529 ln -s ${RUNLIB} ${DEVLIB}
530 FINAL_LIBS
="${RUNLIB} ${DEVLIB}"
535 # examine first object to determine ABI
537 ABI_64
=`file $1 | grep '64-bit'`
538 if [ "${ABI_64}" ] ; then
543 OFILE
=shr.o
#Want to be consistent with the IBM libGL.a
546 if [ $STATIC = 1 ] ; then
547 LIBNAME
="lib${LIBNAME}.a"
548 echo "mklib: Making AIX static library: " ${LIBNAME}
549 ar -ruv ${X64} ${LIBNAME} ${OBJECTS}
550 FINAL_LIBS
=${LIBNAME}
552 EXPFILE
="lib${LIBNAME}.exp"
553 LIBNAME
="lib${LIBNAME}.a" # shared objects are still stored in the .a libraries
554 OPTS
="-bE:${EXPFILE} -bM:SRE -bnoentry ${Q64}"
555 rm -f ${EXPFILE} ${OFILE}
556 NM
="/bin/nm -eC ${X64}"
557 echo "#! /usr/lib/${LIBNAME}" > ${EXPFILE}
558 ${NM} ${OBJECTS} |
awk '{
559 if ((($2 == "T") || ($2 == "D") || ($2 == "B")) \
560 && ( substr($1,1,1) != ".")) {
561 if (substr ($1, 1, 7) != "__sinit" &&
562 substr ($1, 1, 7) != "__sterm") {
563 if (substr ($1, 1, 5) == "__tf1")
564 print (substr ($1, 7))
565 else if (substr ($1, 1, 5) == "__tf9")
566 print (substr ($1, 15))
571 }' |
sort -u >> ${EXPFILE}
573 if [ "${ALTOPTS}" ] ; then
577 # On AIX a shared library is linked differently when
578 # you want to dlopen the file
579 if [ $DLOPEN = "1" ] ; then
580 cc
-G ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
582 cc
${OPTS} ${LDFLAGS} -o ${OFILE} ${OBJECTS} ${DEPS}
583 ar ${X64} -r ${LIBNAME} ${OFILE}
586 FINAL_LIBS
="${LIBNAME}"
591 LIBNAME
="lib${LIBNAME}.a"
592 echo "mklib: Making OpenSTEP static library: " ${LIBNAME}
593 libtool
-static -o ${LIBNAME} - ${OBJECTS}
594 FINAL_LIBS
=${LIBNAME}
598 if [ $STATIC = 1 ] ; then
599 LIBNAME
="lib${LIBNAME}.a"
600 echo "mklib: Making OSF/1 static library: " ${LIBNAME}
602 ar -ruv ${LIBNAME} ${OBJECTS}
603 FINAL_LIBS
=${LIBNAME}
605 VERSION
="${MAJOR}.${MINOR}"
606 LIBNAME
="lib${LIBNAME}.so"
607 echo "mklib: Making OSF/1 shared library: " ${LIBNAME}
608 if [ "x$LINK" = "x" ] ; then
609 if [ $CPLUSPLUS = 1 ] ; then
615 rm -f ${LIBNAME}.
${VERSION}
616 ${LINK} -o ${LIBNAME}.${VERSION} -shared -set_version ${VERSION} -soname ${LIBNAME}.${VERSION} -expect_unresolved \* -all ${OBJECTS} ${DEPS}
617 ln -sf ${LIBNAME}.${VERSION} ${LIBNAME}
618 FINAL_LIBS
="${LIBNAME} ${LIBNAME}.${VERSION}"
623 if [ $STATIC = 1 ] ; then
624 LIBNAME
="lib${LIBNAME}.a"
625 echo "mklib: Making Darwin static library: " ${LIBNAME}
628 if [ "${ALTOPTS}" ] ; then
631 ${LINK} ${OPTS} ${LIBNAME} ${OBJECTS}
632 FINAL_LIBS
=${LIBNAME}
634 # On Darwin a .bundle is used for a library that you want to dlopen
635 if [ $DLOPEN = "1" ] ; then
637 OPTS
="${ARCHOPT} -bundle -multiply_defined suppress"
640 if [ -z "$ID" ] ; then
641 ID
="lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}"
643 OPTS
="${ARCHOPT} -dynamiclib -multiply_defined suppress -current_version ${MAJOR}.${MINOR}.0 -compatibility_version ${MAJOR}.${MINOR}.0 -install_name ${ID}"
646 if [ ${EXPORTS} ] ; then
647 if [ -f ${EXPORTS}".darwin" ] ; then
648 EXPORTS
=$EXPORTS".darwin"
650 OPTS
="${OPTS} -exported_symbols_list ${EXPORTS}"
653 LINKNAME
="lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}"
654 LINKNAME2
="lib${LIBNAME}.${LIBSUFFIX}"
655 LIBNAME
="lib${LIBNAME}.${MAJOR}.${MINOR}.${LIBSUFFIX}"
657 # examine first object to determine ABI
659 ABI_PPC
=`file $1 | grep ' ppc'`
660 ABI_I386
=`file $1 | grep ' i386'`
661 ABI_PPC64
=`file $1 | grep ' ppc64'`
662 ABI_X86_64
=`file $1 | grep ' x86_64'`
663 if [ "${ABI_PPC}" ] ; then
664 OPTS
="${OPTS} -arch ppc"
666 if [ "${ABI_I386}" ] ; then
667 OPTS
="${OPTS} -arch i386"
669 if [ "${ABI_PPC64}" ] ; then
670 OPTS
="${OPTS} -arch ppc64"
672 if [ "${ABI_X86_64}" ] ; then
673 OPTS
="${OPTS} -arch x86_64"
676 if [ "${ALTOPTS}" ] ; then
680 # XXX can we always add -isysroot /Developer/SDKs/MacOSX10.4u.sdk
684 if [ $CPLUSPLUS = 1 ] ; then
690 echo "mklib: Making Darwin shared library: " ${LIBNAME}
692 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
693 ln -s ${LIBNAME} ${LINKNAME}
694 ln -s ${LIBNAME} ${LINKNAME2}
695 FINAL_LIBS
="${LIBNAME} ${LINKNAME} ${LINKNAME2}"
700 LIBNAME
="lib${LIBNAME}.a"
701 echo "mklib: Making LynxOS static library: " ${LIBNAME}
703 ar ru
${LIBNAME} ${OBJECTS}
704 FINAL_LIBS
=${LIBNAME}
708 if [ $STATIC = 1 ] ; then
709 LIBNAME
="lib${LIBNAME}.a"
710 echo "mklib: Making BeOS static library: " ${LIBNAME}
711 ar -cru "${LIBNAME}" ${OBJECTS}
713 LIBNAME
="lib${LIBNAME}.so"
714 echo "mklib: Making BeOS shared library: " ${LIBNAME}
715 gcc
-nostart -Xlinker "-soname=${LIBNAME}" -L/Be/develop/lib/x86 -lbe ${DEPS} ${OBJECTS} -o "${LIBNAME}"
716 mimeset
-f "${LIBNAME}"
717 # XXX remove the Mesa3D stuff here since mklib isn't mesa-specific.
718 setversion
"${LIBNAME}" -app ${MAJOR} ${MINOR} ${PATCH} -short "Powered by Mesa3D
!" -long "Powered by Mesa3D
!"
720 FINAL_LIBS=${LIBNAME}
724 LIBNAME="lib
${LIBNAME}.a
"
725 echo "mklib
: Making QNX library
: " ${LIBNAME}
726 wlib ${LIBNAME} ${OBJECTS}
727 FINAL_LIBS=${LIBNAME}
731 LIBNAME="lib
${LIBNAME}.a
"
732 echo "mklib
: Making MorphOS library
: " ${LIBNAME}
733 ppc-morphos-ar rc ${LIBNAME} ${OBJECTS}
734 FINAL_LIBS="${LIBNAME}"
737 'icc' | 'icc-istatic')
739 # This should get merged into the Linux code, above, since this isn't
740 # really a different architecture.
741 LIBNAME="lib
${LIBNAME}" # prefix with "lib
"
743 if [ $STATIC = 1 ] ; then
744 echo "mklib
: Making Intel ICC static library
: " ${LIBNAME}.a
747 if [ "${ALTOPTS}" ] ; then
751 ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
753 FINAL_LIBS="${LIBNAME}.a
"
755 if [ $ARCH = icc-istatic ] ; then
756 OPTS="-shared -i-static -cxxlib-icc"
760 if [ "${ALTOPTS}" ] ; then
763 VERSION="${MAJOR}.${MINOR}.${PATCH}"
764 echo "mklib
: Making Intel ICC shared library
: " ${LIBNAME}.so.${VERSION}
766 if [ $CPLUSPLUS = 1 ] ; then
772 rm -f ${LIBNAME}.so.${VERSION}
773 rm -f ${LIBNAME}.so.${MAJOR}
776 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
777 # make usual symlinks
778 ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR}
779 ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
781 FINAL_LIBS="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
"
787 if [ $STATIC = 1 ] ; then
788 LIBNAME="lib
${LIBNAME}.a
"
789 echo "mklib
: Making AIX GCC static library
: " ${LIBNAME}
791 ar ru ${LIBNAME} ${OBJECTS}
792 FINAL_LIBS=${LIBNAME}
794 LIBNAME="lib
${LIBNAME}.so
" # prefix with "lib
", suffix with ".so
"
795 echo "mklib
: Making AIX GCC shared library
: " ${LIBNAME}
799 gcc -shared -Wl,-G ${OBJECTS} ${DEPS} -o ${LIBNAME}
800 # NOTE: the application linking with this library must specify
801 # the -Wl,-brtl flags to gcc
802 FINAL_LIBS=${LIBNAME}
808 if [ $STATIC = 0 ] ; then
809 echo "mklib
: Warning shared libs not supported on Ultrix
"
811 LIBNAME="lib
${LIBNAME}.a
"
812 echo "mklib
: Making static library
for Ultrix
: " ${LIBNAME}
814 ar ru ${LIBNAME} ${OBJECTS}
815 FINAL_LIBS="${LIBNAME}"
819 # GCC-based environment
820 CYGNAME="cyg
${LIBNAME}" # prefix with "cyg
"
821 LIBNAME="lib
${LIBNAME}" # prefix with "lib
"
823 if [ $STATIC = 1 ] ; then
824 echo "mklib
: Making
" $ARCH "static library
: " ${LIBNAME}.a
827 if [ "${ALTOPTS}" ] ; then
831 ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
834 FINAL_LIBS=${LIBNAME}.a
836 OPTS="-shared -Wl,-export-all -Wl,--out-implib=${LIBNAME}-${MAJOR}.dll.a
"
837 if [ "${ALTOPTS}" ] ; then
840 echo "mklib
: Making
" $ARCH "shared library
: " ${LIBNAME}-${MAJOR}.dll
842 if [ $CPLUSPLUS = 1 ] ; then
849 rm -f ${LIBNAME}-${MAJOR}.dll
850 rm -f ${LIBNAME}.dll.a
854 ${LINK} ${OPTS} ${LDFLAGS} -o ${CYGNAME}-${MAJOR}.dll ${OBJECTS} ${DEPS}
855 # make usual symlinks
856 ln -s ${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a
858 FINAL_LIBS="${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a
"
859 # special case for installing in bin
860 FINAL_BINS="${CYGNAME}-${MAJOR}.dll
"
865 # If you're adding support for a new architecture, you can
867 if [ $STATIC = 1 ] ; then
868 LIBNAME="lib
${LIBNAME}.a
"
869 echo "mklib
: Making static library
for example arch
: " ${LIBNAME}
871 ar rv ${LIBNAME} ${OBJECTS}
872 FINAL_LIBS="${LIBNAME}"
874 LIBNAME="lib
${LIBNAME}.so
" # prefix with "lib
", suffix with ".so
"
875 echo "mklib
: Making shared library
for example arch
: " ${LIBNAME}
876 ld -o ${LIBNAME} ${OBJECTS} ${DEPS}
877 FINAL_LIBS="${LIBNAME}"
882 echo "mklib
: ERROR
: Don
't know how to make a static/shared library for" ${ARCH}
883 echo "mklib: Please add necessary commands to mklib script."
889 # Put library files into installation directory if specified.
891 if [ ${INSTALLDIR} != "." ] ; then
892 echo "mklib: Installing" ${FINAL_LIBS} "in" ${INSTALLDIR}
893 mv ${FINAL_LIBS} ${INSTALLDIR}/