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 # Check if objects are SPARC v9
398 # file says: ELF 64-bit MSB relocatable SPARCV9 Version 1
400 if [ ${LINK} = "cc" -o ${LINK} = "CC" ] ; then
401 SPARCV9=`file $1 | grep SPARCV9`
402 if [ "${SPARCV9}" ] ; then
403 OPTS="${OPTS} -xarch=v9"
406 if [ "${ALTOPTS}" ] ; then
410 #echo "mklib: linker is" ${LINK} ${OPTS}
411 if [ $NOPREFIX = 1 ] ; then
413 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
415 rm -f ${LIBNAME}.${MAJOR} ${LIBNAME}
416 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.${MAJOR} -h ${LIBNAME}.${MAJOR} ${OBJECTS} ${DEPS}
417 ln -s ${LIBNAME}.${MAJOR} ${LIBNAME}
419 FINAL_LIBS="${LIBNAME}.${MAJOR} ${LIBNAME}"
426 if [ "x$LINK" = "x" ] ; then
427 # -linker was not specified so set default link command now
428 if [ $CPLUSPLUS = 1 ] ; then
435 if [ $NOPREFIX = 1 ] ; then
436 # No "lib" or ".so" part
437 echo "mklib: Making FreeBSD shared library: " ${LIBNAME}
439 if [ "${ALTOPTS}" ] ; then
443 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
444 FINAL_LIBS=${LIBNAME}
445 elif [ $STATIC = 1 ] ; then
446 STLIB="lib${LIBNAME}.a"
447 echo "mklib: Making FreeBSD static library: " ${STLIB}
449 ar cq ${STLIB} ${OBJECTS}
453 SHLIB="lib${LIBNAME}.so.${MAJOR}"
454 OPTS="-shared -Wl,-soname,${SHLIB}"
455 if [ "${ALTOPTS}" ] ; then
458 echo "mklib: Making FreeBSD shared library: " ${SHLIB}
460 ${LINK} ${OPTS} ${LDFLAGS} -o ${SHLIB} ${OBJECTS} ${DEPS}
461 ln -sf ${SHLIB} "lib${LIBNAME}.so"
462 FINAL_LIBS="${SHLIB} lib${LIBNAME}.so"
467 if [ $STATIC = 1 ] ; then
468 LIBNAME="lib${LIBNAME}_pic.a"
469 echo "mklib: Making NetBSD PIC static library: " ${LIBNAME}
471 ar cq ${LIBNAME} ${OBJECTS}
473 FINAL_LIBS=${LIBNAME}
475 LIBNAME="lib${LIBNAME}.so.${MAJOR}.${MINOR}"
476 echo "mklib: Making NetBSD PIC shared library: " ${LIBNAME}
478 ld -x -Bshareable -Bforcearchive -o ${LIBNAME} ${OBJECTS}
479 FINAL_LIBS=${LIBNAME}
484 if [ $STATIC = 1 ] ; then
485 LIBNAME="lib${LIBNAME}.a"
487 ar rc ${LIBNAME} ${OBJECTS}
488 FINAL_LIBS=${LIBNAME}
490 LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
492 # examine first object to determine ABI
494 ABI_O32=`file $1 | grep 'ELF 32-bit'`
495 ABI_N32=`file $1 | grep 'ELF N32'`
496 ABI_N64=`file $1 | grep 'ELF 64-bit'`
497 if [ "${ABI_O32}" ] ; then
498 OPTS="-32 -shared -all"
500 elif [ "${ABI_N32}" ] ; then
501 OPTS="-n32 -shared -all"
503 elif [ "${ABI_N64}" ] ; then
504 OPTS="-64 -shared -all"
507 echo "Error: Unexpected IRIX ABI!"
511 if [ "${ALTOPTS}" ] ; then
515 if [ $CPLUSPLUS = 1 ] ; then
521 echo "mklib: Making IRIX " ${ABI} " shared library: " ${LIBNAME}
522 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
523 FINAL_LIBS=${LIBNAME}
528 LIBNAME="lib${LIBNAME}.a"
529 echo "mklib: Making linux-cygwin library: " ${LIBNAME}
531 gnuwin32ar ruv ${LIBNAME} ${OBJECTS}
532 FINAL_LIBS=${LIBNAME}
536 if [ $STATIC = 1 ] ; then
537 LIBNAME="lib${LIBNAME}.a"
538 echo "mklib: Making HP-UX static library: " ${LIBNAME}
540 ar -ruv ${LIBNAME} ${OBJECTS}
541 FINAL_LIBS=${LIBNAME}
543 # HP uses a .2 for their current GL/GLU libraries
544 if [ ${LIBNAME} = "GL" -o ${LIBNAME} = "GLU" ] ; then
547 RUNLIB="lib${LIBNAME}.${MAJOR}"
548 DEVLIB="lib${LIBNAME}.sl"
549 echo "mklib: Making HP-UX shared library: " ${RUNLIB} ${DEVLIB}
550 ld -b -o ${RUNLIB} +b ${RUNLIB} ${OBJECTS} ${DEPS}
551 ln -s ${RUNLIB} ${DEVLIB}
552 FINAL_LIBS="${RUNLIB} ${DEVLIB}"
557 # examine first object to determine ABI
559 ABI_64=`file $1 | grep '64-bit'`
560 if [ "${ABI_64}" ] ; then
565 OFILE=shr.o #Want to be consistent with the IBM libGL.a
568 if [ $STATIC = 1 ] ; then
569 LIBNAME="lib${LIBNAME}.a"
570 echo "mklib: Making AIX static library: " ${LIBNAME}
571 ar -ruv ${X64} ${LIBNAME} ${OBJECTS}
572 FINAL_LIBS=${LIBNAME}
574 EXPFILE="lib${LIBNAME}.exp"
575 LIBNAME="lib${LIBNAME}.a" # shared objects are still stored in the .a libraries
576 OPTS="-bE:${EXPFILE} -bM:SRE -bnoentry ${Q64}"
577 rm -f ${EXPFILE} ${OFILE}
578 NM="/bin/nm -eC ${X64}"
579 echo "#! /usr/lib/${LIBNAME}" > ${EXPFILE}
580 ${NM} ${OBJECTS} | awk '{
581 if ((($2 == "T") || ($2 == "D") || ($2 == "B")) \
582 && ( substr($1,1,1) != ".")) {
583 if (substr ($1, 1, 7) != "__sinit" &&
584 substr ($1, 1, 7) != "__sterm") {
585 if (substr ($1, 1, 5) == "__tf1")
586 print (substr ($1, 7))
587 else if (substr ($1, 1, 5) == "__tf9")
588 print (substr ($1, 15))
593 }' | sort -u >> ${EXPFILE}
595 if [ "${ALTOPTS}" ] ; then
599 # On AIX a shared library is linked differently when
600 # you want to dlopen the file
601 if [ $DLOPEN = "1" ] ; then
602 cc -G ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
604 cc ${OPTS} ${LDFLAGS} -o ${OFILE} ${OBJECTS} ${DEPS}
605 ar ${X64} -r ${LIBNAME} ${OFILE}
608 FINAL_LIBS="${LIBNAME}"
613 LIBNAME="lib${LIBNAME}.a"
614 echo "mklib: Making OpenSTEP static library: " ${LIBNAME}
615 libtool -static -o ${LIBNAME} - ${OBJECTS}
616 FINAL_LIBS=${LIBNAME}
620 if [ $STATIC = 1 ] ; then
621 LIBNAME="lib${LIBNAME}.a"
622 echo "mklib: Making OSF/1 static library: " ${LIBNAME}
624 ar -ruv ${LIBNAME} ${OBJECTS}
625 FINAL_LIBS=${LIBNAME}
627 VERSION="${MAJOR}.${MINOR}"
628 LIBNAME="lib${LIBNAME}.so"
629 echo "mklib: Making OSF/1 shared library: " ${LIBNAME}
630 if [ "x$LINK" = "x" ] ; then
631 if [ $CPLUSPLUS = 1 ] ; then
637 rm -f ${LIBNAME}.${VERSION}
638 ${LINK} -o ${LIBNAME}.${VERSION} -shared -set_version ${VERSION} -soname ${LIBNAME}.${VERSION} -expect_unresolved \* -all ${OBJECTS} ${DEPS}
639 ln -sf ${LIBNAME}.${VERSION} ${LIBNAME}
640 FINAL_LIBS="${LIBNAME} ${LIBNAME}.${VERSION}"
645 if [ $STATIC = 1 ] ; then
646 LIBNAME="lib${LIBNAME}.a"
647 echo "mklib: Making Darwin static library: " ${LIBNAME}
650 if [ "${ALTOPTS}" ] ; then
653 ${LINK} ${OPTS} ${LIBNAME} ${OBJECTS}
654 FINAL_LIBS=${LIBNAME}
656 # On Darwin a .bundle is used for a library that you want to dlopen
657 if [ $DLOPEN = "1" ] ; then
659 OPTS="${ARCHOPT} -bundle -multiply_defined suppress"
662 if [ -z "$ID" ] ; then
663 ID="lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}"
665 OPTS="${ARCHOPT} -dynamiclib -multiply_defined suppress -current_version ${MAJOR}.${MINOR}.0 -compatibility_version ${MAJOR}.${MINOR}.0 -install_name ${ID}"
668 if [ ${EXPORTS} ] ; then
669 if [ -f ${EXPORTS}".darwin" ] ; then
670 EXPORTS=$EXPORTS".darwin"
672 OPTS="${OPTS} -exported_symbols_list ${EXPORTS}"
675 LINKNAME="lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}"
676 LINKNAME2="lib${LIBNAME}.${LIBSUFFIX}"
677 LIBNAME="lib${LIBNAME}.${MAJOR}.${MINOR}.${LIBSUFFIX}"
679 # examine first object to determine ABI
681 ABI_PPC=`file $1 | grep ' ppc'`
682 ABI_I386=`file $1 | grep ' i386'`
683 ABI_PPC64=`file $1 | grep ' ppc64'`
684 ABI_X86_64=`file $1 | grep ' x86_64'`
685 if [ "${ABI_PPC}" ] ; then
686 OPTS="${OPTS} -arch ppc"
688 if [ "${ABI_I386}" ] ; then
689 OPTS="${OPTS} -arch i386"
691 if [ "${ABI_PPC64}" ] ; then
692 OPTS="${OPTS} -arch ppc64"
694 if [ "${ABI_X86_64}" ] ; then
695 OPTS="${OPTS} -arch x86_64"
698 if [ "${ALTOPTS}" ] ; then
702 # XXX can we always add -isysroot /Developer/SDKs/MacOSX10.4u.sdk
706 if [ $CPLUSPLUS = 1 ] ; then
712 echo "mklib: Making Darwin shared library: " ${LIBNAME}
714 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
715 ln -s ${LIBNAME} ${LINKNAME}
716 ln -s ${LIBNAME} ${LINKNAME2}
717 FINAL_LIBS="${LIBNAME} ${LINKNAME} ${LINKNAME2}"
722 LIBNAME="lib${LIBNAME}.a"
723 echo "mklib: Making LynxOS static library: " ${LIBNAME}
725 ar ru ${LIBNAME} ${OBJECTS}
726 FINAL_LIBS=${LIBNAME}
730 if [ $STATIC = 1 ] ; then
731 LIBNAME="lib${LIBNAME}.a"
732 echo "mklib: Making BeOS static library: " ${LIBNAME}
733 ar -cru "${LIBNAME}" ${OBJECTS}
735 LIBNAME="lib${LIBNAME}.so"
736 echo "mklib: Making BeOS shared library: " ${LIBNAME}
737 gcc -nostart -Xlinker "-soname=${LIBNAME}" -L/Be/develop/lib/x86 -lbe ${DEPS} ${OBJECTS} -o "${LIBNAME}"
738 mimeset -f "${LIBNAME}"
739 # XXX remove the Mesa3D stuff here since mklib isn't mesa-specific.
740 setversion "${LIBNAME}" -app ${MAJOR} ${MINOR} ${PATCH} -short "Powered by Mesa3D!" -long "Powered by Mesa3D!"
742 FINAL_LIBS=${LIBNAME}
746 LIBNAME="lib${LIBNAME}.a"
747 echo "mklib: Making QNX library: " ${LIBNAME}
748 wlib ${LIBNAME} ${OBJECTS}
749 FINAL_LIBS=${LIBNAME}
753 LIBNAME="lib${LIBNAME}.a"
754 echo "mklib: Making MorphOS library: " ${LIBNAME}
755 ppc-morphos-ar rc ${LIBNAME} ${OBJECTS}
756 FINAL_LIBS="${LIBNAME}"
759 'icc' | 'icc-istatic')
761 # This should get merged into the Linux code, above, since this isn't
762 # really a different architecture.
763 LIBNAME="lib${LIBNAME}" # prefix with "lib"
765 if [ $STATIC = 1 ] ; then
766 echo "mklib: Making Intel ICC static library: " ${LIBNAME}.a
769 if [ "${ALTOPTS}" ] ; then
773 ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
775 FINAL_LIBS="${LIBNAME}.a"
777 if [ $ARCH = icc-istatic ] ; then
778 OPTS="-shared -i-static -cxxlib-icc"
782 if [ "${ALTOPTS}" ] ; then
785 VERSION="${MAJOR}.${MINOR}.${PATCH}"
786 echo "mklib: Making Intel ICC shared library: " ${LIBNAME}.so.${VERSION}
788 if [ $CPLUSPLUS = 1 ] ; then
794 rm -f ${LIBNAME}.so.${VERSION}
795 rm -f ${LIBNAME}.so.${MAJOR}
798 ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
799 # make usual symlinks
800 ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR}
801 ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
803 FINAL_LIBS="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so"
809 if [ $STATIC = 1 ] ; then
810 LIBNAME="lib${LIBNAME}.a"
811 echo "mklib: Making AIX GCC static library: " ${LIBNAME}
813 ar ru ${LIBNAME} ${OBJECTS}
814 FINAL_LIBS=${LIBNAME}
816 LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
817 echo "mklib: Making AIX GCC shared library: " ${LIBNAME}
821 gcc -shared -Wl,-G ${OBJECTS} ${DEPS} -o ${LIBNAME}
822 # NOTE: the application linking with this library must specify
823 # the -Wl,-brtl flags to gcc
824 FINAL_LIBS=${LIBNAME}
830 if [ $STATIC = 0 ] ; then
831 echo "mklib: Warning shared libs not supported on Ultrix"
833 LIBNAME="lib${LIBNAME}.a"
834 echo "mklib: Making static library for Ultrix: " ${LIBNAME}
836 ar ru ${LIBNAME} ${OBJECTS}
837 FINAL_LIBS="${LIBNAME}"
841 # GCC-based environment
842 CYGNAME="cyg${LIBNAME}" # prefix with "cyg"
843 LIBNAME="lib${LIBNAME}" # prefix with "lib"
845 if [ $STATIC = 1 ] ; then
846 echo "mklib: Making" $ARCH "static library: " ${LIBNAME}.a
849 if [ "${ALTOPTS}" ] ; then
853 ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
856 FINAL_LIBS=${LIBNAME}.a
858 OPTS="-shared -Wl,-export-all -Wl,--out-implib=${LIBNAME}-${MAJOR}.dll.a"
859 if [ "${ALTOPTS}" ] ; then
862 echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}-${MAJOR}.dll
864 if [ $CPLUSPLUS = 1 ] ; then
871 rm -f ${LIBNAME}-${MAJOR}.dll
872 rm -f ${LIBNAME}.dll.a
876 ${LINK} ${OPTS} ${LDFLAGS} -o ${CYGNAME}-${MAJOR}.dll ${OBJECTS} ${DEPS}
877 # make usual symlinks
878 ln -s ${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a
880 FINAL_LIBS="${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a"
881 # special case for installing in bin
882 FINAL_BINS="${CYGNAME}-${MAJOR}.dll"
887 # If you're adding support for a new architecture, you can
889 if [ $STATIC = 1 ] ; then
890 LIBNAME="lib${LIBNAME}.a"
891 echo "mklib: Making static library for example arch: " ${LIBNAME}
893 ar rv ${LIBNAME} ${OBJECTS}
894 FINAL_LIBS="${LIBNAME}"
896 LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
897 echo "mklib: Making shared library for example arch: " ${LIBNAME}
898 ld -o ${LIBNAME} ${OBJECTS} ${DEPS}
899 FINAL_LIBS="${LIBNAME}"
904 echo "mklib: ERROR: Don't know how to make a static/shared library for" ${ARCH}
905 echo "mklib: Please add necessary commands to mklib script."
911 # Put library files into installation directory if specified.
913 if [ ${INSTALLDIR} != "." ] ; then
914 echo "mklib: Installing" ${FINAL_LIBS} "in" ${INSTALLDIR}
915 mv ${FINAL_LIBS} ${INSTALLDIR}/