Clone of mesa.
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

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