# -arch ARCH override using `uname` to determine architecture
# -archopt OPT specify an extra achitecture-specific option OPT
# -noprefix don't prefix library name with "lib" or any suffix
+# -exports FILE only export the symbols listed in FILE
#
# The library name should just be "GL" or "GLU", etc. The 'lib' prefix
# will be added here if needed, as well as the ".so" or ".a" suffix,
ARCH="auto"
ARCHOPT=""
NOPREFIX=0
+EXPORTS=""
#
'-arch') shift 1; ARCH=$1;;
'-archopt') shift 1; ARCHOPT=$1;;
'-noprefix') NOPREFIX=1;;
+ '-exports') shift 1; EXPORTS=$1;;
-*) echo "mklib: Unknown option: " $1 ; exit 1;;
*) break
esac
echo MINOR is $MINOR
echo PATCH is $PATCH
echo DEPS are $DEPS
+ echo "EXPORTS in" $EXPORTS
echo "-----------------"
fi
case $ARCH in
'Linux' | 'OpenBSD')
- # GCC-based environment
+ # we assume gcc
# Set default compilers if env vars not set
if [ "x$CXX" = "x" ] ; then
else
OPTS="-shared -Wl,-soname,${LIBNAME}.so.${MAJOR}"
fi
+ if [ $EXPORTS ] ; then
+ #OPTS="${OPTS} -Xlinker --retain-symbols-file ${EXPORTS}"
+ # Make the 'exptmp' file for --version-script option
+ echo "VERSION_${MAJOR}.${MINOR} {" > exptmp
+ echo "global:" >> exptmp
+ sed 's/$/;/' ${EXPORTS} >> exptmp
+ echo "local:" >> exptmp
+ echo "*;" >> exptmp
+ echo "};" >> exptmp
+ OPTS="${OPTS} -Xlinker --version-script=exptmp"
+ # exptmp is removed below
+ fi
+
+ # Check if objects are 32-bit and we're running in 64-bit
+ # environment. If so, pass -m32 flag to linker.
+ set ${OBJECTS}
+ ABI32=`file $1 | grep 32-bit`
+ if [ "${ABI32}" -a `uname -m` = "x86_64" ] ; then
+ OPTS="-m32 ${OPTS}"
+ fi
+
if [ x${PATCH} = "x" ] ; then
VERSION="${MAJOR}.${MINOR}"
else
ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
# finish up
FINAL_LIBS="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so"
+# rm -f exptmp
fi
;;
fi
;;
- 'AIX')
- if [ $STATIC = 1 ] ; then
- LIBNAME="lib${LIBNAME}.a"
- echo "mklib: Making AIX static library: " ${LIBNAME}
- ar -ruv ${LIBNAME} ${OBJECTS}
- FINAL_LIBS=${LIBNAME}
- else
- EXPFILE="lib${LIBNAME}.exp"
- OFILE=shr.o #Want to be consistent with the IBM libGL.a
- LIBNAME="lib${LIBNAME}.a" # shared objects are still stored in the .a libraries
- OPTS="-bE:${EXPFILE} -bM:SRE -bnoentry"
- rm -f ${EXPFILE} ${OFILE}
- NM="/bin/nm -eC"
- echo "#! /usr/lib/${LIBNAME}" > ${EXPFILE}
- ${NM} ${OBJECTS} | awk '{
- if ((($2 == "T") || ($2 == "D") || ($2 == "B")) \
- && ( substr($1,1,1) != ".")) {
- if (substr ($1, 1, 7) != "__sinit" &&
- substr ($1, 1, 7) != "__sterm") {
- if (substr ($1, 1, 5) == "__tf1")
- print (substr ($1, 7))
- else if (substr ($1, 1, 5) == "__tf9")
- print (substr ($1, 15))
- else
- print $1
- }
- }
- }' | sort -u >> ${EXPFILE}
- cc ${OPTS} -o ${OFILE} ${OBJECTS} ${DEPS}
- ar -r ${LIBNAME} ${OFILE}
- FINAL_LIBS="${LIBNAME}"
- fi
- ;;
+ 'AIX' | 'AIX64')
+ if [ $ARCH = "AIX64" ] ; then
+ X64="-X64"
+ fi
- 'AIX64')
if [ $STATIC = 1 ] ; then
LIBNAME="lib${LIBNAME}.a"
echo "mklib: Making AIX static library: " ${LIBNAME}
- ar -X64 -ruv ${LIBNAME} ${OBJECTS}
+ ar -ruv ${X64} ${LIBNAME} ${OBJECTS}
FINAL_LIBS=${LIBNAME}
else
EXPFILE="lib${LIBNAME}.exp"
OFILE=shr.o #Want to be consistent with the IBM libGL.a
LIBNAME="lib${LIBNAME}.a" # shared objects are still stored in the .a libraries
- OPTS="-bE:${EXPFILE} -bM:SRE -bnoentry -q64"
+ if [ $ARCH = "AIX64" ] ; then
+ OPTS="-bE:${EXPFILE} -bM:SRE -bnoentry -q64"
+ else
+ OPTS="-bE:${EXPFILE} -bM:SRE -bnoentry"
+ fi
rm -f ${EXPFILE} ${OFILE}
- NM="/bin/nm -eC -X64"
+ NM="/bin/nm -eC ${X64}"
echo "#! /usr/lib/${LIBNAME}" > ${EXPFILE}
${NM} ${OBJECTS} | awk '{
if ((($2 == "T") || ($2 == "D") || ($2 == "B")) \
}
}' | sort -u >> ${EXPFILE}
cc ${OPTS} -o ${OFILE} ${OBJECTS} ${DEPS}
- ar -X64 -r ${LIBNAME} ${OFILE}
+ ar ${X64} -r ${LIBNAME} ${OFILE}
FINAL_LIBS="${LIBNAME}"
fi
;;
VERSION="${MAJOR}.${MINOR}"
LIBNAME="lib${LIBNAME}.so"
echo "mklib: Making OSF/1 shared library: " ${LIBNAME}
+ if [ $CPLUSPLUS = 1 ] ; then
+ LINK=$CXX
+ else
+ LINK=$CC
+ fi
rm -f ${LIBNAME}.${VERSION}
- ld -o ${LIBNAME}.${VERSION} -shared -no_archive -set_version ${VERSION} -soname ${LIBNAME}.${VERSION} -expect_unresolved \* -all ${OBJECTS} ${DEPS}
+ ${LINK} -o ${LIBNAME}.${VERSION} -shared -set_version ${VERSION} -soname ${LIBNAME}.${VERSION} -expect_unresolved \* -all ${OBJECTS} ${DEPS}
ln -sf ${LIBNAME}.${VERSION} ${LIBNAME}
FINAL_LIBS="${LIBNAME} ${LIBNAME}.${VERSION}"
fi