Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | # Make a shared library. |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 4 | # Basically do a switch/case depending on the OS and make a shared (or static) |
| 5 | # library conforming to that OS. |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 6 | |
| 7 | |
| 8 | # Usage: |
| 9 | # mklib [options] objects ... |
| 10 | # Options: |
Brian Paul | 1a644b3 | 2003-12-06 17:57:12 +0000 | [diff] [blame] | 11 | # -o LIBRARY specifies the name of resulting library |
| 12 | # ("-o GL" for example, might result in "libGL.so" being made) |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 13 | # -major N specifies major version number (default is 1) |
| 14 | # -minor N specifies minor version number (default is 0) |
| 15 | # -patch N specifies patch version number (default is 0) |
| 16 | # -lLIBRARY specifies a dependency on LIBRARY |
| 17 | # -LDIR search in DIR for library dependencies |
| 18 | # -cplusplus link with C++ runtime |
| 19 | # -static make a static library (default is dynamic/shared) |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 20 | # -install DIR move resulting library file(s) to DIR |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 21 | # -arch ARCH override using `uname` to determine architecture |
| 22 | # -archopt OPT specify an extra achitecture-specific option OPT |
Brian Paul | dd74e36 | 2004-04-08 22:26:22 +0000 | [diff] [blame] | 23 | # -noprefix don't prefix library name with "lib" or any suffix |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 24 | # |
| 25 | # The library name should just be "GL" or "GLU", etc. The 'lib' prefix |
Brian Paul | dd74e36 | 2004-04-08 22:26:22 +0000 | [diff] [blame] | 26 | # will be added here if needed, as well as the ".so" or ".a" suffix, |
| 27 | # etc (unless the -noprefix option is used). |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 28 | # |
| 29 | # objects should be: foo.o bar.o etc.o |
| 30 | # |
| 31 | # Environment variables recognized: |
| 32 | # CC C compiler command |
| 33 | # CXX C++ compiler command |
| 34 | # |
| 35 | |
| 36 | |
| 37 | # |
| 38 | # Option defaults |
| 39 | # |
| 40 | LIBNAME="" |
| 41 | MAJOR=1 |
| 42 | MINOR=0 |
Brian Paul | 6e450f2 | 2004-02-21 18:08:41 +0000 | [diff] [blame] | 43 | PATCH="" |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 44 | DEPS="" |
| 45 | CPLUSPLUS=0 |
| 46 | STATIC=0 |
| 47 | INSTALLDIR="." |
| 48 | ARCH="auto" |
| 49 | ARCHOPT="" |
Brian Paul | dd74e36 | 2004-04-08 22:26:22 +0000 | [diff] [blame] | 50 | NOPREFIX=0 |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 51 | |
| 52 | |
| 53 | # |
| 54 | # Parse arguments |
| 55 | # |
| 56 | while true |
| 57 | do |
| 58 | case $1 in |
| 59 | '-o') shift 1; LIBNAME=$1;; |
| 60 | '-major') shift 1; MAJOR=$1;; |
| 61 | '-minor') shift 1; MINOR=$1;; |
| 62 | '-patch') shift 1; PATCH=$1;; |
| 63 | -l*) DEPS="$DEPS $1";; |
| 64 | -L*) DEPS="$DEPS $1";; |
| 65 | '-cplusplus') CPLUSPLUS=1;; |
| 66 | '-static') STATIC=1;; |
| 67 | '-install') shift 1; INSTALLDIR=$1;; |
| 68 | '-arch') shift 1; ARCH=$1;; |
| 69 | '-archopt') shift 1; ARCHOPT=$1;; |
Brian Paul | dd74e36 | 2004-04-08 22:26:22 +0000 | [diff] [blame] | 70 | '-noprefix') NOPREFIX=1;; |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 71 | -*) echo "mklib: Unknown option: " $1 ; exit 1;; |
| 72 | *) break |
| 73 | esac |
| 74 | shift 1 |
| 75 | done |
| 76 | OBJECTS=$@ |
| 77 | |
| 78 | if [ ${ARCH} = "auto" ] ; then |
| 79 | ARCH=`uname` |
| 80 | fi |
| 81 | |
| 82 | |
| 83 | # |
| 84 | # Error checking |
| 85 | # |
| 86 | if [ "x${LIBNAME}" = "x" ] ; then |
| 87 | echo "mklib: Error: no library name specified" |
| 88 | exit 1 |
| 89 | fi |
| 90 | if [ "x${OBJECTS}" = "x" ] ; then |
| 91 | echo "mklib: Error: no object files specified" |
| 92 | exit 1 |
| 93 | fi |
| 94 | |
| 95 | |
| 96 | # |
| 97 | # Debugging info |
| 98 | # |
| 99 | if [ ] ; then |
| 100 | echo "-----------------" |
| 101 | echo ARCH is $ARCH |
| 102 | echo LIBNAME is $LIBNAME |
| 103 | echo MAJOR is $MAJOR |
| 104 | echo MINOR is $MINOR |
| 105 | echo PATCH is $PATCH |
| 106 | echo DEPS are $DEPS |
| 107 | echo "-----------------" |
| 108 | fi |
| 109 | |
| 110 | |
| 111 | # |
| 112 | # OK, make the library now |
| 113 | # |
| 114 | case $ARCH in |
| 115 | |
Brian Paul | 12d6cae | 2004-01-10 22:12:21 +0000 | [diff] [blame] | 116 | 'Linux' | 'OpenBSD') |
| 117 | # GCC-based environment |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 118 | |
Brian Paul | dd74e36 | 2004-04-08 22:26:22 +0000 | [diff] [blame] | 119 | if [ $NOPREFIX = 1 ] ; then |
| 120 | # No "lib" or ".so" part |
| 121 | echo "mklib: Making" $ARCH "shared library: " ${LIBNAME} |
| 122 | #OPTS="-shared -Wl,-soname,${LIBNAME}" # soname??? |
| 123 | OPTS="-shared" |
| 124 | if [ $CPLUSPLUS = 1 ] ; then |
Ian Romanick | 9eecb03 | 2004-06-25 22:51:39 +0000 | [diff] [blame] | 125 | LINK=$CXX |
Brian Paul | dd74e36 | 2004-04-08 22:26:22 +0000 | [diff] [blame] | 126 | else |
Ian Romanick | 9eecb03 | 2004-06-25 22:51:39 +0000 | [diff] [blame] | 127 | LINK=$CC |
Brian Paul | dd74e36 | 2004-04-08 22:26:22 +0000 | [diff] [blame] | 128 | fi |
| 129 | rm -f ${LIBNAME} |
| 130 | |
| 131 | # make lib |
| 132 | ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS} |
| 133 | # finish up |
| 134 | FINAL_LIBS="${LIBNAME}" |
| 135 | elif [ $STATIC = 1 ] ; then |
| 136 | LIBNAME="lib${LIBNAME}" # prefix with "lib" |
Brian Paul | 5b9a9d4 | 2004-01-17 18:31:12 +0000 | [diff] [blame] | 137 | echo "mklib: Making" $ARCH "static library: " ${LIBNAME}.a |
Brian Paul | 1c4b711 | 2003-10-10 17:58:38 +0000 | [diff] [blame] | 138 | LINK="ar" |
Brian Paul | 6e450f2 | 2004-02-21 18:08:41 +0000 | [diff] [blame] | 139 | OPTS="-ru" |
Brian Paul | 1c4b711 | 2003-10-10 17:58:38 +0000 | [diff] [blame] | 140 | # make lib |
| 141 | ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS} |
Brian Paul | 6e450f2 | 2004-02-21 18:08:41 +0000 | [diff] [blame] | 142 | ranlib ${LIBNAME}.a |
Brian Paul | 1c4b711 | 2003-10-10 17:58:38 +0000 | [diff] [blame] | 143 | # finish up |
Brian Paul | 6e450f2 | 2004-02-21 18:08:41 +0000 | [diff] [blame] | 144 | FINAL_LIBS=${LIBNAME}.a |
Brian Paul | 1c4b711 | 2003-10-10 17:58:38 +0000 | [diff] [blame] | 145 | else |
Brian Paul | dd74e36 | 2004-04-08 22:26:22 +0000 | [diff] [blame] | 146 | LIBNAME="lib${LIBNAME}" # prefix with "lib" |
Brian Paul | 5b9a9d4 | 2004-01-17 18:31:12 +0000 | [diff] [blame] | 147 | if [ $ARCH = 'Linux' ] ; then |
| 148 | OPTS="-Xlinker -Bsymbolic -shared -Wl,-soname,${LIBNAME}.so.${MAJOR}" |
| 149 | else |
| 150 | OPTS="-shared -Wl,-soname,${LIBNAME}.so.${MAJOR}" |
| 151 | fi |
Brian Paul | 6e450f2 | 2004-02-21 18:08:41 +0000 | [diff] [blame] | 152 | if [ x${PATCH} = "x" ] ; then |
| 153 | VERSION="${MAJOR}.${MINOR}" |
| 154 | else |
| 155 | VERSION="${MAJOR}.${MINOR}.${PATCH}" |
| 156 | fi |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 157 | |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 158 | echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}.so.${VERSION} |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 159 | |
Brian Paul | 1c4b711 | 2003-10-10 17:58:38 +0000 | [diff] [blame] | 160 | if [ $CPLUSPLUS = 1 ] ; then |
Ian Romanick | 9eecb03 | 2004-06-25 22:51:39 +0000 | [diff] [blame] | 161 | LINK=$CXX |
Brian Paul | 1c4b711 | 2003-10-10 17:58:38 +0000 | [diff] [blame] | 162 | else |
Ian Romanick | 9eecb03 | 2004-06-25 22:51:39 +0000 | [diff] [blame] | 163 | LINK=$CC |
Brian Paul | 1c4b711 | 2003-10-10 17:58:38 +0000 | [diff] [blame] | 164 | fi |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 165 | |
Brian Paul | 1c4b711 | 2003-10-10 17:58:38 +0000 | [diff] [blame] | 166 | # rm any old libs |
| 167 | rm -f ${LIBNAME}.so.${VERSION} |
| 168 | rm -f ${LIBNAME}.so.${MAJOR} |
| 169 | rm -f ${LIBNAME}.so |
| 170 | |
| 171 | # make lib |
| 172 | ${LINK} ${OPTS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS} |
| 173 | # make usual symlinks |
| 174 | ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} |
| 175 | ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so |
| 176 | # finish up |
| 177 | FINAL_LIBS="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so" |
| 178 | fi |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 179 | ;; |
| 180 | |
| 181 | 'SunOS') |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 182 | if [ $STATIC = 1 ] ; then |
| 183 | LIBNAME="lib${LIBNAME}.a" |
| 184 | echo "mklib: Making SunOS static library: " ${LIBNAME} |
| 185 | rm -f ${LIBNAME} |
Brian Paul | c193bd0 | 2004-03-18 15:41:59 +0000 | [diff] [blame] | 186 | ar -ruv ${LIBNAME} ${OBJECTS} |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 187 | FINAL_LIBS=${LIBNAME} |
| 188 | else |
| 189 | LIBNAME="lib${LIBNAME}.so" |
| 190 | echo "mklib: Making SunOS shared library: " ${LIBNAME} |
| 191 | # XXX OPTS for gcc should be -shared, but that doesn't work. |
| 192 | # Using -G does work though. |
| 193 | if [ $CPLUSPLUS = 1 ] ; then |
| 194 | # determine linker and options for C++ code |
| 195 | if [ "x${CXX}" = "xg++" ] ; then |
| 196 | # use g++ |
| 197 | LINK="g++" |
| 198 | OPTS="-G" |
| 199 | elif [ "x${CXX}" = "xCC" ] ; then |
| 200 | # use Sun CC |
| 201 | LINK="CC" |
| 202 | OPTS="-G" |
| 203 | elif [ "x${CXX}" = "xc++" ] ; then |
| 204 | # use Sun c++ |
| 205 | LINK="c++" |
| 206 | OPTS="-G" |
| 207 | elif [ `which c++` ] ; then |
| 208 | # use Sun c++ |
| 209 | LINK="c++" |
| 210 | OPTS="-G" |
| 211 | elif [ `type g++` ] ; then |
| 212 | # use g++ |
| 213 | LINK="g++" |
| 214 | OPTS="-G" |
| 215 | else |
| 216 | echo "mklib: warning: can't find C++ comiler, trying CC." |
| 217 | LINK="CC" |
| 218 | OPTS="-G" |
| 219 | fi |
| 220 | elif [ "x${CC}" = "xgcc" ] ; then |
| 221 | # use gcc for linking |
| 222 | LINK="gcc" |
Brian Paul | 4b60344 | 2004-01-14 23:18:47 +0000 | [diff] [blame] | 223 | OPTS="-G" |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 224 | else |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 225 | # use native Sun linker |
| 226 | LINK="ld" |
Brian Paul | 1a644b3 | 2003-12-06 17:57:12 +0000 | [diff] [blame] | 227 | OPTS="-G" |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 228 | fi |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 229 | echo "mklib: linker is" ${LINK} ${OPTS} |
| 230 | rm -f ${LIBNAME}.${MAJOR} ${LIBNAME} |
| 231 | ${LINK} ${OPTS} -o ${LIBNAME}.${MAJOR} ${OBJECTS} ${DEPS} |
| 232 | ln -s ${LIBNAME}.${MAJOR} ${LIBNAME} |
| 233 | FINAL_LIBS="${LIBNAME}.${MAJOR} ${LIBNAME}" |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 234 | fi |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 235 | ;; |
| 236 | |
| 237 | 'FreeBSD') |
Brian Paul | dd74e36 | 2004-04-08 22:26:22 +0000 | [diff] [blame] | 238 | if [ $NOPREFIX = 1 ] ; then |
| 239 | # No "lib" or ".so" part |
| 240 | echo "mklib: Making FreeBSD shared library: " ${LIBNAME} |
| 241 | rm -f ${LIBNAME} |
| 242 | ld -Bshareable -o ${LIBNAME} ${OBJECTS} |
| 243 | FINAL_LIBS=${LIBNAME} |
| 244 | elif [ $STATIC = 1 ] ; then |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 245 | STLIB="lib${LIBNAME}.a" |
| 246 | echo "mklib: Making FreeBSD static library: " ${STLIB} |
| 247 | rm -f ${STLIB} |
| 248 | ar cq ${STLIB} ${OBJECTS} |
| 249 | ranlib ${STLIB} |
| 250 | FINAL_LIBS=${STLIB} |
| 251 | else |
| 252 | SHLIB="lib${LIBNAME}.so.${MAJOR}.${MINOR}" |
| 253 | echo "mklib: Making FreeBSD shared library: " ${SHLIB} |
| 254 | rm -f ${SHLIB} |
| 255 | ld -Bshareable -o ${SHLIB} ${OBJECTS} |
| 256 | # XXX make lib${LIBNAME}.so.${MAJOR} symlink? |
| 257 | FINAL_LIBS=${SHLIB} |
| 258 | fi |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 259 | ;; |
| 260 | |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 261 | 'NetBSD') |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 262 | if [ $STATIC = 1 ] ; then |
| 263 | LIBNAME="lib${LIBNAME}_pic.a" |
| 264 | echo "mklib: Making NetBSD PIC static library: " ${LIBNAME} |
| 265 | rm -f ${LIBNAME} |
| 266 | ar cq ${LIBNAME} ${OBJECTS} |
| 267 | ranlib ${LIBNAME} |
| 268 | FINAL_LIBS=${LIBNAME} |
| 269 | else |
| 270 | LIBNAME="lib${LIBNAME}.so.${MAJOR}.${MINOR}" |
| 271 | echo "mklib: Making NetBSD PIC shared library: " ${LIBNAME} |
| 272 | rm -f ${LIBNAME} |
| 273 | ld -x -Bshareable -Bforcearchive -o ${LIBNAME} ${OBJECTS} |
| 274 | FINAL_LIBS=${LIBNAME} |
| 275 | fi |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 276 | ;; |
| 277 | |
Brian Paul | f8c31fc | 2004-01-29 15:21:47 +0000 | [diff] [blame] | 278 | 'IRIX' | 'IRIX64') |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 279 | if [ $STATIC = 1 ] ; then |
| 280 | LIBNAME="lib${LIBNAME}.a" |
| 281 | rm -f ${LIBNAME} |
| 282 | ar rc ${LIBNAME} ${OBJECTS} |
| 283 | FINAL_LIBS=${LIBNAME} |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 284 | else |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 285 | LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so" |
| 286 | if [ $ARCHOPT = "64" ] ; then |
| 287 | # 64-bit ABI |
| 288 | OPTS="-64 -shared -all" |
| 289 | echo "mklib: Making IRIX 64-bit shared library: " ${LIBNAME} |
| 290 | elif [ $ARCHOPT = "o32" ] ; then |
| 291 | # old 32-bit ABI |
| 292 | OPTS="-32 -shared -all" |
| 293 | echo "mklib: Making IRIX o32-bit shared library: " ${LIBNAME} |
| 294 | else |
| 295 | # new 32-bit ABI |
| 296 | OPTS="-n32 -shared -all" |
| 297 | echo "mklib: Making IRIX n32-bit shared library: " ${LIBNAME} |
| 298 | fi |
| 299 | if [ $CPLUSPLUS = 1 ] ; then |
| 300 | LINK="CC" |
| 301 | else |
| 302 | LINK="ld" |
| 303 | fi |
| 304 | ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS} |
| 305 | FINAL_LIBS=${LIBNAME} |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 306 | fi |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 307 | ;; |
| 308 | |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 309 | 'linux-cygwin') |
| 310 | LIBNAME="lib${LIBNAME}.a" |
| 311 | echo "mklib: Making linux-cygwin library: " ${LIBNAME} |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 312 | rm -f ${LIBNAME} |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 313 | gnuwin32ar ruv ${LIBNAME} ${OBJECTS} |
| 314 | FINAL_LIBS=${LIBNAME} |
| 315 | ;; |
| 316 | |
Brian Paul | c193bd0 | 2004-03-18 15:41:59 +0000 | [diff] [blame] | 317 | 'HP-UX') |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 318 | if [ $STATIC = 1 ] ; then |
| 319 | LIBNAME="lib${LIBNAME}.a" |
Brian Paul | 52fb07e | 2004-03-30 14:47:02 +0000 | [diff] [blame] | 320 | echo "mklib: Making HP-UX static library: " ${LIBNAME} |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 321 | rm -f ${LIBNAME} |
Brian Paul | c193bd0 | 2004-03-18 15:41:59 +0000 | [diff] [blame] | 322 | ar -ruv ${LIBNAME} ${OBJECTS} |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 323 | FINAL_LIBS=${LIBNAME} |
| 324 | else |
| 325 | RUNLIB="lib${LIBNAME}.${MAJOR}" |
| 326 | DEVLIB="lib${LIBNAME}.sl" |
Brian Paul | 52fb07e | 2004-03-30 14:47:02 +0000 | [diff] [blame] | 327 | echo "mklib: Making HP-UX shared library: " ${RUNLIB} ${DEVLIB} |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 328 | ld -b -o ${RUNLIB} +b ${RUNLIB} ${OBJECTS} ${DEPS} |
| 329 | ln -s ${RUNLIB} ${DEVLIB} |
Brian Paul | ac0cfee | 2004-04-25 15:13:56 +0000 | [diff] [blame] | 330 | FINAL_LIBS="${RUNLIB} ${DEVLIB}" |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 331 | fi |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 332 | ;; |
| 333 | |
Brian Paul | c193bd0 | 2004-03-18 15:41:59 +0000 | [diff] [blame] | 334 | 'AIX') |
| 335 | if [ $STATIC = 1 ] ; then |
| 336 | LIBNAME="lib${LIBNAME}.a" |
| 337 | echo "mklib: Making AIX static library: " ${LIBNAME} |
| 338 | ar -ruv ${LIBNAME} ${OBJECTS} |
| 339 | FINAL_LIBS=${LIBNAME} |
| 340 | else |
Brian Paul | 76cfed8 | 2004-07-01 15:33:14 +0000 | [diff] [blame] | 341 | EXPFILE="lib${LIBNAME}.exp" |
| 342 | OFILE=shr.o #Want to be consistent with the IBM libGL.a |
| 343 | LIBNAME="lib${LIBNAME}.a" # shared objects are still stored in the .a libraries |
| 344 | OPTS="-bE:${EXPFILE} -bM:SRE -bnoentry" |
| 345 | rm -f ${EXPFILE} ${OFILE} |
| 346 | NM="/bin/nm -eC" |
| 347 | echo "#! /usr/lib/${LIBNAME}" > ${EXPFILE} |
| 348 | ${NM} ${OBJECTS} | awk '{ |
| 349 | if ((($2 == "T") || ($2 == "D") || ($2 == "B")) \ |
| 350 | && ( substr($1,1,1) != ".")) { |
| 351 | if (substr ($1, 1, 7) != "__sinit" && |
| 352 | substr ($1, 1, 7) != "__sterm") { |
| 353 | if (substr ($1, 1, 5) == "__tf1") |
| 354 | print (substr ($1, 7)) |
| 355 | else if (substr ($1, 1, 5) == "__tf9") |
| 356 | print (substr ($1, 15)) |
| 357 | else |
| 358 | print $1 |
| 359 | } |
| 360 | } |
| 361 | }' | sort -u >> ${EXPFILE} |
| 362 | cc ${OPTS} -o ${OFILE} ${OBJECTS} ${DEPS} |
| 363 | ar -r ${LIBNAME} ${OFILE} |
| 364 | FINAL_LIBS="${LIBNAME}" |
Brian Paul | c193bd0 | 2004-03-18 15:41:59 +0000 | [diff] [blame] | 365 | fi |
| 366 | ;; |
| 367 | |
| 368 | 'AIX64') |
| 369 | if [ $STATIC = 1 ] ; then |
| 370 | LIBNAME="lib${LIBNAME}.a" |
| 371 | echo "mklib: Making AIX static library: " ${LIBNAME} |
| 372 | ar -X64 -ruv ${LIBNAME} ${OBJECTS} |
| 373 | FINAL_LIBS=${LIBNAME} |
| 374 | else |
| 375 | echo "mklib: PROBLEM: AIX64 shared libs not supported!!!" |
| 376 | fi |
| 377 | ;; |
| 378 | |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 379 | 'OpenSTEP') |
| 380 | LIBNAME="lib${LIBNAME}.a" |
| 381 | echo "mklib: Making OpenSTEP static library: " ${LIBNAME} |
| 382 | libtool -static -o ${LIBNAME} - ${OBJECTS} |
| 383 | FINAL_LIBS=${LIBNAME} |
| 384 | ;; |
| 385 | |
| 386 | 'OSF1') |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 387 | if [ $STATIC = 1 ] ; then |
| 388 | LIBNAME="lib${LIBNAME}.a" |
| 389 | echo "mklib: Making OSF/1 static library: " ${LIBNAME} |
| 390 | rm -f ${LIBNAME} |
Brian Paul | c193bd0 | 2004-03-18 15:41:59 +0000 | [diff] [blame] | 391 | ar -ruv ${LIBNAME} ${OBJECTS} |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 392 | FINAL_LIBS=${LIBNAME} |
| 393 | else |
| 394 | VERSION="${MAJOR}.${MINOR}" |
| 395 | LIBNAME="lib${LIBNAME}.so" |
| 396 | echo "mklib: Making OSF/1 shared library: " ${LIBNAME} |
| 397 | rm -f ${LIBNAME}.${VERSION} |
| 398 | ld -o ${LIBNAME}.${VERSION} -shared -no_archive -set_version ${VERSION} -soname ${LIBNAME}.${VERSION} -expect_unresolved \* -all ${OBJECTS} ${DEPS} |
| 399 | ln -sf ${LIBNAME}.${VERSION} ${LIBNAME} |
| 400 | FINAL_LIBS="${LIBNAME} ${LIBNAME}.${VERSION}" |
| 401 | fi |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 402 | ;; |
| 403 | |
| 404 | 'Darwin') |
Brian Paul | c193bd0 | 2004-03-18 15:41:59 +0000 | [diff] [blame] | 405 | if [ $STATIC = 1 ] ; then |
| 406 | LIBNAME="lib${LIBNAME}.a" |
| 407 | echo "mklib: Making Darwin static library: " ${LIBNAME} |
| 408 | LINK="ar" |
| 409 | OPTS="-ruv" |
| 410 | ${LINK} ${OPTS} ${LIBNAME} ${OBJECTS} |
| 411 | FINAL_LIBS=${LIBNAME} |
| 412 | else |
Brian Paul | c193bd0 | 2004-03-18 15:41:59 +0000 | [diff] [blame] | 413 | LIBNAME="${LIBNAME}.dylib" |
Brian Paul | c50d77a | 2004-04-13 17:35:17 +0000 | [diff] [blame] | 414 | echo "mklib: Making Darwin shared library: " ${LIBNAME} |
Brian Paul | c193bd0 | 2004-03-18 15:41:59 +0000 | [diff] [blame] | 415 | FLAGS="-dynamiclib -multiply_defined suppress" |
Brian Paul | c05658d | 2004-03-25 21:18:32 +0000 | [diff] [blame] | 416 | if [ $CPLUSPLUS = 1 ] ; then |
| 417 | LINK="g++" |
| 418 | else |
| 419 | LINK="cc" |
| 420 | fi |
| 421 | ${LINK} ${FLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS} |
Brian Paul | aaba075 | 2004-03-23 23:25:47 +0000 | [diff] [blame] | 422 | FINAL_LIBS=${LIBNAME} |
Brian Paul | c193bd0 | 2004-03-18 15:41:59 +0000 | [diff] [blame] | 423 | fi |
| 424 | ;; |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 425 | |
| 426 | 'LynxOS') |
| 427 | LIBNAME="lib${LIBNAME}.a" |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 428 | echo "mklib: Making LynxOS static library: " ${LIBNAME} |
| 429 | rm -f ${LIBNAME} |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 430 | ar ru ${LIBNAME} ${OBJECTS} |
| 431 | FINAL_LIBS=${LIBNAME} |
| 432 | ;; |
| 433 | |
| 434 | 'BeOS') |
Philippe Houdoin | ef4dd5a | 2004-08-14 10:12:38 +0000 | [diff] [blame] | 435 | if [ $STATIC = 1 ] ; then |
| 436 | LIBNAME="lib${LIBNAME}.a" |
| 437 | echo "mklib: Making BeOS static library: " ${LIBNAME} |
| 438 | ar -cru "${LIBNAME}" ${OBJECTS} |
| 439 | else |
Brian Paul | b784b8f | 2004-08-14 14:30:36 +0000 | [diff] [blame^] | 440 | LIBNAME="lib${LIBNAME}.so" |
| 441 | echo "mklib: Making BeOS shared library: " ${LIBNAME} |
| 442 | gcc -nostart -Xlinker "-soname=${LIBNAME}" -L/Be/develop/lib/x86 -lbe ${DEPS} ${OBJECTS} -o "${LIBNAME}" |
| 443 | mimeset -f "${LIBNAME}" |
| 444 | setversion "${LIBNAME}" -app ${MAJOR} ${MINOR} ${PATCH} -short "Powered by Mesa3D!" -long "Powered by Mesa3D!" |
| 445 | fi |
| 446 | FINAL_LIBS=${LIBNAME} |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 447 | ;; |
| 448 | |
| 449 | 'QNX') |
| 450 | LIBNAME="lib${LIBNAME}.a" |
| 451 | echo "mklib: Making QNX library: " ${LIBNAME} |
| 452 | wlib ${LIBNAME} ${OBJECTS} |
| 453 | FINAL_LIBS=${LIBNAME} |
| 454 | ;; |
| 455 | |
Brian Paul | 65e2ab3 | 2003-10-27 18:13:37 +0000 | [diff] [blame] | 456 | 'MorphOS') |
| 457 | LIBNAME="lib${LIBNAME}.a" |
| 458 | echo "mklib: Making MorphOS library: " ${LIBNAME} |
| 459 | ppc-morphos-ar rc ${LIBNAME} ${OBJECTS} |
| 460 | FINAL_LIBS="${LIBNAME}" |
| 461 | ;; |
| 462 | |
Brian Paul | b3b725b | 2003-12-15 16:14:55 +0000 | [diff] [blame] | 463 | 'icc') |
| 464 | # Intel C compiler |
| 465 | LIBNAME="lib${LIBNAME}" # prefix with "lib" |
| 466 | |
| 467 | if [ $STATIC = 1 ] ; then |
| 468 | echo "mklib: Making Intel ICC static library: " ${LIBNAME}.a |
| 469 | LINK="ar" |
| 470 | OPTS="-ruv" |
| 471 | # make lib |
| 472 | ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS} |
| 473 | # finish up |
| 474 | FINAL_LIBS="${LIBNAME}.a" |
| 475 | else |
| 476 | OPTS="-shared" |
| 477 | VERSION="${MAJOR}.${MINOR}.${PATCH}" |
Brian Paul | b3b725b | 2003-12-15 16:14:55 +0000 | [diff] [blame] | 478 | echo "mklib: Making Intel ICC shared library: " ${LIBNAME}.so.${VERSION} |
| 479 | |
| 480 | if [ $CPLUSPLUS = 1 ] ; then |
| 481 | LINK="icc" |
| 482 | else |
| 483 | LINK="icc" |
| 484 | fi |
Brian Paul | b3b725b | 2003-12-15 16:14:55 +0000 | [diff] [blame] | 485 | # rm any old libs |
| 486 | rm -f ${LIBNAME}.so.${VERSION} |
| 487 | rm -f ${LIBNAME}.so.${MAJOR} |
| 488 | rm -f ${LIBNAME}.so |
Brian Paul | b3b725b | 2003-12-15 16:14:55 +0000 | [diff] [blame] | 489 | # make lib |
| 490 | ${LINK} ${OPTS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS} |
| 491 | # make usual symlinks |
| 492 | ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} |
| 493 | ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so |
| 494 | # finish up |
| 495 | FINAL_LIBS="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so" |
| 496 | fi |
| 497 | ;; |
| 498 | |
Brian Paul | 12d6cae | 2004-01-10 22:12:21 +0000 | [diff] [blame] | 499 | 'aix-gcc') |
| 500 | # AIX with gcc |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 501 | if [ $STATIC = 1 ] ; then |
| 502 | LIBNAME="lib${LIBNAME}.a" |
| 503 | echo "mklib: Making AIX GCC static library: " ${LIBNAME} |
| 504 | rm -f ${LIBNAME} |
| 505 | ar ru ${LIBNAME} ${OBJECTS} |
| 506 | FINAL_LIBS=${LIBNAME} |
| 507 | else |
| 508 | LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so" |
| 509 | echo "mklib: Making AIX GCC shared library: " ${LIBNAME} |
| 510 | # remove old lib |
| 511 | rm -f ${LIBNAME} |
| 512 | # make the lib |
| 513 | gcc -shared -Wl,-G ${OBJECTS} ${DEPS} -o ${LIBNAME} |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 514 | # NOTE: the application linking with this library must specify |
| 515 | # the -Wl,-brtl flags to gcc |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 516 | FINAL_LIBS=${LIBNAME} |
| 517 | fi |
| 518 | ;; |
| 519 | |
| 520 | 'ultrix') |
| 521 | # XXX untested |
| 522 | if [ $STATIC = 0 ] ; then |
| 523 | echo "mklib: Warning shared libs not supported on Ultrix" |
| 524 | fi |
| 525 | LIBNAME="lib${LIBNAME}.a" |
| 526 | echo "mklib: Making static library for Ultrix: " ${LIBNAME} |
Brian Paul | 12d6cae | 2004-01-10 22:12:21 +0000 | [diff] [blame] | 527 | rm -f ${LIBNAME} |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 528 | ar ru ${LIBNAME} ${OBJECTS} |
| 529 | FINAL_LIBS="${LIBNAME}" |
Brian Paul | 12d6cae | 2004-01-10 22:12:21 +0000 | [diff] [blame] | 530 | ;; |
Brian Paul | b3b725b | 2003-12-15 16:14:55 +0000 | [diff] [blame] | 531 | |
Brian Paul | 580548d | 2004-04-22 16:16:42 +0000 | [diff] [blame] | 532 | CYGWIN*) |
| 533 | # GCC-based environment |
| 534 | CYGNAME="cyg${LIBNAME}" # prefix with "cyg" |
| 535 | LIBNAME="lib${LIBNAME}" # prefix with "lib" |
| 536 | |
| 537 | if [ $STATIC = 1 ] ; then |
| 538 | echo "mklib: Making" $ARCH "static library: " ${LIBNAME}.a |
| 539 | LINK="ar" |
| 540 | OPTS="-ru" |
| 541 | # make lib |
| 542 | ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS} |
| 543 | ranlib ${LIBNAME}.a |
| 544 | # finish up |
| 545 | FINAL_LIBS=${LIBNAME}.a |
| 546 | else |
| 547 | OPTS="-shared -Wl,-export-all -Wl,--out-implib=${LIBNAME}-${MAJOR}.dll.a" |
| 548 | echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}-${MAJOR}.dll |
| 549 | |
| 550 | if [ $CPLUSPLUS = 1 ] ; then |
| 551 | LINK="g++" |
| 552 | else |
| 553 | LINK="gcc" |
| 554 | fi |
| 555 | |
| 556 | # rm any old libs |
| 557 | rm -f ${LIBNAME}-${MAJOR}.dll |
| 558 | rm -f ${LIBNAME}.dll.a |
| 559 | rm -f ${LIBNAME}.a |
| 560 | |
| 561 | # make lib |
| 562 | ${LINK} ${OPTS} -o ${CYGNAME}-${MAJOR}.dll ${OBJECTS} ${DEPS} |
| 563 | # make usual symlinks |
| 564 | ln -s ${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a |
| 565 | # finish up |
| 566 | FINAL_LIBS="${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a" |
| 567 | # special case for installing in bin |
| 568 | FINAL_BINS="${CYGNAME}-${MAJOR}.dll" |
| 569 | fi |
| 570 | ;; |
| 571 | |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 572 | 'example') |
| 573 | # If you're adding support for a new architecture, you can |
| 574 | # start with this: |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 575 | if [ $STATIC = 1 ] ; then |
| 576 | LIBNAME="lib${LIBNAME}.a" |
| 577 | echo "mklib: Making static library for example arch: " ${LIBNAME} |
| 578 | rm -f ${LIBNAME} |
| 579 | ar rv ${LIBNAME} ${OBJECTS} |
| 580 | FINAL_LIBS="${LIBNAME}" |
| 581 | else |
| 582 | LIBNAME="lib${LIBNAME}.so" # prefix with "lib" |
| 583 | echo "mklib: Making shared library for example arch: " ${LIBNAME} |
| 584 | ld -o ${LIBNAME} ${OBJECTS} ${DEPS} |
| 585 | FINAL_LIBS="${LIBNAME}" |
| 586 | fi |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 587 | ;; |
| 588 | |
| 589 | *) |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 590 | echo "mklib: ERROR: Don't know how to make a static/shared library for" ${ARCH} |
| 591 | echo "mklib: Please add necessary commands to mklib script." |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 592 | ;; |
| 593 | esac |
| 594 | |
| 595 | |
| 596 | # |
| 597 | # Put library files into installation directory if specified. |
| 598 | # |
| 599 | if [ ${INSTALLDIR} != "." ] ; then |
| 600 | echo "mklib: Installing" ${FINAL_LIBS} "in" ${INSTALLDIR} |
| 601 | mv ${FINAL_LIBS} ${INSTALLDIR}/ |
| 602 | fi |