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