# -patch N specifies patch version number (default is 0)
# -lLIBRARY specifies a dependency on LIBRARY
# -LDIR search in DIR for library dependencies
+# -linker L explicity specify the linker program to use (ex: gcc, g++)
+# Not observed on all systems at this time.
# -cplusplus link with C++ runtime
# -static make a static library (default is dynamic/shared)
-# -install DIR move resulting library file(s) to DIR
+# -install DIR pu resulting library file(s) in DIR
# -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
+# -noprefix don't prefix library name with "lib" nor add any suffix
# -exports FILE only export the symbols listed in FILE
#
# The library name should just be "GL" or "GLU", etc. The 'lib' prefix
#
# objects should be: foo.o bar.o etc.o
#
-# Environment variables recognized:
-# CC C compiler command
-# CXX C++ compiler command
-#
#
MINOR=0
PATCH=""
DEPS=""
+LINK=""
CPLUSPLUS=0
STATIC=0
INSTALLDIR="."
'-major') shift 1; MAJOR=$1;;
'-minor') shift 1; MINOR=$1;;
'-patch') shift 1; PATCH=$1;;
+ '-linker') shift 1; LINK=$1;;
-l*) DEPS="$DEPS $1";;
-L*) DEPS="$DEPS $1";;
'-cplusplus') CPLUSPLUS=1;;
'Linux' | 'OpenBSD')
# we assume gcc
- # Set default compilers if env vars not set
- if [ "x$CXX" = "x" ] ; then
- CXX=g++
- fi
- if [ "x$CC" = "x" ] ; then
- CC=gcc
+ if [ "x$LINK" = "x" ] ; then
+ # -linker was not specified so set default link command now
+ if [ $CPLUSPLUS = 1 ] ; then
+ LINK=g++
+ else
+ LINK=gcc
+ fi
fi
if [ $NOPREFIX = 1 ] ; then
echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}
#OPTS="-shared -Wl,-soname,${LIBNAME}" # soname???
OPTS="-shared"
- if [ $CPLUSPLUS = 1 ] ; then
- LINK=$CXX
- else
- LINK=$CC
- fi
rm -f ${LIBNAME}
-
# make lib
${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
# finish up
echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}.so.${VERSION}
- if [ $CPLUSPLUS = 1 ] ; then
- LINK=$CXX
- else
- LINK=$CC
- fi
-
# rm any old libs
rm -f ${LIBNAME}.so.${VERSION}
rm -f ${LIBNAME}.so.${MAJOR}
echo "mklib: Making SunOS shared library: " ${LIBNAME}
# XXX OPTS for gcc should be -shared, but that doesn't work.
# Using -G does work though.
- if [ $CPLUSPLUS = 1 ] ; then
- # determine linker and options for C++ code
- if [ "x${CXX}" = "xg++" ] ; then
- # use g++
- LINK="g++"
- OPTS="-G"
- elif [ "x${CXX}" = "xCC" ] ; then
- # use Sun CC
- LINK="CC"
- OPTS="-G"
- elif [ "x${CXX}" = "xc++" ] ; then
- # use Sun c++
- LINK="c++"
- OPTS="-G"
- elif [ `which c++` ] ; then
- # use Sun c++
- LINK="c++"
- OPTS="-G"
- elif [ `type g++` ] ; then
- # use g++
- LINK="g++"
- OPTS="-G"
+ OPTS="-G"
+ if [ "x$LINK" = "x" ] ; then
+ # -linker was not specified, choose default linker now
+ if [ $CPLUSPLUS = 1 ] ; then
+ # determine linker and options for C++ code
+ if [ `which c++` ] ; then
+ # use Sun c++
+ LINK="c++"
+ elif [ `type g++` ] ; then
+ # use g++
+ LINK="g++"
+ else
+ echo "mklib: warning: can't find C++ comiler, trying CC."
+ LINK="CC"
+ fi
else
- echo "mklib: warning: can't find C++ comiler, trying CC."
- LINK="CC"
- OPTS="-G"
+ # use native Sun linker for C code
+ LINK="ld"
fi
- elif [ "x${CC}" = "xgcc" ] ; then
- # use gcc for linking
- LINK="gcc"
- OPTS="-G"
- else
- # use native Sun linker
- LINK="ld"
- OPTS="-G"
fi
echo "mklib: linker is" ${LINK} ${OPTS}
rm -f ${LIBNAME}.${MAJOR} ${LIBNAME}
FINAL_LIBS=${LIBNAME}
else
LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
+ # XXX we should run 'file' on the first object file to determine
+ # if it's o32, n32 or 64 format, as we do for Linux above.
if [ $ARCHOPT = "64" ] ; then
# 64-bit ABI
OPTS="-64 -shared -all"
VERSION="${MAJOR}.${MINOR}"
LIBNAME="lib${LIBNAME}.so"
echo "mklib: Making OSF/1 shared library: " ${LIBNAME}
- if [ $CPLUSPLUS = 1 ] ; then
- LINK=$CXX
- else
- LINK=$CC
+ if [ "x$LINK" = "x" ] ; then
+ if [ $CPLUSPLUS = 1 ] ; then
+ LINK=cxx
+ else
+ LINK=cc
+ fi
fi
rm -f ${LIBNAME}.${VERSION}
${LINK} -o ${LIBNAME}.${VERSION} -shared -set_version ${VERSION} -soname ${LIBNAME}.${VERSION} -expect_unresolved \* -all ${OBJECTS} ${DEPS}
echo "mklib: Making BeOS shared library: " ${LIBNAME}
gcc -nostart -Xlinker "-soname=${LIBNAME}" -L/Be/develop/lib/x86 -lbe ${DEPS} ${OBJECTS} -o "${LIBNAME}"
mimeset -f "${LIBNAME}"
+ # XXX remove the Mesa3D stuff here since mklib isn't mesa-specific.
setversion "${LIBNAME}" -app ${MAJOR} ${MINOR} ${PATCH} -short "Powered by Mesa3D!" -long "Powered by Mesa3D!"
fi
FINAL_LIBS=${LIBNAME}
# Make libGL from core object files
libgl-core: $(LIBGL_CORE_OBJECTS)
- @ CC="$(CC)" CXX="$(CXX)" $(TOP)/bin/mklib -o $(GL_LIB) \
+ @ $(TOP)/bin/mklib -o $(GL_LIB) -linker $(CC) \
-major $(MESA_MAJOR) -minor $(MESA_MINOR) -patch $(MESA_TINY) \
-install $(LIB_DIR) $(MKLIB_OPTIONS) $(LIBGL_CORE_OBJECTS) $(GL_LIB_DEPS)
# Make the GL library
$(LIB_DIR)/$(GL_LIB_NAME): $(STAND_ALONE_OBJECTS)
- @ CC="$(CC)" CXX="$(CXX)" $(TOP)/bin/mklib -o $(GL_LIB) \
+ @ $(TOP)/bin/mklib -o $(GL_LIB) -linker $(CC) \
-major $(GL_MAJOR) -minor $(GL_MINOR) -patch $(GL_TINY) \
-install $(LIB_DIR) \
$(MKLIB_OPTIONS) $(GL_LIB_DEPS) $(STAND_ALONE_OBJECTS)
# Make the OSMesa library
$(LIB_DIR)/$(OSMESA_LIB_NAME): $(OSMESA_DRIVER_OBJECTS) $(OSMESA16_OBJECTS)
@ if [ "${DRIVER_DIRS}" = "osmesa" ] ; then \
- CC="$(CC)" CXX="$(CXX)" $(TOP)/bin/mklib -o $(OSMESA_LIB) \
+ $(TOP)/bin/mklib -o $(OSMESA_LIB) -linker $(CC) \
-major $(MESA_MAJOR) \
-minor $(MESA_MINOR) -patch $(MESA_TINY) \
-install $(LIB_DIR) $(MKLIB_OPTIONS) \
$(OSMESA_LIB_DEPS) $(OSMESA16_OBJECTS) ; \
else \
- CC="$(CC)" CXX="$(CXX)" $(TOP)/bin/mklib -o $(OSMESA_LIB) \
+ $(TOP)/bin/mklib -o $(OSMESA_LIB) -linker $(CC) \
-major $(MESA_MAJOR) \
-minor $(MESA_MINOR) -patch $(GL_TINY) \
-install $(LIB_DIR) $(MKLIB_OPTIONS) \