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