Clone of mesa.
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697
  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-2005 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. INSTALLDIR="."
  35. ARCH="auto"
  36. ARCHOPT=""
  37. NOPREFIX=0
  38. EXPORTS=""
  39. #
  40. # Parse arguments
  41. #
  42. while true
  43. do
  44. case $1 in
  45. '-h' | '--help')
  46. echo 'Usage: mklib [options] objects'
  47. echo 'Create a shared library from object files.'
  48. echo ' -o LIBRARY specifies the name of the resulting library, without'
  49. echo ' the leading "lib" or any suffix.'
  50. echo ' (eg: "-o GL" might result in "libGL.so" being made)'
  51. echo ' -major N specifies major version number (default is 1)'
  52. echo ' -minor N specifies minor version number (default is 0)'
  53. echo ' -patch N specifies patch version number (default is 0)'
  54. echo ' -lLIBRARY specifies a dependency on LIBRARY'
  55. echo ' -LDIR search in DIR for library dependencies'
  56. echo ' -linker L explicity specify the linker program to use (eg: gcc, g++)'
  57. echo ' Not observed on all systems at this time.'
  58. echo ' -cplusplus link with C++ runtime'
  59. echo ' -static make a static library (default is dynamic/shared)'
  60. echo ' -install DIR put resulting library file(s) in DIR'
  61. echo ' -arch ARCH override using `uname` to determine host system'
  62. echo ' -archopt OPT specify an extra achitecture-specific option OPT'
  63. echo " -noprefix don't prefix library name with 'lib' nor add any suffix"
  64. echo ' -exports FILE only export the symbols listed in FILE'
  65. echo ' -h, --help display this information and exit'
  66. exit 1
  67. ;;
  68. '-o')
  69. shift 1;
  70. LIBNAME=$1
  71. ;;
  72. '-major')
  73. shift 1;
  74. MAJOR=$1
  75. ;;
  76. '-minor')
  77. shift 1;
  78. MINOR=$1
  79. ;;
  80. '-patch')
  81. shift 1;
  82. PATCH=$1
  83. ;;
  84. '-linker')
  85. shift 1;
  86. LINK=$1
  87. ;;
  88. -l*)
  89. DEPS="$DEPS $1"
  90. ;;
  91. -L*)
  92. DEPS="$DEPS $1"
  93. ;;
  94. '-cplusplus')
  95. CPLUSPLUS=1
  96. ;;
  97. '-static')
  98. STATIC=1
  99. ;;
  100. '-install')
  101. shift 1;
  102. INSTALLDIR=$1
  103. ;;
  104. '-arch')
  105. shift 1;
  106. ARCH=$1
  107. ;;
  108. '-archopt')
  109. shift 1;
  110. ARCHOPT=$1
  111. ;;
  112. '-noprefix')
  113. NOPREFIX=1
  114. ;;
  115. '-exports')
  116. shift 1;
  117. EXPORTS=$1
  118. ;;
  119. -*)
  120. echo "mklib: Unknown option: " $1 ;
  121. exit 1
  122. ;;
  123. *)
  124. # This should be the first object file, stop parsing
  125. break
  126. esac
  127. shift 1
  128. done
  129. OBJECTS=$@
  130. if [ ${ARCH} = "auto" ] ; then
  131. ARCH=`uname`
  132. fi
  133. #
  134. # Error checking
  135. #
  136. if [ "x${LIBNAME}" = "x" ] ; then
  137. echo "mklib: Error: no library name specified"
  138. exit 1
  139. fi
  140. if [ "x${OBJECTS}" = "x" ] ; then
  141. echo "mklib: Error: no object files specified"
  142. exit 1
  143. fi
  144. #
  145. # Debugging info
  146. #
  147. if [ ] ; then
  148. echo "-----------------"
  149. echo ARCH is $ARCH
  150. echo LIBNAME is $LIBNAME
  151. echo MAJOR is $MAJOR
  152. echo MINOR is $MINOR
  153. echo PATCH is $PATCH
  154. echo DEPS are $DEPS
  155. echo "EXPORTS in" $EXPORTS
  156. echo "-----------------"
  157. fi
  158. #
  159. # OK, make the library now
  160. #
  161. case $ARCH in
  162. 'Linux' | 'OpenBSD')
  163. # we assume gcc
  164. if [ "x$LINK" = "x" ] ; then
  165. # -linker was not specified so set default link command now
  166. if [ $CPLUSPLUS = 1 ] ; then
  167. LINK=g++
  168. else
  169. LINK=gcc
  170. fi
  171. fi
  172. if [ $NOPREFIX = 1 ] ; then
  173. # No "lib" or ".so" part
  174. echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}
  175. #OPTS="-shared -Wl,-soname,${LIBNAME}" # soname???
  176. OPTS="-shared"
  177. # Check if objects are 32-bit and we're running in 64-bit
  178. # environment. If so, pass -m32 flag to linker.
  179. set ${OBJECTS}
  180. ABI32=`file $1 | grep 32-bit`
  181. if [ "${ABI32}" -a `uname -m` = "x86_64" ] ; then
  182. OPTS="-m32 ${OPTS}"
  183. fi
  184. rm -f ${LIBNAME}
  185. # make lib
  186. ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
  187. # finish up
  188. FINAL_LIBS="${LIBNAME}"
  189. elif [ $STATIC = 1 ] ; then
  190. LIBNAME="lib${LIBNAME}" # prefix with "lib"
  191. echo "mklib: Making" $ARCH "static library: " ${LIBNAME}.a
  192. rm -f ${LIBNAME}.a
  193. ar -ru ${LIBNAME}.a ${OBJECTS}
  194. ranlib ${LIBNAME}.a
  195. # finish up
  196. FINAL_LIBS=${LIBNAME}.a
  197. else
  198. LIBNAME="lib${LIBNAME}" # prefix with "lib"
  199. if [ $ARCH = 'Linux' ] ; then
  200. OPTS="-Xlinker -Bsymbolic -shared -Wl,-soname,${LIBNAME}.so.${MAJOR}"
  201. else
  202. OPTS="-shared -Wl,-soname,${LIBNAME}.so.${MAJOR}"
  203. fi
  204. if [ $EXPORTS ] ; then
  205. #OPTS="${OPTS} -Xlinker --retain-symbols-file ${EXPORTS}"
  206. # Make the 'exptmp' file for --version-script option
  207. echo "VERSION_${MAJOR}.${MINOR} {" > exptmp
  208. echo "global:" >> exptmp
  209. sed 's/$/;/' ${EXPORTS} >> exptmp
  210. echo "local:" >> exptmp
  211. echo "*;" >> exptmp
  212. echo "};" >> exptmp
  213. OPTS="${OPTS} -Xlinker --version-script=exptmp"
  214. # exptmp is removed below
  215. fi
  216. # Check if objects are 32-bit and we're running in 64-bit
  217. # environment. If so, pass -m32 flag to linker.
  218. set ${OBJECTS}
  219. ABI32=`file $1 | grep 32-bit`
  220. if [ "${ABI32}" -a `uname -m` = "x86_64" ] ; then
  221. OPTS="-m32 ${OPTS}"
  222. fi
  223. if [ x${PATCH} = "x" ] ; then
  224. VERSION="${MAJOR}.${MINOR}"
  225. else
  226. VERSION="${MAJOR}.${MINOR}.${PATCH}"
  227. fi
  228. echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}.so.${VERSION}
  229. # rm any old libs
  230. rm -f ${LIBNAME}.so.${VERSION}
  231. rm -f ${LIBNAME}.so.${MAJOR}
  232. rm -f ${LIBNAME}.so
  233. # make lib
  234. ${LINK} ${OPTS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
  235. # make usual symlinks
  236. ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR}
  237. ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
  238. # finish up
  239. FINAL_LIBS="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so"
  240. # rm -f exptmp
  241. fi
  242. ;;
  243. 'SunOS')
  244. if [ $STATIC = 1 ] ; then
  245. LIBNAME="lib${LIBNAME}.a"
  246. echo "mklib: Making SunOS static library: " ${LIBNAME}
  247. rm -f ${LIBNAME}
  248. ar -ruv ${LIBNAME} ${OBJECTS}
  249. FINAL_LIBS=${LIBNAME}
  250. else
  251. LIBNAME="lib${LIBNAME}.so"
  252. echo "mklib: Making SunOS shared library: " ${LIBNAME}
  253. # XXX OPTS for gcc should be -shared, but that doesn't work.
  254. # Using -G does work though.
  255. OPTS="-G"
  256. if [ "x$LINK" = "x" ] ; then
  257. # -linker was not specified, choose default linker now
  258. if [ $CPLUSPLUS = 1 ] ; then
  259. # determine linker and options for C++ code
  260. if [ `which c++` ] ; then
  261. # use Sun c++
  262. LINK="c++"
  263. elif [ `type g++` ] ; then
  264. # use g++
  265. LINK="g++"
  266. else
  267. echo "mklib: warning: can't find C++ comiler, trying CC."
  268. LINK="CC"
  269. fi
  270. else
  271. # use native Sun linker for C code
  272. LINK="ld"
  273. fi
  274. fi
  275. echo "mklib: linker is" ${LINK} ${OPTS}
  276. rm -f ${LIBNAME}.${MAJOR} ${LIBNAME}
  277. ${LINK} ${OPTS} -o ${LIBNAME}.${MAJOR} ${OBJECTS} ${DEPS}
  278. ln -s ${LIBNAME}.${MAJOR} ${LIBNAME}
  279. FINAL_LIBS="${LIBNAME}.${MAJOR} ${LIBNAME}"
  280. fi
  281. ;;
  282. 'FreeBSD')
  283. # we assume gcc
  284. if [ "x$LINK" = "x" ] ; then
  285. # -linker was not specified so set default link command now
  286. if [ $CPLUSPLUS = 1 ] ; then
  287. LINK=g++
  288. else
  289. LINK=gcc
  290. fi
  291. fi
  292. if [ $NOPREFIX = 1 ] ; then
  293. # No "lib" or ".so" part
  294. echo "mklib: Making FreeBSD shared library: " ${LIBNAME}
  295. OPTS="-shared"
  296. rm -f ${LIBNAME}
  297. ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
  298. FINAL_LIBS=${LIBNAME}
  299. elif [ $STATIC = 1 ] ; then
  300. STLIB="lib${LIBNAME}.a"
  301. echo "mklib: Making FreeBSD static library: " ${STLIB}
  302. rm -f ${STLIB}
  303. ar cq ${STLIB} ${OBJECTS}
  304. ranlib ${STLIB}
  305. FINAL_LIBS=${STLIB}
  306. else
  307. SHLIB="lib${LIBNAME}.so.${MAJOR}"
  308. OPTS="-shared -Wl,-soname,${SHLIB}"
  309. echo "mklib: Making FreeBSD shared library: " ${SHLIB}
  310. rm -f ${SHLIB}
  311. ${LINK} ${OPTS} -o ${SHLIB} ${OBJECTS} ${DEPS}
  312. ln -sf ${SHLIB} "lib${LIBNAME}.so"
  313. FINAL_LIBS="${SHLIB} lib${LIBNAME}.so"
  314. fi
  315. ;;
  316. 'NetBSD')
  317. if [ $STATIC = 1 ] ; then
  318. LIBNAME="lib${LIBNAME}_pic.a"
  319. echo "mklib: Making NetBSD PIC static library: " ${LIBNAME}
  320. rm -f ${LIBNAME}
  321. ar cq ${LIBNAME} ${OBJECTS}
  322. ranlib ${LIBNAME}
  323. FINAL_LIBS=${LIBNAME}
  324. else
  325. LIBNAME="lib${LIBNAME}.so.${MAJOR}.${MINOR}"
  326. echo "mklib: Making NetBSD PIC shared library: " ${LIBNAME}
  327. rm -f ${LIBNAME}
  328. ld -x -Bshareable -Bforcearchive -o ${LIBNAME} ${OBJECTS}
  329. FINAL_LIBS=${LIBNAME}
  330. fi
  331. ;;
  332. 'IRIX' | 'IRIX64')
  333. if [ $STATIC = 1 ] ; then
  334. LIBNAME="lib${LIBNAME}.a"
  335. rm -f ${LIBNAME}
  336. ar rc ${LIBNAME} ${OBJECTS}
  337. FINAL_LIBS=${LIBNAME}
  338. else
  339. LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
  340. # XXX we should run 'file' on the first object file to determine
  341. # if it's o32, n32 or 64 format, as we do for Linux above.
  342. if [ $ARCHOPT = "64" ] ; then
  343. # 64-bit ABI
  344. OPTS="-64 -shared -all"
  345. echo "mklib: Making IRIX 64-bit shared library: " ${LIBNAME}
  346. elif [ $ARCHOPT = "o32" ] ; then
  347. # old 32-bit ABI
  348. OPTS="-32 -shared -all"
  349. echo "mklib: Making IRIX o32-bit shared library: " ${LIBNAME}
  350. else
  351. # new 32-bit ABI
  352. OPTS="-n32 -shared -all"
  353. echo "mklib: Making IRIX n32-bit shared library: " ${LIBNAME}
  354. fi
  355. if [ $CPLUSPLUS = 1 ] ; then
  356. LINK="CC"
  357. else
  358. LINK="ld"
  359. fi
  360. ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
  361. FINAL_LIBS=${LIBNAME}
  362. fi
  363. ;;
  364. 'linux-cygwin')
  365. LIBNAME="lib${LIBNAME}.a"
  366. echo "mklib: Making linux-cygwin library: " ${LIBNAME}
  367. rm -f ${LIBNAME}
  368. gnuwin32ar ruv ${LIBNAME} ${OBJECTS}
  369. FINAL_LIBS=${LIBNAME}
  370. ;;
  371. 'HP-UX')
  372. if [ $STATIC = 1 ] ; then
  373. LIBNAME="lib${LIBNAME}.a"
  374. echo "mklib: Making HP-UX static library: " ${LIBNAME}
  375. rm -f ${LIBNAME}
  376. ar -ruv ${LIBNAME} ${OBJECTS}
  377. FINAL_LIBS=${LIBNAME}
  378. else
  379. RUNLIB="lib${LIBNAME}.${MAJOR}"
  380. DEVLIB="lib${LIBNAME}.sl"
  381. echo "mklib: Making HP-UX shared library: " ${RUNLIB} ${DEVLIB}
  382. ld -b -o ${RUNLIB} +b ${RUNLIB} ${OBJECTS} ${DEPS}
  383. ln -s ${RUNLIB} ${DEVLIB}
  384. FINAL_LIBS="${RUNLIB} ${DEVLIB}"
  385. fi
  386. ;;
  387. 'AIX' | 'AIX64')
  388. if [ $ARCH = "AIX64" ] ; then
  389. X64="-X64"
  390. fi
  391. if [ $STATIC = 1 ] ; then
  392. LIBNAME="lib${LIBNAME}.a"
  393. echo "mklib: Making AIX static library: " ${LIBNAME}
  394. rm -f ${LIBNAME}
  395. ar -ruv ${X64} ${LIBNAME} ${OBJECTS}
  396. FINAL_LIBS=${LIBNAME}
  397. else
  398. EXPFILE="lib${LIBNAME}.exp"
  399. OFILE=shr.o #Want to be consistent with the IBM libGL.a
  400. LIBNAME="lib${LIBNAME}.a" # shared objects are still stored in the .a libraries
  401. if [ $ARCH = "AIX64" ] ; then
  402. OPTS="-bE:${EXPFILE} -bM:SRE -bnoentry -q64"
  403. else
  404. OPTS="-bE:${EXPFILE} -bM:SRE -bnoentry"
  405. fi
  406. rm -f ${EXPFILE} ${OFILE}
  407. NM="/bin/nm -eC ${X64}"
  408. echo "#! /usr/lib/${LIBNAME}" > ${EXPFILE}
  409. ${NM} ${OBJECTS} | awk '{
  410. if ((($2 == "T") || ($2 == "D") || ($2 == "B")) \
  411. && ( substr($1,1,1) != ".")) {
  412. if (substr ($1, 1, 7) != "__sinit" &&
  413. substr ($1, 1, 7) != "__sterm") {
  414. if (substr ($1, 1, 5) == "__tf1")
  415. print (substr ($1, 7))
  416. else if (substr ($1, 1, 5) == "__tf9")
  417. print (substr ($1, 15))
  418. else
  419. print $1
  420. }
  421. }
  422. }' | sort -u >> ${EXPFILE}
  423. cc ${OPTS} -o ${OFILE} ${OBJECTS} ${DEPS}
  424. ar ${X64} -r ${LIBNAME} ${OFILE}
  425. FINAL_LIBS="${LIBNAME}"
  426. fi
  427. ;;
  428. 'OpenSTEP')
  429. LIBNAME="lib${LIBNAME}.a"
  430. echo "mklib: Making OpenSTEP static library: " ${LIBNAME}
  431. libtool -static -o ${LIBNAME} - ${OBJECTS}
  432. FINAL_LIBS=${LIBNAME}
  433. ;;
  434. 'OSF1')
  435. if [ $STATIC = 1 ] ; then
  436. LIBNAME="lib${LIBNAME}.a"
  437. echo "mklib: Making OSF/1 static library: " ${LIBNAME}
  438. rm -f ${LIBNAME}
  439. ar -ruv ${LIBNAME} ${OBJECTS}
  440. FINAL_LIBS=${LIBNAME}
  441. else
  442. VERSION="${MAJOR}.${MINOR}"
  443. LIBNAME="lib${LIBNAME}.so"
  444. echo "mklib: Making OSF/1 shared library: " ${LIBNAME}
  445. if [ "x$LINK" = "x" ] ; then
  446. if [ $CPLUSPLUS = 1 ] ; then
  447. LINK=cxx
  448. else
  449. LINK=cc
  450. fi
  451. fi
  452. rm -f ${LIBNAME}.${VERSION}
  453. ${LINK} -o ${LIBNAME}.${VERSION} -shared -set_version ${VERSION} -soname ${LIBNAME}.${VERSION} -expect_unresolved \* -all ${OBJECTS} ${DEPS}
  454. ln -sf ${LIBNAME}.${VERSION} ${LIBNAME}
  455. FINAL_LIBS="${LIBNAME} ${LIBNAME}.${VERSION}"
  456. fi
  457. ;;
  458. 'Darwin')
  459. if [ $STATIC = 1 ] ; then
  460. LIBNAME="lib${LIBNAME}.a"
  461. echo "mklib: Making Darwin static library: " ${LIBNAME}
  462. LINK="ar"
  463. OPTS="-ruv"
  464. ${LINK} ${OPTS} ${LIBNAME} ${OBJECTS}
  465. FINAL_LIBS=${LIBNAME}
  466. else
  467. LIBNAME="lib${LIBNAME}.dylib"
  468. echo "mklib: Making Darwin shared library: " ${LIBNAME}
  469. FLAGS="-dynamiclib -multiply_defined suppress -current_version ${MAJOR}.${MINOR}.0 -compatibility_version ${MAJOR}.${MINOR}.0"
  470. if [ $CPLUSPLUS = 1 ] ; then
  471. LINK="g++"
  472. else
  473. LINK="cc"
  474. fi
  475. ${LINK} ${FLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
  476. FINAL_LIBS=${LIBNAME}
  477. fi
  478. ;;
  479. 'LynxOS')
  480. LIBNAME="lib${LIBNAME}.a"
  481. echo "mklib: Making LynxOS static library: " ${LIBNAME}
  482. rm -f ${LIBNAME}
  483. ar ru ${LIBNAME} ${OBJECTS}
  484. FINAL_LIBS=${LIBNAME}
  485. ;;
  486. 'BeOS')
  487. if [ $STATIC = 1 ] ; then
  488. LIBNAME="lib${LIBNAME}.a"
  489. echo "mklib: Making BeOS static library: " ${LIBNAME}
  490. ar -cru "${LIBNAME}" ${OBJECTS}
  491. else
  492. LIBNAME="lib${LIBNAME}.so"
  493. echo "mklib: Making BeOS shared library: " ${LIBNAME}
  494. gcc -nostart -Xlinker "-soname=${LIBNAME}" -L/Be/develop/lib/x86 -lbe ${DEPS} ${OBJECTS} -o "${LIBNAME}"
  495. mimeset -f "${LIBNAME}"
  496. # XXX remove the Mesa3D stuff here since mklib isn't mesa-specific.
  497. setversion "${LIBNAME}" -app ${MAJOR} ${MINOR} ${PATCH} -short "Powered by Mesa3D!" -long "Powered by Mesa3D!"
  498. fi
  499. FINAL_LIBS=${LIBNAME}
  500. ;;
  501. 'QNX')
  502. LIBNAME="lib${LIBNAME}.a"
  503. echo "mklib: Making QNX library: " ${LIBNAME}
  504. wlib ${LIBNAME} ${OBJECTS}
  505. FINAL_LIBS=${LIBNAME}
  506. ;;
  507. 'MorphOS')
  508. LIBNAME="lib${LIBNAME}.a"
  509. echo "mklib: Making MorphOS library: " ${LIBNAME}
  510. ppc-morphos-ar rc ${LIBNAME} ${OBJECTS}
  511. FINAL_LIBS="${LIBNAME}"
  512. ;;
  513. 'icc')
  514. # Intel C compiler
  515. # This should get merged into the Linux code, above, since this isn't
  516. # really a different architecture.
  517. LIBNAME="lib${LIBNAME}" # prefix with "lib"
  518. if [ $STATIC = 1 ] ; then
  519. echo "mklib: Making Intel ICC static library: " ${LIBNAME}.a
  520. LINK="ar"
  521. OPTS="-ruv"
  522. # make lib
  523. ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
  524. # finish up
  525. FINAL_LIBS="${LIBNAME}.a"
  526. else
  527. OPTS="-shared"
  528. VERSION="${MAJOR}.${MINOR}.${PATCH}"
  529. echo "mklib: Making Intel ICC shared library: " ${LIBNAME}.so.${VERSION}
  530. if [ $CPLUSPLUS = 1 ] ; then
  531. LINK="icc"
  532. else
  533. LINK="icc"
  534. fi
  535. # rm any old libs
  536. rm -f ${LIBNAME}.so.${VERSION}
  537. rm -f ${LIBNAME}.so.${MAJOR}
  538. rm -f ${LIBNAME}.so
  539. # make lib
  540. ${LINK} ${OPTS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
  541. # make usual symlinks
  542. ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR}
  543. ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
  544. # finish up
  545. FINAL_LIBS="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so"
  546. fi
  547. ;;
  548. 'aix-gcc')
  549. # AIX with gcc
  550. if [ $STATIC = 1 ] ; then
  551. LIBNAME="lib${LIBNAME}.a"
  552. echo "mklib: Making AIX GCC static library: " ${LIBNAME}
  553. rm -f ${LIBNAME}
  554. ar ru ${LIBNAME} ${OBJECTS}
  555. FINAL_LIBS=${LIBNAME}
  556. else
  557. LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
  558. echo "mklib: Making AIX GCC shared library: " ${LIBNAME}
  559. # remove old lib
  560. rm -f ${LIBNAME}
  561. # make the lib
  562. gcc -shared -Wl,-G ${OBJECTS} ${DEPS} -o ${LIBNAME}
  563. # NOTE: the application linking with this library must specify
  564. # the -Wl,-brtl flags to gcc
  565. FINAL_LIBS=${LIBNAME}
  566. fi
  567. ;;
  568. 'ultrix')
  569. # XXX untested
  570. if [ $STATIC = 0 ] ; then
  571. echo "mklib: Warning shared libs not supported on Ultrix"
  572. fi
  573. LIBNAME="lib${LIBNAME}.a"
  574. echo "mklib: Making static library for Ultrix: " ${LIBNAME}
  575. rm -f ${LIBNAME}
  576. ar ru ${LIBNAME} ${OBJECTS}
  577. FINAL_LIBS="${LIBNAME}"
  578. ;;
  579. CYGWIN*)
  580. # GCC-based environment
  581. CYGNAME="cyg${LIBNAME}" # prefix with "cyg"
  582. LIBNAME="lib${LIBNAME}" # prefix with "lib"
  583. if [ $STATIC = 1 ] ; then
  584. echo "mklib: Making" $ARCH "static library: " ${LIBNAME}.a
  585. LINK="ar"
  586. OPTS="-ru"
  587. # make lib
  588. ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
  589. ranlib ${LIBNAME}.a
  590. # finish up
  591. FINAL_LIBS=${LIBNAME}.a
  592. else
  593. OPTS="-shared -Wl,-export-all -Wl,--out-implib=${LIBNAME}-${MAJOR}.dll.a"
  594. echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}-${MAJOR}.dll
  595. if [ $CPLUSPLUS = 1 ] ; then
  596. LINK="g++"
  597. else
  598. LINK="gcc"
  599. fi
  600. # rm any old libs
  601. rm -f ${LIBNAME}-${MAJOR}.dll
  602. rm -f ${LIBNAME}.dll.a
  603. rm -f ${LIBNAME}.a
  604. # make lib
  605. ${LINK} ${OPTS} -o ${CYGNAME}-${MAJOR}.dll ${OBJECTS} ${DEPS}
  606. # make usual symlinks
  607. ln -s ${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a
  608. # finish up
  609. FINAL_LIBS="${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a"
  610. # special case for installing in bin
  611. FINAL_BINS="${CYGNAME}-${MAJOR}.dll"
  612. fi
  613. ;;
  614. 'example')
  615. # If you're adding support for a new architecture, you can
  616. # start with this:
  617. if [ $STATIC = 1 ] ; then
  618. LIBNAME="lib${LIBNAME}.a"
  619. echo "mklib: Making static library for example arch: " ${LIBNAME}
  620. rm -f ${LIBNAME}
  621. ar rv ${LIBNAME} ${OBJECTS}
  622. FINAL_LIBS="${LIBNAME}"
  623. else
  624. LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
  625. echo "mklib: Making shared library for example arch: " ${LIBNAME}
  626. ld -o ${LIBNAME} ${OBJECTS} ${DEPS}
  627. FINAL_LIBS="${LIBNAME}"
  628. fi
  629. ;;
  630. *)
  631. echo "mklib: ERROR: Don't know how to make a static/shared library for" ${ARCH}
  632. echo "mklib: Please add necessary commands to mklib script."
  633. ;;
  634. esac
  635. #
  636. # Put library files into installation directory if specified.
  637. #
  638. if [ ${INSTALLDIR} != "." ] ; then
  639. echo "mklib: Installing" ${FINAL_LIBS} "in" ${INSTALLDIR}
  640. mv ${FINAL_LIBS} ${INSTALLDIR}/
  641. fi