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