Clone of mesa.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

mklib 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718
  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. if [ "x$LINK" = "x" ] ; then
  254. # -linker was not specified, choose default linker now
  255. if [ $CPLUSPLUS = 1 ] ; then
  256. # determine linker and options for C++ code
  257. if [ `which c++` ] ; then
  258. # use Sun c++
  259. LINK="c++"
  260. elif [ `type g++` ] ; then
  261. # use g++
  262. LINK="g++"
  263. else
  264. echo "mklib: warning: can't find C++ comiler, trying CC."
  265. LINK="CC"
  266. fi
  267. else
  268. # use native Sun linker for C code
  269. LINK="ld"
  270. fi
  271. fi
  272. # linker options
  273. if [ ${LINK} = "ld" ] ; then
  274. # SunOS linker, -G to make shared libs
  275. OPTS="-G"
  276. else
  277. # gcc linker
  278. # Check if objects are 32-bit and we're running in 64-bit
  279. # environment. If so, pass -m32 flag to linker.
  280. set ${OBJECTS}
  281. ABI32=`file $1 | grep 32-bit`
  282. if [ "${ABI32}" ] ; then
  283. OPTS="-m32 -shared -Wl,-Bdynamic"
  284. else
  285. OPTS="-m64 -shared -Wl,-Bdynamic"
  286. fi
  287. fi
  288. # for debug:
  289. #echo "mklib: linker is" ${LINK} ${OPTS}
  290. rm -f ${LIBNAME}.${MAJOR} ${LIBNAME}
  291. ${LINK} ${OPTS} -o ${LIBNAME}.${MAJOR} ${OBJECTS} ${DEPS}
  292. ln -s ${LIBNAME}.${MAJOR} ${LIBNAME}
  293. FINAL_LIBS="${LIBNAME}.${MAJOR} ${LIBNAME}"
  294. fi
  295. ;;
  296. 'FreeBSD')
  297. # we assume gcc
  298. if [ "x$LINK" = "x" ] ; then
  299. # -linker was not specified so set default link command now
  300. if [ $CPLUSPLUS = 1 ] ; then
  301. LINK=g++
  302. else
  303. LINK=gcc
  304. fi
  305. fi
  306. if [ $NOPREFIX = 1 ] ; then
  307. # No "lib" or ".so" part
  308. echo "mklib: Making FreeBSD shared library: " ${LIBNAME}
  309. OPTS="-shared"
  310. rm -f ${LIBNAME}
  311. ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
  312. FINAL_LIBS=${LIBNAME}
  313. elif [ $STATIC = 1 ] ; then
  314. STLIB="lib${LIBNAME}.a"
  315. echo "mklib: Making FreeBSD static library: " ${STLIB}
  316. rm -f ${STLIB}
  317. ar cq ${STLIB} ${OBJECTS}
  318. ranlib ${STLIB}
  319. FINAL_LIBS=${STLIB}
  320. else
  321. SHLIB="lib${LIBNAME}.so.${MAJOR}"
  322. OPTS="-shared -Wl,-soname,${SHLIB}"
  323. echo "mklib: Making FreeBSD shared library: " ${SHLIB}
  324. rm -f ${SHLIB}
  325. ${LINK} ${OPTS} -o ${SHLIB} ${OBJECTS} ${DEPS}
  326. ln -sf ${SHLIB} "lib${LIBNAME}.so"
  327. FINAL_LIBS="${SHLIB} lib${LIBNAME}.so"
  328. fi
  329. ;;
  330. 'NetBSD')
  331. if [ $STATIC = 1 ] ; then
  332. LIBNAME="lib${LIBNAME}_pic.a"
  333. echo "mklib: Making NetBSD PIC static library: " ${LIBNAME}
  334. rm -f ${LIBNAME}
  335. ar cq ${LIBNAME} ${OBJECTS}
  336. ranlib ${LIBNAME}
  337. FINAL_LIBS=${LIBNAME}
  338. else
  339. LIBNAME="lib${LIBNAME}.so.${MAJOR}.${MINOR}"
  340. echo "mklib: Making NetBSD PIC shared library: " ${LIBNAME}
  341. rm -f ${LIBNAME}
  342. ld -x -Bshareable -Bforcearchive -o ${LIBNAME} ${OBJECTS}
  343. FINAL_LIBS=${LIBNAME}
  344. fi
  345. ;;
  346. 'IRIX' | 'IRIX64')
  347. if [ $STATIC = 1 ] ; then
  348. LIBNAME="lib${LIBNAME}.a"
  349. rm -f ${LIBNAME}
  350. ar rc ${LIBNAME} ${OBJECTS}
  351. FINAL_LIBS=${LIBNAME}
  352. else
  353. LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
  354. # XXX we should run 'file' on the first object file to determine
  355. # if it's o32, n32 or 64 format, as we do for Linux above.
  356. if [ $ARCHOPT = "64" ] ; then
  357. # 64-bit ABI
  358. OPTS="-64 -shared -all"
  359. echo "mklib: Making IRIX 64-bit shared library: " ${LIBNAME}
  360. elif [ $ARCHOPT = "o32" ] ; then
  361. # old 32-bit ABI
  362. OPTS="-32 -shared -all"
  363. echo "mklib: Making IRIX o32-bit shared library: " ${LIBNAME}
  364. else
  365. # new 32-bit ABI
  366. OPTS="-n32 -shared -all"
  367. echo "mklib: Making IRIX n32-bit shared library: " ${LIBNAME}
  368. fi
  369. if [ $CPLUSPLUS = 1 ] ; then
  370. LINK="CC"
  371. else
  372. LINK="ld"
  373. fi
  374. ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
  375. FINAL_LIBS=${LIBNAME}
  376. fi
  377. ;;
  378. 'linux-cygwin')
  379. LIBNAME="lib${LIBNAME}.a"
  380. echo "mklib: Making linux-cygwin library: " ${LIBNAME}
  381. rm -f ${LIBNAME}
  382. gnuwin32ar ruv ${LIBNAME} ${OBJECTS}
  383. FINAL_LIBS=${LIBNAME}
  384. ;;
  385. 'HP-UX')
  386. if [ $STATIC = 1 ] ; then
  387. LIBNAME="lib${LIBNAME}.a"
  388. echo "mklib: Making HP-UX static library: " ${LIBNAME}
  389. rm -f ${LIBNAME}
  390. ar -ruv ${LIBNAME} ${OBJECTS}
  391. FINAL_LIBS=${LIBNAME}
  392. else
  393. RUNLIB="lib${LIBNAME}.${MAJOR}"
  394. DEVLIB="lib${LIBNAME}.sl"
  395. echo "mklib: Making HP-UX shared library: " ${RUNLIB} ${DEVLIB}
  396. ld -b -o ${RUNLIB} +b ${RUNLIB} ${OBJECTS} ${DEPS}
  397. ln -s ${RUNLIB} ${DEVLIB}
  398. FINAL_LIBS="${RUNLIB} ${DEVLIB}"
  399. fi
  400. ;;
  401. 'AIX' | 'AIX64')
  402. if [ $ARCH = "AIX64" ] ; then
  403. X64="-X64"
  404. fi
  405. if [ $STATIC = 1 ] ; then
  406. LIBNAME="lib${LIBNAME}.a"
  407. echo "mklib: Making AIX static library: " ${LIBNAME}
  408. rm -f ${LIBNAME}
  409. ar -ruv ${X64} ${LIBNAME} ${OBJECTS}
  410. FINAL_LIBS=${LIBNAME}
  411. else
  412. EXPFILE="lib${LIBNAME}.exp"
  413. OFILE=shr.o #Want to be consistent with the IBM libGL.a
  414. LIBNAME="lib${LIBNAME}.a" # shared objects are still stored in the .a libraries
  415. if [ $ARCH = "AIX64" ] ; then
  416. OPTS="-bE:${EXPFILE} -bM:SRE -bnoentry -q64"
  417. else
  418. OPTS="-bE:${EXPFILE} -bM:SRE -bnoentry"
  419. fi
  420. rm -f ${EXPFILE} ${OFILE}
  421. NM="/bin/nm -eC ${X64}"
  422. echo "#! /usr/lib/${LIBNAME}" > ${EXPFILE}
  423. ${NM} ${OBJECTS} | awk '{
  424. if ((($2 == "T") || ($2 == "D") || ($2 == "B")) \
  425. && ( substr($1,1,1) != ".")) {
  426. if (substr ($1, 1, 7) != "__sinit" &&
  427. substr ($1, 1, 7) != "__sterm") {
  428. if (substr ($1, 1, 5) == "__tf1")
  429. print (substr ($1, 7))
  430. else if (substr ($1, 1, 5) == "__tf9")
  431. print (substr ($1, 15))
  432. else
  433. print $1
  434. }
  435. }
  436. }' | sort -u >> ${EXPFILE}
  437. cc ${OPTS} -o ${OFILE} ${OBJECTS} ${DEPS}
  438. ar ${X64} -r ${LIBNAME} ${OFILE}
  439. FINAL_LIBS="${LIBNAME}"
  440. fi
  441. ;;
  442. 'OpenSTEP')
  443. LIBNAME="lib${LIBNAME}.a"
  444. echo "mklib: Making OpenSTEP static library: " ${LIBNAME}
  445. libtool -static -o ${LIBNAME} - ${OBJECTS}
  446. FINAL_LIBS=${LIBNAME}
  447. ;;
  448. 'OSF1')
  449. if [ $STATIC = 1 ] ; then
  450. LIBNAME="lib${LIBNAME}.a"
  451. echo "mklib: Making OSF/1 static library: " ${LIBNAME}
  452. rm -f ${LIBNAME}
  453. ar -ruv ${LIBNAME} ${OBJECTS}
  454. FINAL_LIBS=${LIBNAME}
  455. else
  456. VERSION="${MAJOR}.${MINOR}"
  457. LIBNAME="lib${LIBNAME}.so"
  458. echo "mklib: Making OSF/1 shared library: " ${LIBNAME}
  459. if [ "x$LINK" = "x" ] ; then
  460. if [ $CPLUSPLUS = 1 ] ; then
  461. LINK=cxx
  462. else
  463. LINK=cc
  464. fi
  465. fi
  466. rm -f ${LIBNAME}.${VERSION}
  467. ${LINK} -o ${LIBNAME}.${VERSION} -shared -set_version ${VERSION} -soname ${LIBNAME}.${VERSION} -expect_unresolved \* -all ${OBJECTS} ${DEPS}
  468. ln -sf ${LIBNAME}.${VERSION} ${LIBNAME}
  469. FINAL_LIBS="${LIBNAME} ${LIBNAME}.${VERSION}"
  470. fi
  471. ;;
  472. 'Darwin')
  473. if [ $STATIC = 1 ] ; then
  474. LIBNAME="lib${LIBNAME}.a"
  475. echo "mklib: Making Darwin static library: " ${LIBNAME}
  476. LINK="ar"
  477. OPTS="-ruv"
  478. ${LINK} ${OPTS} ${LIBNAME} ${OBJECTS}
  479. FINAL_LIBS=${LIBNAME}
  480. else
  481. # may need these:
  482. # CFLAGS += -fno-common
  483. # LDFLAGS += -bundle -flat_namespace -undefined suppress
  484. LIBNAME="lib${LIBNAME}.dylib"
  485. echo "mklib: Making Darwin shared library: " ${LIBNAME}
  486. FLAGS="-dynamiclib -multiply_defined suppress -current_version ${MAJOR}.${MINOR}.0 -compatibility_version ${MAJOR}.${MINOR}.0"
  487. if [ $CPLUSPLUS = 1 ] ; then
  488. LINK="g++"
  489. else
  490. LINK="cc"
  491. fi
  492. ${LINK} ${FLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
  493. FINAL_LIBS=${LIBNAME}
  494. fi
  495. ;;
  496. 'LynxOS')
  497. LIBNAME="lib${LIBNAME}.a"
  498. echo "mklib: Making LynxOS static library: " ${LIBNAME}
  499. rm -f ${LIBNAME}
  500. ar ru ${LIBNAME} ${OBJECTS}
  501. FINAL_LIBS=${LIBNAME}
  502. ;;
  503. 'BeOS')
  504. if [ $STATIC = 1 ] ; then
  505. LIBNAME="lib${LIBNAME}.a"
  506. echo "mklib: Making BeOS static library: " ${LIBNAME}
  507. ar -cru "${LIBNAME}" ${OBJECTS}
  508. else
  509. LIBNAME="lib${LIBNAME}.so"
  510. echo "mklib: Making BeOS shared library: " ${LIBNAME}
  511. gcc -nostart -Xlinker "-soname=${LIBNAME}" -L/Be/develop/lib/x86 -lbe ${DEPS} ${OBJECTS} -o "${LIBNAME}"
  512. mimeset -f "${LIBNAME}"
  513. # XXX remove the Mesa3D stuff here since mklib isn't mesa-specific.
  514. setversion "${LIBNAME}" -app ${MAJOR} ${MINOR} ${PATCH} -short "Powered by Mesa3D!" -long "Powered by Mesa3D!"
  515. fi
  516. FINAL_LIBS=${LIBNAME}
  517. ;;
  518. 'QNX')
  519. LIBNAME="lib${LIBNAME}.a"
  520. echo "mklib: Making QNX library: " ${LIBNAME}
  521. wlib ${LIBNAME} ${OBJECTS}
  522. FINAL_LIBS=${LIBNAME}
  523. ;;
  524. 'MorphOS')
  525. LIBNAME="lib${LIBNAME}.a"
  526. echo "mklib: Making MorphOS library: " ${LIBNAME}
  527. ppc-morphos-ar rc ${LIBNAME} ${OBJECTS}
  528. FINAL_LIBS="${LIBNAME}"
  529. ;;
  530. 'icc')
  531. # Intel C compiler
  532. # This should get merged into the Linux code, above, since this isn't
  533. # really a different architecture.
  534. LIBNAME="lib${LIBNAME}" # prefix with "lib"
  535. if [ $STATIC = 1 ] ; then
  536. echo "mklib: Making Intel ICC static library: " ${LIBNAME}.a
  537. LINK="ar"
  538. OPTS="-ruv"
  539. # make lib
  540. ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
  541. # finish up
  542. FINAL_LIBS="${LIBNAME}.a"
  543. else
  544. OPTS="-shared"
  545. VERSION="${MAJOR}.${MINOR}.${PATCH}"
  546. echo "mklib: Making Intel ICC shared library: " ${LIBNAME}.so.${VERSION}
  547. if [ $CPLUSPLUS = 1 ] ; then
  548. LINK="icc"
  549. else
  550. LINK="icc"
  551. fi
  552. # rm any old libs
  553. rm -f ${LIBNAME}.so.${VERSION}
  554. rm -f ${LIBNAME}.so.${MAJOR}
  555. rm -f ${LIBNAME}.so
  556. # make lib
  557. ${LINK} ${OPTS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
  558. # make usual symlinks
  559. ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR}
  560. ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
  561. # finish up
  562. FINAL_LIBS="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so"
  563. fi
  564. ;;
  565. 'aix-gcc')
  566. # AIX with gcc
  567. if [ $STATIC = 1 ] ; then
  568. LIBNAME="lib${LIBNAME}.a"
  569. echo "mklib: Making AIX GCC static library: " ${LIBNAME}
  570. rm -f ${LIBNAME}
  571. ar ru ${LIBNAME} ${OBJECTS}
  572. FINAL_LIBS=${LIBNAME}
  573. else
  574. LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
  575. echo "mklib: Making AIX GCC shared library: " ${LIBNAME}
  576. # remove old lib
  577. rm -f ${LIBNAME}
  578. # make the lib
  579. gcc -shared -Wl,-G ${OBJECTS} ${DEPS} -o ${LIBNAME}
  580. # NOTE: the application linking with this library must specify
  581. # the -Wl,-brtl flags to gcc
  582. FINAL_LIBS=${LIBNAME}
  583. fi
  584. ;;
  585. 'ultrix')
  586. # XXX untested
  587. if [ $STATIC = 0 ] ; then
  588. echo "mklib: Warning shared libs not supported on Ultrix"
  589. fi
  590. LIBNAME="lib${LIBNAME}.a"
  591. echo "mklib: Making static library for Ultrix: " ${LIBNAME}
  592. rm -f ${LIBNAME}
  593. ar ru ${LIBNAME} ${OBJECTS}
  594. FINAL_LIBS="${LIBNAME}"
  595. ;;
  596. CYGWIN*)
  597. # GCC-based environment
  598. CYGNAME="cyg${LIBNAME}" # prefix with "cyg"
  599. LIBNAME="lib${LIBNAME}" # prefix with "lib"
  600. if [ $STATIC = 1 ] ; then
  601. echo "mklib: Making" $ARCH "static library: " ${LIBNAME}.a
  602. LINK="ar"
  603. OPTS="-ru"
  604. # make lib
  605. ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
  606. ranlib ${LIBNAME}.a
  607. # finish up
  608. FINAL_LIBS=${LIBNAME}.a
  609. else
  610. OPTS="-shared -Wl,-export-all -Wl,--out-implib=${LIBNAME}-${MAJOR}.dll.a"
  611. echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}-${MAJOR}.dll
  612. if [ $CPLUSPLUS = 1 ] ; then
  613. LINK="g++"
  614. else
  615. LINK="gcc"
  616. fi
  617. # rm any old libs
  618. rm -f ${LIBNAME}-${MAJOR}.dll
  619. rm -f ${LIBNAME}.dll.a
  620. rm -f ${LIBNAME}.a
  621. # make lib
  622. ${LINK} ${OPTS} -o ${CYGNAME}-${MAJOR}.dll ${OBJECTS} ${DEPS}
  623. # make usual symlinks
  624. ln -s ${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a
  625. # finish up
  626. FINAL_LIBS="${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a"
  627. # special case for installing in bin
  628. FINAL_BINS="${CYGNAME}-${MAJOR}.dll"
  629. fi
  630. ;;
  631. 'example')
  632. # If you're adding support for a new architecture, you can
  633. # start with this:
  634. if [ $STATIC = 1 ] ; then
  635. LIBNAME="lib${LIBNAME}.a"
  636. echo "mklib: Making static library for example arch: " ${LIBNAME}
  637. rm -f ${LIBNAME}
  638. ar rv ${LIBNAME} ${OBJECTS}
  639. FINAL_LIBS="${LIBNAME}"
  640. else
  641. LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
  642. echo "mklib: Making shared library for example arch: " ${LIBNAME}
  643. ld -o ${LIBNAME} ${OBJECTS} ${DEPS}
  644. FINAL_LIBS="${LIBNAME}"
  645. fi
  646. ;;
  647. *)
  648. echo "mklib: ERROR: Don't know how to make a static/shared library for" ${ARCH}
  649. echo "mklib: Please add necessary commands to mklib script."
  650. ;;
  651. esac
  652. #
  653. # Put library files into installation directory if specified.
  654. #
  655. if [ ${INSTALLDIR} != "." ] ; then
  656. echo "mklib: Installing" ${FINAL_LIBS} "in" ${INSTALLDIR}
  657. mv ${FINAL_LIBS} ${INSTALLDIR}/
  658. fi