summaryrefslogtreecommitdiff
path: root/bin/mklib
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2006-04-13 02:23:25 +0000
committerBrian Paul <brian.paul@tungstengraphics.com>2006-04-13 02:23:25 +0000
commitfe14cf6951a8a925994dfe6a540784f2ed6ad3bf (patch)
treeb4654b56053e9a3af9253881e72a2f3a64e7966d /bin/mklib
parentecc0d10d2dc8b4c930a00589baa81054f8b9c2da (diff)
Fixes for AIX, SunOS, Darwin. -dlopen flag to build dlopen()'able modules
for AIX, Darwin. (Dan Schikore)
Diffstat (limited to 'bin/mklib')
-rwxr-xr-xbin/mklib62
1 files changed, 51 insertions, 11 deletions
diff --git a/bin/mklib b/bin/mklib
index befda6632b..b8f7a0127f 100755
--- a/bin/mklib
+++ b/bin/mklib
@@ -36,6 +36,7 @@ DEPS=""
LINK=""
CPLUSPLUS=0
STATIC=0
+DLOPEN=0
INSTALLDIR="."
ARCH="auto"
ARCHOPT=""
@@ -64,6 +65,7 @@ do
echo ' Not observed on all systems at this time.'
echo ' -cplusplus link with C++ runtime'
echo ' -static make a static library (default is dynamic/shared)'
+ echo ' -dlopen make a shared library suitable for dynamic loading'
echo ' -install DIR put resulting library file(s) in DIR'
echo ' -arch ARCH override using `uname` to determine host system'
echo ' -archopt OPT specify an extra achitecture-specific option OPT'
@@ -104,6 +106,9 @@ do
'-static')
STATIC=1
;;
+ '-dlopen')
+ DLOPEN=1
+ ;;
'-install')
shift 1;
INSTALLDIR=$1
@@ -314,11 +319,17 @@ case $ARCH in
fi
fi
+ ARCHOPTS=""
+ if [ "$ARCHOPT" = "SUNV9" ] ; then
+ ARCHOPTS="-xarch=v9"
+ fi
+ echo "mklib: linker is" ${LINK} ${OPTS} ${ARCHOPTS}
+
# for debug:
#echo "mklib: linker is" ${LINK} ${OPTS}
rm -f ${LIBNAME}.${MAJOR} ${LIBNAME}
- ${LINK} ${OPTS} -o ${LIBNAME}.${MAJOR} ${OBJECTS} ${DEPS}
+ ${LINK} ${OPTS} ${ARCHOPTS} -o ${LIBNAME}.${MAJOR} ${OBJECTS} ${DEPS}
ln -s ${LIBNAME}.${MAJOR} ${LIBNAME}
FINAL_LIBS="${LIBNAME}.${MAJOR} ${LIBNAME}"
fi
@@ -427,6 +438,10 @@ case $ARCH in
ar -ruv ${LIBNAME} ${OBJECTS}
FINAL_LIBS=${LIBNAME}
else
+ # HP uses a .2 for their current GL/GLU libraries
+ if [ ${LIBNAME} = "GL" -o ${LIBNAME} = "GLU" ] ; then
+ MAJOR=2
+ fi
RUNLIB="lib${LIBNAME}.${MAJOR}"
DEVLIB="lib${LIBNAME}.sl"
echo "mklib: Making HP-UX shared library: " ${RUNLIB} ${DEVLIB}
@@ -449,7 +464,11 @@ case $ARCH in
FINAL_LIBS=${LIBNAME}
else
EXPFILE="lib${LIBNAME}.exp"
- OFILE=shr.o #Want to be consistent with the IBM libGL.a
+ if [ $ARCH = "AIX64" ] ; then
+ OFILE=shr_64.o
+ else
+ OFILE=shr.o #Want to be consistent with the IBM libGL.a
+ fi
LIBNAME="lib${LIBNAME}.a" # shared objects are still stored in the .a libraries
if [ $ARCH = "AIX64" ] ; then
OPTS="-bE:${EXPFILE} -bM:SRE -bnoentry -q64"
@@ -473,8 +492,15 @@ case $ARCH in
}
}
}' | sort -u >> ${EXPFILE}
- cc ${OPTS} -o ${OFILE} ${OBJECTS} ${DEPS}
- ar ${X64} -r ${LIBNAME} ${OFILE}
+
+ # On AIX a shared library is linked differently when
+ # you want to dlopen the file
+ if [ $DLOPEN = "1" ] ; then
+ cc -G ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
+ else
+ cc ${OPTS} -o ${OFILE} ${OBJECTS} ${DEPS}
+ ar ${X64} -r ${LIBNAME} ${OFILE}
+ fi
FINAL_LIBS="${LIBNAME}"
fi
;;
@@ -516,23 +542,33 @@ case $ARCH in
LIBNAME="lib${LIBNAME}.a"
echo "mklib: Making Darwin static library: " ${LIBNAME}
LINK="ar"
- OPTS="-ruv"
+ OPTS="-ruvs"
${LINK} ${OPTS} ${LIBNAME} ${OBJECTS}
FINAL_LIBS=${LIBNAME}
else
# may need these:
# CFLAGS += -fno-common
# LDFLAGS += -bundle -flat_namespace -undefined suppress
- LIBNAME="lib${LIBNAME}.dylib"
+ # On Darwin a .bundle is used for a library that you want to dlopen
+ if [ $DLOPEN = "1" ] ; then
+ LIBSUFFIX="bundle"
+ FLAGS="${ARCHOPT} -bundle -multiply_defined suppress"
+ else
+ LIBSUFFIX="dylib"
+ FLAGS="${ARCHOPT} -dynamiclib -multiply_defined suppress -current_version ${MAJOR}.${MINOR}.0 -compatibility_version ${MAJOR}.${MINOR}.0 -install_name lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}"
+ fi
+ LINKNAME="lib${LIBNAME}.${LIBSUFFIX}"
+ LIBNAME="lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}"
+
echo "mklib: Making Darwin shared library: " ${LIBNAME}
- FLAGS="-dynamiclib -multiply_defined suppress -current_version ${MAJOR}.${MINOR}.0 -compatibility_version ${MAJOR}.${MINOR}.0"
if [ $CPLUSPLUS = 1 ] ; then
LINK="g++"
else
LINK="cc"
fi
${LINK} ${FLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
- FINAL_LIBS=${LIBNAME}
+ ln -s ${LIBNAME} ${LINKNAME}
+ FINAL_LIBS="${LIBNAME} ${LINKNAME}"
fi
;;
@@ -574,7 +610,7 @@ case $ARCH in
FINAL_LIBS="${LIBNAME}"
;;
- 'icc')
+ 'icc' | 'icc-istatic')
# Intel C compiler
# This should get merged into the Linux code, above, since this isn't
# really a different architecture.
@@ -589,12 +625,16 @@ case $ARCH in
# finish up
FINAL_LIBS="${LIBNAME}.a"
else
- OPTS="-shared"
+ if [ $ARCH = icc-istatic ] ; then
+ OPTS="-shared -i-static -cxxlib-icc"
+ else
+ OPTS="-shared"
+ fi
VERSION="${MAJOR}.${MINOR}.${PATCH}"
echo "mklib: Making Intel ICC shared library: " ${LIBNAME}.so.${VERSION}
if [ $CPLUSPLUS = 1 ] ; then
- LINK="icc"
+ LINK="icpc"
else
LINK="icc"
fi