Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | # Make a shared library. |
Brian Paul | 7c1ab40 | 2005-07-25 23:49:50 +0000 | [diff] [blame] | 4 | # This script should be useful for projects other than Mesa. |
| 5 | # Improvements/fixes are welcome. |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 6 | |
| 7 | |
Brian Paul | 56e0ee8 | 2006-04-13 15:17:50 +0000 | [diff] [blame^] | 8 | # Copyright (C) 1999-2006 Brian Paul All Rights Reserved. |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 9 | # |
Brian Paul | 7c1ab40 | 2005-07-25 23:49:50 +0000 | [diff] [blame] | 10 | # Permission is hereby granted, free of charge, to any person obtaining a |
| 11 | # copy of this software and associated documentation files (the "Software"), |
| 12 | # to deal in the Software without restriction, including without limitation |
| 13 | # the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 14 | # and/or sell copies of the Software, and to permit persons to whom the |
| 15 | # Software is furnished to do so, subject to the following conditions: |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 16 | # |
Brian Paul | 7c1ab40 | 2005-07-25 23:49:50 +0000 | [diff] [blame] | 17 | # The above copyright notice and this permission notice shall be included |
| 18 | # in all copies or substantial portions of the Software. |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 19 | # |
Brian Paul | 7c1ab40 | 2005-07-25 23:49:50 +0000 | [diff] [blame] | 20 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 21 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 22 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 23 | # BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
| 24 | # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 25 | # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 26 | |
| 27 | |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 28 | # |
| 29 | # Option defaults |
| 30 | # |
| 31 | LIBNAME="" |
| 32 | MAJOR=1 |
| 33 | MINOR=0 |
Brian Paul | 6e450f2 | 2004-02-21 18:08:41 +0000 | [diff] [blame] | 34 | PATCH="" |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 35 | DEPS="" |
Brian Paul | 8dcc673 | 2005-07-25 22:59:58 +0000 | [diff] [blame] | 36 | LINK="" |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 37 | CPLUSPLUS=0 |
| 38 | STATIC=0 |
| 39 | INSTALLDIR="." |
| 40 | ARCH="auto" |
| 41 | ARCHOPT="" |
Brian Paul | dd74e36 | 2004-04-08 22:26:22 +0000 | [diff] [blame] | 42 | NOPREFIX=0 |
Brian Paul | 158a251 | 2004-10-16 15:10:45 +0000 | [diff] [blame] | 43 | EXPORTS="" |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 44 | |
| 45 | |
| 46 | # |
| 47 | # Parse arguments |
| 48 | # |
| 49 | while true |
| 50 | do |
| 51 | case $1 in |
Brian Paul | 7c1ab40 | 2005-07-25 23:49:50 +0000 | [diff] [blame] | 52 | '-h' | '--help') |
Eric Anholt | f1a2613 | 2005-08-08 03:26:18 +0000 | [diff] [blame] | 53 | echo 'Usage: mklib [options] objects' |
| 54 | echo 'Create a shared library from object files.' |
| 55 | echo ' -o LIBRARY specifies the name of the resulting library, without' |
| 56 | echo ' the leading "lib" or any suffix.' |
| 57 | echo ' (eg: "-o GL" might result in "libGL.so" being made)' |
| 58 | echo ' -major N specifies major version number (default is 1)' |
| 59 | echo ' -minor N specifies minor version number (default is 0)' |
| 60 | echo ' -patch N specifies patch version number (default is 0)' |
| 61 | echo ' -lLIBRARY specifies a dependency on LIBRARY' |
| 62 | echo ' -LDIR search in DIR for library dependencies' |
| 63 | echo ' -linker L explicity specify the linker program to use (eg: gcc, g++)' |
| 64 | echo ' Not observed on all systems at this time.' |
| 65 | echo ' -cplusplus link with C++ runtime' |
| 66 | echo ' -static make a static library (default is dynamic/shared)' |
| 67 | echo ' -install DIR put resulting library file(s) in DIR' |
| 68 | echo ' -arch ARCH override using `uname` to determine host system' |
| 69 | echo ' -archopt OPT specify an extra achitecture-specific option OPT' |
| 70 | echo " -noprefix don't prefix library name with 'lib' nor add any suffix" |
| 71 | echo ' -exports FILE only export the symbols listed in FILE' |
| 72 | echo ' -h, --help display this information and exit' |
Brian Paul | 7c1ab40 | 2005-07-25 23:49:50 +0000 | [diff] [blame] | 73 | exit 1 |
| 74 | ;; |
| 75 | '-o') |
| 76 | shift 1; |
| 77 | LIBNAME=$1 |
| 78 | ;; |
| 79 | '-major') |
| 80 | shift 1; |
| 81 | MAJOR=$1 |
| 82 | ;; |
| 83 | '-minor') |
| 84 | shift 1; |
| 85 | MINOR=$1 |
| 86 | ;; |
| 87 | '-patch') |
| 88 | shift 1; |
| 89 | PATCH=$1 |
| 90 | ;; |
| 91 | '-linker') |
| 92 | shift 1; |
| 93 | LINK=$1 |
| 94 | ;; |
| 95 | -l*) |
| 96 | DEPS="$DEPS $1" |
| 97 | ;; |
| 98 | -L*) |
| 99 | DEPS="$DEPS $1" |
| 100 | ;; |
| 101 | '-cplusplus') |
| 102 | CPLUSPLUS=1 |
| 103 | ;; |
| 104 | '-static') |
| 105 | STATIC=1 |
| 106 | ;; |
| 107 | '-install') |
| 108 | shift 1; |
| 109 | INSTALLDIR=$1 |
| 110 | ;; |
| 111 | '-arch') |
| 112 | shift 1; |
| 113 | ARCH=$1 |
| 114 | ;; |
| 115 | '-archopt') |
| 116 | shift 1; |
| 117 | ARCHOPT=$1 |
| 118 | ;; |
| 119 | '-noprefix') |
| 120 | NOPREFIX=1 |
| 121 | ;; |
| 122 | '-exports') |
| 123 | shift 1; |
| 124 | EXPORTS=$1 |
| 125 | ;; |
| 126 | -*) |
| 127 | echo "mklib: Unknown option: " $1 ; |
| 128 | exit 1 |
| 129 | ;; |
| 130 | *) |
| 131 | # This should be the first object file, stop parsing |
| 132 | break |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 133 | esac |
| 134 | shift 1 |
| 135 | done |
| 136 | OBJECTS=$@ |
| 137 | |
Brian Paul | 7c1ab40 | 2005-07-25 23:49:50 +0000 | [diff] [blame] | 138 | |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 139 | if [ ${ARCH} = "auto" ] ; then |
| 140 | ARCH=`uname` |
| 141 | fi |
| 142 | |
| 143 | |
| 144 | # |
| 145 | # Error checking |
| 146 | # |
| 147 | if [ "x${LIBNAME}" = "x" ] ; then |
| 148 | echo "mklib: Error: no library name specified" |
| 149 | exit 1 |
| 150 | fi |
| 151 | if [ "x${OBJECTS}" = "x" ] ; then |
| 152 | echo "mklib: Error: no object files specified" |
| 153 | exit 1 |
| 154 | fi |
| 155 | |
| 156 | |
| 157 | # |
| 158 | # Debugging info |
| 159 | # |
| 160 | if [ ] ; then |
| 161 | echo "-----------------" |
| 162 | echo ARCH is $ARCH |
| 163 | echo LIBNAME is $LIBNAME |
| 164 | echo MAJOR is $MAJOR |
| 165 | echo MINOR is $MINOR |
| 166 | echo PATCH is $PATCH |
| 167 | echo DEPS are $DEPS |
Brian Paul | 158a251 | 2004-10-16 15:10:45 +0000 | [diff] [blame] | 168 | echo "EXPORTS in" $EXPORTS |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 169 | echo "-----------------" |
| 170 | fi |
| 171 | |
| 172 | |
| 173 | # |
| 174 | # OK, make the library now |
| 175 | # |
| 176 | case $ARCH in |
| 177 | |
Brian Paul | 12d6cae | 2004-01-10 22:12:21 +0000 | [diff] [blame] | 178 | 'Linux' | 'OpenBSD') |
Brian Paul | 158a251 | 2004-10-16 15:10:45 +0000 | [diff] [blame] | 179 | # we assume gcc |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 180 | |
Brian Paul | 8dcc673 | 2005-07-25 22:59:58 +0000 | [diff] [blame] | 181 | if [ "x$LINK" = "x" ] ; then |
| 182 | # -linker was not specified so set default link command now |
| 183 | if [ $CPLUSPLUS = 1 ] ; then |
| 184 | LINK=g++ |
| 185 | else |
| 186 | LINK=gcc |
| 187 | fi |
Brian Paul | c498742 | 2004-10-16 15:02:16 +0000 | [diff] [blame] | 188 | fi |
| 189 | |
Brian Paul | dd74e36 | 2004-04-08 22:26:22 +0000 | [diff] [blame] | 190 | if [ $NOPREFIX = 1 ] ; then |
| 191 | # No "lib" or ".so" part |
| 192 | echo "mklib: Making" $ARCH "shared library: " ${LIBNAME} |
| 193 | #OPTS="-shared -Wl,-soname,${LIBNAME}" # soname??? |
| 194 | OPTS="-shared" |
Ian Romanick | aba4864 | 2005-08-08 23:22:46 +0000 | [diff] [blame] | 195 | |
| 196 | # Check if objects are 32-bit and we're running in 64-bit |
| 197 | # environment. If so, pass -m32 flag to linker. |
| 198 | set ${OBJECTS} |
| 199 | ABI32=`file $1 | grep 32-bit` |
| 200 | if [ "${ABI32}" -a `uname -m` = "x86_64" ] ; then |
| 201 | OPTS="-m32 ${OPTS}" |
| 202 | fi |
| 203 | |
Brian Paul | dd74e36 | 2004-04-08 22:26:22 +0000 | [diff] [blame] | 204 | rm -f ${LIBNAME} |
Brian Paul | dd74e36 | 2004-04-08 22:26:22 +0000 | [diff] [blame] | 205 | # make lib |
| 206 | ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS} |
| 207 | # finish up |
| 208 | FINAL_LIBS="${LIBNAME}" |
| 209 | elif [ $STATIC = 1 ] ; then |
| 210 | LIBNAME="lib${LIBNAME}" # prefix with "lib" |
Brian Paul | 5b9a9d4 | 2004-01-17 18:31:12 +0000 | [diff] [blame] | 211 | echo "mklib: Making" $ARCH "static library: " ${LIBNAME}.a |
Brian Paul | 56e0ee8 | 2006-04-13 15:17:50 +0000 | [diff] [blame^] | 212 | LINK="ar" |
| 213 | OPTS="-ru" |
| 214 | # make lib |
| 215 | ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS} |
Brian Paul | 6e450f2 | 2004-02-21 18:08:41 +0000 | [diff] [blame] | 216 | ranlib ${LIBNAME}.a |
Brian Paul | 1c4b711 | 2003-10-10 17:58:38 +0000 | [diff] [blame] | 217 | # finish up |
Brian Paul | 6e450f2 | 2004-02-21 18:08:41 +0000 | [diff] [blame] | 218 | FINAL_LIBS=${LIBNAME}.a |
Brian Paul | 1c4b711 | 2003-10-10 17:58:38 +0000 | [diff] [blame] | 219 | else |
Brian Paul | dd74e36 | 2004-04-08 22:26:22 +0000 | [diff] [blame] | 220 | LIBNAME="lib${LIBNAME}" # prefix with "lib" |
Brian Paul | 5b9a9d4 | 2004-01-17 18:31:12 +0000 | [diff] [blame] | 221 | if [ $ARCH = 'Linux' ] ; then |
| 222 | OPTS="-Xlinker -Bsymbolic -shared -Wl,-soname,${LIBNAME}.so.${MAJOR}" |
| 223 | else |
| 224 | OPTS="-shared -Wl,-soname,${LIBNAME}.so.${MAJOR}" |
| 225 | fi |
Brian Paul | 158a251 | 2004-10-16 15:10:45 +0000 | [diff] [blame] | 226 | if [ $EXPORTS ] ; then |
| 227 | #OPTS="${OPTS} -Xlinker --retain-symbols-file ${EXPORTS}" |
| 228 | # Make the 'exptmp' file for --version-script option |
| 229 | echo "VERSION_${MAJOR}.${MINOR} {" > exptmp |
| 230 | echo "global:" >> exptmp |
| 231 | sed 's/$/;/' ${EXPORTS} >> exptmp |
| 232 | echo "local:" >> exptmp |
| 233 | echo "*;" >> exptmp |
| 234 | echo "};" >> exptmp |
| 235 | OPTS="${OPTS} -Xlinker --version-script=exptmp" |
| 236 | # exptmp is removed below |
| 237 | fi |
Brian Paul | 3e19618 | 2005-03-03 01:38:13 +0000 | [diff] [blame] | 238 | |
| 239 | # Check if objects are 32-bit and we're running in 64-bit |
| 240 | # environment. If so, pass -m32 flag to linker. |
| 241 | set ${OBJECTS} |
| 242 | ABI32=`file $1 | grep 32-bit` |
| 243 | if [ "${ABI32}" -a `uname -m` = "x86_64" ] ; then |
| 244 | OPTS="-m32 ${OPTS}" |
| 245 | fi |
| 246 | |
Brian Paul | 6e450f2 | 2004-02-21 18:08:41 +0000 | [diff] [blame] | 247 | if [ x${PATCH} = "x" ] ; then |
| 248 | VERSION="${MAJOR}.${MINOR}" |
| 249 | else |
| 250 | VERSION="${MAJOR}.${MINOR}.${PATCH}" |
| 251 | fi |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 252 | |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 253 | echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}.so.${VERSION} |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 254 | |
Brian Paul | 1c4b711 | 2003-10-10 17:58:38 +0000 | [diff] [blame] | 255 | # rm any old libs |
| 256 | rm -f ${LIBNAME}.so.${VERSION} |
| 257 | rm -f ${LIBNAME}.so.${MAJOR} |
| 258 | rm -f ${LIBNAME}.so |
| 259 | |
| 260 | # make lib |
| 261 | ${LINK} ${OPTS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS} |
| 262 | # make usual symlinks |
| 263 | ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} |
| 264 | ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so |
| 265 | # finish up |
| 266 | FINAL_LIBS="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so" |
Brian Paul | b17a1a1 | 2004-11-01 22:28:42 +0000 | [diff] [blame] | 267 | # rm -f exptmp |
Brian Paul | 1c4b711 | 2003-10-10 17:58:38 +0000 | [diff] [blame] | 268 | fi |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 269 | ;; |
| 270 | |
| 271 | 'SunOS') |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 272 | if [ $STATIC = 1 ] ; then |
| 273 | LIBNAME="lib${LIBNAME}.a" |
| 274 | echo "mklib: Making SunOS static library: " ${LIBNAME} |
| 275 | rm -f ${LIBNAME} |
Brian Paul | c193bd0 | 2004-03-18 15:41:59 +0000 | [diff] [blame] | 276 | ar -ruv ${LIBNAME} ${OBJECTS} |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 277 | FINAL_LIBS=${LIBNAME} |
| 278 | else |
| 279 | LIBNAME="lib${LIBNAME}.so" |
| 280 | echo "mklib: Making SunOS shared library: " ${LIBNAME} |
Brian Paul | 59ebe1f | 2006-04-05 13:43:02 +0000 | [diff] [blame] | 281 | |
Brian Paul | 8dcc673 | 2005-07-25 22:59:58 +0000 | [diff] [blame] | 282 | if [ "x$LINK" = "x" ] ; then |
| 283 | # -linker was not specified, choose default linker now |
| 284 | if [ $CPLUSPLUS = 1 ] ; then |
| 285 | # determine linker and options for C++ code |
| 286 | if [ `which c++` ] ; then |
| 287 | # use Sun c++ |
| 288 | LINK="c++" |
| 289 | elif [ `type g++` ] ; then |
| 290 | # use g++ |
| 291 | LINK="g++" |
| 292 | else |
| 293 | echo "mklib: warning: can't find C++ comiler, trying CC." |
| 294 | LINK="CC" |
| 295 | fi |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 296 | else |
Brian Paul | 8dcc673 | 2005-07-25 22:59:58 +0000 | [diff] [blame] | 297 | # use native Sun linker for C code |
| 298 | LINK="ld" |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 299 | fi |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 300 | fi |
Brian Paul | 59ebe1f | 2006-04-05 13:43:02 +0000 | [diff] [blame] | 301 | |
| 302 | # linker options |
| 303 | if [ ${LINK} = "ld" ] ; then |
| 304 | # SunOS linker, -G to make shared libs |
| 305 | OPTS="-G" |
| 306 | else |
| 307 | # gcc linker |
| 308 | # Check if objects are 32-bit and we're running in 64-bit |
| 309 | # environment. If so, pass -m32 flag to linker. |
| 310 | set ${OBJECTS} |
| 311 | ABI32=`file $1 | grep 32-bit` |
| 312 | if [ "${ABI32}" ] ; then |
| 313 | OPTS="-m32 -shared -Wl,-Bdynamic" |
| 314 | else |
| 315 | OPTS="-m64 -shared -Wl,-Bdynamic" |
| 316 | fi |
| 317 | fi |
| 318 | |
Brian Paul | fe14cf6 | 2006-04-13 02:23:25 +0000 | [diff] [blame] | 319 | ARCHOPTS="" |
| 320 | if [ "$ARCHOPT" = "SUNV9" ] ; then |
| 321 | ARCHOPTS="-xarch=v9" |
| 322 | fi |
Brian Paul | 59ebe1f | 2006-04-05 13:43:02 +0000 | [diff] [blame] | 323 | # for debug: |
Brian Paul | 56e0ee8 | 2006-04-13 15:17:50 +0000 | [diff] [blame^] | 324 | #echo "mklib: linker is" ${LINK} ${OPTS} ${ARCHOPTS} |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 325 | rm -f ${LIBNAME}.${MAJOR} ${LIBNAME} |
Brian Paul | fe14cf6 | 2006-04-13 02:23:25 +0000 | [diff] [blame] | 326 | ${LINK} ${OPTS} ${ARCHOPTS} -o ${LIBNAME}.${MAJOR} ${OBJECTS} ${DEPS} |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 327 | ln -s ${LIBNAME}.${MAJOR} ${LIBNAME} |
| 328 | FINAL_LIBS="${LIBNAME}.${MAJOR} ${LIBNAME}" |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 329 | fi |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 330 | ;; |
| 331 | |
| 332 | 'FreeBSD') |
Eric Anholt | b83435f | 2005-10-18 23:36:40 +0000 | [diff] [blame] | 333 | # we assume gcc |
| 334 | |
| 335 | if [ "x$LINK" = "x" ] ; then |
| 336 | # -linker was not specified so set default link command now |
| 337 | if [ $CPLUSPLUS = 1 ] ; then |
| 338 | LINK=g++ |
| 339 | else |
| 340 | LINK=gcc |
| 341 | fi |
| 342 | fi |
| 343 | |
Brian Paul | dd74e36 | 2004-04-08 22:26:22 +0000 | [diff] [blame] | 344 | if [ $NOPREFIX = 1 ] ; then |
| 345 | # No "lib" or ".so" part |
| 346 | echo "mklib: Making FreeBSD shared library: " ${LIBNAME} |
Eric Anholt | b83435f | 2005-10-18 23:36:40 +0000 | [diff] [blame] | 347 | OPTS="-shared" |
Brian Paul | dd74e36 | 2004-04-08 22:26:22 +0000 | [diff] [blame] | 348 | rm -f ${LIBNAME} |
Eric Anholt | b83435f | 2005-10-18 23:36:40 +0000 | [diff] [blame] | 349 | ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS} |
Brian Paul | dd74e36 | 2004-04-08 22:26:22 +0000 | [diff] [blame] | 350 | FINAL_LIBS=${LIBNAME} |
| 351 | elif [ $STATIC = 1 ] ; then |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 352 | STLIB="lib${LIBNAME}.a" |
| 353 | echo "mklib: Making FreeBSD static library: " ${STLIB} |
| 354 | rm -f ${STLIB} |
| 355 | ar cq ${STLIB} ${OBJECTS} |
| 356 | ranlib ${STLIB} |
| 357 | FINAL_LIBS=${STLIB} |
| 358 | else |
Eric Anholt | b83435f | 2005-10-18 23:36:40 +0000 | [diff] [blame] | 359 | SHLIB="lib${LIBNAME}.so.${MAJOR}" |
| 360 | OPTS="-shared -Wl,-soname,${SHLIB}" |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 361 | echo "mklib: Making FreeBSD shared library: " ${SHLIB} |
| 362 | rm -f ${SHLIB} |
Eric Anholt | b83435f | 2005-10-18 23:36:40 +0000 | [diff] [blame] | 363 | ${LINK} ${OPTS} -o ${SHLIB} ${OBJECTS} ${DEPS} |
Eric Anholt | 1c04be5 | 2005-10-22 01:41:40 +0000 | [diff] [blame] | 364 | ln -sf ${SHLIB} "lib${LIBNAME}.so" |
| 365 | FINAL_LIBS="${SHLIB} lib${LIBNAME}.so" |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 366 | fi |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 367 | ;; |
| 368 | |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 369 | 'NetBSD') |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 370 | if [ $STATIC = 1 ] ; then |
| 371 | LIBNAME="lib${LIBNAME}_pic.a" |
| 372 | echo "mklib: Making NetBSD PIC static library: " ${LIBNAME} |
| 373 | rm -f ${LIBNAME} |
| 374 | ar cq ${LIBNAME} ${OBJECTS} |
| 375 | ranlib ${LIBNAME} |
| 376 | FINAL_LIBS=${LIBNAME} |
| 377 | else |
| 378 | LIBNAME="lib${LIBNAME}.so.${MAJOR}.${MINOR}" |
| 379 | echo "mklib: Making NetBSD PIC shared library: " ${LIBNAME} |
| 380 | rm -f ${LIBNAME} |
| 381 | ld -x -Bshareable -Bforcearchive -o ${LIBNAME} ${OBJECTS} |
| 382 | FINAL_LIBS=${LIBNAME} |
| 383 | fi |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 384 | ;; |
| 385 | |
Brian Paul | f8c31fc | 2004-01-29 15:21:47 +0000 | [diff] [blame] | 386 | 'IRIX' | 'IRIX64') |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 387 | if [ $STATIC = 1 ] ; then |
| 388 | LIBNAME="lib${LIBNAME}.a" |
| 389 | rm -f ${LIBNAME} |
| 390 | ar rc ${LIBNAME} ${OBJECTS} |
| 391 | FINAL_LIBS=${LIBNAME} |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 392 | else |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 393 | LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so" |
Brian Paul | 8dcc673 | 2005-07-25 22:59:58 +0000 | [diff] [blame] | 394 | # XXX we should run 'file' on the first object file to determine |
| 395 | # if it's o32, n32 or 64 format, as we do for Linux above. |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 396 | if [ $ARCHOPT = "64" ] ; then |
| 397 | # 64-bit ABI |
| 398 | OPTS="-64 -shared -all" |
| 399 | echo "mklib: Making IRIX 64-bit shared library: " ${LIBNAME} |
| 400 | elif [ $ARCHOPT = "o32" ] ; then |
| 401 | # old 32-bit ABI |
| 402 | OPTS="-32 -shared -all" |
| 403 | echo "mklib: Making IRIX o32-bit shared library: " ${LIBNAME} |
| 404 | else |
| 405 | # new 32-bit ABI |
| 406 | OPTS="-n32 -shared -all" |
| 407 | echo "mklib: Making IRIX n32-bit shared library: " ${LIBNAME} |
| 408 | fi |
| 409 | if [ $CPLUSPLUS = 1 ] ; then |
| 410 | LINK="CC" |
| 411 | else |
| 412 | LINK="ld" |
| 413 | fi |
| 414 | ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS} |
| 415 | FINAL_LIBS=${LIBNAME} |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 416 | fi |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 417 | ;; |
| 418 | |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 419 | 'linux-cygwin') |
| 420 | LIBNAME="lib${LIBNAME}.a" |
| 421 | echo "mklib: Making linux-cygwin library: " ${LIBNAME} |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 422 | rm -f ${LIBNAME} |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 423 | gnuwin32ar ruv ${LIBNAME} ${OBJECTS} |
| 424 | FINAL_LIBS=${LIBNAME} |
| 425 | ;; |
| 426 | |
Brian Paul | c193bd0 | 2004-03-18 15:41:59 +0000 | [diff] [blame] | 427 | 'HP-UX') |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 428 | if [ $STATIC = 1 ] ; then |
| 429 | LIBNAME="lib${LIBNAME}.a" |
Brian Paul | 52fb07e | 2004-03-30 14:47:02 +0000 | [diff] [blame] | 430 | echo "mklib: Making HP-UX static library: " ${LIBNAME} |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 431 | rm -f ${LIBNAME} |
Brian Paul | c193bd0 | 2004-03-18 15:41:59 +0000 | [diff] [blame] | 432 | ar -ruv ${LIBNAME} ${OBJECTS} |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 433 | FINAL_LIBS=${LIBNAME} |
| 434 | else |
Brian Paul | fe14cf6 | 2006-04-13 02:23:25 +0000 | [diff] [blame] | 435 | # HP uses a .2 for their current GL/GLU libraries |
| 436 | if [ ${LIBNAME} = "GL" -o ${LIBNAME} = "GLU" ] ; then |
| 437 | MAJOR=2 |
| 438 | fi |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 439 | RUNLIB="lib${LIBNAME}.${MAJOR}" |
| 440 | DEVLIB="lib${LIBNAME}.sl" |
Brian Paul | 52fb07e | 2004-03-30 14:47:02 +0000 | [diff] [blame] | 441 | echo "mklib: Making HP-UX shared library: " ${RUNLIB} ${DEVLIB} |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 442 | ld -b -o ${RUNLIB} +b ${RUNLIB} ${OBJECTS} ${DEPS} |
| 443 | ln -s ${RUNLIB} ${DEVLIB} |
Brian Paul | ac0cfee | 2004-04-25 15:13:56 +0000 | [diff] [blame] | 444 | FINAL_LIBS="${RUNLIB} ${DEVLIB}" |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 445 | fi |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 446 | ;; |
| 447 | |
Brian Paul | b17a1a1 | 2004-11-01 22:28:42 +0000 | [diff] [blame] | 448 | 'AIX' | 'AIX64') |
| 449 | if [ $ARCH = "AIX64" ] ; then |
| 450 | X64="-X64" |
| 451 | fi |
Brian Paul | c193bd0 | 2004-03-18 15:41:59 +0000 | [diff] [blame] | 452 | |
Brian Paul | c193bd0 | 2004-03-18 15:41:59 +0000 | [diff] [blame] | 453 | if [ $STATIC = 1 ] ; then |
| 454 | LIBNAME="lib${LIBNAME}.a" |
| 455 | echo "mklib: Making AIX static library: " ${LIBNAME} |
Brian Paul | b17a1a1 | 2004-11-01 22:28:42 +0000 | [diff] [blame] | 456 | ar -ruv ${X64} ${LIBNAME} ${OBJECTS} |
Brian Paul | c193bd0 | 2004-03-18 15:41:59 +0000 | [diff] [blame] | 457 | FINAL_LIBS=${LIBNAME} |
| 458 | else |
Brian Paul | 56e0ee8 | 2006-04-13 15:17:50 +0000 | [diff] [blame^] | 459 | # We make both .a (normal shared lib) and .so (which can be |
| 460 | # loaded with dlopen). |
Karl Schultz | a16bdb5 | 2004-10-01 13:33:26 +0000 | [diff] [blame] | 461 | EXPFILE="lib${LIBNAME}.exp" |
Brian Paul | fe14cf6 | 2006-04-13 02:23:25 +0000 | [diff] [blame] | 462 | if [ $ARCH = "AIX64" ] ; then |
| 463 | OFILE=shr_64.o |
| 464 | else |
| 465 | OFILE=shr.o #Want to be consistent with the IBM libGL.a |
| 466 | fi |
Brian Paul | 56e0ee8 | 2006-04-13 15:17:50 +0000 | [diff] [blame^] | 467 | DLOPENLIBNAME="lib${LIBNAME}.so" # different libs required for dlopen |
Karl Schultz | a16bdb5 | 2004-10-01 13:33:26 +0000 | [diff] [blame] | 468 | LIBNAME="lib${LIBNAME}.a" # shared objects are still stored in the .a libraries |
Brian Paul | b17a1a1 | 2004-11-01 22:28:42 +0000 | [diff] [blame] | 469 | if [ $ARCH = "AIX64" ] ; then |
| 470 | OPTS="-bE:${EXPFILE} -bM:SRE -bnoentry -q64" |
| 471 | else |
| 472 | OPTS="-bE:${EXPFILE} -bM:SRE -bnoentry" |
| 473 | fi |
Karl Schultz | a16bdb5 | 2004-10-01 13:33:26 +0000 | [diff] [blame] | 474 | rm -f ${EXPFILE} ${OFILE} |
Brian Paul | b17a1a1 | 2004-11-01 22:28:42 +0000 | [diff] [blame] | 475 | NM="/bin/nm -eC ${X64}" |
Karl Schultz | a16bdb5 | 2004-10-01 13:33:26 +0000 | [diff] [blame] | 476 | echo "#! /usr/lib/${LIBNAME}" > ${EXPFILE} |
| 477 | ${NM} ${OBJECTS} | awk '{ |
| 478 | if ((($2 == "T") || ($2 == "D") || ($2 == "B")) \ |
| 479 | && ( substr($1,1,1) != ".")) { |
| 480 | if (substr ($1, 1, 7) != "__sinit" && |
| 481 | substr ($1, 1, 7) != "__sterm") { |
| 482 | if (substr ($1, 1, 5) == "__tf1") |
| 483 | print (substr ($1, 7)) |
| 484 | else if (substr ($1, 1, 5) == "__tf9") |
| 485 | print (substr ($1, 15)) |
| 486 | else |
| 487 | print $1 |
| 488 | } |
| 489 | } |
| 490 | }' | sort -u >> ${EXPFILE} |
Brian Paul | fe14cf6 | 2006-04-13 02:23:25 +0000 | [diff] [blame] | 491 | |
| 492 | # On AIX a shared library is linked differently when |
| 493 | # you want to dlopen the file |
Brian Paul | 56e0ee8 | 2006-04-13 15:17:50 +0000 | [diff] [blame^] | 494 | cc -G ${OPTS} -o ${DLOPENLIBNAME} ${OBJECTS} ${DEPS} |
| 495 | |
| 496 | # Traditional link-time binding compatible with system lib |
| 497 | cc ${OPTS} -o ${OFILE} ${OBJECTS} ${DEPS} |
| 498 | ar ${X64} -r ${LIBNAME} ${OFILE} |
| 499 | |
| 500 | FINAL_LIBS="${LIBNAME} ${DLOPENLIBNAME}" |
Brian Paul | c193bd0 | 2004-03-18 15:41:59 +0000 | [diff] [blame] | 501 | fi |
| 502 | ;; |
| 503 | |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 504 | 'OpenSTEP') |
| 505 | LIBNAME="lib${LIBNAME}.a" |
| 506 | echo "mklib: Making OpenSTEP static library: " ${LIBNAME} |
| 507 | libtool -static -o ${LIBNAME} - ${OBJECTS} |
| 508 | FINAL_LIBS=${LIBNAME} |
| 509 | ;; |
| 510 | |
| 511 | 'OSF1') |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 512 | if [ $STATIC = 1 ] ; then |
| 513 | LIBNAME="lib${LIBNAME}.a" |
| 514 | echo "mklib: Making OSF/1 static library: " ${LIBNAME} |
| 515 | rm -f ${LIBNAME} |
Brian Paul | c193bd0 | 2004-03-18 15:41:59 +0000 | [diff] [blame] | 516 | ar -ruv ${LIBNAME} ${OBJECTS} |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 517 | FINAL_LIBS=${LIBNAME} |
| 518 | else |
| 519 | VERSION="${MAJOR}.${MINOR}" |
| 520 | LIBNAME="lib${LIBNAME}.so" |
| 521 | echo "mklib: Making OSF/1 shared library: " ${LIBNAME} |
Brian Paul | 8dcc673 | 2005-07-25 22:59:58 +0000 | [diff] [blame] | 522 | if [ "x$LINK" = "x" ] ; then |
| 523 | if [ $CPLUSPLUS = 1 ] ; then |
| 524 | LINK=cxx |
| 525 | else |
| 526 | LINK=cc |
| 527 | fi |
Brian Paul | 0d5e6cc | 2004-11-29 17:23:12 +0000 | [diff] [blame] | 528 | fi |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 529 | rm -f ${LIBNAME}.${VERSION} |
Brian Paul | 0d5e6cc | 2004-11-29 17:23:12 +0000 | [diff] [blame] | 530 | ${LINK} -o ${LIBNAME}.${VERSION} -shared -set_version ${VERSION} -soname ${LIBNAME}.${VERSION} -expect_unresolved \* -all ${OBJECTS} ${DEPS} |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 531 | ln -sf ${LIBNAME}.${VERSION} ${LIBNAME} |
| 532 | FINAL_LIBS="${LIBNAME} ${LIBNAME}.${VERSION}" |
| 533 | fi |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 534 | ;; |
| 535 | |
| 536 | 'Darwin') |
Brian Paul | c193bd0 | 2004-03-18 15:41:59 +0000 | [diff] [blame] | 537 | if [ $STATIC = 1 ] ; then |
| 538 | LIBNAME="lib${LIBNAME}.a" |
| 539 | echo "mklib: Making Darwin static library: " ${LIBNAME} |
| 540 | LINK="ar" |
Brian Paul | fe14cf6 | 2006-04-13 02:23:25 +0000 | [diff] [blame] | 541 | OPTS="-ruvs" |
Brian Paul | c193bd0 | 2004-03-18 15:41:59 +0000 | [diff] [blame] | 542 | ${LINK} ${OPTS} ${LIBNAME} ${OBJECTS} |
| 543 | FINAL_LIBS=${LIBNAME} |
| 544 | else |
Brian Paul | fe14cf6 | 2006-04-13 02:23:25 +0000 | [diff] [blame] | 545 | # On Darwin a .bundle is used for a library that you want to dlopen |
Brian Paul | 56e0ee8 | 2006-04-13 15:17:50 +0000 | [diff] [blame^] | 546 | FLAGS="${ARCHOPT} -bundle -multiply_defined suppress" |
| 547 | BLINKNAME="lib${LIBNAME}.bundle" |
| 548 | BLIBNAME="lib${LIBNAME}.${MAJOR}.bundle" |
| 549 | echo "mklib: Making Darwin bundle: " ${BLIBNAME} |
| 550 | if [ $CPLUSPLUS = 1 ] ; then |
| 551 | LINK="g++" |
| 552 | else |
| 553 | LINK="cc" |
| 554 | fi |
| 555 | ${LINK} ${FLAGS} -o ${BLIBNAME} ${OBJECTS} ${DEPS} |
| 556 | ln -s ${BLIBNAME} ${BLINKNAME} |
Brian Paul | fe14cf6 | 2006-04-13 02:23:25 +0000 | [diff] [blame] | 557 | |
Brian Paul | 56e0ee8 | 2006-04-13 15:17:50 +0000 | [diff] [blame^] | 558 | # A .dylib is for link-time binding |
| 559 | FLAGS="${ARCHOPT} -dynamiclib -multiply_defined suppress -current_version ${MAJOR}.${MINOR}.0 -compatibility_version ${MAJOR}.${MINOR}.0 -install_name lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}" |
| 560 | LINKNAME="lib${LIBNAME}.dylib" |
| 561 | LIBNAME="lib${LIBNAME}.${MAJOR}.dylib" |
Brian Paul | c50d77a | 2004-04-13 17:35:17 +0000 | [diff] [blame] | 562 | echo "mklib: Making Darwin shared library: " ${LIBNAME} |
Brian Paul | c05658d | 2004-03-25 21:18:32 +0000 | [diff] [blame] | 563 | if [ $CPLUSPLUS = 1 ] ; then |
| 564 | LINK="g++" |
| 565 | else |
| 566 | LINK="cc" |
| 567 | fi |
| 568 | ${LINK} ${FLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS} |
Brian Paul | fe14cf6 | 2006-04-13 02:23:25 +0000 | [diff] [blame] | 569 | ln -s ${LIBNAME} ${LINKNAME} |
Brian Paul | 56e0ee8 | 2006-04-13 15:17:50 +0000 | [diff] [blame^] | 570 | |
| 571 | FINAL_LIBS="${LIBNAME} ${LINKNAME} ${BLIBNAME} ${BLINKNAME}" |
Brian Paul | c193bd0 | 2004-03-18 15:41:59 +0000 | [diff] [blame] | 572 | fi |
| 573 | ;; |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 574 | |
| 575 | 'LynxOS') |
| 576 | LIBNAME="lib${LIBNAME}.a" |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 577 | echo "mklib: Making LynxOS static library: " ${LIBNAME} |
| 578 | rm -f ${LIBNAME} |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 579 | ar ru ${LIBNAME} ${OBJECTS} |
| 580 | FINAL_LIBS=${LIBNAME} |
| 581 | ;; |
| 582 | |
| 583 | 'BeOS') |
Philippe Houdoin | ef4dd5a | 2004-08-14 10:12:38 +0000 | [diff] [blame] | 584 | if [ $STATIC = 1 ] ; then |
| 585 | LIBNAME="lib${LIBNAME}.a" |
| 586 | echo "mklib: Making BeOS static library: " ${LIBNAME} |
| 587 | ar -cru "${LIBNAME}" ${OBJECTS} |
| 588 | else |
Brian Paul | b784b8f | 2004-08-14 14:30:36 +0000 | [diff] [blame] | 589 | LIBNAME="lib${LIBNAME}.so" |
| 590 | echo "mklib: Making BeOS shared library: " ${LIBNAME} |
| 591 | gcc -nostart -Xlinker "-soname=${LIBNAME}" -L/Be/develop/lib/x86 -lbe ${DEPS} ${OBJECTS} -o "${LIBNAME}" |
| 592 | mimeset -f "${LIBNAME}" |
Brian Paul | 8dcc673 | 2005-07-25 22:59:58 +0000 | [diff] [blame] | 593 | # XXX remove the Mesa3D stuff here since mklib isn't mesa-specific. |
Brian Paul | b784b8f | 2004-08-14 14:30:36 +0000 | [diff] [blame] | 594 | setversion "${LIBNAME}" -app ${MAJOR} ${MINOR} ${PATCH} -short "Powered by Mesa3D!" -long "Powered by Mesa3D!" |
| 595 | fi |
| 596 | FINAL_LIBS=${LIBNAME} |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 597 | ;; |
| 598 | |
| 599 | 'QNX') |
| 600 | LIBNAME="lib${LIBNAME}.a" |
| 601 | echo "mklib: Making QNX library: " ${LIBNAME} |
| 602 | wlib ${LIBNAME} ${OBJECTS} |
| 603 | FINAL_LIBS=${LIBNAME} |
| 604 | ;; |
| 605 | |
Brian Paul | 65e2ab3 | 2003-10-27 18:13:37 +0000 | [diff] [blame] | 606 | 'MorphOS') |
| 607 | LIBNAME="lib${LIBNAME}.a" |
| 608 | echo "mklib: Making MorphOS library: " ${LIBNAME} |
| 609 | ppc-morphos-ar rc ${LIBNAME} ${OBJECTS} |
| 610 | FINAL_LIBS="${LIBNAME}" |
| 611 | ;; |
| 612 | |
Brian Paul | fe14cf6 | 2006-04-13 02:23:25 +0000 | [diff] [blame] | 613 | 'icc' | 'icc-istatic') |
Brian Paul | b3b725b | 2003-12-15 16:14:55 +0000 | [diff] [blame] | 614 | # Intel C compiler |
Brian Paul | 7c1ab40 | 2005-07-25 23:49:50 +0000 | [diff] [blame] | 615 | # This should get merged into the Linux code, above, since this isn't |
| 616 | # really a different architecture. |
Brian Paul | b3b725b | 2003-12-15 16:14:55 +0000 | [diff] [blame] | 617 | LIBNAME="lib${LIBNAME}" # prefix with "lib" |
| 618 | |
| 619 | if [ $STATIC = 1 ] ; then |
| 620 | echo "mklib: Making Intel ICC static library: " ${LIBNAME}.a |
| 621 | LINK="ar" |
| 622 | OPTS="-ruv" |
| 623 | # make lib |
| 624 | ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS} |
| 625 | # finish up |
| 626 | FINAL_LIBS="${LIBNAME}.a" |
| 627 | else |
Brian Paul | fe14cf6 | 2006-04-13 02:23:25 +0000 | [diff] [blame] | 628 | if [ $ARCH = icc-istatic ] ; then |
| 629 | OPTS="-shared -i-static -cxxlib-icc" |
| 630 | else |
| 631 | OPTS="-shared" |
| 632 | fi |
Brian Paul | b3b725b | 2003-12-15 16:14:55 +0000 | [diff] [blame] | 633 | VERSION="${MAJOR}.${MINOR}.${PATCH}" |
Brian Paul | b3b725b | 2003-12-15 16:14:55 +0000 | [diff] [blame] | 634 | echo "mklib: Making Intel ICC shared library: " ${LIBNAME}.so.${VERSION} |
| 635 | |
| 636 | if [ $CPLUSPLUS = 1 ] ; then |
Brian Paul | fe14cf6 | 2006-04-13 02:23:25 +0000 | [diff] [blame] | 637 | LINK="icpc" |
Brian Paul | b3b725b | 2003-12-15 16:14:55 +0000 | [diff] [blame] | 638 | else |
| 639 | LINK="icc" |
| 640 | fi |
Brian Paul | b3b725b | 2003-12-15 16:14:55 +0000 | [diff] [blame] | 641 | # rm any old libs |
| 642 | rm -f ${LIBNAME}.so.${VERSION} |
| 643 | rm -f ${LIBNAME}.so.${MAJOR} |
| 644 | rm -f ${LIBNAME}.so |
Brian Paul | b3b725b | 2003-12-15 16:14:55 +0000 | [diff] [blame] | 645 | # make lib |
| 646 | ${LINK} ${OPTS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS} |
| 647 | # make usual symlinks |
| 648 | ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} |
| 649 | ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so |
| 650 | # finish up |
| 651 | FINAL_LIBS="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so" |
| 652 | fi |
| 653 | ;; |
| 654 | |
Brian Paul | 12d6cae | 2004-01-10 22:12:21 +0000 | [diff] [blame] | 655 | 'aix-gcc') |
| 656 | # AIX with gcc |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 657 | if [ $STATIC = 1 ] ; then |
| 658 | LIBNAME="lib${LIBNAME}.a" |
| 659 | echo "mklib: Making AIX GCC static library: " ${LIBNAME} |
| 660 | rm -f ${LIBNAME} |
| 661 | ar ru ${LIBNAME} ${OBJECTS} |
| 662 | FINAL_LIBS=${LIBNAME} |
| 663 | else |
| 664 | LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so" |
| 665 | echo "mklib: Making AIX GCC shared library: " ${LIBNAME} |
| 666 | # remove old lib |
| 667 | rm -f ${LIBNAME} |
| 668 | # make the lib |
| 669 | gcc -shared -Wl,-G ${OBJECTS} ${DEPS} -o ${LIBNAME} |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 670 | # NOTE: the application linking with this library must specify |
| 671 | # the -Wl,-brtl flags to gcc |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 672 | FINAL_LIBS=${LIBNAME} |
| 673 | fi |
| 674 | ;; |
| 675 | |
| 676 | 'ultrix') |
| 677 | # XXX untested |
| 678 | if [ $STATIC = 0 ] ; then |
| 679 | echo "mklib: Warning shared libs not supported on Ultrix" |
| 680 | fi |
| 681 | LIBNAME="lib${LIBNAME}.a" |
| 682 | echo "mklib: Making static library for Ultrix: " ${LIBNAME} |
Brian Paul | 12d6cae | 2004-01-10 22:12:21 +0000 | [diff] [blame] | 683 | rm -f ${LIBNAME} |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 684 | ar ru ${LIBNAME} ${OBJECTS} |
| 685 | FINAL_LIBS="${LIBNAME}" |
Brian Paul | 12d6cae | 2004-01-10 22:12:21 +0000 | [diff] [blame] | 686 | ;; |
Brian Paul | b3b725b | 2003-12-15 16:14:55 +0000 | [diff] [blame] | 687 | |
Brian Paul | 580548d | 2004-04-22 16:16:42 +0000 | [diff] [blame] | 688 | CYGWIN*) |
| 689 | # GCC-based environment |
| 690 | CYGNAME="cyg${LIBNAME}" # prefix with "cyg" |
| 691 | LIBNAME="lib${LIBNAME}" # prefix with "lib" |
| 692 | |
| 693 | if [ $STATIC = 1 ] ; then |
| 694 | echo "mklib: Making" $ARCH "static library: " ${LIBNAME}.a |
| 695 | LINK="ar" |
| 696 | OPTS="-ru" |
| 697 | # make lib |
| 698 | ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS} |
| 699 | ranlib ${LIBNAME}.a |
| 700 | # finish up |
| 701 | FINAL_LIBS=${LIBNAME}.a |
| 702 | else |
| 703 | OPTS="-shared -Wl,-export-all -Wl,--out-implib=${LIBNAME}-${MAJOR}.dll.a" |
| 704 | echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}-${MAJOR}.dll |
| 705 | |
| 706 | if [ $CPLUSPLUS = 1 ] ; then |
| 707 | LINK="g++" |
| 708 | else |
| 709 | LINK="gcc" |
| 710 | fi |
| 711 | |
| 712 | # rm any old libs |
| 713 | rm -f ${LIBNAME}-${MAJOR}.dll |
| 714 | rm -f ${LIBNAME}.dll.a |
| 715 | rm -f ${LIBNAME}.a |
| 716 | |
| 717 | # make lib |
| 718 | ${LINK} ${OPTS} -o ${CYGNAME}-${MAJOR}.dll ${OBJECTS} ${DEPS} |
| 719 | # make usual symlinks |
| 720 | ln -s ${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a |
| 721 | # finish up |
| 722 | FINAL_LIBS="${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a" |
| 723 | # special case for installing in bin |
| 724 | FINAL_BINS="${CYGNAME}-${MAJOR}.dll" |
| 725 | fi |
| 726 | ;; |
| 727 | |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 728 | 'example') |
| 729 | # If you're adding support for a new architecture, you can |
| 730 | # start with this: |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 731 | if [ $STATIC = 1 ] ; then |
| 732 | LIBNAME="lib${LIBNAME}.a" |
| 733 | echo "mklib: Making static library for example arch: " ${LIBNAME} |
| 734 | rm -f ${LIBNAME} |
| 735 | ar rv ${LIBNAME} ${OBJECTS} |
| 736 | FINAL_LIBS="${LIBNAME}" |
| 737 | else |
Brian Paul | 7c1ab40 | 2005-07-25 23:49:50 +0000 | [diff] [blame] | 738 | LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so" |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 739 | echo "mklib: Making shared library for example arch: " ${LIBNAME} |
| 740 | ld -o ${LIBNAME} ${OBJECTS} ${DEPS} |
| 741 | FINAL_LIBS="${LIBNAME}" |
| 742 | fi |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 743 | ;; |
| 744 | |
| 745 | *) |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 746 | echo "mklib: ERROR: Don't know how to make a static/shared library for" ${ARCH} |
| 747 | echo "mklib: Please add necessary commands to mklib script." |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 748 | ;; |
| 749 | esac |
| 750 | |
| 751 | |
| 752 | # |
| 753 | # Put library files into installation directory if specified. |
| 754 | # |
| 755 | if [ ${INSTALLDIR} != "." ] ; then |
| 756 | echo "mklib: Installing" ${FINAL_LIBS} "in" ${INSTALLDIR} |
| 757 | mv ${FINAL_LIBS} ${INSTALLDIR}/ |
| 758 | fi |