Clone of mesa.
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

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