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 | 5beff7c | 2006-04-19 14:03:04 +0000 | [diff] [blame] | 183 | 'Linux' | 'OpenBSD' | 'GNU' | GNU/*) |
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 | 5beff7c | 2006-04-19 14:03:04 +0000 | [diff] [blame] | 226 | case $ARCH in 'Linux' | 'GNU' | GNU/*) |
Brian Paul | 5b9a9d4 | 2004-01-17 18:31:12 +0000 | [diff] [blame] | 227 | OPTS="-Xlinker -Bsymbolic -shared -Wl,-soname,${LIBNAME}.so.${MAJOR}" |
Brian Paul | 5beff7c | 2006-04-19 14:03:04 +0000 | [diff] [blame] | 228 | ;; |
| 229 | *) |
Brian Paul | 5b9a9d4 | 2004-01-17 18:31:12 +0000 | [diff] [blame] | 230 | OPTS="-shared -Wl,-soname,${LIBNAME}.so.${MAJOR}" |
Brian Paul | 5beff7c | 2006-04-19 14:03:04 +0000 | [diff] [blame] | 231 | ;; |
| 232 | esac |
Brian Paul | 158a251 | 2004-10-16 15:10:45 +0000 | [diff] [blame] | 233 | if [ $EXPORTS ] ; then |
| 234 | #OPTS="${OPTS} -Xlinker --retain-symbols-file ${EXPORTS}" |
| 235 | # Make the 'exptmp' file for --version-script option |
| 236 | echo "VERSION_${MAJOR}.${MINOR} {" > exptmp |
| 237 | echo "global:" >> exptmp |
| 238 | sed 's/$/;/' ${EXPORTS} >> exptmp |
| 239 | echo "local:" >> exptmp |
| 240 | echo "*;" >> exptmp |
| 241 | echo "};" >> exptmp |
| 242 | OPTS="${OPTS} -Xlinker --version-script=exptmp" |
| 243 | # exptmp is removed below |
| 244 | fi |
Brian Paul | 3e19618 | 2005-03-03 01:38:13 +0000 | [diff] [blame] | 245 | |
| 246 | # Check if objects are 32-bit and we're running in 64-bit |
| 247 | # environment. If so, pass -m32 flag to linker. |
| 248 | set ${OBJECTS} |
| 249 | ABI32=`file $1 | grep 32-bit` |
| 250 | if [ "${ABI32}" -a `uname -m` = "x86_64" ] ; then |
| 251 | OPTS="-m32 ${OPTS}" |
| 252 | fi |
| 253 | |
Brian Paul | 6e450f2 | 2004-02-21 18:08:41 +0000 | [diff] [blame] | 254 | if [ x${PATCH} = "x" ] ; then |
| 255 | VERSION="${MAJOR}.${MINOR}" |
| 256 | else |
| 257 | VERSION="${MAJOR}.${MINOR}.${PATCH}" |
| 258 | fi |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 259 | |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 260 | echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}.so.${VERSION} |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 261 | |
Brian Paul | 1c4b711 | 2003-10-10 17:58:38 +0000 | [diff] [blame] | 262 | # rm any old libs |
| 263 | rm -f ${LIBNAME}.so.${VERSION} |
| 264 | rm -f ${LIBNAME}.so.${MAJOR} |
| 265 | rm -f ${LIBNAME}.so |
| 266 | |
| 267 | # make lib |
| 268 | ${LINK} ${OPTS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS} |
| 269 | # make usual symlinks |
| 270 | ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} |
| 271 | ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so |
| 272 | # finish up |
| 273 | FINAL_LIBS="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so" |
Brian Paul | b17a1a1 | 2004-11-01 22:28:42 +0000 | [diff] [blame] | 274 | # rm -f exptmp |
Brian Paul | 1c4b711 | 2003-10-10 17:58:38 +0000 | [diff] [blame] | 275 | fi |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 276 | ;; |
| 277 | |
| 278 | 'SunOS') |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 279 | if [ $STATIC = 1 ] ; then |
| 280 | LIBNAME="lib${LIBNAME}.a" |
| 281 | echo "mklib: Making SunOS static library: " ${LIBNAME} |
| 282 | rm -f ${LIBNAME} |
Brian Paul | c193bd0 | 2004-03-18 15:41:59 +0000 | [diff] [blame] | 283 | ar -ruv ${LIBNAME} ${OBJECTS} |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 284 | FINAL_LIBS=${LIBNAME} |
| 285 | else |
Brian Paul | 0a3a1c6 | 2006-11-10 12:47:56 +0000 | [diff] [blame^] | 286 | if [ $NOPREFIX = 0 ] ; then |
| 287 | LIBNAME="lib${LIBNAME}.so" |
| 288 | fi |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 289 | echo "mklib: Making SunOS shared library: " ${LIBNAME} |
Brian Paul | 59ebe1f | 2006-04-05 13:43:02 +0000 | [diff] [blame] | 290 | |
Brian Paul | 8dcc673 | 2005-07-25 22:59:58 +0000 | [diff] [blame] | 291 | if [ "x$LINK" = "x" ] ; then |
| 292 | # -linker was not specified, choose default linker now |
| 293 | if [ $CPLUSPLUS = 1 ] ; then |
| 294 | # determine linker and options for C++ code |
| 295 | if [ `which c++` ] ; then |
| 296 | # use Sun c++ |
| 297 | LINK="c++" |
| 298 | elif [ `type g++` ] ; then |
| 299 | # use g++ |
| 300 | LINK="g++" |
| 301 | else |
| 302 | echo "mklib: warning: can't find C++ comiler, trying CC." |
| 303 | LINK="CC" |
| 304 | fi |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 305 | else |
Brian Paul | 8dcc673 | 2005-07-25 22:59:58 +0000 | [diff] [blame] | 306 | # use native Sun linker for C code |
| 307 | LINK="ld" |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 308 | fi |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 309 | fi |
Brian Paul | 59ebe1f | 2006-04-05 13:43:02 +0000 | [diff] [blame] | 310 | |
| 311 | # linker options |
Brian Paul | b3282a3 | 2006-04-18 12:56:11 +0000 | [diff] [blame] | 312 | if [ ${LINK} = "ld" -o ${LINK} = "cc" -o ${LINK} = "CC" ] ; then |
| 313 | # SunOS tools, -G to make shared libs |
Brian Paul | 59ebe1f | 2006-04-05 13:43:02 +0000 | [diff] [blame] | 314 | OPTS="-G" |
| 315 | else |
| 316 | # gcc linker |
| 317 | # Check if objects are 32-bit and we're running in 64-bit |
| 318 | # environment. If so, pass -m32 flag to linker. |
| 319 | set ${OBJECTS} |
| 320 | ABI32=`file $1 | grep 32-bit` |
| 321 | if [ "${ABI32}" ] ; then |
| 322 | OPTS="-m32 -shared -Wl,-Bdynamic" |
| 323 | else |
| 324 | OPTS="-m64 -shared -Wl,-Bdynamic" |
| 325 | fi |
| 326 | fi |
| 327 | |
Brian Paul | 1e1af99 | 2006-04-14 14:14:51 +0000 | [diff] [blame] | 328 | # Check if objects are SPARC v9 |
| 329 | # file says: ELF 64-bit MSB relocatable SPARCV9 Version 1 |
| 330 | set ${OBJECTS} |
| 331 | SPARCV9=`file $1 | grep SPARCV9` |
| 332 | if [ "${SPARCV9}" ] ; then |
| 333 | OPTS="${OPTS} -xarch=v9" |
| 334 | fi |
| 335 | |
Brian Paul | 59ebe1f | 2006-04-05 13:43:02 +0000 | [diff] [blame] | 336 | # for debug: |
Brian Paul | 1e1af99 | 2006-04-14 14:14:51 +0000 | [diff] [blame] | 337 | #echo "mklib: linker is" ${LINK} ${OPTS} |
Brian Paul | 0a3a1c6 | 2006-11-10 12:47:56 +0000 | [diff] [blame^] | 338 | if [ $NOPREFIX = 1 ] ; then |
| 339 | rm -f ${LIBNAME} |
| 340 | ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS} |
| 341 | else |
| 342 | rm -f ${LIBNAME}.${MAJOR} ${LIBNAME} |
| 343 | ${LINK} ${OPTS} -o ${LIBNAME}.${MAJOR} ${OBJECTS} ${DEPS} |
| 344 | ln -s ${LIBNAME}.${MAJOR} ${LIBNAME} |
| 345 | fi |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 346 | FINAL_LIBS="${LIBNAME}.${MAJOR} ${LIBNAME}" |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 347 | fi |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 348 | ;; |
| 349 | |
| 350 | 'FreeBSD') |
Eric Anholt | b83435f | 2005-10-18 23:36:40 +0000 | [diff] [blame] | 351 | # we assume gcc |
| 352 | |
| 353 | if [ "x$LINK" = "x" ] ; then |
| 354 | # -linker was not specified so set default link command now |
| 355 | if [ $CPLUSPLUS = 1 ] ; then |
| 356 | LINK=g++ |
| 357 | else |
| 358 | LINK=gcc |
| 359 | fi |
| 360 | fi |
| 361 | |
Brian Paul | dd74e36 | 2004-04-08 22:26:22 +0000 | [diff] [blame] | 362 | if [ $NOPREFIX = 1 ] ; then |
| 363 | # No "lib" or ".so" part |
| 364 | echo "mklib: Making FreeBSD shared library: " ${LIBNAME} |
Eric Anholt | b83435f | 2005-10-18 23:36:40 +0000 | [diff] [blame] | 365 | OPTS="-shared" |
Brian Paul | dd74e36 | 2004-04-08 22:26:22 +0000 | [diff] [blame] | 366 | rm -f ${LIBNAME} |
Eric Anholt | b83435f | 2005-10-18 23:36:40 +0000 | [diff] [blame] | 367 | ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS} |
Brian Paul | dd74e36 | 2004-04-08 22:26:22 +0000 | [diff] [blame] | 368 | FINAL_LIBS=${LIBNAME} |
| 369 | elif [ $STATIC = 1 ] ; then |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 370 | STLIB="lib${LIBNAME}.a" |
| 371 | echo "mklib: Making FreeBSD static library: " ${STLIB} |
| 372 | rm -f ${STLIB} |
| 373 | ar cq ${STLIB} ${OBJECTS} |
| 374 | ranlib ${STLIB} |
| 375 | FINAL_LIBS=${STLIB} |
| 376 | else |
Eric Anholt | b83435f | 2005-10-18 23:36:40 +0000 | [diff] [blame] | 377 | SHLIB="lib${LIBNAME}.so.${MAJOR}" |
| 378 | OPTS="-shared -Wl,-soname,${SHLIB}" |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 379 | echo "mklib: Making FreeBSD shared library: " ${SHLIB} |
| 380 | rm -f ${SHLIB} |
Eric Anholt | b83435f | 2005-10-18 23:36:40 +0000 | [diff] [blame] | 381 | ${LINK} ${OPTS} -o ${SHLIB} ${OBJECTS} ${DEPS} |
Eric Anholt | 1c04be5 | 2005-10-22 01:41:40 +0000 | [diff] [blame] | 382 | ln -sf ${SHLIB} "lib${LIBNAME}.so" |
| 383 | FINAL_LIBS="${SHLIB} lib${LIBNAME}.so" |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 384 | fi |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 385 | ;; |
| 386 | |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 387 | 'NetBSD') |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 388 | if [ $STATIC = 1 ] ; then |
| 389 | LIBNAME="lib${LIBNAME}_pic.a" |
| 390 | echo "mklib: Making NetBSD PIC static library: " ${LIBNAME} |
| 391 | rm -f ${LIBNAME} |
| 392 | ar cq ${LIBNAME} ${OBJECTS} |
| 393 | ranlib ${LIBNAME} |
| 394 | FINAL_LIBS=${LIBNAME} |
| 395 | else |
| 396 | LIBNAME="lib${LIBNAME}.so.${MAJOR}.${MINOR}" |
| 397 | echo "mklib: Making NetBSD PIC shared library: " ${LIBNAME} |
| 398 | rm -f ${LIBNAME} |
| 399 | ld -x -Bshareable -Bforcearchive -o ${LIBNAME} ${OBJECTS} |
| 400 | FINAL_LIBS=${LIBNAME} |
| 401 | fi |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 402 | ;; |
| 403 | |
Brian Paul | f8c31fc | 2004-01-29 15:21:47 +0000 | [diff] [blame] | 404 | 'IRIX' | 'IRIX64') |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 405 | if [ $STATIC = 1 ] ; then |
| 406 | LIBNAME="lib${LIBNAME}.a" |
| 407 | rm -f ${LIBNAME} |
| 408 | ar rc ${LIBNAME} ${OBJECTS} |
| 409 | FINAL_LIBS=${LIBNAME} |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 410 | else |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 411 | LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so" |
Brian Paul | 1e1af99 | 2006-04-14 14:14:51 +0000 | [diff] [blame] | 412 | |
| 413 | # examine first object to determine ABI |
| 414 | set ${OBJECTS} |
| 415 | ABI_O32=`file $1 | grep 'ELF 32-bit'` |
Brian Paul | b3282a3 | 2006-04-18 12:56:11 +0000 | [diff] [blame] | 416 | ABI_N32=`file $1 | grep 'ELF N32'` |
Brian Paul | 1e1af99 | 2006-04-14 14:14:51 +0000 | [diff] [blame] | 417 | ABI_N64=`file $1 | grep 'ELF 64-bit'` |
Brian Paul | b3282a3 | 2006-04-18 12:56:11 +0000 | [diff] [blame] | 418 | if [ "${ABI_O32}" ] ; then |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 419 | OPTS="-32 -shared -all" |
Brian Paul | 1e1af99 | 2006-04-14 14:14:51 +0000 | [diff] [blame] | 420 | ABI="o32-bit" |
Brian Paul | b3282a3 | 2006-04-18 12:56:11 +0000 | [diff] [blame] | 421 | elif [ "${ABI_N32}" ] ; then |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 422 | OPTS="-n32 -shared -all" |
Brian Paul | 1e1af99 | 2006-04-14 14:14:51 +0000 | [diff] [blame] | 423 | ABI="n32-bit" |
Brian Paul | b3282a3 | 2006-04-18 12:56:11 +0000 | [diff] [blame] | 424 | elif [ "${ABI_N64}" ] ; then |
Brian Paul | 1e1af99 | 2006-04-14 14:14:51 +0000 | [diff] [blame] | 425 | OPTS="-64 -shared -all" |
| 426 | ABI="64-bit" |
| 427 | else |
| 428 | echo "Error: Unexpected IRIX ABI!" |
| 429 | exit 1 |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 430 | fi |
Brian Paul | 1e1af99 | 2006-04-14 14:14:51 +0000 | [diff] [blame] | 431 | |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 432 | if [ $CPLUSPLUS = 1 ] ; then |
| 433 | LINK="CC" |
| 434 | else |
| 435 | LINK="ld" |
| 436 | fi |
Brian Paul | 1e1af99 | 2006-04-14 14:14:51 +0000 | [diff] [blame] | 437 | |
| 438 | echo "mklib: Making IRIX " ${ABI} " shared library: " ${LIBNAME} |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 439 | ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS} |
| 440 | FINAL_LIBS=${LIBNAME} |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 441 | fi |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 442 | ;; |
| 443 | |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 444 | 'linux-cygwin') |
| 445 | LIBNAME="lib${LIBNAME}.a" |
| 446 | echo "mklib: Making linux-cygwin library: " ${LIBNAME} |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 447 | rm -f ${LIBNAME} |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 448 | gnuwin32ar ruv ${LIBNAME} ${OBJECTS} |
| 449 | FINAL_LIBS=${LIBNAME} |
| 450 | ;; |
| 451 | |
Brian Paul | c193bd0 | 2004-03-18 15:41:59 +0000 | [diff] [blame] | 452 | 'HP-UX') |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 453 | if [ $STATIC = 1 ] ; then |
| 454 | LIBNAME="lib${LIBNAME}.a" |
Brian Paul | 52fb07e | 2004-03-30 14:47:02 +0000 | [diff] [blame] | 455 | echo "mklib: Making HP-UX static library: " ${LIBNAME} |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 456 | rm -f ${LIBNAME} |
Brian Paul | c193bd0 | 2004-03-18 15:41:59 +0000 | [diff] [blame] | 457 | ar -ruv ${LIBNAME} ${OBJECTS} |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 458 | FINAL_LIBS=${LIBNAME} |
| 459 | else |
Brian Paul | fe14cf6 | 2006-04-13 02:23:25 +0000 | [diff] [blame] | 460 | # HP uses a .2 for their current GL/GLU libraries |
| 461 | if [ ${LIBNAME} = "GL" -o ${LIBNAME} = "GLU" ] ; then |
| 462 | MAJOR=2 |
| 463 | fi |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 464 | RUNLIB="lib${LIBNAME}.${MAJOR}" |
| 465 | DEVLIB="lib${LIBNAME}.sl" |
Brian Paul | 52fb07e | 2004-03-30 14:47:02 +0000 | [diff] [blame] | 466 | echo "mklib: Making HP-UX shared library: " ${RUNLIB} ${DEVLIB} |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 467 | ld -b -o ${RUNLIB} +b ${RUNLIB} ${OBJECTS} ${DEPS} |
| 468 | ln -s ${RUNLIB} ${DEVLIB} |
Brian Paul | ac0cfee | 2004-04-25 15:13:56 +0000 | [diff] [blame] | 469 | FINAL_LIBS="${RUNLIB} ${DEVLIB}" |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 470 | fi |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 471 | ;; |
| 472 | |
Brian Paul | b3282a3 | 2006-04-18 12:56:11 +0000 | [diff] [blame] | 473 | 'AIX' ) |
| 474 | # examine first object to determine ABI |
| 475 | set ${OBJECTS} |
| 476 | ABI_64=`file $1 | grep '64-bit'` |
| 477 | if [ "${ABI_64}" ] ; then |
Brian Paul | b17a1a1 | 2004-11-01 22:28:42 +0000 | [diff] [blame] | 478 | X64="-X64" |
Brian Paul | b3282a3 | 2006-04-18 12:56:11 +0000 | [diff] [blame] | 479 | Q64="-q64" |
| 480 | OFILE=shr_64.o |
| 481 | else |
| 482 | OFILE=shr.o #Want to be consistent with the IBM libGL.a |
Brian Paul | b17a1a1 | 2004-11-01 22:28:42 +0000 | [diff] [blame] | 483 | fi |
Brian Paul | c193bd0 | 2004-03-18 15:41:59 +0000 | [diff] [blame] | 484 | |
Brian Paul | b3282a3 | 2006-04-18 12:56:11 +0000 | [diff] [blame] | 485 | if [ $STATIC = 1 ] ; then |
| 486 | LIBNAME="lib${LIBNAME}.a" |
| 487 | echo "mklib: Making AIX static library: " ${LIBNAME} |
| 488 | ar -ruv ${X64} ${LIBNAME} ${OBJECTS} |
| 489 | FINAL_LIBS=${LIBNAME} |
| 490 | else |
Karl Schultz | a16bdb5 | 2004-10-01 13:33:26 +0000 | [diff] [blame] | 491 | EXPFILE="lib${LIBNAME}.exp" |
Karl Schultz | a16bdb5 | 2004-10-01 13:33:26 +0000 | [diff] [blame] | 492 | LIBNAME="lib${LIBNAME}.a" # shared objects are still stored in the .a libraries |
Brian Paul | b3282a3 | 2006-04-18 12:56:11 +0000 | [diff] [blame] | 493 | OPTS="-bE:${EXPFILE} -bM:SRE -bnoentry ${Q64}" |
Karl Schultz | a16bdb5 | 2004-10-01 13:33:26 +0000 | [diff] [blame] | 494 | rm -f ${EXPFILE} ${OFILE} |
Brian Paul | b17a1a1 | 2004-11-01 22:28:42 +0000 | [diff] [blame] | 495 | NM="/bin/nm -eC ${X64}" |
Karl Schultz | a16bdb5 | 2004-10-01 13:33:26 +0000 | [diff] [blame] | 496 | echo "#! /usr/lib/${LIBNAME}" > ${EXPFILE} |
| 497 | ${NM} ${OBJECTS} | awk '{ |
| 498 | if ((($2 == "T") || ($2 == "D") || ($2 == "B")) \ |
| 499 | && ( substr($1,1,1) != ".")) { |
| 500 | if (substr ($1, 1, 7) != "__sinit" && |
| 501 | substr ($1, 1, 7) != "__sterm") { |
| 502 | if (substr ($1, 1, 5) == "__tf1") |
| 503 | print (substr ($1, 7)) |
| 504 | else if (substr ($1, 1, 5) == "__tf9") |
| 505 | print (substr ($1, 15)) |
| 506 | else |
| 507 | print $1 |
| 508 | } |
| 509 | } |
| 510 | }' | sort -u >> ${EXPFILE} |
Brian Paul | fe14cf6 | 2006-04-13 02:23:25 +0000 | [diff] [blame] | 511 | |
| 512 | # On AIX a shared library is linked differently when |
| 513 | # you want to dlopen the file |
Brian Paul | 1e1af99 | 2006-04-14 14:14:51 +0000 | [diff] [blame] | 514 | if [ $DLOPEN = "1" ] ; then |
| 515 | cc -G ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS} |
| 516 | else |
| 517 | cc ${OPTS} -o ${OFILE} ${OBJECTS} ${DEPS} |
| 518 | ar ${X64} -r ${LIBNAME} ${OFILE} |
| 519 | fi |
Brian Paul | 56e0ee8 | 2006-04-13 15:17:50 +0000 | [diff] [blame] | 520 | |
Brian Paul | 1e1af99 | 2006-04-14 14:14:51 +0000 | [diff] [blame] | 521 | FINAL_LIBS="${LIBNAME}" |
Brian Paul | c193bd0 | 2004-03-18 15:41:59 +0000 | [diff] [blame] | 522 | fi |
| 523 | ;; |
| 524 | |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 525 | 'OpenSTEP') |
| 526 | LIBNAME="lib${LIBNAME}.a" |
| 527 | echo "mklib: Making OpenSTEP static library: " ${LIBNAME} |
| 528 | libtool -static -o ${LIBNAME} - ${OBJECTS} |
| 529 | FINAL_LIBS=${LIBNAME} |
| 530 | ;; |
| 531 | |
| 532 | 'OSF1') |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 533 | if [ $STATIC = 1 ] ; then |
| 534 | LIBNAME="lib${LIBNAME}.a" |
| 535 | echo "mklib: Making OSF/1 static library: " ${LIBNAME} |
| 536 | rm -f ${LIBNAME} |
Brian Paul | c193bd0 | 2004-03-18 15:41:59 +0000 | [diff] [blame] | 537 | ar -ruv ${LIBNAME} ${OBJECTS} |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 538 | FINAL_LIBS=${LIBNAME} |
| 539 | else |
| 540 | VERSION="${MAJOR}.${MINOR}" |
| 541 | LIBNAME="lib${LIBNAME}.so" |
| 542 | echo "mklib: Making OSF/1 shared library: " ${LIBNAME} |
Brian Paul | 8dcc673 | 2005-07-25 22:59:58 +0000 | [diff] [blame] | 543 | if [ "x$LINK" = "x" ] ; then |
| 544 | if [ $CPLUSPLUS = 1 ] ; then |
| 545 | LINK=cxx |
| 546 | else |
| 547 | LINK=cc |
| 548 | fi |
Brian Paul | 0d5e6cc | 2004-11-29 17:23:12 +0000 | [diff] [blame] | 549 | fi |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 550 | rm -f ${LIBNAME}.${VERSION} |
Brian Paul | 0d5e6cc | 2004-11-29 17:23:12 +0000 | [diff] [blame] | 551 | ${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] | 552 | ln -sf ${LIBNAME}.${VERSION} ${LIBNAME} |
| 553 | FINAL_LIBS="${LIBNAME} ${LIBNAME}.${VERSION}" |
| 554 | fi |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 555 | ;; |
| 556 | |
| 557 | 'Darwin') |
Brian Paul | c193bd0 | 2004-03-18 15:41:59 +0000 | [diff] [blame] | 558 | if [ $STATIC = 1 ] ; then |
| 559 | LIBNAME="lib${LIBNAME}.a" |
| 560 | echo "mklib: Making Darwin static library: " ${LIBNAME} |
| 561 | LINK="ar" |
Brian Paul | fe14cf6 | 2006-04-13 02:23:25 +0000 | [diff] [blame] | 562 | OPTS="-ruvs" |
Brian Paul | c193bd0 | 2004-03-18 15:41:59 +0000 | [diff] [blame] | 563 | ${LINK} ${OPTS} ${LIBNAME} ${OBJECTS} |
| 564 | FINAL_LIBS=${LIBNAME} |
| 565 | else |
Brian Paul | fe14cf6 | 2006-04-13 02:23:25 +0000 | [diff] [blame] | 566 | # 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] | 567 | if [ $DLOPEN = "1" ] ; then |
| 568 | LIBSUFFIX="bundle" |
| 569 | OPTS="${ARCHOPT} -bundle -multiply_defined suppress" |
| 570 | else |
| 571 | LIBSUFFIX="dylib" |
| 572 | OPTS="${ARCHOPT} -dynamiclib -multiply_defined suppress -current_version ${MAJOR}.${MINOR}.0 -compatibility_version ${MAJOR}.${MINOR}.0 -install_name lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}" |
| 573 | fi |
| 574 | LINKNAME="lib${LIBNAME}.${LIBSUFFIX}" |
| 575 | LIBNAME="lib${LIBNAME}.${MAJOR}.${LIBSUFFIX}" |
| 576 | |
| 577 | # examine first object to determine ABI |
| 578 | set ${OBJECTS} |
Brian Paul | b3282a3 | 2006-04-18 12:56:11 +0000 | [diff] [blame] | 579 | ABI_PPC=`file $1 | grep 'object ppc'` |
Brian Paul | 1e1af99 | 2006-04-14 14:14:51 +0000 | [diff] [blame] | 580 | ABI_I386=`file $1 | grep 'object i386'` |
Brian Paul | b3282a3 | 2006-04-18 12:56:11 +0000 | [diff] [blame] | 581 | if [ "${ABI_PPC}" ] ; then |
Brian Paul | 1e1af99 | 2006-04-14 14:14:51 +0000 | [diff] [blame] | 582 | OPTS="${OPTS} -arch ppc" |
| 583 | fi |
Brian Paul | b3282a3 | 2006-04-18 12:56:11 +0000 | [diff] [blame] | 584 | if [ "${ABI_I386}" ] ; then |
Brian Paul | 1e1af99 | 2006-04-14 14:14:51 +0000 | [diff] [blame] | 585 | OPTS="${OPTS} -arch i386" |
| 586 | fi |
| 587 | |
| 588 | # XXX can we always add -isysroot /Developer/SDKs/MacOSX10.4u.sdk |
| 589 | # to OPTS here? |
| 590 | |
| 591 | # determine linker |
Brian Paul | 56e0ee8 | 2006-04-13 15:17:50 +0000 | [diff] [blame] | 592 | if [ $CPLUSPLUS = 1 ] ; then |
| 593 | LINK="g++" |
| 594 | else |
| 595 | LINK="cc" |
| 596 | fi |
Brian Paul | fe14cf6 | 2006-04-13 02:23:25 +0000 | [diff] [blame] | 597 | |
Brian Paul | c50d77a | 2004-04-13 17:35:17 +0000 | [diff] [blame] | 598 | echo "mklib: Making Darwin shared library: " ${LIBNAME} |
Brian Paul | 1e1af99 | 2006-04-14 14:14:51 +0000 | [diff] [blame] | 599 | ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS} |
Brian Paul | fe14cf6 | 2006-04-13 02:23:25 +0000 | [diff] [blame] | 600 | ln -s ${LIBNAME} ${LINKNAME} |
Brian Paul | 1e1af99 | 2006-04-14 14:14:51 +0000 | [diff] [blame] | 601 | FINAL_LIBS="${LIBNAME} ${LINKNAME}" |
Brian Paul | c193bd0 | 2004-03-18 15:41:59 +0000 | [diff] [blame] | 602 | fi |
| 603 | ;; |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 604 | |
| 605 | 'LynxOS') |
| 606 | LIBNAME="lib${LIBNAME}.a" |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 607 | echo "mklib: Making LynxOS static library: " ${LIBNAME} |
| 608 | rm -f ${LIBNAME} |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 609 | ar ru ${LIBNAME} ${OBJECTS} |
| 610 | FINAL_LIBS=${LIBNAME} |
| 611 | ;; |
| 612 | |
| 613 | 'BeOS') |
Philippe Houdoin | ef4dd5a | 2004-08-14 10:12:38 +0000 | [diff] [blame] | 614 | if [ $STATIC = 1 ] ; then |
| 615 | LIBNAME="lib${LIBNAME}.a" |
| 616 | echo "mklib: Making BeOS static library: " ${LIBNAME} |
| 617 | ar -cru "${LIBNAME}" ${OBJECTS} |
| 618 | else |
Brian Paul | b784b8f | 2004-08-14 14:30:36 +0000 | [diff] [blame] | 619 | LIBNAME="lib${LIBNAME}.so" |
| 620 | echo "mklib: Making BeOS shared library: " ${LIBNAME} |
| 621 | gcc -nostart -Xlinker "-soname=${LIBNAME}" -L/Be/develop/lib/x86 -lbe ${DEPS} ${OBJECTS} -o "${LIBNAME}" |
| 622 | mimeset -f "${LIBNAME}" |
Brian Paul | 8dcc673 | 2005-07-25 22:59:58 +0000 | [diff] [blame] | 623 | # XXX remove the Mesa3D stuff here since mklib isn't mesa-specific. |
Brian Paul | b784b8f | 2004-08-14 14:30:36 +0000 | [diff] [blame] | 624 | setversion "${LIBNAME}" -app ${MAJOR} ${MINOR} ${PATCH} -short "Powered by Mesa3D!" -long "Powered by Mesa3D!" |
| 625 | fi |
| 626 | FINAL_LIBS=${LIBNAME} |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 627 | ;; |
| 628 | |
| 629 | 'QNX') |
| 630 | LIBNAME="lib${LIBNAME}.a" |
| 631 | echo "mklib: Making QNX library: " ${LIBNAME} |
| 632 | wlib ${LIBNAME} ${OBJECTS} |
| 633 | FINAL_LIBS=${LIBNAME} |
| 634 | ;; |
| 635 | |
Brian Paul | 65e2ab3 | 2003-10-27 18:13:37 +0000 | [diff] [blame] | 636 | 'MorphOS') |
| 637 | LIBNAME="lib${LIBNAME}.a" |
| 638 | echo "mklib: Making MorphOS library: " ${LIBNAME} |
| 639 | ppc-morphos-ar rc ${LIBNAME} ${OBJECTS} |
| 640 | FINAL_LIBS="${LIBNAME}" |
| 641 | ;; |
| 642 | |
Brian Paul | fe14cf6 | 2006-04-13 02:23:25 +0000 | [diff] [blame] | 643 | 'icc' | 'icc-istatic') |
Brian Paul | b3b725b | 2003-12-15 16:14:55 +0000 | [diff] [blame] | 644 | # Intel C compiler |
Brian Paul | 7c1ab40 | 2005-07-25 23:49:50 +0000 | [diff] [blame] | 645 | # This should get merged into the Linux code, above, since this isn't |
| 646 | # really a different architecture. |
Brian Paul | b3b725b | 2003-12-15 16:14:55 +0000 | [diff] [blame] | 647 | LIBNAME="lib${LIBNAME}" # prefix with "lib" |
| 648 | |
| 649 | if [ $STATIC = 1 ] ; then |
| 650 | echo "mklib: Making Intel ICC static library: " ${LIBNAME}.a |
| 651 | LINK="ar" |
| 652 | OPTS="-ruv" |
| 653 | # make lib |
| 654 | ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS} |
| 655 | # finish up |
| 656 | FINAL_LIBS="${LIBNAME}.a" |
| 657 | else |
Brian Paul | fe14cf6 | 2006-04-13 02:23:25 +0000 | [diff] [blame] | 658 | if [ $ARCH = icc-istatic ] ; then |
| 659 | OPTS="-shared -i-static -cxxlib-icc" |
| 660 | else |
| 661 | OPTS="-shared" |
| 662 | fi |
Brian Paul | b3b725b | 2003-12-15 16:14:55 +0000 | [diff] [blame] | 663 | VERSION="${MAJOR}.${MINOR}.${PATCH}" |
Brian Paul | b3b725b | 2003-12-15 16:14:55 +0000 | [diff] [blame] | 664 | echo "mklib: Making Intel ICC shared library: " ${LIBNAME}.so.${VERSION} |
| 665 | |
| 666 | if [ $CPLUSPLUS = 1 ] ; then |
Brian Paul | fe14cf6 | 2006-04-13 02:23:25 +0000 | [diff] [blame] | 667 | LINK="icpc" |
Brian Paul | b3b725b | 2003-12-15 16:14:55 +0000 | [diff] [blame] | 668 | else |
| 669 | LINK="icc" |
| 670 | fi |
Brian Paul | b3b725b | 2003-12-15 16:14:55 +0000 | [diff] [blame] | 671 | # rm any old libs |
| 672 | rm -f ${LIBNAME}.so.${VERSION} |
| 673 | rm -f ${LIBNAME}.so.${MAJOR} |
| 674 | rm -f ${LIBNAME}.so |
Brian Paul | b3b725b | 2003-12-15 16:14:55 +0000 | [diff] [blame] | 675 | # make lib |
| 676 | ${LINK} ${OPTS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS} |
| 677 | # make usual symlinks |
| 678 | ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} |
| 679 | ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so |
| 680 | # finish up |
| 681 | FINAL_LIBS="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so" |
| 682 | fi |
| 683 | ;; |
| 684 | |
Brian Paul | 12d6cae | 2004-01-10 22:12:21 +0000 | [diff] [blame] | 685 | 'aix-gcc') |
| 686 | # AIX with gcc |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 687 | if [ $STATIC = 1 ] ; then |
| 688 | LIBNAME="lib${LIBNAME}.a" |
| 689 | echo "mklib: Making AIX GCC static library: " ${LIBNAME} |
| 690 | rm -f ${LIBNAME} |
| 691 | ar ru ${LIBNAME} ${OBJECTS} |
| 692 | FINAL_LIBS=${LIBNAME} |
| 693 | else |
| 694 | LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so" |
| 695 | echo "mklib: Making AIX GCC shared library: " ${LIBNAME} |
| 696 | # remove old lib |
| 697 | rm -f ${LIBNAME} |
| 698 | # make the lib |
| 699 | gcc -shared -Wl,-G ${OBJECTS} ${DEPS} -o ${LIBNAME} |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 700 | # NOTE: the application linking with this library must specify |
| 701 | # the -Wl,-brtl flags to gcc |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 702 | FINAL_LIBS=${LIBNAME} |
| 703 | fi |
| 704 | ;; |
| 705 | |
| 706 | 'ultrix') |
| 707 | # XXX untested |
| 708 | if [ $STATIC = 0 ] ; then |
| 709 | echo "mklib: Warning shared libs not supported on Ultrix" |
| 710 | fi |
| 711 | LIBNAME="lib${LIBNAME}.a" |
| 712 | echo "mklib: Making static library for Ultrix: " ${LIBNAME} |
Brian Paul | 12d6cae | 2004-01-10 22:12:21 +0000 | [diff] [blame] | 713 | rm -f ${LIBNAME} |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 714 | ar ru ${LIBNAME} ${OBJECTS} |
| 715 | FINAL_LIBS="${LIBNAME}" |
Brian Paul | 12d6cae | 2004-01-10 22:12:21 +0000 | [diff] [blame] | 716 | ;; |
Brian Paul | b3b725b | 2003-12-15 16:14:55 +0000 | [diff] [blame] | 717 | |
Brian Paul | 580548d | 2004-04-22 16:16:42 +0000 | [diff] [blame] | 718 | CYGWIN*) |
| 719 | # GCC-based environment |
| 720 | CYGNAME="cyg${LIBNAME}" # prefix with "cyg" |
| 721 | LIBNAME="lib${LIBNAME}" # prefix with "lib" |
| 722 | |
| 723 | if [ $STATIC = 1 ] ; then |
| 724 | echo "mklib: Making" $ARCH "static library: " ${LIBNAME}.a |
| 725 | LINK="ar" |
| 726 | OPTS="-ru" |
| 727 | # make lib |
| 728 | ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS} |
| 729 | ranlib ${LIBNAME}.a |
| 730 | # finish up |
| 731 | FINAL_LIBS=${LIBNAME}.a |
| 732 | else |
| 733 | OPTS="-shared -Wl,-export-all -Wl,--out-implib=${LIBNAME}-${MAJOR}.dll.a" |
| 734 | echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}-${MAJOR}.dll |
| 735 | |
| 736 | if [ $CPLUSPLUS = 1 ] ; then |
| 737 | LINK="g++" |
| 738 | else |
| 739 | LINK="gcc" |
| 740 | fi |
| 741 | |
| 742 | # rm any old libs |
| 743 | rm -f ${LIBNAME}-${MAJOR}.dll |
| 744 | rm -f ${LIBNAME}.dll.a |
| 745 | rm -f ${LIBNAME}.a |
| 746 | |
| 747 | # make lib |
| 748 | ${LINK} ${OPTS} -o ${CYGNAME}-${MAJOR}.dll ${OBJECTS} ${DEPS} |
| 749 | # make usual symlinks |
| 750 | ln -s ${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a |
| 751 | # finish up |
| 752 | FINAL_LIBS="${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a" |
| 753 | # special case for installing in bin |
| 754 | FINAL_BINS="${CYGNAME}-${MAJOR}.dll" |
| 755 | fi |
| 756 | ;; |
| 757 | |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 758 | 'example') |
| 759 | # If you're adding support for a new architecture, you can |
| 760 | # start with this: |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 761 | if [ $STATIC = 1 ] ; then |
| 762 | LIBNAME="lib${LIBNAME}.a" |
| 763 | echo "mklib: Making static library for example arch: " ${LIBNAME} |
| 764 | rm -f ${LIBNAME} |
| 765 | ar rv ${LIBNAME} ${OBJECTS} |
| 766 | FINAL_LIBS="${LIBNAME}" |
| 767 | else |
Brian Paul | 7c1ab40 | 2005-07-25 23:49:50 +0000 | [diff] [blame] | 768 | LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so" |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 769 | echo "mklib: Making shared library for example arch: " ${LIBNAME} |
| 770 | ld -o ${LIBNAME} ${OBJECTS} ${DEPS} |
| 771 | FINAL_LIBS="${LIBNAME}" |
| 772 | fi |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 773 | ;; |
| 774 | |
| 775 | *) |
Brian Paul | 5396ab2 | 2004-02-12 14:48:52 +0000 | [diff] [blame] | 776 | echo "mklib: ERROR: Don't know how to make a static/shared library for" ${ARCH} |
| 777 | echo "mklib: Please add necessary commands to mklib script." |
Brian Paul | 8c20c7b | 2003-06-01 16:21:45 +0000 | [diff] [blame] | 778 | ;; |
| 779 | esac |
| 780 | |
| 781 | |
| 782 | # |
| 783 | # Put library files into installation directory if specified. |
| 784 | # |
| 785 | if [ ${INSTALLDIR} != "." ] ; then |
| 786 | echo "mklib: Installing" ${FINAL_LIBS} "in" ${INSTALLDIR} |
| 787 | mv ${FINAL_LIBS} ${INSTALLDIR}/ |
| 788 | fi |