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 ' -h, --help display this information and exit'
118 # this is a special case (see bugzilla 10876)
122 DEPS
="$DEPS -pthread"
157 echo "mklib: Unknown option: " $1 ;
161 # This should be the first object file, stop parsing
169 if [ ${ARCH} = "auto" ] ; then
177 if [ "x${LIBNAME}" = "x" ] ; then
178 echo "mklib: Error: no library name specified"
181 if [ "x${OBJECTS}" = "x" ] ; then
182 echo "mklib: Error: no object files specified"
191 echo "-----------------"
193 echo LIBNAME is
$LIBNAME
198 echo "EXPORTS in" $EXPORTS
199 echo "-----------------"
204 # OK, make the library now
208 'Linux' |
'OpenBSD' |
'DragonFly' |
'GNU' | GNU
/*)
211 if [ "x$LINK" = "x" ] ; then
212 # -linker was not specified so set default link command now
213 if [ $CPLUSPLUS = 1 ] ; then
220 if [ $NOPREFIX = 1 ] ; then
221 # No "lib" or ".so" part
222 echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}
223 case $ARCH in 'Linux' |
'GNU' | GNU
/*)
224 OPTS
="-Xlinker -Bsymbolic -shared"
231 # Check if objects are 32-bit and we're running in 64-bit
232 # environment. If so, pass -m32 flag to linker.
234 ABI32
=`file $1 | grep 32-bit`
235 if [ "${ABI32}" -a `uname -m` = "x86_64" ] ; then
239 if [ "${ALTOPTS}" ] ; then
245 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
247 FINAL_LIBS
="${LIBNAME}"
248 elif [ $STATIC = 1 ] ; then
249 LIBNAME
="lib${LIBNAME}.a" # prefix with "lib", suffix with ".a"
250 echo "mklib: Making" $ARCH "static library: " ${LIBNAME}
253 if [ "${ALTOPTS}" ] ; then
258 ${LINK} ${OPTS} ${LIBNAME} ${OBJECTS}
261 FINAL_LIBS
=${LIBNAME}
263 LIBNAME
="lib${LIBNAME}" # prefix with "lib"
264 case $ARCH in 'Linux' |
'GNU' | GNU
/*)
265 OPTS
="-Xlinker -Bsymbolic -shared -Wl,-soname,${LIBNAME}.so.${MAJOR}"
268 OPTS
="-shared -Wl,-soname,${LIBNAME}.so.${MAJOR}"
271 if [ $EXPORTS ] ; then
272 #OPTS="${OPTS} -Xlinker --retain-symbols-file ${EXPORTS}"
273 # Make the 'exptmp' file for --version-script option
275 echo "global:" >> exptmp
276 sed 's/$/;/' ${EXPORTS} >> exptmp
277 echo "local:" >> exptmp
280 OPTS
="${OPTS} -Xlinker --version-script=exptmp"
281 # exptmp is removed below
284 # Check if objects are 32-bit and we're running in 64-bit
285 # environment. If so, pass -m32 flag to linker.
287 ABI32
=`file $1 | grep 32-bit`
288 if [ "${ABI32}" -a `uname -m` = "x86_64" ] ; then
291 if [ "${ALTOPTS}" ] ; then
295 if [ x
${PATCH} = "x" ] ; then
296 VERSION
="${MAJOR}.${MINOR}"
298 VERSION
="${MAJOR}.${MINOR}.${PATCH}"
301 echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}.so.
${VERSION}
304 rm -f ${LIBNAME}.so.
${VERSION}
305 rm -f ${LIBNAME}.so.
${MAJOR}
309 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
310 # make usual symlinks
311 ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR}
312 ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
314 FINAL_LIBS
="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so"
320 if [ $STATIC = 1 ] ; then
321 LIBNAME
="lib${LIBNAME}.a"
322 echo "mklib: Making SunOS static library: " ${LIBNAME}
324 ar -ruv ${LIBNAME} ${OBJECTS}
325 FINAL_LIBS
=${LIBNAME}
327 if [ $NOPREFIX = 0 ] ; then
328 LIBNAME
="lib${LIBNAME}.so"
330 echo "mklib: Making SunOS shared library: " ${LIBNAME}
332 if [ "x$LINK" = "x" ] ; then
333 # -linker was not specified, choose default linker now
334 if [ $CPLUSPLUS = 1 ] ; then
335 # determine linker and options for C++ code
336 if [ `which c++` ] ; then
339 elif [ `type g++` ] ; then
343 echo "mklib: warning: can't find C++ compiler, trying CC."
347 # use native Sun linker for C code
353 if [ ${LINK} = "ld" -o ${LINK} = "cc" -o ${LINK} = "CC" ] ; then
354 # SunOS tools, -G to make shared libs
358 # Check if objects are 32-bit and we're running in 64-bit
359 # environment. If so, pass -m32 flag to linker.
361 ABI32
=`file $1 | grep 32-bit`
362 if [ "${ABI32}" ] ; then
363 OPTS
="-m32 -shared -Wl,-Bdynamic"
365 OPTS
="-m64 -shared -Wl,-Bdynamic"
369 # Check if objects are SPARC v9
370 # file says: ELF 64-bit MSB relocatable SPARCV9 Version 1
372 if [ ${LINK} = "cc" -o ${LINK} = "CC" ] ; then
373 SPARCV9
=`file $1 | grep SPARCV9`
374 if [ "${SPARCV9}" ] ; then
375 OPTS
="${OPTS} -xarch=v9"
378 if [ "${ALTOPTS}" ] ; then
382 #echo "mklib: linker is" ${LINK} ${OPTS}
383 if [ $NOPREFIX = 1 ] ; then
385 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
387 rm -f ${LIBNAME}.${MAJOR} ${LIBNAME}
388 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.${MAJOR} -h ${LIBNAME}.${MAJOR} ${OBJECTS} ${DEPS}
389 ln -s ${LIBNAME}.${MAJOR} ${LIBNAME}
391 FINAL_LIBS
="${LIBNAME}.${MAJOR} ${LIBNAME}"
398 if [ "x$LINK" = "x" ] ; then
399 # -linker was not specified so set default link command now
400 if [ $CPLUSPLUS = 1 ] ; then
407 if [ $NOPREFIX = 1 ] ; then
408 # No "lib" or ".so" part
409 echo "mklib: Making FreeBSD shared library: " ${LIBNAME}
411 if [ "${ALTOPTS}" ] ; then
415 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
416 FINAL_LIBS
=${LIBNAME}
417 elif [ $STATIC = 1 ] ; then
418 STLIB
="lib${LIBNAME}.a"
419 echo "mklib: Making FreeBSD static library: " ${STLIB}
421 ar cq
${STLIB} ${OBJECTS}
425 SHLIB
="lib${LIBNAME}.so.${MAJOR}"
426 OPTS
="-shared -Wl,-soname,${SHLIB}"
427 if [ "${ALTOPTS}" ] ; then
430 echo "mklib: Making FreeBSD shared library: " ${SHLIB}
432 ${LINK} ${OPTS} ${LDFLAGS} -o ${SHLIB} ${OBJECTS} ${DEPS}
433 ln -sf ${SHLIB} "lib${LIBNAME}.so"
434 FINAL_LIBS
="${SHLIB} lib${LIBNAME}.so"
439 if [ $STATIC = 1 ] ; then
440 LIBNAME
="lib${LIBNAME}_pic.a"
441 echo "mklib: Making NetBSD PIC static library: " ${LIBNAME}
443 ar cq
${LIBNAME} ${OBJECTS}
445 FINAL_LIBS
=${LIBNAME}
447 LIBNAME
="lib${LIBNAME}.so.${MAJOR}.${MINOR}"
448 echo "mklib: Making NetBSD PIC shared library: " ${LIBNAME}
450 ld
-x -Bshareable -Bforcearchive -o ${LIBNAME} ${OBJECTS}
451 FINAL_LIBS
=${LIBNAME}
456 if [ $STATIC = 1 ] ; then
457 LIBNAME
="lib${LIBNAME}.a"
459 ar rc
${LIBNAME} ${OBJECTS}
460 FINAL_LIBS
=${LIBNAME}
462 LIBNAME
="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
464 # examine first object to determine ABI
466 ABI_O32
=`file $1 | grep 'ELF 32-bit'`
467 ABI_N32
=`file $1 | grep 'ELF N32'`
468 ABI_N64
=`file $1 | grep 'ELF 64-bit'`
469 if [ "${ABI_O32}" ] ; then
470 OPTS
="-32 -shared -all"
472 elif [ "${ABI_N32}" ] ; then
473 OPTS
="-n32 -shared -all"
475 elif [ "${ABI_N64}" ] ; then
476 OPTS
="-64 -shared -all"
479 echo "Error: Unexpected IRIX ABI!"
483 if [ "${ALTOPTS}" ] ; then
487 if [ $CPLUSPLUS = 1 ] ; then
493 echo "mklib: Making IRIX " ${ABI} " shared library: " ${LIBNAME}
494 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
495 FINAL_LIBS
=${LIBNAME}
500 LIBNAME
="lib${LIBNAME}.a"
501 echo "mklib: Making linux-cygwin library: " ${LIBNAME}
503 gnuwin32ar ruv
${LIBNAME} ${OBJECTS}
504 FINAL_LIBS
=${LIBNAME}
508 if [ $STATIC = 1 ] ; then
509 LIBNAME
="lib${LIBNAME}.a"
510 echo "mklib: Making HP-UX static library: " ${LIBNAME}
512 ar -ruv ${LIBNAME} ${OBJECTS}
513 FINAL_LIBS
=${LIBNAME}
515 # HP uses a .2 for their current GL/GLU libraries
516 if [ ${LIBNAME} = "GL" -o ${LIBNAME} = "GLU" ] ; then
519 RUNLIB
="lib${LIBNAME}.${MAJOR}"
520 DEVLIB
="lib${LIBNAME}.sl"
521 echo "mklib: Making HP-UX shared library: " ${RUNLIB} ${DEVLIB}
522 ld
-b -o ${RUNLIB} +b ${RUNLIB} ${OBJECTS} ${DEPS}
523 ln -s ${RUNLIB} ${DEVLIB}
524 FINAL_LIBS
="${RUNLIB} ${DEVLIB}"
529 # examine first object to determine ABI
531 ABI_64
=`file $1 | grep '64-bit'`
532 if [ "${ABI_64}" ] ; then
537 OFILE
=shr.o
#Want to be consistent with the IBM libGL.a
540 if [ $STATIC = 1 ] ; then
541 LIBNAME
="lib${LIBNAME}.a"
542 echo "mklib: Making AIX static library: " ${LIBNAME}
543 ar -ruv ${X64} ${LIBNAME} ${OBJECTS}
544 FINAL_LIBS
=${LIBNAME}
546 EXPFILE
="lib${LIBNAME}.exp"
547 LIBNAME
="lib${LIBNAME}.a" # shared objects are still stored in the .a libraries
548 OPTS
="-bE:${EXPFILE} -bM:SRE -bnoentry ${Q64}"
549 rm -f ${EXPFILE} ${OFILE}
550 NM
="/bin/nm -eC ${X64}"
551 echo "#! /usr/lib/${LIBNAME}" > ${EXPFILE}
552 ${NM} ${OBJECTS} |
awk '{
553 if ((($2 == "T") || ($2 == "D") || ($2 == "B")) \
554 && ( substr($1,1,1) != ".")) {
555 if (substr ($1, 1, 7) != "__sinit" &&
556 substr ($1, 1, 7) != "__sterm") {
557 if (substr ($1, 1, 5) == "__tf1")
558 print (substr ($1, 7))
559 else if (substr ($1, 1, 5) == "__tf9")
560 print (substr ($1, 15))
565 }' |
sort -u >> ${EXPFILE}
567 if [ "${ALTOPTS}" ] ; then
571 # On AIX a shared library is linked differently when
572 # you want to dlopen the file
573 if [ $DLOPEN = "1" ] ; then
574 cc
-G ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
576 cc
${OPTS} ${LDFLAGS} -o ${OFILE} ${OBJECTS} ${DEPS}
577 ar ${X64} -r ${LIBNAME} ${OFILE}
580 FINAL_LIBS
="${LIBNAME}"
585 LIBNAME
="lib${LIBNAME}.a"
586 echo "mklib: Making OpenSTEP static library: " ${LIBNAME}
587 libtool
-static -o ${LIBNAME} - ${OBJECTS}
588 FINAL_LIBS
=${LIBNAME}
592 if [ $STATIC = 1 ] ; then
593 LIBNAME
="lib${LIBNAME}.a"
594 echo "mklib: Making OSF/1 static library: " ${LIBNAME}
596 ar -ruv ${LIBNAME} ${OBJECTS}
597 FINAL_LIBS
=${LIBNAME}
599 VERSION
="${MAJOR}.${MINOR}"
600 LIBNAME
="lib${LIBNAME}.so"
601 echo "mklib: Making OSF/1 shared library: " ${LIBNAME}
602 if [ "x$LINK" = "x" ] ; then
603 if [ $CPLUSPLUS = 1 ] ; then
609 rm -f ${LIBNAME}.
${VERSION}
610 ${LINK} -o ${LIBNAME}.${VERSION} -shared -set_version ${VERSION} -soname ${LIBNAME}.${VERSION} -expect_unresolved \* -all ${OBJECTS} ${DEPS}
611 ln -sf ${LIBNAME}.${VERSION} ${LIBNAME}
612 FINAL_LIBS
="${LIBNAME} ${LIBNAME}.${VERSION}"
617 if [ $STATIC = 1 ] ; then
618 LIBNAME
="lib${LIBNAME}.a"
619 echo "mklib: Making Darwin static library: " ${LIBNAME}
622 if [ "${ALTOPTS}" ] ; then
625 ${LINK} ${OPTS} ${LIBNAME} ${OBJECTS}
626 FINAL_LIBS
=${LIBNAME}
628 # On Darwin a .bundle is used for a library that you want to dlopen
629 if [ $DLOPEN = "1" ] ; then
631 OPTS
="${ARCHOPT} -bundle -multiply_defined suppress"
634 OPTS
="${ARCHOPT} -dynamiclib -multiply_defined suppress -current_version ${MAJOR}.${MINOR}.0 -compatibility_version ${MAJOR}.${MINOR}.0 -install_name lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}"
637 if [ ${EXPORTS} ] ; then
638 OPTS
="${OPTS} -exported_symbols_list ${EXPORTS}"
641 LINKNAME
="lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}"
642 LINKNAME2
="lib${LIBNAME}.${LIBSUFFIX}"
643 LIBNAME
="lib${LIBNAME}.${MAJOR}.${MINOR}.${LIBSUFFIX}"
645 # examine first object to determine ABI
647 ABI_PPC
=`file $1 | grep ' ppc'`
648 ABI_I386
=`file $1 | grep ' i386'`
649 ABI_PPC64
=`file $1 | grep ' ppc64'`
650 ABI_X86_64
=`file $1 | grep ' x86_64'`
651 if [ "${ABI_PPC}" ] ; then
652 OPTS
="${OPTS} -arch ppc"
654 if [ "${ABI_I386}" ] ; then
655 OPTS
="${OPTS} -arch i386"
657 if [ "${ABI_PPC64}" ] ; then
658 OPTS
="${OPTS} -arch ppc64"
660 if [ "${ABI_X86_64}" ] ; then
661 OPTS
="${OPTS} -arch x86_64"
664 if [ "${ALTOPTS}" ] ; then
668 # XXX can we always add -isysroot /Developer/SDKs/MacOSX10.4u.sdk
672 if [ $CPLUSPLUS = 1 ] ; then
678 echo "mklib: Making Darwin shared library: " ${LIBNAME}
680 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
681 ln -s ${LIBNAME} ${LINKNAME}
682 ln -s ${LIBNAME} ${LINKNAME2}
683 FINAL_LIBS
="${LIBNAME} ${LINKNAME} ${LINKNAME2}"
688 LIBNAME
="lib${LIBNAME}.a"
689 echo "mklib: Making LynxOS static library: " ${LIBNAME}
691 ar ru
${LIBNAME} ${OBJECTS}
692 FINAL_LIBS
=${LIBNAME}
696 if [ $STATIC = 1 ] ; then
697 LIBNAME
="lib${LIBNAME}.a"
698 echo "mklib: Making BeOS static library: " ${LIBNAME}
699 ar -cru "${LIBNAME}" ${OBJECTS}
701 LIBNAME
="lib${LIBNAME}.so"
702 echo "mklib: Making BeOS shared library: " ${LIBNAME}
703 gcc
-nostart -Xlinker "-soname=${LIBNAME}" -L/Be/develop/lib/x86 -lbe ${DEPS} ${OBJECTS} -o "${LIBNAME}"
704 mimeset
-f "${LIBNAME}"
705 # XXX remove the Mesa3D stuff here since mklib isn't mesa-specific.
706 setversion
"${LIBNAME}" -app ${MAJOR} ${MINOR} ${PATCH} -short "Powered by Mesa3D
!" -long "Powered by Mesa3D
!"
708 FINAL_LIBS=${LIBNAME}
712 LIBNAME="lib
${LIBNAME}.a
"
713 echo "mklib
: Making QNX library
: " ${LIBNAME}
714 wlib ${LIBNAME} ${OBJECTS}
715 FINAL_LIBS=${LIBNAME}
719 LIBNAME="lib
${LIBNAME}.a
"
720 echo "mklib
: Making MorphOS library
: " ${LIBNAME}
721 ppc-morphos-ar rc ${LIBNAME} ${OBJECTS}
722 FINAL_LIBS="${LIBNAME}"
725 'icc' | 'icc-istatic')
727 # This should get merged into the Linux code, above, since this isn't
728 # really a different architecture.
729 LIBNAME="lib
${LIBNAME}" # prefix with "lib
"
731 if [ $STATIC = 1 ] ; then
732 echo "mklib
: Making Intel ICC static library
: " ${LIBNAME}.a
735 if [ "${ALTOPTS}" ] ; then
739 ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
741 FINAL_LIBS="${LIBNAME}.a
"
743 if [ $ARCH = icc-istatic ] ; then
744 OPTS="-shared -i-static -cxxlib-icc"
748 if [ "${ALTOPTS}" ] ; then
751 VERSION="${MAJOR}.${MINOR}.${PATCH}"
752 echo "mklib
: Making Intel ICC shared library
: " ${LIBNAME}.so.${VERSION}
754 if [ $CPLUSPLUS = 1 ] ; then
760 rm -f ${LIBNAME}.so.${VERSION}
761 rm -f ${LIBNAME}.so.${MAJOR}
764 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
765 # make usual symlinks
766 ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR}
767 ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
769 FINAL_LIBS="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
"
775 if [ $STATIC = 1 ] ; then
776 LIBNAME="lib
${LIBNAME}.a
"
777 echo "mklib
: Making AIX GCC static library
: " ${LIBNAME}
779 ar ru ${LIBNAME} ${OBJECTS}
780 FINAL_LIBS=${LIBNAME}
782 LIBNAME="lib
${LIBNAME}.so
" # prefix with "lib
", suffix with ".so
"
783 echo "mklib
: Making AIX GCC shared library
: " ${LIBNAME}
787 gcc -shared -Wl,-G ${OBJECTS} ${DEPS} -o ${LIBNAME}
788 # NOTE: the application linking with this library must specify
789 # the -Wl,-brtl flags to gcc
790 FINAL_LIBS=${LIBNAME}
796 if [ $STATIC = 0 ] ; then
797 echo "mklib
: Warning shared libs not supported on Ultrix
"
799 LIBNAME="lib
${LIBNAME}.a
"
800 echo "mklib
: Making static library
for Ultrix
: " ${LIBNAME}
802 ar ru ${LIBNAME} ${OBJECTS}
803 FINAL_LIBS="${LIBNAME}"
807 # GCC-based environment
808 CYGNAME="cyg
${LIBNAME}" # prefix with "cyg
"
809 LIBNAME="lib
${LIBNAME}" # prefix with "lib
"
811 if [ $STATIC = 1 ] ; then
812 echo "mklib
: Making
" $ARCH "static library
: " ${LIBNAME}.a
815 if [ "${ALTOPTS}" ] ; then
819 ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
822 FINAL_LIBS=${LIBNAME}.a
824 OPTS="-shared -Wl,-export-all -Wl,--out-implib=${LIBNAME}-${MAJOR}.dll.a
"
825 if [ "${ALTOPTS}" ] ; then
828 echo "mklib
: Making
" $ARCH "shared library
: " ${LIBNAME}-${MAJOR}.dll
830 if [ $CPLUSPLUS = 1 ] ; then
837 rm -f ${LIBNAME}-${MAJOR}.dll
838 rm -f ${LIBNAME}.dll.a
842 ${LINK} ${OPTS} ${LDFLAGS} -o ${CYGNAME}-${MAJOR}.dll ${OBJECTS} ${DEPS}
843 # make usual symlinks
844 ln -s ${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a
846 FINAL_LIBS="${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a
"
847 # special case for installing in bin
848 FINAL_BINS="${CYGNAME}-${MAJOR}.dll
"
853 # If you're adding support for a new architecture, you can
855 if [ $STATIC = 1 ] ; then
856 LIBNAME="lib
${LIBNAME}.a
"
857 echo "mklib
: Making static library
for example arch
: " ${LIBNAME}
859 ar rv ${LIBNAME} ${OBJECTS}
860 FINAL_LIBS="${LIBNAME}"
862 LIBNAME="lib
${LIBNAME}.so
" # prefix with "lib
", suffix with ".so
"
863 echo "mklib
: Making shared library
for example arch
: " ${LIBNAME}
864 ld -o ${LIBNAME} ${OBJECTS} ${DEPS}
865 FINAL_LIBS="${LIBNAME}"
870 echo "mklib
: ERROR
: Don
't know how to make a static/shared library for" ${ARCH}
871 echo "mklib: Please add necessary commands to mklib script."
877 # Put library files into installation directory if specified.
879 if [ ${INSTALLDIR} != "." ] ; then
880 echo "mklib: Installing" ${FINAL_LIBS} "in" ${INSTALLDIR}
881 mv ${FINAL_LIBS} ${INSTALLDIR}/