configure.in.sample 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622
  1. # This is a sample configure.in for CMake
  2. # To use CMake, you must put the CMake directory and
  3. # all of its source into the top level of your source tree.
  4. # You need to have the configure script in .. from CMake.
  5. # Process this file with autoconf to produce a configure script.
  6. AC_INIT()
  7. AC_CONFIG_HEADER(itkConfigure.h)
  8. CMAKE_CONFIG_DIR=`pwd`
  9. AC_SUBST(CMAKE_CONFIG_DIR)
  10. #
  11. # check for some programs we use
  12. #
  13. AC_PROG_CC
  14. AC_PROG_CXX
  15. AC_PROG_RANLIB
  16. AC_PROG_INSTALL
  17. AC_PATH_XTRA
  18. # get byte swapping info
  19. AC_C_BIGENDIAN
  20. if test $ac_cv_c_bigendian = yes; then
  21. AC_DEFINE(CMAKE_WORDS_BIGENDIAN)
  22. fi
  23. # some stuff Tcl uses
  24. #
  25. AC_CHECK_HEADER(limits.h, HAVE_LIMITS_H=-DHAVE_LIMITS_H,HAVE_LIMITS_H="")
  26. AC_SUBST(HAVE_LIMITS_H)
  27. AC_HAVE_HEADERS(unistd.h, HAVE_UNISTD_H=-DHAVE_UNISTD_H,HAVE_UNISTD_H="")
  28. AC_SUBST(HAVE_UNISTD_H)
  29. # Step 1: set the variable "system" to hold the name and version number
  30. # for the system. This can usually be done via the "uname" command, but
  31. # there are a few systems, like Next, where this doesn't work.
  32. AC_MSG_CHECKING([system version (for dynamic loading)])
  33. if test -f /usr/lib/NextStep/software_version; then
  34. system=NEXTSTEP-`awk '/3/,/3/' /usr/lib/NextStep/software_version`
  35. else
  36. system=`uname -s`-`uname -r`
  37. if test "$?" -ne 0 ; then
  38. AC_MSG_RESULT([unknown (can't find uname command)])
  39. system=unknown
  40. else
  41. # Special check for weird MP-RAS system (uname returns weird
  42. # results, and the version is kept in special file).
  43. if test -r /etc/.relid -a "X`uname -n`" = "X`uname -s`" ; then
  44. system=MP-RAS-`awk '{print $3}' /etc/.relid'`
  45. fi
  46. AC_MSG_RESULT($system)
  47. fi
  48. fi
  49. #
  50. # use shared libs
  51. #
  52. AC_ARG_WITH(shared,
  53. [ --with-shared create shared libraries],
  54. [CMAKE_shared_ok=$withval], [CMAKE_shared_ok=no])
  55. INSTALL_TARGET="install"
  56. AC_SUBST(INSTALL_TARGET)
  57. BUILD_TOOLKITS=""
  58. CLEAN_TOOLKITS=""
  59. DEPEND_TOOLKITS=""
  60. INSTALL_TOOLKITS=""
  61. # --with-kits goes here
  62. AC_SUBST(BUILD_TOOLKITS)
  63. AC_SUBST(INSTALL_TOOLKITS)
  64. AC_SUBST(DEPEND_TOOLKITS)
  65. AC_SUBST(CLEAN_TOOLKITS)
  66. # option for handling BSD style makefile includes
  67. #
  68. AC_ARG_WITH(bsdmake,
  69. [ --with-bsdmake uses bsd style makefile includes],
  70. if test "$withval" = yes; then
  71. MAKEINCLUDE=".include"
  72. MAKEQUOTE='"'
  73. fi,
  74. MAKEINCLUDE="include"
  75. MAKEQUOTE='')
  76. AC_SUBST(MAKEINCLUDE)
  77. AC_SUBST(MAKEQUOTE)
  78. # the following is an excerpt from the tcl7.5b2 configure.in
  79. #--------------------------------------------------------------------
  80. # The statements below define a collection of symbols related to
  81. # dynamic loading and shared libraries:
  82. #
  83. # SHLIB_CFLAGS - Flags to pass to cc when compiling the components
  84. # of a shared library (may request position-independent
  85. # code, among other things).
  86. # SHLIB_LD_LIBS - Dependent libraries for the linker to scan when
  87. # creating shared libraries. This symbol typically
  88. # goes at the end of the "ld" commands that build
  89. # shared libraries. The value of the symbol if
  90. # "${LIBS}" if all of the dependent libraries should
  91. # be specified when creating a shared library. If
  92. # dependent libraries should not be specified (as on
  93. # SunOS 4.x, where they cause the link to fail, or in
  94. # general if Tcl and Tk aren't themselves shared
  95. # libraries), then this symbol has an empty string
  96. # as its value.
  97. # SHLIB_SUFFIX - Suffix to use for the name of the shared library. An
  98. # empty string means we don't know how to use shared
  99. # libraries on this platform.
  100. # CMAKE_SHLIB_BUILD_FLAGS -
  101. # Flags to use when building a shared library.
  102. # CMAKE_SHLIB_LINK_FLAGS -
  103. # Flags to pass to the compiler when linking object
  104. # files into an executable application binary such
  105. # as tclsh.
  106. #--------------------------------------------------------------------
  107. # Step 2: check for existence of -ldl library. This is needed because
  108. # Linux can use either -ldl or -ldld for dynamic loading.
  109. AC_CHECK_LIB(dl, dlopen, have_dl=yes, have_dl=no)
  110. # Step 4: set configuration options based on system name and version.
  111. fullSrcDir=`cd $srcdir; pwd`
  112. AC_SUBST(fullSrcDir)
  113. case $system in
  114. AIX-*)
  115. # AIX: can't link shared library extensions unless Tcl and Tk are
  116. # also shared libraries.
  117. SHLIB_CFLAGS=""
  118. SHLIB_LD_LIBS='${LIBS}'
  119. SHLIB_SUFFIX="..o"
  120. DL_LIBS=""
  121. AC_CHECK_LIB(ld,printf, DL_LIBS="-lld")
  122. CMAKE_SHLIB_LINK_FLAGS=""
  123. ;;
  124. HP-UX-*.08.*|HP-UX-*.09.*|HP-UX-*.10.*)
  125. SHLIB_CFLAGS="+z"
  126. SHLIB_LD_LIBS=""
  127. SHLIB_SUFFIX=".sl"
  128. DL_LIBS="-ldld"
  129. CMAKE_SHLIB_BUILD_FLAGS='+Z -Wl,-E -Wl,-b'
  130. CMAKE_SHLIB_LINK_FLAGS='-Wl,+s -Wl,+b,${LIB_RUNTIME_DIR}'
  131. if test "$CC" = "gcc" -o `$CC -v 2>&1 | grep -c gcc` != "0" ; then
  132. CMAKE_SHLIB_BUILD_FLAGS='-shared -Wl,-E -Wl,-b'
  133. CMAKE_SHLIB_LINK_FLAGS='-Wl,+s -Wl,+b,${LIB_RUNTIME_DIR}'
  134. fi
  135. ;;
  136. IRIX-5.*)
  137. SHLIB_CFLAGS=""
  138. SHLIB_LD_LIBS=""
  139. SHLIB_SUFFIX=".so"
  140. DL_LIBS=""
  141. CMAKE_SHLIB_BUILD_FLAGS="-shared -rdata_shared"
  142. ;;
  143. IRIX-6* | IRIX64-6* | IRIX-64-6*)
  144. SHLIB_CFLAGS=""
  145. SHLIB_LD_LIBS=""
  146. SHLIB_SUFFIX=".so"
  147. DL_LIBS=""
  148. CMAKE_SHLIB_BUILD_FLAGS="-shared -rdata_shared"
  149. ;;
  150. Linux*)
  151. SHLIB_CFLAGS="-fPIC"
  152. SHLIB_LD_LIBS=""
  153. SHLIB_SUFFIX=".so"
  154. CMAKE_SHLIB_BUILD_FLAGS="-shared"
  155. if test "$have_dl" = yes; then
  156. DL_LIBS="-ldl"
  157. CMAKE_SHLIB_LINK_FLAGS="-rdynamic"
  158. else
  159. AC_CHECK_HEADER(dld.h, [
  160. DL_LIBS="-ldld"
  161. CMAKE_SHLIB_LINK_FLAGS=""])
  162. fi
  163. ;;
  164. CYGWIN_NT*)
  165. DL_LIBS="-lgdi32"
  166. ;;
  167. MP-RAS-02*)
  168. SHLIB_CFLAGS="-K PIC"
  169. SHLIB_LD_LIBS=""
  170. SHLIB_SUFFIX=".so"
  171. DL_LIBS="-ldl"
  172. CMAKE_SHLIB_LINK_FLAGS=""
  173. ;;
  174. MP-RAS-*)
  175. SHLIB_CFLAGS="-K PIC"
  176. SHLIB_LD_LIBS=""
  177. SHLIB_SUFFIX=".so"
  178. DL_LIBS="-ldl"
  179. CMAKE_SHLIB_LINK_FLAGS="-Wl,-Bexport"
  180. ;;
  181. NetBSD-*|FreeBSD-*)
  182. # Not available on all versions: check for include file.
  183. if test -f /usr/include/dlfcn.h; then
  184. SHLIB_CFLAGS="-fpic"
  185. SHLIB_LD_LIBS=""
  186. SHLIB_SUFFIX=".so"
  187. DL_LIBS=""
  188. CMAKE_SHLIB_LINK_FLAGS="-shared"
  189. else
  190. SHLIB_CFLAGS=""
  191. SHLIB_LD_LIBS=""
  192. SHLIB_SUFFIX="..o"
  193. DL_LIBS=""
  194. CMAKE_SHLIB_LINK_FLAGS=""
  195. fi
  196. ;;
  197. NEXTSTEP-*)
  198. SHLIB_CFLAGS=""
  199. SHLIB_LD_LIBS=""
  200. SHLIB_SUFFIX=".so"
  201. DL_LIBS=""
  202. CMAKE_SHLIB_LINK_FLAGS=""
  203. ;;
  204. OSF1-1.[012])
  205. # OSF/1 1.[012] from OSF, and derivatives, including Paragon OSF/1
  206. SHLIB_CFLAGS=""
  207. # Hack: make package name same as library name
  208. SHLIB_LD_LIBS=""
  209. SHLIB_SUFFIX=".so"
  210. DL_LIBS=""
  211. CMAKE_SHLIB_LINK_FLAGS=""
  212. ;;
  213. OSF1-1.*)
  214. # OSF/1 1.3 from OSF using ELF, and derivatives, including AD2
  215. SHLIB_CFLAGS="-fpic"
  216. SHLIB_LD_LIBS=""
  217. SHLIB_SUFFIX=".so"
  218. DL_LIBS=""
  219. CMAKE_SHLIB_LINK_FLAGS=""
  220. ;;
  221. OSF1-V*)
  222. # Digital OSF/1
  223. SHLIB_CFLAGS=""
  224. SHLIB_LD_LIBS=""
  225. SHLIB_SUFFIX=".so"
  226. DL_LIBS=""
  227. CMAKE_SHLIB_BUILD_FLAGS='-shared -Wl,-expect_unresolved,"*"'
  228. CMAKE_SHLIB_LINK_FLAGS='-Wl,-rpath,${LIB_RUNTIME_DIR}'
  229. ;;
  230. RISCos-*)
  231. SHLIB_CFLAGS="-G 0"
  232. SHLIB_LD_LIBS=""
  233. SHLIB_SUFFIX="..o"
  234. DL_LIBS=""
  235. CMAKE_SHLIB_LINK_FLAGS="-Wl,-D,08000000"
  236. ;;
  237. SCO_SV-3.2*)
  238. # Note, dlopen is available only on SCO 3.2.5 and greater. However,
  239. # this test works, since "uname -s" was non-standard in 3.2.4 and
  240. # below.
  241. SHLIB_CFLAGS="-Kpic -belf"
  242. SHLIB_LD_LIBS=""
  243. SHLIB_SUFFIX=".so"
  244. DL_LIBS=""
  245. CMAKE_SHLIB_LINK_FLAGS="-belf -Wl,-Bexport"
  246. ;;
  247. SINIX*5.4*)
  248. SHLIB_CFLAGS="-K PIC"
  249. SHLIB_LD_LIBS=""
  250. SHLIB_SUFFIX=".so"
  251. DL_LIBS="-ldl"
  252. CMAKE_SHLIB_LINK_FLAGS=""
  253. ;;
  254. SunOS-4*)
  255. SHLIB_CFLAGS="-PIC"
  256. SHLIB_LD_LIBS=""
  257. SHLIB_SUFFIX=".so"
  258. DL_LIBS="-ldl"
  259. CMAKE_SHLIB_BUILD_FLAGS='-shared -Wl,-r -nostdlib'
  260. CMAKE_SHLIB_LINK_FLAGS='-Wl,-L${LIB_RUNTIME_DIR}'
  261. ;;
  262. SunOS-5*)
  263. SHLIB_CFLAGS="-KPIC"
  264. SHLIB_LD_LIBS='${LIBS}'
  265. SHLIB_SUFFIX=".so"
  266. DL_LIBS="-ldl"
  267. CMAKE_SHLIB_BUILD_FLAGS='-G'
  268. CMAKE_SHLIB_LINK_FLAGS='-R ${LIB_RUNTIME_DIR}'
  269. if test "$CC" = "gcc" -o `$CC -v 2>&1 | grep -c gcc` != "0" ; then
  270. CMAKE_SHLIB_BUILD_FLAGS='-Wl,-G'
  271. CMAKE_SHLIB_LINK_FLAGS='-Wl,-R,${LIB_RUNTIME_DIR}'
  272. fi
  273. ;;
  274. ULTRIX-4.*)
  275. SHLIB_CFLAGS="-G 0"
  276. SHLIB_SUFFIX="..o"
  277. SHLIB_LD_LIBS=""
  278. DL_LIBS=""
  279. CMAKE_SHLIB_LINK_FLAGS="-Wl,-D,08000000"
  280. ;;
  281. UNIX_SV*)
  282. SHLIB_CFLAGS="-K PIC"
  283. SHLIB_LD_LIBS=""
  284. SHLIB_SUFFIX=".so"
  285. DL_LIBS="-ldl"
  286. CMAKE_SHLIB_LINK_FLAGS="-Wl,-Bexport"
  287. ;;
  288. esac
  289. export SHLIB_SUFFIX
  290. # If we're running gcc, then change the C flags for compiling shared
  291. # libraries to the right flags for gcc, instead of those for the
  292. # standard manufacturer compiler.
  293. if test "$CC" = "gcc" -o `$CC -v 2>&1 | grep -c gcc` != "0" ; then
  294. SHLIB_CFLAGS="-fPIC"
  295. fi
  296. if test "$CMAKE_shared_ok" = "yes"; then
  297. CMAKE_SHLIB_CFLAGS="${SHLIB_CFLAGS}"
  298. CMAKE_LD_SEARCH_FLAGS="${LD_SEARCH_FLAGS}"
  299. CMAKE_TCL_SHLIB_TARGET="CMAKEtcl"
  300. RANLIB=":"
  301. TOOLKIT_DEPENDS=""
  302. CMAKE_LIB_EXT="${SHLIB_SUFFIX}"
  303. else
  304. CMAKE_LIB_EXT=".a"
  305. SHLIB_LD_LIBS=""
  306. CMAKE_SHLIB_CFLAGS=""
  307. CMAKE_LD_SEARCH_FLAGS=""
  308. fi
  309. export CMAKE_LIB_EXT
  310. AC_SUBST(CMAKE_TCL_SHLIB_TARGET)
  311. AC_SUBST(TOOLKIT_DEPENDS)
  312. AC_SUBST(CMAKE_SHLIB_LINK_FLAGS)
  313. AC_SUBST(CMAKE_SHLIB_BUILD_FLAGS)
  314. AC_SUBST(CMAKE_SHLIB_CFLAGS)
  315. AC_SUBST(CMAKE_LIB_EXT)
  316. AC_SUBST(DL_LIBS)
  317. AC_SUBST(SHLIB_LD_LIBS)
  318. AC_SUBST(SHLIB_SUFFIX)
  319. #--------------------------------------------------------------------
  320. # Include sys/select.h if it exists and if it supplies things
  321. # that appear to be useful and aren't already in sys/types.h.
  322. # This appears to be true only on the RS/6000 under AIX. Some
  323. # systems like OSF/1 have a sys/select.h that's of no use, and
  324. # other systems like SCO UNIX have a sys/select.h that's
  325. # pernicious. If "fd_set" isn't defined anywhere then set a
  326. # special flag.
  327. #--------------------------------------------------------------------
  328. AC_MSG_CHECKING([fd_set and sys/select])
  329. AC_TRY_COMPILE([#include <sys/types.h>],
  330. [fd_set readMask, writeMask;], tk_ok=yes, tk_ok=no)
  331. if test $tk_ok = no; then
  332. AC_HEADER_EGREP(fd_mask, sys/select.h, tk_ok=yes)
  333. if test $tk_ok = yes; then
  334. AC_DEFINE(HAVE_SYS_SELECT_H)
  335. fi
  336. fi
  337. AC_MSG_RESULT($tk_ok)
  338. if test $tk_ok = no; then
  339. AC_DEFINE(NO_FD_SET)
  340. fi
  341. ##########################
  342. ## ##
  343. ## Check thread support ##
  344. ## ##
  345. ##########################
  346. # initialize thread vars
  347. THREAD_LIBS=""
  348. THREAD_FLAGS=""
  349. use_sproc=no
  350. CMAKE_USE_SPROC=0
  351. CMAKE_USE_PTHREADS=0
  352. CMAKE_HP_PTHREADS=0
  353. ##########################
  354. ## ##
  355. ## sproc ##
  356. ## ##
  357. ##########################
  358. # check for sproc
  359. force_sproc=no
  360. AC_ARG_WITH(sproc,
  361. [ --with-sproc use sproc instead of pthreads if possible],
  362. if test "$withval" = yes; then
  363. force_sproc=yes
  364. fi,)
  365. AC_CHECK_HEADERS(sys/prctl.h, [use_sproc=yes])
  366. if test "$use_sproc" = "yes"; then
  367. case $system in
  368. Linux* | IRIX64-6.5 | IRIX-6.5)
  369. if test "$force_sproc" = "yes"; then
  370. CMAKE_USE_SPROC=1
  371. else
  372. use_sproc=no
  373. fi
  374. ;;
  375. IRIX*)
  376. CMAKE_USE_SPROC=1
  377. ;;
  378. esac
  379. fi
  380. use_pthreads=no
  381. AC_CHECK_HEADERS(pthread.h, [use_pthreads=yes])
  382. if test "$use_pthreads" = "yes"; then
  383. if test "$use_sproc" = "no"; then
  384. AC_CHECK_LIB(pthreads, pthread_create, THREAD_LIBS="-lpthreads")
  385. AC_CHECK_LIB(pthread, pthread_create, THREAD_LIBS="-lpthread")
  386. # Work around Solaris 5.6 and 5.7 bug:
  387. if test "`uname -s -r`" = "SunOS 5.6"; then
  388. AC_CHECK_LIB(thread, thr_create, THREAD_LIBS="$THREAD_LIBS -lthread")
  389. fi
  390. if test "`uname -s -r`" = "SunOS 5.7"; then
  391. AC_CHECK_LIB(thread, thr_create, THREAD_LIBS="$THREAD_LIBS -lthread")
  392. fi
  393. CMAKE_USE_PTHREADS=1
  394. fi
  395. fi
  396. # on an HP with pthread we need to use -lcma
  397. # on dec alphas we have had problems as well
  398. if test "$use_pthreads" = "yes"; then
  399. case $system in
  400. HP-UX-*.10.*)
  401. THREAD_LIBS="-lcma"
  402. CMAKE_USE_PTHREADS=1
  403. CMAKE_HP_PTHREADS=1
  404. ;;
  405. OSF1-V*)
  406. CMAKE_USE_PTHREADS=0
  407. THREAD_LIBS=""
  408. ;;
  409. FreeBSD*)
  410. CMAKE_USE_PTHREADS=0
  411. THREAD_LIBS=""
  412. ;;
  413. esac
  414. fi
  415. if test $CMAKE_USE_SPROC = 1; then
  416. AC_DEFINE(CMAKE_USE_SPROC)
  417. fi
  418. if test $CMAKE_USE_PTHREADS = 1; then
  419. AC_DEFINE(CMAKE_USE_PTHREADS)
  420. fi
  421. if test $CMAKE_HP_PTHREADS = 1; then
  422. AC_DEFINE(CMAKE_HP_PTHREADS)
  423. fi
  424. AC_SUBST(THREAD_LIBS)
  425. # on hp use -Aa for ansi
  426. if test $ac_cv_prog_gxx = no; then
  427. case $system in
  428. HP-UX-*.08.*|HP-UX-*.09.*|HP-UX-*.10.*)
  429. echo $ac_n "checking whether ${CC} accepts -Aa""... $ac_c" 1>&6
  430. echo 'void f(){}' > conftest.c
  431. if test -z "`${CC} -Aa -c conftest.cc 2>&1`"; then
  432. echo "$ac_t""yes" 1>&6
  433. ANSI_CFLAGS="-Aa"
  434. else
  435. echo "$ac_t""no" 1>&6
  436. fi
  437. rm -f conftest*
  438. ;;
  439. esac
  440. fi
  441. AC_SUBST(ANSI_CFLAGS)
  442. # if we are not running g++ then we might need some other flags
  443. # to get the templates compiled correctly
  444. CMAKE_TEMPLATE_FLAGS=""
  445. if test $ac_cv_prog_gxx = no; then
  446. echo $ac_n "checking whether ${CXX} accepts -ptused -no_prelink""... $ac_c" 1>&6
  447. echo 'void f(){}' > conftest.cc
  448. if test -z "`${CXX} -ptused -no_prelink -c conftest.cc 2>&1`"; then
  449. echo "$ac_t""yes" 1>&6
  450. CMAKE_TEMPLATE_FLAGS="-ptused -no_prelink"
  451. else
  452. echo "$ac_t""no" 1>&6
  453. fi
  454. rm -f conftest*
  455. echo $ac_n "checking whether ${CXX} accepts -instances=semiexplicit""... $ac_c" 1>&6
  456. echo 'void f(){}' > conftest.cc
  457. if test -z "`${CXX} -instances=static -c conftest.cc 2>&1`"; then
  458. echo "$ac_t""yes" 1>&6
  459. CMAKE_TEMPLATE_FLAGS="-instances=static"
  460. else
  461. echo "$ac_t""no" 1>&6
  462. fi
  463. fi
  464. AC_SUBST(CMAKE_TEMPLATE_FLAGS)
  465. if test "$CC" = "gcc" -o `$CC -v 2>&1 | grep -c gcc` != "0" ; then
  466. SHLIB_CFLAGS="-fPIC"
  467. fi
  468. if test -f $CMAKE_CONFIG_DIR/CMakeLocal.make.in; then
  469. echo "create CMakeLocal.make from $CMAKE_CONFIG_DIR/CMakeLocal.make.in"
  470. rm -f local.make
  471. cp $CMAKE_CONFIG_DIR/local.make.in local.make
  472. else
  473. echo "no $CMAKE_CONFIG_DIR/CMakeLocal.make.in creating an empty CMakeLocal.make file"
  474. rm -f CMakeLocal.make
  475. touch CMakeLocal.make
  476. fi
  477. AC_SUBST(EXTRA_GCC_FLAG)
  478. # run any sub directory cofigure scripts here
  479. AC_CONFIG_SUBDIRS(Code/Insight3DParty/vxl/vcl)
  480. # *****************************************
  481. #
  482. # This next section extracts the sub-directories from
  483. # the CMakeLists.txt file in the current directory,
  484. # and any sub directories recursivley
  485. #
  486. echo "Searching CMakeLists.txt files for all sub directories"
  487. # the result of a the directories found is stored in allDirs
  488. allDirs=
  489. # start looking in the current directory .
  490. searchDirs=$srcdir
  491. # loop until the flag dirHasListsFile is set to falls
  492. dirHasListsFile=:
  493. while $dirHasListsFile; do
  494. # reset the varible used to store the full paths to the directory
  495. # outside the for loop
  496. fullPathDirs=
  497. # loop over all directorirs in the current searchDirs varible
  498. for currentDir in $searchDirs;do
  499. # look for a CMakeLists.txt file in the current directory
  500. if test -e$currentDir/CMakeLists.txt; then
  501. # extract the SUBDIRS varible from the CMakeLists.txt file
  502. dirsInListsFile=`cat $currentDir/CMakeLists.txt | sed -e :a -e '/SUBDIRS.*\\\\$/N; s/\\\\\\n//; ta' | grep SUBDIRS | sed -e "s/SUBDIRS//g; s/(//g;s/)//g" `
  503. # add the current directory to any sub dirs found
  504. # in the above search of CMakeLists.txt
  505. for subdir in $dirsInListsFile;do
  506. fullPathDirs="$fullPathDirs $currentDir/$subdir"
  507. allDirs="$allDirs $currentDir/$subdir"
  508. done
  509. fi
  510. done
  511. # now get ready to search any directories found in the above for loop
  512. searchDirs=$fullPathDirs
  513. # check to see if searchDirs is emtpy
  514. if test "x$searchDirs" = x; then
  515. dirHasListsFile=false
  516. fi
  517. done # continue while loop until dirHasListsFile=false
  518. if test "x$srcdir" = x.; then
  519. allDirs=`echo $allDirs | sed -e "s|\./||g"`
  520. else
  521. allDirs=`echo $allDirs | sed -e "s|$srcdir/||g"`
  522. fi
  523. SUBDIR_MAKEFILES=`echo $allDirs | sed -e 's|\\([[A-Za-z0-9_/]][[A-Za-z0-9_/]]*\\)|\1/Makefile:CMake/MakefileTemplate.in|g'`
  524. SUBDIR_CMAKE_TARGETS=`echo $allDirs | sed -e 's|\\([[A-Za-z0-9_/]][[A-Za-z0-9_/]]*\\)|\1/CMakeTargets.make:CMake/CMakeTargets.make.in|g'`
  525. #
  526. # *****************************************
  527. # end of extract SUBDIRS out of CMakeLists.txt files
  528. #
  529. # output to the top level Makefile, which must be present
  530. # create the toplevel CMakeTargets.make file
  531. # Create all the make file fragments in CMake
  532. # Create the Makefile in CMake/Source
  533. # Create all the Makefiles and CMakeTargets.make files for
  534. # sub directories found in CMakeLists.txt files
  535. AC_OUTPUT(
  536. Makefile:CMake/MakefileTemplate.in
  537. CMakeTargets.make:CMake/CMakeTargets.make.in
  538. CMake/CMakeSimpleRules.make
  539. CMake/CMakeMaster.make
  540. CMake/CMakeVariables.make
  541. CMake/CMakeRules.make
  542. CMake/Source/CMakeTargets.make:CMake/dummy.in
  543. CMake/Source/Makefile
  544. $SUBDIR_MAKEFILES
  545. $SUBDIR_CMAKE_TARGETS
  546. )
  547. # force a rebuild of rulesgen which will rebuild CMakeTargets.make
  548. # this has to be done because configure generates empty CMakeTargets.make files
  549. # for makes other than gnu.
  550. rm -f CMake/Source/CMakeBuildTargets
  551. rm -f CMake/Source/CMakeBuildTargets.exe