Added -linker option to mklib, used to specify a particular program for
authorBrian Paul <brian.paul@tungstengraphics.com>
Mon, 25 Jul 2005 22:59:58 +0000 (22:59 +0000)
committerBrian Paul <brian.paul@tungstengraphics.com>
Mon, 25 Jul 2005 22:59:58 +0000 (22:59 +0000)
linking, if relevant.
Updated Makefiles to use -linker option instead of setting CC, CXX env vars.

bin/mklib
src/glu/mesa/Makefile
src/glu/sgi/Makefile
src/glut/ggi/Makefile
src/glut/glx/Makefile
src/glut/mini/Makefile
src/glw/Makefile
src/glx/mini/Makefile
src/glx/x11/Makefile
src/mesa/Makefile

index e8c58c56682e91de967fd8199b195ffc7796306a..06436ff388f544f10c8ac4316771b43f0788a738 100755 (executable)
--- a/bin/mklib
+++ b/bin/mklib
 #   -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
-#
 
 
 #
@@ -43,6 +41,7 @@ MAJOR=1
 MINOR=0
 PATCH=""
 DEPS=""
+LINK=""
 CPLUSPLUS=0
 STATIC=0
 INSTALLDIR="."
@@ -62,6 +61,7 @@ do
        '-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;;
@@ -120,12 +120,13 @@ case $ARCH in
     '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
@@ -133,13 +134,7 @@ case $ARCH in
            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
@@ -190,12 +185,6 @@ case $ARCH in
 
             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}
@@ -224,41 +213,25 @@ case $ARCH in
            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}
@@ -317,6 +290,8 @@ case $ARCH in
            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"
@@ -425,10 +400,12 @@ case $ARCH in
            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}
@@ -477,6 +454,7 @@ case $ARCH in
            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}
index 0924cf89403764d045248c23b28de7ddefd27085..de6c0282bb7d8f63d5d970f5fa3df9f3c826dbba 100644 (file)
@@ -45,8 +45,8 @@ $(LIB_DIR):
 
 # Make the library:
 $(LIB_DIR)/$(GLU_LIB_NAME): $(OBJECTS)
-       @CC="$(CC)" CXX="$(CXX)" $(TOP)/bin/mklib -o $(GLU_LIB) -major $(GLU_MAJOR) \
-               -minor $(GLU_MINOR) -patch $(GLU_TINY) \
+       @ $(TOP)/bin/mklib -o $(GLU_LIB) -linker $(CC) \
+               -major $(GLU_MAJOR) -minor $(GLU_MINOR) -patch $(GLU_TINY) \
                $(MKLIB_OPTIONS) -install $(LIB_DIR) \
                $(GLU_LIB_DEPS) $(OBJECTS)
 
index 19f5e280b7a85c70b8737b267ec3b67c2eb8d1d8..30372c9592d58d7cd2923df07754df0742f23c5f 100644 (file)
@@ -136,8 +136,8 @@ $(LIB_DIR):
 
 # Make the library:
 $(LIB_DIR)/$(GLU_LIB_NAME): $(OBJECTS)
-       CC="$(CC)" CXX="$(CXX)" $(TOP)/bin/mklib -o $(GLU_LIB) -major $(GLU_MAJOR) \
-               -minor $(GLU_MINOR) -patch $(GLU_TINY) \
+       $(TOP)/bin/mklib -o $(GLU_LIB) -linker $(CXX) \
+               -major $(GLU_MAJOR) -minor $(GLU_MINOR) -patch $(GLU_TINY) \
                -cplusplus $(MKLIB_OPTIONS) -install $(LIB_DIR) \
                $(GLU_LIB_DEPS) $(OBJECTS)
 
index a5ffcecea86df6d6e448c0148a53d3b7d4d692ad..f46da59ee9b4870825b8c6d333975ab509ff7e74 100644 (file)
@@ -32,7 +32,7 @@ default: $(LIB_DIR)/$(GLUT_LIB_NAME)
 
 # Make the library
 $(LIB_DIR)/$(GLUT_LIB_NAME): depend $(OBJECTS)
-       CC="$(CC)" CXX="$(CXX)" $(TOP)/bin/mklib -o $(GLUT_LIB) \
+       $(TOP)/bin/mklib -o $(GLUT_LIB) -linker $(CC) \
                -major $(GLUT_MAJOR) -minor $(GLUT_MINOR) \
                -patch $(GLUT_TINY) $(MKLIB_OPTIONS) -install $(LIB_DIR) \
                $(GLUT_LIB_DEPS) $(OBJECTS)
index 2b7180493f78ebea2060da337815cf431c92fa88..e345c8df40092822ee24fa1c39927a4e93b1b31b 100644 (file)
@@ -90,9 +90,9 @@ default: $(LIB_DIR)/$(GLUT_LIB_NAME)
 
 # Make the library
 $(LIB_DIR)/$(GLUT_LIB_NAME): depend $(OBJECTS)
-       CC="$(CC)" CXX="$(CXX)" $(TOP)/bin/mklib -o $(GLUT_LIB) \
-               -major $(GLUT_MAJOR) -minor $(GLUT_MINOR) \
-               -patch $(GLUT_TINY) $(MKLIB_OPTIONS) -install $(LIB_DIR) \
+       $(TOP)/bin/mklib -o $(GLUT_LIB) -linker $(CC) \
+               -major $(GLUT_MAJOR) -minor $(GLUT_MINOR) -patch $(GLUT_TINY) \
+               $(MKLIB_OPTIONS) -install $(LIB_DIR) \
                $(GLUT_LIB_DEPS) $(OBJECTS)
 
 
index c1dc5c5a0549ae7c37e83476c4959694b9c38f6e..ffd224e6f168d4bf9bd6ef83bab3c02576a3d794 100644 (file)
@@ -55,9 +55,9 @@ default: depend $(LIB_DIR)/$(GLUT_LIB_NAME)
 
 # Make the library
 $(LIB_DIR)/$(GLUT_LIB_NAME): depend $(OBJECTS)
-       CC="$(CC)" CXX="$(CXX)" $(TOP)/bin/mklib -o $(GLUT_LIB) \
-               -major $(GLUT_MAJOR) -minor $(GLUT_MINOR) \
-               -patch $(GLUT_TINY) $(GLUT_LIB_DEPS) -install $(LIB_DIR) \
+       $(TOP)/bin/mklib -o $(GLUT_LIB) -linker $(CC) \
+               -major $(GLUT_MAJOR) -minor $(GLUT_MINOR) -patch $(GLUT_TINY) \
+               $(GLUT_LIB_DEPS) -install $(LIB_DIR) \
                $(MKLIB_OPTIONS) $(OBJECTS)
 
 
index 4f1abf5d31dd1eb759331e3dd9c8bd378ed476ce..12719f7c72f048a70b08385b0ecddac84ff03733 100644 (file)
@@ -33,8 +33,9 @@ clean:
 
 # Make the library
 $(LIB_DIR)/$(GLW_LIB_NAME): $(OBJECTS)
-       CC="$(CC)" CXX="$(CXX)" $(TOP)/bin/mklib -o $(GLW_LIB) -major $(MAJOR) -minor $(MINOR) \
-               -patch $(TINY) $(MKLIB_OPTIONS) -install $(LIB_DIR) \
+       $(TOP)/bin/mklib -o $(GLW_LIB) -linker $(CC) \
+               -major $(MAJOR) -minor $(MINOR) -patch $(TINY) \
+               $(MKLIB_OPTIONS) -install $(LIB_DIR) \
                $(GLW_LIB_DEPS) $(OBJECTS)
 
 
index 612610526e85b235b3086ba78c50fcc201555452..a9bced2508cd66cae06ebf033c07805191d7a033 100644 (file)
@@ -55,7 +55,8 @@ default: depend $(LIB_DIR)/$(GL_LIB_NAME)
 
 # Make libGL
 $(LIB_DIR)/$(GL_LIB_NAME):  $(OBJECTS) Makefile
-       CC="$(CC)" CXX="$(CXX)" $(TOP)/bin/mklib -o $(GL_LIB) -major 1 -minor 2 $(MKLIB_OPTIONS) \
+       $(TOP)/bin/mklib -o $(GL_LIB) -linker $(CC) \
+               -major 1 -minor 2 $(MKLIB_OPTIONS) \
                -install $(LIB_DIR) $(GL_LIB_DEPS) $(OBJECTS)
        rm -f $(LIB_DIR)/miniglx.conf
        install example.miniglx.conf $(LIB_DIR)/miniglx.conf
index bca2ee4ffa963c7e5515ddf2eda721abcaf2531c..3ffa4780d46e82b7665b6e290440dcff27ae733c 100644 (file)
@@ -88,7 +88,8 @@ dispatch.c:
 
 # Make libGL
 $(LIB_DIR)/$(GL_LIB_NAME):  $(OBJECTS) Makefile
-       CC="$(CC)" CXX="$(CXX)" $(TOP)/bin/mklib -o $(GL_LIB) -major 1 -minor 2 $(MKLIB_OPTIONS) \
+       $(TOP)/bin/mklib -o $(GL_LIB) -linker $(CC) \
+               -major 1 -minor 2 $(MKLIB_OPTIONS) \
                -install $(LIB_DIR) $(GL_LIB_DEPS) $(OBJECTS)
 
 
index 6e13f5289c5ec825456d544c623026436210f3b0..7a17bf5a618645f7623be349d897d5f018069ebb 100644 (file)
@@ -96,7 +96,7 @@ LIBGL_CORE_OBJECTS =  \
 
 # 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)
 
@@ -150,7 +150,7 @@ subdirs:
 
 # 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)
@@ -158,13 +158,13 @@ $(LIB_DIR)/$(GL_LIB_NAME): $(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) \