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