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 |
| 23 | # |
| 24 | # The library name should just be "GL" or "GLU", etc. The 'lib' prefix |
| 25 | # will be added here if needed, as well as the ".so" or ".a" suffix, etc. |
| 26 | # |
| 27 | # objects should be: foo.o bar.o etc.o |
| 28 | # |
| 29 | # Environment variables recognized: |
| 30 | # CC C compiler command |
| 31 | # CXX C++ compiler command |
| 32 | # |
| 33 | |
| 34 | |
| 35 | # |
| 36 | # Option defaults |
| 37 | # |
| 38 | LIBNAME="" |
| 39 | MAJOR=1 |
| 40 | MINOR=0 |
| 41 | PATCH=0 |
| 42 | DEPS="" |
| 43 | CPLUSPLUS=0 |
| 44 | STATIC=0 |
| 45 | INSTALLDIR="." |
| 46 | ARCH="auto" |
| 47 | ARCHOPT="" |
| 48 | |
| 49 | |
| 50 | # |
| 51 | # Parse arguments |
| 52 | # |
| 53 | while true |
| 54 | do |
| 55 | case $1 in |
| 56 | '-o') shift 1; LIBNAME=$1;; |
| 57 | '-major') shift 1; MAJOR=$1;; |
| 58 | '-minor') shift 1; MINOR=$1;; |
| 59 | '-patch') shift 1; PATCH=$1;; |
| 60 | -l*) DEPS="$DEPS $1";; |
| 61 | -L*) DEPS="$DEPS $1";; |
| 62 | '-cplusplus') CPLUSPLUS=1;; |
| 63 | '-static') STATIC=1;; |
| 64 | '-install') shift 1; INSTALLDIR=$1;; |
| 65 | '-arch') shift 1; ARCH=$1;; |
| 66 | '-archopt') shift 1; ARCHOPT=$1;; |
| 67 | -*) echo "mklib: Unknown option: " $1 ; exit 1;; |
| 68 | *) break |
| 69 | esac |
| 70 | shift 1 |
| 71 | done |
| 72 | OBJECTS=$@ |
| 73 | |
| 74 | if [ ${ARCH} = "auto" ] ; then |
| 75 | ARCH=`uname` |
| 76 | fi |
| 77 | |
| 78 | |
| 79 | # |
| 80 | # Error checking |
| 81 | # |
| 82 | if [ "x${LIBNAME}" = "x" ] ; then |
| 83 | echo "mklib: Error: no library name specified" |
| 84 | exit 1 |
| 85 | fi |
| 86 | if [ "x${OBJECTS}" = "x" ] ; then |
| 87 | echo "mklib: Error: no object files specified" |
| 88 | exit 1 |
| 89 | fi |
| 90 | |
| 91 | |
| 92 | # |
| 93 | # Debugging info |
| 94 | # |
| 95 | if [ ] ; then |
| 96 | echo "-----------------" |
| 97 | echo ARCH is $ARCH |
| 98 | echo LIBNAME is $LIBNAME |
| 99 | echo MAJOR is $MAJOR |
| 100 | echo MINOR is $MINOR |
| 101 | echo PATCH is $PATCH |
| 102 | echo DEPS are $DEPS |
| 103 | echo "-----------------" |
| 104 | fi |
| 105 | |
| 106 | |
| 107 | # |
| 108 | # OK, make the library now |
| 109 | # |
| 110 | case $ARCH in |
| 111 | |
Brian Paul | 12d6cae | 2004-01-10 22:12:21 +0000 | [diff] [blame] | 112 | 'Linux' | 'OpenBSD') |
| 113 | # GCC-based environment |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 114 | LIBNAME="lib${LIBNAME}" # prefix with "lib" |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 115 | |
Brian Paul | 1c4b711 | 2003-10-10 17:58:38 +0000 | [diff] [blame] | 116 | if [ $STATIC = 1 ] ; then |
Brian Paul | 5b9a9d4 | 2004-01-17 18:31:12 +0000 | [diff] [blame] | 117 | echo "mklib: Making" $ARCH "static library: " ${LIBNAME}.a |
Brian Paul | 1c4b711 | 2003-10-10 17:58:38 +0000 | [diff] [blame] | 118 | LINK="ar" |
| 119 | OPTS="-ruv" |
| 120 | # make lib |
| 121 | ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS} |
| 122 | # finish up |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame^] | 123 | FINAL_LIBS=${LIBNAME} |
Brian Paul | 1c4b711 | 2003-10-10 17:58:38 +0000 | [diff] [blame] | 124 | else |
Brian Paul | 5b9a9d4 | 2004-01-17 18:31:12 +0000 | [diff] [blame] | 125 | if [ $ARCH = 'Linux' ] ; then |
| 126 | OPTS="-Xlinker -Bsymbolic -shared -Wl,-soname,${LIBNAME}.so.${MAJOR}" |
| 127 | else |
| 128 | OPTS="-shared -Wl,-soname,${LIBNAME}.so.${MAJOR}" |
| 129 | fi |
Brian Paul | 1c4b711 | 2003-10-10 17:58:38 +0000 | [diff] [blame] | 130 | VERSION="${MAJOR}.${MINOR}.${PATCH}" |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 131 | |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame^] | 132 | echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}.so.${VERSION} |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 133 | |
Brian Paul | 1c4b711 | 2003-10-10 17:58:38 +0000 | [diff] [blame] | 134 | if [ $CPLUSPLUS = 1 ] ; then |
| 135 | LINK="g++" |
| 136 | else |
| 137 | LINK="gcc" |
| 138 | fi |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 139 | |
Brian Paul | 1c4b711 | 2003-10-10 17:58:38 +0000 | [diff] [blame] | 140 | # rm any old libs |
| 141 | rm -f ${LIBNAME}.so.${VERSION} |
| 142 | rm -f ${LIBNAME}.so.${MAJOR} |
| 143 | rm -f ${LIBNAME}.so |
| 144 | |
| 145 | # make lib |
| 146 | ${LINK} ${OPTS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS} |
| 147 | # make usual symlinks |
| 148 | ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} |
| 149 | ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so |
| 150 | # finish up |
| 151 | FINAL_LIBS="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so" |
| 152 | fi |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 153 | ;; |
| 154 | |
| 155 | 'SunOS') |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame^] | 156 | if [ $STATIC = 1 ] ; then |
| 157 | LIBNAME="lib${LIBNAME}.a" |
| 158 | echo "mklib: Making SunOS static library: " ${LIBNAME} |
| 159 | rm -f ${LIBNAME} |
| 160 | ar ru ${LIBNAME} ${OBJECTS} |
| 161 | FINAL_LIBS=${LIBNAME} |
| 162 | else |
| 163 | LIBNAME="lib${LIBNAME}.so" |
| 164 | echo "mklib: Making SunOS shared library: " ${LIBNAME} |
| 165 | # XXX OPTS for gcc should be -shared, but that doesn't work. |
| 166 | # Using -G does work though. |
| 167 | if [ $CPLUSPLUS = 1 ] ; then |
| 168 | # determine linker and options for C++ code |
| 169 | if [ "x${CXX}" = "xg++" ] ; then |
| 170 | # use g++ |
| 171 | LINK="g++" |
| 172 | OPTS="-G" |
| 173 | elif [ "x${CXX}" = "xCC" ] ; then |
| 174 | # use Sun CC |
| 175 | LINK="CC" |
| 176 | OPTS="-G" |
| 177 | elif [ "x${CXX}" = "xc++" ] ; then |
| 178 | # use Sun c++ |
| 179 | LINK="c++" |
| 180 | OPTS="-G" |
| 181 | elif [ `which c++` ] ; then |
| 182 | # use Sun c++ |
| 183 | LINK="c++" |
| 184 | OPTS="-G" |
| 185 | elif [ `type g++` ] ; then |
| 186 | # use g++ |
| 187 | LINK="g++" |
| 188 | OPTS="-G" |
| 189 | else |
| 190 | echo "mklib: warning: can't find C++ comiler, trying CC." |
| 191 | LINK="CC" |
| 192 | OPTS="-G" |
| 193 | fi |
| 194 | elif [ "x${CC}" = "xgcc" ] ; then |
| 195 | # use gcc for linking |
| 196 | LINK="gcc" |
Brian Paul | 4b60344 | 2004-01-14 23:18:47 +0000 | [diff] [blame] | 197 | OPTS="-G" |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 198 | else |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame^] | 199 | # use native Sun linker |
| 200 | LINK="ld" |
Brian Paul | 1a644b3 | 2003-12-06 17:57:12 +0000 | [diff] [blame] | 201 | OPTS="-G" |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 202 | fi |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame^] | 203 | echo "mklib: linker is" ${LINK} ${OPTS} |
| 204 | rm -f ${LIBNAME}.${MAJOR} ${LIBNAME} |
| 205 | ${LINK} ${OPTS} -o ${LIBNAME}.${MAJOR} ${OBJECTS} ${DEPS} |
| 206 | ln -s ${LIBNAME}.${MAJOR} ${LIBNAME} |
| 207 | FINAL_LIBS="${LIBNAME}.${MAJOR} ${LIBNAME}" |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 208 | fi |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 209 | ;; |
| 210 | |
| 211 | 'FreeBSD') |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame^] | 212 | if [ $STATIC = 1 ] ; then |
| 213 | STLIB="lib${LIBNAME}.a" |
| 214 | echo "mklib: Making FreeBSD static library: " ${STLIB} |
| 215 | rm -f ${STLIB} |
| 216 | ar cq ${STLIB} ${OBJECTS} |
| 217 | ranlib ${STLIB} |
| 218 | FINAL_LIBS=${STLIB} |
| 219 | else |
| 220 | SHLIB="lib${LIBNAME}.so.${MAJOR}.${MINOR}" |
| 221 | echo "mklib: Making FreeBSD shared library: " ${SHLIB} |
| 222 | rm -f ${SHLIB} |
| 223 | ld -Bshareable -o ${SHLIB} ${OBJECTS} |
| 224 | # XXX make lib${LIBNAME}.so.${MAJOR} symlink? |
| 225 | FINAL_LIBS=${SHLIB} |
| 226 | fi |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 227 | ;; |
| 228 | |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 229 | 'NetBSD') |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame^] | 230 | if [ $STATIC = 1 ] ; then |
| 231 | LIBNAME="lib${LIBNAME}_pic.a" |
| 232 | echo "mklib: Making NetBSD PIC static library: " ${LIBNAME} |
| 233 | rm -f ${LIBNAME} |
| 234 | ar cq ${LIBNAME} ${OBJECTS} |
| 235 | ranlib ${LIBNAME} |
| 236 | FINAL_LIBS=${LIBNAME} |
| 237 | else |
| 238 | LIBNAME="lib${LIBNAME}.so.${MAJOR}.${MINOR}" |
| 239 | echo "mklib: Making NetBSD PIC shared library: " ${LIBNAME} |
| 240 | rm -f ${LIBNAME} |
| 241 | ld -x -Bshareable -Bforcearchive -o ${LIBNAME} ${OBJECTS} |
| 242 | FINAL_LIBS=${LIBNAME} |
| 243 | fi |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 244 | ;; |
| 245 | |
Brian Paul | f8c31fc | 2004-01-29 15:21:47 +0000 | [diff] [blame] | 246 | 'IRIX' | 'IRIX64') |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame^] | 247 | if [ $STATIC = 1 ] ; then |
| 248 | LIBNAME="lib${LIBNAME}.a" |
| 249 | rm -f ${LIBNAME} |
| 250 | ar rc ${LIBNAME} ${OBJECTS} |
| 251 | FINAL_LIBS=${LIBNAME} |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 252 | else |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame^] | 253 | LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so" |
| 254 | if [ $ARCHOPT = "64" ] ; then |
| 255 | # 64-bit ABI |
| 256 | OPTS="-64 -shared -all" |
| 257 | echo "mklib: Making IRIX 64-bit shared library: " ${LIBNAME} |
| 258 | elif [ $ARCHOPT = "o32" ] ; then |
| 259 | # old 32-bit ABI |
| 260 | OPTS="-32 -shared -all" |
| 261 | echo "mklib: Making IRIX o32-bit shared library: " ${LIBNAME} |
| 262 | else |
| 263 | # new 32-bit ABI |
| 264 | OPTS="-n32 -shared -all" |
| 265 | echo "mklib: Making IRIX n32-bit shared library: " ${LIBNAME} |
| 266 | fi |
| 267 | if [ $CPLUSPLUS = 1 ] ; then |
| 268 | LINK="CC" |
| 269 | else |
| 270 | LINK="ld" |
| 271 | fi |
| 272 | ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS} |
| 273 | FINAL_LIBS=${LIBNAME} |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 274 | fi |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 275 | ;; |
| 276 | |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 277 | 'linux-cygwin') |
| 278 | LIBNAME="lib${LIBNAME}.a" |
| 279 | echo "mklib: Making linux-cygwin library: " ${LIBNAME} |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame^] | 280 | rm -f ${LIBNAME} |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 281 | gnuwin32ar ruv ${LIBNAME} ${OBJECTS} |
| 282 | FINAL_LIBS=${LIBNAME} |
| 283 | ;; |
| 284 | |
| 285 | 'HPUX') |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame^] | 286 | if [ $STATIC = 1 ] ; then |
| 287 | LIBNAME="lib${LIBNAME}.a" |
| 288 | echo "mklib: Making HPUX static library: " ${LIBNAME} |
| 289 | rm -f ${LIBNAME} |
| 290 | ar ru ${LIBNAME} ${OBJECTS} |
| 291 | FINAL_LIBS=${LIBNAME} |
| 292 | else |
| 293 | RUNLIB="lib${LIBNAME}.${MAJOR}" |
| 294 | DEVLIB="lib${LIBNAME}.sl" |
| 295 | echo "mklib: Making HPUX stared library: " ${RUNLIB} ${DEVLIB} |
| 296 | ld -b -o ${RUNLIB} +b ${RUNLIB} ${OBJECTS} ${DEPS} |
| 297 | ln -s ${RUNLIB} ${DEVLIB} |
| 298 | FINAL_LIBS="{RUNLIB} ${DEVLIB}" |
| 299 | fi |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 300 | ;; |
| 301 | |
| 302 | 'OpenSTEP') |
| 303 | LIBNAME="lib${LIBNAME}.a" |
| 304 | echo "mklib: Making OpenSTEP static library: " ${LIBNAME} |
| 305 | libtool -static -o ${LIBNAME} - ${OBJECTS} |
| 306 | FINAL_LIBS=${LIBNAME} |
| 307 | ;; |
| 308 | |
| 309 | 'OSF1') |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame^] | 310 | if [ $STATIC = 1 ] ; then |
| 311 | LIBNAME="lib${LIBNAME}.a" |
| 312 | echo "mklib: Making OSF/1 static library: " ${LIBNAME} |
| 313 | rm -f ${LIBNAME} |
| 314 | ar clqz ${LIBNAME} ${OBJECTS} |
| 315 | FINAL_LIBS=${LIBNAME} |
| 316 | else |
| 317 | VERSION="${MAJOR}.${MINOR}" |
| 318 | LIBNAME="lib${LIBNAME}.so" |
| 319 | echo "mklib: Making OSF/1 shared library: " ${LIBNAME} |
| 320 | rm -f ${LIBNAME}.${VERSION} |
| 321 | ld -o ${LIBNAME}.${VERSION} -shared -no_archive -set_version ${VERSION} -soname ${LIBNAME}.${VERSION} -expect_unresolved \* -all ${OBJECTS} ${DEPS} |
| 322 | ln -sf ${LIBNAME}.${VERSION} ${LIBNAME} |
| 323 | FINAL_LIBS="${LIBNAME} ${LIBNAME}.${VERSION}" |
| 324 | fi |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 325 | ;; |
| 326 | |
| 327 | 'Darwin') |
| 328 | VERSION="${MAJOR}.${MINOR}.${TINY}" |
| 329 | LIBNAME="lib${LIBNAME}.dylib" |
| 330 | ARNAME="lib${LIBNAME}.dylib.a" |
| 331 | echo "mklib: Making Darwin libraries: " ${LIBNAME} ${ARNAME} |
| 332 | FLAGS="-dynamiclib -multiply_defined suppress" |
| 333 | cc ${FLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS} |
| 334 | # also make regular .a files, |
| 335 | # provided by Danek Duvall (duvall@dhduvall.student.princeton.edu) |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame^] | 336 | rm -f ${ARNAME} |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 337 | ar ruv ${ARNAME} ${OBJECTS} |
| 338 | ranlib ${ARNAME} |
| 339 | FINAL_LIBS="${ARNAME} ${LIBNAME}" |
| 340 | ;; |
| 341 | |
| 342 | 'LynxOS') |
| 343 | LIBNAME="lib${LIBNAME}.a" |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame^] | 344 | echo "mklib: Making LynxOS static library: " ${LIBNAME} |
| 345 | rm -f ${LIBNAME} |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 346 | ar ru ${LIBNAME} ${OBJECTS} |
| 347 | FINAL_LIBS=${LIBNAME} |
| 348 | ;; |
| 349 | |
| 350 | 'BeOS') |
| 351 | LIBNAME="lib${LIBNAME}.so" |
| 352 | echo "mklib: Making BeOS shared library: " ${LIBNAME} |
| 353 | gcc -nostart -Xlinker -soname=${LIBNAME} -L/Be/develop/lib/x86 ${OBJECTS} -lbe -o ${LIBNAME} |
| 354 | FINAL_LIBS=${LIBNAME} |
| 355 | ;; |
| 356 | |
| 357 | 'QNX') |
| 358 | LIBNAME="lib${LIBNAME}.a" |
| 359 | echo "mklib: Making QNX library: " ${LIBNAME} |
| 360 | wlib ${LIBNAME} ${OBJECTS} |
| 361 | FINAL_LIBS=${LIBNAME} |
| 362 | ;; |
| 363 | |
Brian Paul | 65e2ab3 | 2003-10-27 18:13:37 +0000 | [diff] [blame] | 364 | 'MorphOS') |
| 365 | LIBNAME="lib${LIBNAME}.a" |
| 366 | echo "mklib: Making MorphOS library: " ${LIBNAME} |
| 367 | ppc-morphos-ar rc ${LIBNAME} ${OBJECTS} |
| 368 | FINAL_LIBS="${LIBNAME}" |
| 369 | ;; |
| 370 | |
Brian Paul | b3b725b | 2003-12-15 16:14:55 +0000 | [diff] [blame] | 371 | 'icc') |
| 372 | # Intel C compiler |
| 373 | LIBNAME="lib${LIBNAME}" # prefix with "lib" |
| 374 | |
| 375 | if [ $STATIC = 1 ] ; then |
| 376 | echo "mklib: Making Intel ICC static library: " ${LIBNAME}.a |
| 377 | LINK="ar" |
| 378 | OPTS="-ruv" |
| 379 | # make lib |
| 380 | ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS} |
| 381 | # finish up |
| 382 | FINAL_LIBS="${LIBNAME}.a" |
| 383 | else |
| 384 | OPTS="-shared" |
| 385 | VERSION="${MAJOR}.${MINOR}.${PATCH}" |
| 386 | |
| 387 | echo "mklib: Making Intel ICC shared library: " ${LIBNAME}.so.${VERSION} |
| 388 | |
| 389 | if [ $CPLUSPLUS = 1 ] ; then |
| 390 | LINK="icc" |
| 391 | else |
| 392 | LINK="icc" |
| 393 | fi |
| 394 | |
| 395 | # rm any old libs |
| 396 | rm -f ${LIBNAME}.so.${VERSION} |
| 397 | rm -f ${LIBNAME}.so.${MAJOR} |
| 398 | rm -f ${LIBNAME}.so |
| 399 | |
| 400 | # make lib |
| 401 | ${LINK} ${OPTS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS} |
| 402 | # make usual symlinks |
| 403 | ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} |
| 404 | ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so |
| 405 | # finish up |
| 406 | FINAL_LIBS="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so" |
| 407 | fi |
| 408 | ;; |
| 409 | |
Brian Paul | 12d6cae | 2004-01-10 22:12:21 +0000 | [diff] [blame] | 410 | 'aix-gcc') |
| 411 | # AIX with gcc |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame^] | 412 | if [ $STATIC = 1 ] ; then |
| 413 | LIBNAME="lib${LIBNAME}.a" |
| 414 | echo "mklib: Making AIX GCC static library: " ${LIBNAME} |
| 415 | rm -f ${LIBNAME} |
| 416 | ar ru ${LIBNAME} ${OBJECTS} |
| 417 | FINAL_LIBS=${LIBNAME} |
| 418 | else |
| 419 | LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so" |
| 420 | echo "mklib: Making AIX GCC shared library: " ${LIBNAME} |
| 421 | # remove old lib |
| 422 | rm -f ${LIBNAME} |
| 423 | # make the lib |
| 424 | gcc -shared -Wl,-G ${OBJECTS} ${DEPS} -o ${LIBNAME} |
| 425 | |
| 426 | # NOTE: the application linking with this library must specify |
| 427 | # the -Wl,-brtl flags to gcc |
| 428 | |
| 429 | FINAL_LIBS=${LIBNAME} |
| 430 | fi |
| 431 | ;; |
| 432 | |
| 433 | 'ultrix') |
| 434 | # XXX untested |
| 435 | if [ $STATIC = 0 ] ; then |
| 436 | echo "mklib: Warning shared libs not supported on Ultrix" |
| 437 | fi |
| 438 | LIBNAME="lib${LIBNAME}.a" |
| 439 | echo "mklib: Making static library for Ultrix: " ${LIBNAME} |
Brian Paul | 12d6cae | 2004-01-10 22:12:21 +0000 | [diff] [blame] | 440 | rm -f ${LIBNAME} |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame^] | 441 | ar ru ${LIBNAME} ${OBJECTS} |
| 442 | FINAL_LIBS="${LIBNAME}" |
Brian Paul | 12d6cae | 2004-01-10 22:12:21 +0000 | [diff] [blame] | 443 | ;; |
Brian Paul | b3b725b | 2003-12-15 16:14:55 +0000 | [diff] [blame] | 444 | |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 445 | 'example') |
| 446 | # If you're adding support for a new architecture, you can |
| 447 | # start with this: |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame^] | 448 | if [ $STATIC = 1 ] ; then |
| 449 | LIBNAME="lib${LIBNAME}.a" |
| 450 | echo "mklib: Making static library for example arch: " ${LIBNAME} |
| 451 | rm -f ${LIBNAME} |
| 452 | ar rv ${LIBNAME} ${OBJECTS} |
| 453 | FINAL_LIBS="${LIBNAME}" |
| 454 | else |
| 455 | LIBNAME="lib${LIBNAME}.so" # prefix with "lib" |
| 456 | echo "mklib: Making shared library for example arch: " ${LIBNAME} |
| 457 | ld -o ${LIBNAME} ${OBJECTS} ${DEPS} |
| 458 | FINAL_LIBS="${LIBNAME}" |
| 459 | fi |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 460 | ;; |
| 461 | |
| 462 | *) |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame^] | 463 | echo "mklib: ERROR: Don't know how to make a static/shared library for" ${ARCH} |
| 464 | echo "mklib: Please add necessary commands to mklib script." |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 465 | ;; |
| 466 | esac |
| 467 | |
| 468 | |
| 469 | # |
| 470 | # Put library files into installation directory if specified. |
| 471 | # |
| 472 | if [ ${INSTALLDIR} != "." ] ; then |
| 473 | echo "mklib: Installing" ${FINAL_LIBS} "in" ${INSTALLDIR} |
| 474 | mv ${FINAL_LIBS} ${INSTALLDIR}/ |
| 475 | fi |