bakefile.m4 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152
  1. dnl
  2. dnl This file is part of Bakefile (http://www.bakefile.org)
  3. dnl
  4. dnl Copyright (C) 2003-2007 Vaclav Slavik and others
  5. dnl
  6. dnl Permission is hereby granted, free of charge, to any person obtaining a
  7. dnl copy of this software and associated documentation files (the "Software"),
  8. dnl to deal in the Software without restriction, including without limitation
  9. dnl the rights to use, copy, modify, merge, publish, distribute, sublicense,
  10. dnl and/or sell copies of the Software, and to permit persons to whom the
  11. dnl Software is furnished to do so, subject to the following conditions:
  12. dnl
  13. dnl The above copyright notice and this permission notice shall be included in
  14. dnl all copies or substantial portions of the Software.
  15. dnl
  16. dnl THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. dnl IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. dnl FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  19. dnl THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. dnl LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  21. dnl FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  22. dnl DEALINGS IN THE SOFTWARE.
  23. dnl
  24. dnl Support macros for makefiles generated by BAKEFILE.
  25. dnl
  26. dnl ---------------------------------------------------------------------------
  27. dnl Lots of compiler & linker detection code contained here was taken from
  28. dnl wxWidgets configure.in script (see http://www.wxwidgets.org)
  29. dnl ---------------------------------------------------------------------------
  30. dnl ---------------------------------------------------------------------------
  31. dnl AC_BAKEFILE_GNUMAKE
  32. dnl
  33. dnl Detects GNU make
  34. dnl ---------------------------------------------------------------------------
  35. AC_DEFUN([AC_BAKEFILE_GNUMAKE],
  36. [
  37. dnl does make support "-include" (only GNU make does AFAIK)?
  38. AC_CACHE_CHECK([if make is GNU make], bakefile_cv_prog_makeisgnu,
  39. [
  40. if ( ${SHELL-sh} -c "${MAKE-make} --version" 2> /dev/null |
  41. egrep -s GNU > /dev/null); then
  42. bakefile_cv_prog_makeisgnu="yes"
  43. else
  44. bakefile_cv_prog_makeisgnu="no"
  45. fi
  46. ])
  47. if test "x$bakefile_cv_prog_makeisgnu" = "xyes"; then
  48. IF_GNU_MAKE=""
  49. else
  50. IF_GNU_MAKE="#"
  51. fi
  52. AC_SUBST(IF_GNU_MAKE)
  53. ])
  54. dnl ---------------------------------------------------------------------------
  55. dnl AC_BAKEFILE_PLATFORM
  56. dnl
  57. dnl Detects platform and sets PLATFORM_XXX variables accordingly
  58. dnl ---------------------------------------------------------------------------
  59. AC_DEFUN([AC_BAKEFILE_PLATFORM],
  60. [
  61. PLATFORM_UNIX=0
  62. PLATFORM_WIN32=0
  63. PLATFORM_MSDOS=0
  64. PLATFORM_MAC=0
  65. PLATFORM_MACOS=0
  66. PLATFORM_MACOSX=0
  67. PLATFORM_OS2=0
  68. PLATFORM_BEOS=0
  69. if test "x$BAKEFILE_FORCE_PLATFORM" = "x"; then
  70. case "${BAKEFILE_HOST}" in
  71. *-*-mingw32* )
  72. PLATFORM_WIN32=1
  73. ;;
  74. *-pc-msdosdjgpp )
  75. PLATFORM_MSDOS=1
  76. ;;
  77. *-pc-os2_emx | *-pc-os2-emx )
  78. PLATFORM_OS2=1
  79. ;;
  80. *-*-darwin* )
  81. PLATFORM_MAC=1
  82. PLATFORM_MACOSX=1
  83. ;;
  84. *-*-beos* )
  85. PLATFORM_BEOS=1
  86. ;;
  87. powerpc-apple-macos* )
  88. PLATFORM_MAC=1
  89. PLATFORM_MACOS=1
  90. ;;
  91. * )
  92. PLATFORM_UNIX=1
  93. ;;
  94. esac
  95. else
  96. case "$BAKEFILE_FORCE_PLATFORM" in
  97. win32 )
  98. PLATFORM_WIN32=1
  99. ;;
  100. msdos )
  101. PLATFORM_MSDOS=1
  102. ;;
  103. os2 )
  104. PLATFORM_OS2=1
  105. ;;
  106. darwin )
  107. PLATFORM_MAC=1
  108. PLATFORM_MACOSX=1
  109. ;;
  110. unix )
  111. PLATFORM_UNIX=1
  112. ;;
  113. beos )
  114. PLATFORM_BEOS=1
  115. ;;
  116. * )
  117. AC_MSG_ERROR([Unknown platform: $BAKEFILE_FORCE_PLATFORM])
  118. ;;
  119. esac
  120. fi
  121. AC_SUBST(PLATFORM_UNIX)
  122. AC_SUBST(PLATFORM_WIN32)
  123. AC_SUBST(PLATFORM_MSDOS)
  124. AC_SUBST(PLATFORM_MAC)
  125. AC_SUBST(PLATFORM_MACOS)
  126. AC_SUBST(PLATFORM_MACOSX)
  127. AC_SUBST(PLATFORM_OS2)
  128. AC_SUBST(PLATFORM_BEOS)
  129. ])
  130. dnl ---------------------------------------------------------------------------
  131. dnl AC_BAKEFILE_PLATFORM_SPECIFICS
  132. dnl
  133. dnl Sets misc platform-specific settings
  134. dnl ---------------------------------------------------------------------------
  135. AC_DEFUN([AC_BAKEFILE_PLATFORM_SPECIFICS],
  136. [
  137. AC_ARG_ENABLE([omf], AS_HELP_STRING([--enable-omf],
  138. [use OMF object format (OS/2)]),
  139. [bk_os2_use_omf="$enableval"])
  140. case "${BAKEFILE_HOST}" in
  141. *-*-darwin* )
  142. dnl For Unix to MacOS X porting instructions, see:
  143. dnl http://fink.sourceforge.net/doc/porting/porting.html
  144. if test "x$GCC" = "xyes"; then
  145. CFLAGS="$CFLAGS -fno-common"
  146. CXXFLAGS="$CXXFLAGS -fno-common"
  147. fi
  148. if test "x$XLCC" = "xyes"; then
  149. CFLAGS="$CFLAGS -qnocommon"
  150. CXXFLAGS="$CXXFLAGS -qnocommon"
  151. fi
  152. ;;
  153. *-pc-os2_emx | *-pc-os2-emx )
  154. if test "x$bk_os2_use_omf" = "xyes" ; then
  155. AR=emxomfar
  156. RANLIB=:
  157. LDFLAGS="-Zomf $LDFLAGS"
  158. CFLAGS="-Zomf $CFLAGS"
  159. CXXFLAGS="-Zomf $CXXFLAGS"
  160. OS2_LIBEXT="lib"
  161. else
  162. OS2_LIBEXT="a"
  163. fi
  164. ;;
  165. i*86-*-beos* )
  166. LDFLAGS="-L/boot/develop/lib/x86 $LDFLAGS"
  167. ;;
  168. esac
  169. ])
  170. dnl ---------------------------------------------------------------------------
  171. dnl AC_BAKEFILE_SUFFIXES
  172. dnl
  173. dnl Detects shared various suffixes for shared libraries, libraries, programs,
  174. dnl plugins etc.
  175. dnl ---------------------------------------------------------------------------
  176. AC_DEFUN([AC_BAKEFILE_SUFFIXES],
  177. [
  178. SO_SUFFIX="so"
  179. SO_SUFFIX_MODULE="so"
  180. EXEEXT=""
  181. LIBPREFIX="lib"
  182. LIBEXT=".a"
  183. DLLPREFIX="lib"
  184. DLLPREFIX_MODULE=""
  185. DLLIMP_SUFFIX=""
  186. dlldir="$libdir"
  187. case "${BAKEFILE_HOST}" in
  188. dnl PA-RISC HP systems used .sl but IA64 use ELF-64 and so use the
  189. dnl standard .so extension
  190. ia64-hp-hpux* )
  191. ;;
  192. *-hp-hpux* )
  193. SO_SUFFIX="sl"
  194. SO_SUFFIX_MODULE="sl"
  195. ;;
  196. *-*-aix* )
  197. dnl quoting from
  198. dnl http://www-1.ibm.com/servers/esdd/articles/gnu.html:
  199. dnl Both archive libraries and shared libraries on AIX have an
  200. dnl .a extension. This will explain why you can't link with an
  201. dnl .so and why it works with the name changed to .a.
  202. SO_SUFFIX="a"
  203. SO_SUFFIX_MODULE="a"
  204. ;;
  205. *-*-cygwin* )
  206. SO_SUFFIX="dll"
  207. SO_SUFFIX_MODULE="dll"
  208. DLLIMP_SUFFIX="dll.a"
  209. EXEEXT=".exe"
  210. DLLPREFIX="cyg"
  211. dlldir="$bindir"
  212. ;;
  213. *-*-mingw32* )
  214. SO_SUFFIX="dll"
  215. SO_SUFFIX_MODULE="dll"
  216. DLLIMP_SUFFIX="dll.a"
  217. EXEEXT=".exe"
  218. DLLPREFIX=""
  219. dlldir="$bindir"
  220. ;;
  221. *-pc-msdosdjgpp )
  222. EXEEXT=".exe"
  223. DLLPREFIX=""
  224. dlldir="$bindir"
  225. ;;
  226. *-pc-os2_emx | *-pc-os2-emx )
  227. SO_SUFFIX="dll"
  228. SO_SUFFIX_MODULE="dll"
  229. DLLIMP_SUFFIX=$OS2_LIBEXT
  230. EXEEXT=".exe"
  231. DLLPREFIX=""
  232. LIBPREFIX=""
  233. LIBEXT=".$OS2_LIBEXT"
  234. dlldir="$bindir"
  235. ;;
  236. *-*-darwin* )
  237. SO_SUFFIX="dylib"
  238. SO_SUFFIX_MODULE="bundle"
  239. ;;
  240. esac
  241. if test "x$DLLIMP_SUFFIX" = "x" ; then
  242. DLLIMP_SUFFIX="$SO_SUFFIX"
  243. fi
  244. AC_SUBST(SO_SUFFIX)
  245. AC_SUBST(SO_SUFFIX_MODULE)
  246. AC_SUBST(DLLIMP_SUFFIX)
  247. AC_SUBST(EXEEXT)
  248. AC_SUBST(LIBPREFIX)
  249. AC_SUBST(LIBEXT)
  250. AC_SUBST(DLLPREFIX)
  251. AC_SUBST(DLLPREFIX_MODULE)
  252. AC_SUBST(dlldir)
  253. ])
  254. dnl ---------------------------------------------------------------------------
  255. dnl AC_BAKEFILE_SHARED_LD
  256. dnl
  257. dnl Detects command for making shared libraries, substitutes SHARED_LD_CC
  258. dnl and SHARED_LD_CXX.
  259. dnl ---------------------------------------------------------------------------
  260. AC_DEFUN([AC_BAKEFILE_SHARED_LD],
  261. [
  262. dnl the extra compiler flags needed for compilation of shared library
  263. PIC_FLAG=""
  264. if test "x$GCC" = "xyes"; then
  265. dnl the switch for gcc is the same under all platforms
  266. PIC_FLAG="-fPIC"
  267. fi
  268. dnl Defaults for GCC and ELF .so shared libs:
  269. SHARED_LD_CC="\$(CC) -shared ${PIC_FLAG} -o"
  270. SHARED_LD_CXX="\$(CXX) -shared ${PIC_FLAG} -o"
  271. WINDOWS_IMPLIB=0
  272. case "${BAKEFILE_HOST}" in
  273. *-hp-hpux* )
  274. dnl default settings are good for gcc but not for the native HP-UX
  275. if test "x$GCC" != "xyes"; then
  276. dnl no idea why it wants it, but it does
  277. LDFLAGS="$LDFLAGS -L/usr/lib"
  278. SHARED_LD_CC="${CC} -b -o"
  279. SHARED_LD_CXX="${CXX} -b -o"
  280. PIC_FLAG="+Z"
  281. fi
  282. ;;
  283. *-*-linux* )
  284. dnl newer icc versions use -fPIC just as gcc does and, in fact, the
  285. dnl newest (v10+) ones don't even understand -KPIC any longer
  286. if test "$INTELCC" = "yes" -a "$INTELCC8" != "yes"; then
  287. PIC_FLAG="-KPIC"
  288. elif test "x$SUNCXX" = "xyes"; then
  289. SHARED_LD_CC="${CC} -G -o"
  290. SHARED_LD_CXX="${CXX} -G -o"
  291. PIC_FLAG="-KPIC"
  292. fi
  293. ;;
  294. *-*-solaris2* )
  295. if test "x$SUNCXX" = xyes ; then
  296. SHARED_LD_CC="${CC} -G -o"
  297. SHARED_LD_CXX="${CXX} -G -o"
  298. PIC_FLAG="-KPIC"
  299. fi
  300. ;;
  301. *-*-darwin* )
  302. AC_BAKEFILE_CREATE_FILE_SHARED_LD_SH
  303. chmod +x shared-ld-sh
  304. SHARED_LD_MODULE_CC="`pwd`/shared-ld-sh -bundle -headerpad_max_install_names -o"
  305. SHARED_LD_MODULE_CXX="CXX=\"\$(CXX)\" $SHARED_LD_MODULE_CC"
  306. dnl Most apps benefit from being fully binded (its faster and static
  307. dnl variables initialized at startup work).
  308. dnl This can be done either with the exe linker flag -Wl,-bind_at_load
  309. dnl or with a double stage link in order to create a single module
  310. dnl "-init _wxWindowsDylibInit" not useful with lazy linking solved
  311. dnl If using newer dev tools then there is a -single_module flag that
  312. dnl we can use to do this for dylibs, otherwise we'll need to use a helper
  313. dnl script. Check the version of gcc to see which way we can go:
  314. AC_CACHE_CHECK([for gcc 3.1 or later], bakefile_cv_gcc31, [
  315. AC_TRY_COMPILE([],
  316. [
  317. #if (__GNUC__ < 3) || \
  318. ((__GNUC__ == 3) && (__GNUC_MINOR__ < 1))
  319. This is old gcc
  320. #endif
  321. ],
  322. [
  323. bakefile_cv_gcc31=yes
  324. ],
  325. [
  326. bakefile_cv_gcc31=no
  327. ]
  328. )
  329. ])
  330. if test "$bakefile_cv_gcc31" = "no"; then
  331. dnl Use the shared-ld-sh helper script
  332. SHARED_LD_CC="`pwd`/shared-ld-sh -dynamiclib -headerpad_max_install_names -o"
  333. SHARED_LD_CXX="$SHARED_LD_CC"
  334. else
  335. dnl Use the -single_module flag and let the linker do it for us
  336. SHARED_LD_CC="\${CC} -dynamiclib -single_module -headerpad_max_install_names -o"
  337. SHARED_LD_CXX="\${CXX} -dynamiclib -single_module -headerpad_max_install_names -o"
  338. fi
  339. if test "x$GCC" == "xyes"; then
  340. PIC_FLAG="-dynamic -fPIC"
  341. fi
  342. if test "x$XLCC" = "xyes"; then
  343. PIC_FLAG="-dynamic -DPIC"
  344. fi
  345. ;;
  346. *-*-aix* )
  347. if test "x$GCC" = "xyes"; then
  348. dnl at least gcc 2.95 warns that -fPIC is ignored when
  349. dnl compiling each and every file under AIX which is annoying,
  350. dnl so don't use it there (it's useless as AIX runs on
  351. dnl position-independent architectures only anyhow)
  352. PIC_FLAG=""
  353. dnl -bexpfull is needed by AIX linker to export all symbols (by
  354. dnl default it doesn't export any and even with -bexpall it
  355. dnl doesn't export all C++ support symbols, e.g. vtable
  356. dnl pointers) but it's only available starting from 5.1 (with
  357. dnl maintenance pack 2, whatever this is), see
  358. dnl http://www-128.ibm.com/developerworks/eserver/articles/gnu.html
  359. case "${BAKEFILE_HOST}" in
  360. *-*-aix5* )
  361. LD_EXPFULL="-Wl,-bexpfull"
  362. ;;
  363. esac
  364. SHARED_LD_CC="\$(CC) -shared $LD_EXPFULL -o"
  365. SHARED_LD_CXX="\$(CXX) -shared $LD_EXPFULL -o"
  366. else
  367. dnl FIXME: makeC++SharedLib is obsolete, what should we do for
  368. dnl recent AIX versions?
  369. AC_CHECK_PROG(AIX_CXX_LD, makeC++SharedLib,
  370. makeC++SharedLib, /usr/lpp/xlC/bin/makeC++SharedLib)
  371. SHARED_LD_CC="$AIX_CC_LD -p 0 -o"
  372. SHARED_LD_CXX="$AIX_CXX_LD -p 0 -o"
  373. fi
  374. ;;
  375. *-*-beos* )
  376. dnl can't use gcc under BeOS for shared library creation because it
  377. dnl complains about missing 'main'
  378. SHARED_LD_CC="${LD} -nostart -o"
  379. SHARED_LD_CXX="${LD} -nostart -o"
  380. ;;
  381. *-*-irix* )
  382. dnl default settings are ok for gcc
  383. if test "x$GCC" != "xyes"; then
  384. PIC_FLAG="-KPIC"
  385. fi
  386. ;;
  387. *-*-cygwin* | *-*-mingw32* )
  388. PIC_FLAG=""
  389. SHARED_LD_CC="\$(CC) -shared -o"
  390. SHARED_LD_CXX="\$(CXX) -shared -o"
  391. WINDOWS_IMPLIB=1
  392. ;;
  393. *-pc-os2_emx | *-pc-os2-emx )
  394. SHARED_LD_CC="`pwd`/dllar.sh -libf INITINSTANCE -libf TERMINSTANCE -o"
  395. SHARED_LD_CXX="`pwd`/dllar.sh -libf INITINSTANCE -libf TERMINSTANCE -o"
  396. PIC_FLAG=""
  397. AC_BAKEFILE_CREATE_FILE_DLLAR_SH
  398. chmod +x dllar.sh
  399. ;;
  400. powerpc-apple-macos* | \
  401. *-*-freebsd* | *-*-openbsd* | *-*-netbsd* | *-*-gnu* | *-*-k*bsd*-gnu | \
  402. *-*-mirbsd* | \
  403. *-*-sunos4* | \
  404. *-*-osf* | \
  405. *-*-dgux5* | \
  406. *-*-sysv5* | \
  407. *-pc-msdosdjgpp )
  408. dnl defaults are ok
  409. ;;
  410. *)
  411. AC_MSG_ERROR(unknown system type $BAKEFILE_HOST.)
  412. esac
  413. if test "x$PIC_FLAG" != "x" ; then
  414. PIC_FLAG="$PIC_FLAG -DPIC"
  415. fi
  416. if test "x$SHARED_LD_MODULE_CC" = "x" ; then
  417. SHARED_LD_MODULE_CC="$SHARED_LD_CC"
  418. fi
  419. if test "x$SHARED_LD_MODULE_CXX" = "x" ; then
  420. SHARED_LD_MODULE_CXX="$SHARED_LD_CXX"
  421. fi
  422. AC_SUBST(SHARED_LD_CC)
  423. AC_SUBST(SHARED_LD_CXX)
  424. AC_SUBST(SHARED_LD_MODULE_CC)
  425. AC_SUBST(SHARED_LD_MODULE_CXX)
  426. AC_SUBST(PIC_FLAG)
  427. AC_SUBST(WINDOWS_IMPLIB)
  428. ])
  429. dnl ---------------------------------------------------------------------------
  430. dnl AC_BAKEFILE_SHARED_VERSIONS
  431. dnl
  432. dnl Detects linker options for attaching versions (sonames) to shared libs.
  433. dnl ---------------------------------------------------------------------------
  434. AC_DEFUN([AC_BAKEFILE_SHARED_VERSIONS],
  435. [
  436. USE_SOVERSION=0
  437. USE_SOVERLINUX=0
  438. USE_SOVERSOLARIS=0
  439. USE_SOVERCYGWIN=0
  440. USE_SOTWOSYMLINKS=0
  441. USE_MACVERSION=0
  442. SONAME_FLAG=
  443. case "${BAKEFILE_HOST}" in
  444. *-*-linux* | *-*-freebsd* | *-*-openbsd* | *-*-netbsd* | \
  445. *-*-k*bsd*-gnu | *-*-mirbsd* | *-*-gnu* )
  446. if test "x$SUNCXX" = "xyes"; then
  447. SONAME_FLAG="-h "
  448. else
  449. SONAME_FLAG="-Wl,-soname,"
  450. fi
  451. USE_SOVERSION=1
  452. USE_SOVERLINUX=1
  453. USE_SOTWOSYMLINKS=1
  454. ;;
  455. *-*-solaris2* )
  456. SONAME_FLAG="-h "
  457. USE_SOVERSION=1
  458. USE_SOVERSOLARIS=1
  459. ;;
  460. *-*-darwin* )
  461. USE_MACVERSION=1
  462. USE_SOVERSION=1
  463. USE_SOTWOSYMLINKS=1
  464. ;;
  465. *-*-cygwin* )
  466. USE_SOVERSION=1
  467. USE_SOVERCYGWIN=1
  468. ;;
  469. esac
  470. AC_SUBST(USE_SOVERSION)
  471. AC_SUBST(USE_SOVERLINUX)
  472. AC_SUBST(USE_SOVERSOLARIS)
  473. AC_SUBST(USE_SOVERCYGWIN)
  474. AC_SUBST(USE_MACVERSION)
  475. AC_SUBST(USE_SOTWOSYMLINKS)
  476. AC_SUBST(SONAME_FLAG)
  477. ])
  478. dnl ---------------------------------------------------------------------------
  479. dnl AC_BAKEFILE_DEPS
  480. dnl
  481. dnl Detects available C/C++ dependency tracking options
  482. dnl ---------------------------------------------------------------------------
  483. AC_DEFUN([AC_BAKEFILE_DEPS],
  484. [
  485. AC_ARG_ENABLE([dependency-tracking],
  486. AS_HELP_STRING([--disable-dependency-tracking],
  487. [don't use dependency tracking even if the compiler can]),
  488. [bk_use_trackdeps="$enableval"])
  489. AC_MSG_CHECKING([for dependency tracking method])
  490. BK_DEPS=""
  491. if test "x$bk_use_trackdeps" = "xno" ; then
  492. DEPS_TRACKING=0
  493. AC_MSG_RESULT([disabled])
  494. else
  495. DEPS_TRACKING=1
  496. if test "x$GCC" = "xyes"; then
  497. DEPSMODE=gcc
  498. DEPSFLAG="-MMD"
  499. AC_MSG_RESULT([gcc])
  500. elif test "x$MWCC" = "xyes"; then
  501. DEPSMODE=mwcc
  502. DEPSFLAG="-MM"
  503. AC_MSG_RESULT([mwcc])
  504. elif test "x$SUNCC" = "xyes"; then
  505. DEPSMODE=unixcc
  506. DEPSFLAG="-xM1"
  507. AC_MSG_RESULT([Sun cc])
  508. elif test "x$SGICC" = "xyes"; then
  509. DEPSMODE=unixcc
  510. DEPSFLAG="-M"
  511. AC_MSG_RESULT([SGI cc])
  512. elif test "x$HPCC" = "xyes"; then
  513. DEPSMODE=unixcc
  514. DEPSFLAG="+make"
  515. AC_MSG_RESULT([HP cc])
  516. elif test "x$COMPAQCC" = "xyes"; then
  517. DEPSMODE=gcc
  518. DEPSFLAG="-MD"
  519. AC_MSG_RESULT([Compaq cc])
  520. else
  521. DEPS_TRACKING=0
  522. AC_MSG_RESULT([none])
  523. fi
  524. if test $DEPS_TRACKING = 1 ; then
  525. AC_BAKEFILE_CREATE_FILE_BK_DEPS
  526. chmod +x bk-deps
  527. dnl FIXME: make this $(top_builddir)/bk-deps once autoconf-2.60
  528. dnl is required (and so top_builddir is never empty):
  529. BK_DEPS="`pwd`/bk-deps"
  530. fi
  531. fi
  532. AC_SUBST(DEPS_TRACKING)
  533. AC_SUBST(BK_DEPS)
  534. ])
  535. dnl ---------------------------------------------------------------------------
  536. dnl AC_BAKEFILE_CHECK_BASIC_STUFF
  537. dnl
  538. dnl Checks for presence of basic programs, such as C and C++ compiler, "ranlib"
  539. dnl or "install"
  540. dnl ---------------------------------------------------------------------------
  541. AC_DEFUN([AC_BAKEFILE_CHECK_BASIC_STUFF],
  542. [
  543. AC_PROG_RANLIB
  544. AC_PROG_INSTALL
  545. AC_PROG_LN_S
  546. AC_PROG_MAKE_SET
  547. AC_SUBST(MAKE_SET)
  548. if test "x$SUNCXX" = "xyes"; then
  549. dnl Sun C++ compiler requires special way of creating static libs;
  550. dnl see here for more details:
  551. dnl https://sourceforge.net/tracker/?func=detail&atid=109863&aid=1229751&group_id=9863
  552. AR=$CXX
  553. AROPTIONS="-xar -o"
  554. AC_SUBST(AR)
  555. elif test "x$SGICC" = "xyes"; then
  556. dnl Almost the same as above for SGI mipsPro compiler
  557. AR=$CXX
  558. AROPTIONS="-ar -o"
  559. AC_SUBST(AR)
  560. else
  561. AC_CHECK_TOOL(AR, ar, ar)
  562. AROPTIONS=rcu
  563. fi
  564. AC_SUBST(AROPTIONS)
  565. AC_CHECK_TOOL(STRIP, strip, :)
  566. AC_CHECK_TOOL(NM, nm, :)
  567. dnl Don't use `install -d`, see http://trac.wxwidgets.org/ticket/13452
  568. INSTALL_DIR="mkdir -p"
  569. AC_SUBST(INSTALL_DIR)
  570. LDFLAGS_GUI=
  571. case ${BAKEFILE_HOST} in
  572. *-*-cygwin* | *-*-mingw32* )
  573. LDFLAGS_GUI="-mwindows"
  574. esac
  575. AC_SUBST(LDFLAGS_GUI)
  576. ])
  577. dnl ---------------------------------------------------------------------------
  578. dnl AC_BAKEFILE_RES_COMPILERS
  579. dnl
  580. dnl Checks for presence of resource compilers for win32 or mac
  581. dnl ---------------------------------------------------------------------------
  582. AC_DEFUN([AC_BAKEFILE_RES_COMPILERS],
  583. [
  584. case ${BAKEFILE_HOST} in
  585. *-*-cygwin* | *-*-mingw32* )
  586. dnl Check for win32 resources compiler:
  587. AC_CHECK_TOOL(WINDRES, windres)
  588. ;;
  589. *-*-darwin* | powerpc-apple-macos* )
  590. AC_CHECK_PROG(REZ, Rez, Rez, /Developer/Tools/Rez)
  591. AC_CHECK_PROG(SETFILE, SetFile, SetFile, /Developer/Tools/SetFile)
  592. ;;
  593. esac
  594. AC_SUBST(WINDRES)
  595. AC_SUBST(REZ)
  596. AC_SUBST(SETFILE)
  597. ])
  598. dnl ---------------------------------------------------------------------------
  599. dnl AC_BAKEFILE_PRECOMP_HEADERS
  600. dnl
  601. dnl Check for precompiled headers support (GCC >= 3.4)
  602. dnl ---------------------------------------------------------------------------
  603. AC_DEFUN([AC_BAKEFILE_PRECOMP_HEADERS],
  604. [
  605. AC_ARG_ENABLE([precomp-headers],
  606. AS_HELP_STRING([--disable-precomp-headers],
  607. [don't use precompiled headers even if compiler can]),
  608. [bk_use_pch="$enableval"])
  609. GCC_PCH=0
  610. ICC_PCH=0
  611. USE_PCH=0
  612. BK_MAKE_PCH=""
  613. case ${BAKEFILE_HOST} in
  614. *-*-cygwin* )
  615. dnl PCH support is broken in cygwin gcc because of unportable
  616. dnl assumptions about mmap() in gcc code which make PCH generation
  617. dnl fail erratically; disable PCH completely until this is fixed
  618. bk_use_pch="no"
  619. ;;
  620. esac
  621. if test "x$bk_use_pch" = "x" -o "x$bk_use_pch" = "xyes" ; then
  622. if test "x$GCC" = "xyes"; then
  623. dnl test if we have gcc-3.4:
  624. AC_MSG_CHECKING([if the compiler supports precompiled headers])
  625. AC_TRY_COMPILE([],
  626. [
  627. #if !defined(__GNUC__) || !defined(__GNUC_MINOR__)
  628. There is no PCH support
  629. #endif
  630. #if (__GNUC__ < 3)
  631. There is no PCH support
  632. #endif
  633. #if (__GNUC__ == 3) && \
  634. ((!defined(__APPLE_CC__) && (__GNUC_MINOR__ < 4)) || \
  635. ( defined(__APPLE_CC__) && (__GNUC_MINOR__ < 3))) || \
  636. ( defined(__INTEL_COMPILER) )
  637. There is no PCH support
  638. #endif
  639. ],
  640. [
  641. AC_MSG_RESULT([yes])
  642. GCC_PCH=1
  643. ],
  644. [
  645. if test "$INTELCXX8" = "yes"; then
  646. AC_MSG_RESULT([yes])
  647. ICC_PCH=1
  648. if test "$INTELCXX10" = "yes"; then
  649. ICC_PCH_CREATE_SWITCH="-pch-create"
  650. ICC_PCH_USE_SWITCH="-pch-use"
  651. else
  652. ICC_PCH_CREATE_SWITCH="-create-pch"
  653. ICC_PCH_USE_SWITCH="-use-pch"
  654. fi
  655. else
  656. AC_MSG_RESULT([no])
  657. fi
  658. ])
  659. if test $GCC_PCH = 1 -o $ICC_PCH = 1 ; then
  660. USE_PCH=1
  661. AC_BAKEFILE_CREATE_FILE_BK_MAKE_PCH
  662. chmod +x bk-make-pch
  663. dnl FIXME: make this $(top_builddir)/bk-make-pch once
  664. dnl autoconf-2.60 is required (and so top_builddir is
  665. dnl never empty):
  666. BK_MAKE_PCH="`pwd`/bk-make-pch"
  667. fi
  668. fi
  669. fi
  670. AC_SUBST(GCC_PCH)
  671. AC_SUBST(ICC_PCH)
  672. AC_SUBST(ICC_PCH_CREATE_SWITCH)
  673. AC_SUBST(ICC_PCH_USE_SWITCH)
  674. AC_SUBST(BK_MAKE_PCH)
  675. ])
  676. dnl ---------------------------------------------------------------------------
  677. dnl AC_BAKEFILE([autoconf_inc.m4 inclusion])
  678. dnl
  679. dnl To be used in configure.in of any project using Bakefile-generated mks
  680. dnl
  681. dnl Behaviour can be modified by setting following variables:
  682. dnl BAKEFILE_CHECK_BASICS set to "no" if you don't want bakefile to
  683. dnl to perform check for basic tools like ranlib
  684. dnl BAKEFILE_HOST set this to override host detection, defaults
  685. dnl to ${host}
  686. dnl BAKEFILE_FORCE_PLATFORM set to override platform detection
  687. dnl
  688. dnl Example usage:
  689. dnl
  690. dnl AC_BAKEFILE([FOO(autoconf_inc.m4)])
  691. dnl
  692. dnl (replace FOO with m4_include above, aclocal would die otherwise)
  693. dnl (yes, it's ugly, but thanks to a bug in aclocal, it's the only thing
  694. dnl we can do...)
  695. dnl ---------------------------------------------------------------------------
  696. AC_DEFUN([AC_BAKEFILE],
  697. [
  698. AC_PREREQ([2.58])
  699. dnl We need to always run C/C++ compiler tests, but it's also possible
  700. dnl for the user to call these macros manually, hence this instead of
  701. dnl simply calling these macros. See http://www.bakefile.org/ticket/64
  702. AC_REQUIRE([AC_BAKEFILE_PROG_CC])
  703. AC_REQUIRE([AC_BAKEFILE_PROG_CXX])
  704. if test "x$BAKEFILE_HOST" = "x"; then
  705. if test "x${host}" = "x" ; then
  706. AC_MSG_ERROR([You must call the autoconf "CANONICAL_HOST" macro in your configure.ac (or .in) file.])
  707. fi
  708. BAKEFILE_HOST="${host}"
  709. fi
  710. if test "x$BAKEFILE_CHECK_BASICS" != "xno"; then
  711. AC_BAKEFILE_CHECK_BASIC_STUFF
  712. fi
  713. AC_BAKEFILE_GNUMAKE
  714. AC_BAKEFILE_PLATFORM
  715. AC_BAKEFILE_PLATFORM_SPECIFICS
  716. AC_BAKEFILE_SUFFIXES
  717. AC_BAKEFILE_SHARED_LD
  718. AC_BAKEFILE_SHARED_VERSIONS
  719. AC_BAKEFILE_DEPS
  720. AC_BAKEFILE_RES_COMPILERS
  721. dnl OBJCFLAGS is set by Autoconf, but OBJCXXFLAGS is not:
  722. AC_SUBST(OBJCXXFLAGS)
  723. BAKEFILE_BAKEFILE_M4_VERSION="0.2.9"
  724. dnl includes autoconf_inc.m4:
  725. $1
  726. if test "$BAKEFILE_AUTOCONF_INC_M4_VERSION" = "" ; then
  727. AC_MSG_ERROR([No version found in autoconf_inc.m4 - bakefile macro was changed to take additional argument, perhaps configure.in wasn't updated (see the documentation)?])
  728. fi
  729. if test "$BAKEFILE_BAKEFILE_M4_VERSION" != "$BAKEFILE_AUTOCONF_INC_M4_VERSION" ; then
  730. AC_MSG_ERROR([Versions of Bakefile used to generate makefiles ($BAKEFILE_AUTOCONF_INC_M4_VERSION) and configure ($BAKEFILE_BAKEFILE_M4_VERSION) do not match.])
  731. fi
  732. ])
  733. dnl ---------------------------------------------------------------------------
  734. dnl Embedded copies of helper scripts follow:
  735. dnl ---------------------------------------------------------------------------
  736. AC_DEFUN([AC_BAKEFILE_CREATE_FILE_BK_DEPS],
  737. [
  738. dnl ===================== bk-deps begins here =====================
  739. dnl (Created by merge-scripts.py from bk-deps
  740. dnl file do not edit here!)
  741. D='$'
  742. cat <<EOF >bk-deps
  743. #!/bin/sh
  744. # This script is part of Bakefile (http://www.bakefile.org) autoconf
  745. # script. It is used to track C/C++ files dependencies in portable way.
  746. #
  747. # Permission is given to use this file in any way.
  748. DEPSMODE=${DEPSMODE}
  749. DEPSFLAG="${DEPSFLAG}"
  750. DEPSDIRBASE=.deps
  751. if test ${D}DEPSMODE = gcc ; then
  752. ${D}* ${D}{DEPSFLAG}
  753. status=${D}?
  754. # determine location of created files:
  755. while test ${D}# -gt 0; do
  756. case "${D}1" in
  757. -o )
  758. shift
  759. objfile=${D}1
  760. ;;
  761. -* )
  762. ;;
  763. * )
  764. srcfile=${D}1
  765. ;;
  766. esac
  767. shift
  768. done
  769. objfilebase=\`basename ${D}objfile\`
  770. builddir=\`dirname ${D}objfile\`
  771. depfile=\`basename ${D}srcfile | sed -e 's/\\..*${D}/.d/g'\`
  772. depobjname=\`echo ${D}depfile |sed -e 's/\\.d/.o/g'\`
  773. depsdir=${D}builddir/${D}DEPSDIRBASE
  774. mkdir -p ${D}depsdir
  775. # if the compiler failed, we're done:
  776. if test ${D}{status} != 0 ; then
  777. rm -f ${D}depfile
  778. exit ${D}{status}
  779. fi
  780. # move created file to the location we want it in:
  781. if test -f ${D}depfile ; then
  782. sed -e "s,${D}depobjname:,${D}objfile:,g" ${D}depfile >${D}{depsdir}/${D}{objfilebase}.d
  783. rm -f ${D}depfile
  784. else
  785. # "g++ -MMD -o fooobj.o foosrc.cpp" produces fooobj.d
  786. depfile=\`echo "${D}objfile" | sed -e 's/\\..*${D}/.d/g'\`
  787. if test ! -f ${D}depfile ; then
  788. # "cxx -MD -o fooobj.o foosrc.cpp" creates fooobj.o.d (Compaq C++)
  789. depfile="${D}objfile.d"
  790. fi
  791. if test -f ${D}depfile ; then
  792. sed -e "\\,^${D}objfile,!s,${D}depobjname:,${D}objfile:,g" ${D}depfile >${D}{depsdir}/${D}{objfilebase}.d
  793. rm -f ${D}depfile
  794. fi
  795. fi
  796. exit 0
  797. elif test ${D}DEPSMODE = mwcc ; then
  798. ${D}* || exit ${D}?
  799. # Run mwcc again with -MM and redirect into the dep file we want
  800. # NOTE: We can't use shift here because we need ${D}* to be valid
  801. prevarg=
  802. for arg in ${D}* ; do
  803. if test "${D}prevarg" = "-o"; then
  804. objfile=${D}arg
  805. else
  806. case "${D}arg" in
  807. -* )
  808. ;;
  809. * )
  810. srcfile=${D}arg
  811. ;;
  812. esac
  813. fi
  814. prevarg="${D}arg"
  815. done
  816. objfilebase=\`basename ${D}objfile\`
  817. builddir=\`dirname ${D}objfile\`
  818. depsdir=${D}builddir/${D}DEPSDIRBASE
  819. mkdir -p ${D}depsdir
  820. ${D}* ${D}DEPSFLAG >${D}{depsdir}/${D}{objfilebase}.d
  821. exit 0
  822. elif test ${D}DEPSMODE = unixcc; then
  823. ${D}* || exit ${D}?
  824. # Run compiler again with deps flag and redirect into the dep file.
  825. # It doesn't work if the '-o FILE' option is used, but without it the
  826. # dependency file will contain the wrong name for the object. So it is
  827. # removed from the command line, and the dep file is fixed with sed.
  828. cmd=""
  829. while test ${D}# -gt 0; do
  830. case "${D}1" in
  831. -o )
  832. shift
  833. objfile=${D}1
  834. ;;
  835. * )
  836. eval arg${D}#=\\${D}1
  837. cmd="${D}cmd \\${D}arg${D}#"
  838. ;;
  839. esac
  840. shift
  841. done
  842. objfilebase=\`basename ${D}objfile\`
  843. builddir=\`dirname ${D}objfile\`
  844. depsdir=${D}builddir/${D}DEPSDIRBASE
  845. mkdir -p ${D}depsdir
  846. eval "${D}cmd ${D}DEPSFLAG" | sed "s|.*:|${D}objfile:|" >${D}{depsdir}/${D}{objfilebase}.d
  847. exit 0
  848. else
  849. ${D}*
  850. exit ${D}?
  851. fi
  852. EOF
  853. dnl ===================== bk-deps ends here =====================
  854. ])
  855. AC_DEFUN([AC_BAKEFILE_CREATE_FILE_SHARED_LD_SH],
  856. [
  857. dnl ===================== shared-ld-sh begins here =====================
  858. dnl (Created by merge-scripts.py from shared-ld-sh
  859. dnl file do not edit here!)
  860. D='$'
  861. cat <<EOF >shared-ld-sh
  862. #!/bin/sh
  863. #-----------------------------------------------------------------------------
  864. #-- Name: distrib/mac/shared-ld-sh
  865. #-- Purpose: Link a mach-o dynamic shared library for Darwin / Mac OS X
  866. #-- Author: Gilles Depeyrot
  867. #-- Copyright: (c) 2002 Gilles Depeyrot
  868. #-- Licence: any use permitted
  869. #-----------------------------------------------------------------------------
  870. verbose=0
  871. args=""
  872. objects=""
  873. linking_flag="-dynamiclib"
  874. ldargs="-r -keep_private_externs -nostdlib"
  875. if test "x${D}CXX" = "x"; then
  876. CXX="c++"
  877. fi
  878. while test ${D}# -gt 0; do
  879. case ${D}1 in
  880. -v)
  881. verbose=1
  882. ;;
  883. -o|-compatibility_version|-current_version|-framework|-undefined|-install_name)
  884. # collect these options and values
  885. args="${D}{args} ${D}1 ${D}2"
  886. shift
  887. ;;
  888. -arch|-isysroot)
  889. # collect these options and values
  890. ldargs="${D}{ldargs} ${D}1 ${D}2"
  891. shift
  892. ;;
  893. -s|-Wl,*)
  894. # collect these load args
  895. ldargs="${D}{ldargs} ${D}1"
  896. ;;
  897. -l*|-L*|-flat_namespace|-headerpad_max_install_names)
  898. # collect these options
  899. args="${D}{args} ${D}1"
  900. ;;
  901. -dynamiclib|-bundle)
  902. linking_flag="${D}1"
  903. ;;
  904. -*)
  905. echo "shared-ld: unhandled option '${D}1'"
  906. exit 1
  907. ;;
  908. *.o | *.a | *.dylib)
  909. # collect object files
  910. objects="${D}{objects} ${D}1"
  911. ;;
  912. *)
  913. echo "shared-ld: unhandled argument '${D}1'"
  914. exit 1
  915. ;;
  916. esac
  917. shift
  918. done
  919. status=0
  920. #
  921. # Link one module containing all the others
  922. #
  923. if test ${D}{verbose} = 1; then
  924. echo "${D}CXX ${D}{ldargs} ${D}{objects} -o master.${D}${D}.o"
  925. fi
  926. ${D}CXX ${D}{ldargs} ${D}{objects} -o master.${D}${D}.o
  927. status=${D}?
  928. #
  929. # Link the shared library from the single module created, but only if the
  930. # previous command didn't fail:
  931. #
  932. if test ${D}{status} = 0; then
  933. if test ${D}{verbose} = 1; then
  934. echo "${D}CXX ${D}{linking_flag} master.${D}${D}.o ${D}{args}"
  935. fi
  936. ${D}CXX ${D}{linking_flag} master.${D}${D}.o ${D}{args}
  937. status=${D}?
  938. fi
  939. #
  940. # Remove intermediate module
  941. #
  942. rm -f master.${D}${D}.o
  943. exit ${D}status
  944. EOF
  945. dnl ===================== shared-ld-sh ends here =====================
  946. ])
  947. AC_DEFUN([AC_BAKEFILE_CREATE_FILE_BK_MAKE_PCH],
  948. [
  949. dnl ===================== bk-make-pch begins here =====================
  950. dnl (Created by merge-scripts.py from bk-make-pch
  951. dnl file do not edit here!)
  952. D='$'
  953. cat <<EOF >bk-make-pch
  954. #!/bin/sh
  955. # This script is part of Bakefile (http://www.bakefile.org) autoconf
  956. # script. It is used to generated precompiled headers.
  957. #
  958. # Permission is given to use this file in any way.
  959. outfile="${D}{1}"
  960. header="${D}{2}"
  961. shift
  962. shift
  963. builddir=\`echo ${D}outfile | sed -e 's,/\\.pch/.*${D},,g'\`
  964. compiler=""
  965. headerfile=""
  966. while test ${D}{#} -gt 0; do
  967. add_to_cmdline=1
  968. case "${D}{1}" in
  969. -I* )
  970. incdir=\`echo ${D}{1} | sed -e 's/-I\\(.*\\)/\\1/g'\`
  971. if test "x${D}{headerfile}" = "x" -a -f "${D}{incdir}/${D}{header}" ; then
  972. headerfile="${D}{incdir}/${D}{header}"
  973. fi
  974. ;;
  975. -use-pch|-use_pch|-pch-use )
  976. shift
  977. add_to_cmdline=0
  978. ;;
  979. esac
  980. if test ${D}add_to_cmdline = 1 ; then
  981. compiler="${D}{compiler} ${D}{1}"
  982. fi
  983. shift
  984. done
  985. if test "x${D}{headerfile}" = "x" ; then
  986. echo "error: can't find header ${D}{header} in include paths" >&2
  987. else
  988. if test -f ${D}{outfile} ; then
  989. rm -f ${D}{outfile}
  990. else
  991. mkdir -p \`dirname ${D}{outfile}\`
  992. fi
  993. depsfile="${D}{builddir}/.deps/\`echo ${D}{outfile} | tr '/.' '__'\`.d"
  994. mkdir -p ${D}{builddir}/.deps
  995. if test "x${GCC_PCH}" = "x1" ; then
  996. # can do this because gcc is >= 3.4:
  997. ${D}{compiler} -o ${D}{outfile} -MMD -MF "${D}{depsfile}" "${D}{headerfile}"
  998. elif test "x${ICC_PCH}" = "x1" ; then
  999. filename=pch_gen-${D}${D}
  1000. file=${D}{filename}.c
  1001. dfile=${D}{filename}.d
  1002. cat > ${D}file <<EOT
  1003. #include "${D}header"
  1004. EOT
  1005. # using -MF icc complains about differing command lines in creation/use
  1006. ${D}compiler -c ${ICC_PCH_CREATE_SWITCH} ${D}outfile -MMD ${D}file && \\
  1007. sed -e "s,^.*:,${D}outfile:," -e "s, ${D}file,," < ${D}dfile > ${D}depsfile && \\
  1008. rm -f ${D}file ${D}dfile ${D}{filename}.o
  1009. fi
  1010. exit ${D}{?}
  1011. fi
  1012. EOF
  1013. dnl ===================== bk-make-pch ends here =====================
  1014. ])