configure.ac 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  1. AC_INIT(biobambam2,2.0.185,[germant@miltenyibiotec.de],[biobambam2],[https://gitlab.com/german.tischler/biobambam2])
  2. AC_CANONICAL_SYSTEM
  3. AC_PROG_LIBTOOL
  4. AM_INIT_AUTOMAKE([std-options subdir-objects parallel-tests])
  5. AM_CONFIG_HEADER(config.h)
  6. AC_CONFIG_MACRO_DIR([m4])
  7. AC_CANONICAL_SYSTEM
  8. AC_MSG_CHECKING([whether we are cross compiling])
  9. ISNATIVE=
  10. if test \( "${ac_cv_build}" = "${ac_cv_host}" \) -a \( "${ac_cv_build}" = "${ac_cv_target}" \) ; then
  11. ISNATIVE=1
  12. AC_MSG_RESULT([no])
  13. else
  14. ISNATIVE=0
  15. AC_MSG_RESULT([yes])
  16. fi
  17. AC_ARG_ENABLE(optimization,
  18. AS_HELP_STRING([--enable-optimization],[use compiler optimization (default yes)]),
  19. [optimization=${enableval}],[optimization=yes])
  20. AC_ARG_ENABLE(debug,
  21. AS_HELP_STRING([--enable-debug],[use compiler debug flags (default no)]),
  22. [debug=${enableval}],[debug=no])
  23. AC_ARG_ENABLE(profile,
  24. AS_HELP_STRING([--enable-profile],[use compiler profiling flags (default no)]),
  25. [profile=${enableval}],[profile=no])
  26. AC_ARG_ENABLE(fast,
  27. AS_HELP_STRING([--enable-fast],[disable evaluation of assertions (default no)]),
  28. [fast=${enableval}],[fast=no])
  29. AC_ARG_ENABLE(install-experimental,
  30. AS_HELP_STRING([--enable-install-experimental],[install experimental programs (default no)]),
  31. [install_experimental=${enableval}],[install_experimental=no])
  32. AC_ARG_ENABLE(asan,
  33. AS_HELP_STRING([--enable-asan],[enable address sanitizer in debug mode (default no)]),
  34. [enableasan=${enableval}],[enableasan=no])
  35. dnl if test "${install_experimental}" = "yes" ; then
  36. dnl else
  37. dnl fi
  38. # check for C compiler
  39. CFLAGS_SAVE="${CFLAGS}"
  40. CFLAGS=""
  41. AC_PROG_CC
  42. CFLAGS="${CFLAGS_SAVE}"
  43. CFLAGS_SAVE="${CFLAGS}"
  44. CFLAGS=""
  45. CXXFLAGS_SAVE="${CXXFLAGS}"
  46. CXXFLAGS=""
  47. AM_PROG_CC_C_O
  48. CFLAGS="${CFLAGS_SAVE}"
  49. CXXFLAGS="${CXXFLAGS_SAVE}"
  50. # check for C++ compiler
  51. CXXFLAGS_SAVE="${CXXFLAGS}"
  52. CXXFLAGS=""
  53. AC_PROG_CXX
  54. CXXFLAGS="${CXXFLAGS_SAVE}"
  55. AC_LANG_PUSH([C++])
  56. CXXFLAGS_SAVE="${CXXFLAGS}"
  57. CXXFLAGS="-fsanitize=address"
  58. AC_MSG_CHECKING([whether the C++ compiler supports the -fsanitize=address flag])
  59. AC_TRY_COMPILE([],[],[sanitizeaddress=yes],[sanitizeaddress=no])
  60. AC_MSG_RESULT([${sanitizeaddress}])
  61. CXXFLAGS="${CXXFLAGS_SAVE}"
  62. AC_LANG_POP
  63. if test \( "${sanitizeaddress}" = "yes" \) -a \( "${enableasan}" = "yes" \) ; then
  64. CXXFLAGS="${CXXFLAGS} -fsanitize=address"
  65. CFLAGS="${CFLAGS} -fsanitize=address"
  66. fi
  67. if test "${debug}" = "yes" ; then
  68. CXXDEBUGFLAGS="-g -O0"
  69. CDEBUGFLAGS="-g -O0"
  70. CXXFLAGS="${CXXFLAGS} ${CXXDEBUGFLAGS}"
  71. CFLAGS="${CFLAGS} ${CDEBUGFLAGS}"
  72. LDFLAGS="${LDFLAGS} -rdynamic"
  73. openmp="no"
  74. AC_MSG_NOTICE([Adding debug options ${CDEBUGFLAGS} to C compiler ${CC} flags, full list now ${CFLAGS}])
  75. AC_MSG_NOTICE([Adding debug options ${CXXDEBUGFLAGS} to C compiler ${CXX} flags, full list now ${CXXFLAGS}])
  76. else
  77. if test "${profile}" = "yes" ; then
  78. CXXPROFFLAGS="-g -pg"
  79. CPROFFLAGS="-g -pg"
  80. CXXFLAGS="${CXXPROFFLAGS} -g -pg"
  81. CFLAGS="${CPROFFLAGS} -g -pg"
  82. LDFLAGS="${LDFLAGS} -rdynamic"
  83. AC_MSG_NOTICE([Adding profiling options ${CPROFFLAGS} to C compiler ${CC} flags, full list now ${CFLAGS}])
  84. AC_MSG_NOTICE([Adding profiling options ${CXXPROFFLAGS} to C compiler ${CXX} flags, full list now ${CXXFLAGS}])
  85. else
  86. if test "${optimization}" = "yes" ; then
  87. COPTFLAGS=
  88. case ${CC} in
  89. gcc)
  90. COPTFLAGS="-O3"
  91. ;;
  92. *-mingw32msvc-gcc)
  93. COPTFLAGS="-O3"
  94. ;;
  95. cl.exe)
  96. COPTFLAGS="-O2 -Ob2 -Ot -Oy"
  97. ;;
  98. esac
  99. CFLAGS="${CFLAGS} ${COPTFLAGS}"
  100. AC_MSG_NOTICE([Adding optimisation options ${COPTFLAGS} to C compiler ${CC} flags, full list now ${CFLAGS}])
  101. CXXOPTFLAGS=
  102. case ${CXX} in
  103. g++)
  104. CXXOPTFLAGS="-O3"
  105. LDFLAGS="${LDFLAGS} -rdynamic"
  106. ;;
  107. *-mingw32msvc-g++)
  108. CXXOPTFLAGS="-O3"
  109. LDFLAGS="${LDFLAGS} -rdynamic"
  110. ;;
  111. cl.exe)
  112. CXXOPTFLAGS="-O2 -Ob2 -Ot -Oy"
  113. ;;
  114. esac
  115. CXXFLAGS="${CXXFLAGS} ${CXXOPTFLAGS}"
  116. AC_MSG_NOTICE([Adding optimisation options ${CXXOPTFLAGS} to C++ compiler ${CXX} flags, full list now ${CXXFLAGS}])
  117. fi
  118. fi
  119. fi
  120. # check for pkg-config tool
  121. PKG_PROG_PKG_CONFIG
  122. if test "${fast}" = "yes" ; then
  123. CPPFLAGS="${CPPFLAGS} -DNDEBUG"
  124. fi
  125. # check for standard headers
  126. AC_LANG_PUSH([C++])
  127. AC_HEADER_STDC
  128. AC_LANG_POP
  129. if test "${CXX}" = "g++" ; then
  130. CPPFLAGS="${CPPFLAGS} -W -Wall"
  131. fi
  132. AC_ARG_WITH([libmaus2],
  133. [AS_HELP_STRING([--with-libmaus2@<:@=PATH@:>@], [path to installed libmaus2 library @<:@default=@:>@])],
  134. [with_libmaus2=${withval}],
  135. [with_libmaus2=])
  136. if test ! -z "${with_libmaus2}" ; then
  137. PKGCONFIGPATHSAVE="${PKG_CONFIG_PATH}"
  138. if test -z "${PKG_CONFIG_PATH}" ; then
  139. export PKG_CONFIG_PATH="${with_libmaus2}/lib/pkgconfig"
  140. else
  141. export PKG_CONFIG_PATH="${with_libmaus2}/lib/pkgconfig:${PKG_CONFIG_PATH}"
  142. fi
  143. fi
  144. PKG_CHECK_MODULES([libmaus2],[libmaus2 >= 2.0.800])
  145. if test ! -z "${with_libmaus2}" ; then
  146. if test ! -z "${PKGCONFIGPATHSAVE}" ; then
  147. export PKG_CONFIG_PATH="${PKGCONFIGPATHSAVE}"
  148. fi
  149. fi
  150. LIBMAUS2CPPFLAGS="${libmaus2_CFLAGS}"
  151. LIBMAUS2LIBS="${libmaus2_LIBS}"
  152. CPPFLAGS_SAVE="${CPPFLAGS}"
  153. LDFLAGS_SAVE="${LDFLAGS}"
  154. LIBS_SAVE="${LIBS}"
  155. CPPFLAGS="${CPPFLAGS} ${libmaus2_CFLAGS}"
  156. LIBS="${LIBS} ${libmaus2_LIBS}"
  157. AC_LANG_PUSH([C++])
  158. AC_MSG_CHECKING([whether we can compile a program using libmaus2])
  159. AC_LINK_IFELSE([AC_LANG_SOURCE([
  160. #include <libmaus2/util/ArgInfo.hpp>
  161. int main(int argc, char * argv[[]]) {
  162. ::libmaus2::util::ArgInfo const arginfo(argc,argv);
  163. return 0;
  164. }])],
  165. have_libmaus2=yes,
  166. have_libmaus2=no
  167. )
  168. AC_LANG_POP
  169. AC_MSG_RESULT($have_libmaus2)
  170. if test "${have_libmaus2}" = "no" ; then
  171. AC_MSG_ERROR([Required libmaus2 is not available.])
  172. fi
  173. AC_LANG_PUSH([C++])
  174. AC_MSG_CHECKING([whether pthread_mutexattr_settype supports PTHREAD_MUTEX_RECURSIVE_NP])
  175. AC_LINK_IFELSE([AC_LANG_SOURCE([
  176. #include <pthread.h>
  177. int main(int argc, char * argv[[]]) {
  178. pthread_mutexattr_t attr;
  179. pthread_mutexattr_init(&attr);
  180. pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
  181. return 0;
  182. }])],
  183. have_pthread_mutex_recursive_np=yes,
  184. have_pthread_mutex_recursive_np=no
  185. )
  186. AC_LANG_POP
  187. AC_MSG_RESULT($have_pthread_mutex_recursive_np)
  188. AC_LANG_PUSH([C++])
  189. AC_MSG_CHECKING([whether pthread_mutexattr_settype supports PTHREAD_MUTEX_RECURSIVE])
  190. AC_LINK_IFELSE([AC_LANG_SOURCE([
  191. #include <pthread.h>
  192. int main(int argc, char * argv[[]]) {
  193. pthread_mutexattr_t attr;
  194. pthread_mutexattr_init(&attr);
  195. pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
  196. return 0;
  197. }])],
  198. have_pthread_mutex_recursive=yes,
  199. have_pthread_mutex_recursive=no
  200. )
  201. AC_LANG_POP
  202. AC_MSG_RESULT($have_pthread_mutex_recursive)
  203. HAVE_PTHREAD_MUTEX_RECURSIVE_NP=
  204. if test "${have_pthread_mutex_recursive_np}" = "yes" ; then
  205. HAVE_PTHREAD_MUTEX_RECURSIVE_NP="#define HAVE_PTHREAD_MUTEX_RECURSIVE_NP"
  206. fi
  207. HAVE_PTHREAD_MUTEX_RECURSIVE=
  208. if test "${have_pthread_mutex_recursive}" = "yes" ; then
  209. HAVE_PTHREAD_MUTEX_RECURSIVE="#define HAVE_PTHREAD_MUTEX_RECURSIVE"
  210. fi
  211. AC_LANG_PUSH([C++])
  212. AC_MSG_CHECKING([whether libmaus2 has support for io_lib])
  213. AC_LINK_IFELSE([AC_LANG_SOURCE([
  214. #include <libmaus2/LibMausConfig.hpp>
  215. int main(int argc, char * argv[[]]) {
  216. #if ! defined(LIBMAUS2_HAVE_IO_LIB)
  217. #error "installed libmaus2 does not support io_lib"
  218. #endif
  219. return 0;
  220. }])],
  221. have_libmaus2_iolib=yes,
  222. have_libmaus2_iolib=no
  223. )
  224. AC_LANG_POP
  225. AC_MSG_RESULT($have_libmaus2_iolib)
  226. LIBMAUS2IOLIBDEFINE=
  227. if test "${have_libmaus2_iolib}" = "yes" ; then
  228. LIBMAUS2IOLIBDEFINE="#define BIOBAMBAM_LIBMAUS2_HAVE_IO_LIB"
  229. fi
  230. CPPFLAGS="${CPPFLAGS_SAVE}"
  231. LDFLAGS="${LDFLAGS_SAVE}"
  232. LIBS="${LIBS_SAVE}"
  233. AC_ARG_WITH([liftingwavelettransform],
  234. [AS_HELP_STRING([--with-liftingwavelettransform@<:@=PATH@:>@], [path to installed LiftingWaveletTransform library @<:@default=no@:>@])],
  235. [with_liftingwavelettransform=${withval}],
  236. [with_liftingwavelettransform=no])
  237. if test ! -z "${with_liftingwavelettransform}" ; then
  238. PKGCONFIGPATHSAVE="${PKG_CONFIG_PATH}"
  239. if test -z "${PKG_CONFIG_PATH}" ; then
  240. export PKG_CONFIG_PATH="${with_liftingwavelettransform}/lib/pkgconfig"
  241. else
  242. export PKG_CONFIG_PATH="${with_liftingwavelettransform}/lib/pkgconfig:${PKG_CONFIG_PATH}"
  243. fi
  244. fi
  245. if test "${with_liftingwavelettransform}" != "no" ; then
  246. PKG_CHECK_MODULES([liftingwavelettransform],[liftingwavelettransform >= 0.0.0])
  247. LIFTINGWAVELETTRANSFORMDEFINE="#define BIOBAMBAM_HAVE_LIFTINGWAVELETTRANSFORM"
  248. BAMREFDEPTHPEAKS="bamrefdepthpeaks"
  249. LIFTINGWAVELETTRANSFORMCPPFLAGS="${liftingwavelettransform_CFLAGS}"
  250. LIFTINGWAVELETTRANSFORMLIBS="${liftingwavelettransform_LIBS}"
  251. CPPFLAGS="${CPPFLAGS} ${LIFTINGWAVELETTRANSFORMCPPFLAGS}"
  252. LIBS="${LIBS} ${LIFTINGWAVELETTRANSFORMLIBS}"
  253. fi
  254. AC_PATH_PROG(BASHPROG,bash,no)
  255. AC_PATH_PROG(BASE64PROG,base64,no)
  256. TESTDIR=
  257. if test \( "${ISNATIVE}" -eq 1 \) -a \( "${BASHPROG}" != "no" \) -a \( "${BASE64PROG}" != "no" \) ; then
  258. TESTDIR=test
  259. fi
  260. AC_ARG_WITH([xerces-c],
  261. [AS_HELP_STRING([--with-xerces-c@<:@=PATH@:>@], [path to installed xerces-c library @<:@default=no@:>@])],
  262. [with_xerces_c=${withval}],
  263. [with_xerces_c=])
  264. BIOBAMBAM_HAVE_XERCES_C=
  265. xerces_c_CFLAGS=
  266. xerces_c_LIBS=
  267. BLASTNXMLTOBAM=
  268. if test "${with_xerces_c}" != "no" ; then
  269. if test ! -z "${with_xerces_c}" ; then
  270. PKGCONFIGPATHSAVE="${PKG_CONFIG_PATH}"
  271. if test -z "${PKG_CONFIG_PATH}" ; then
  272. export PKG_CONFIG_PATH="${with_xerces_c}/lib/pkgconfig"
  273. else
  274. export PKG_CONFIG_PATH="${with_xerces_c}/lib/pkgconfig:${PKG_CONFIG_PATH}"
  275. fi
  276. fi
  277. HAVE_XERCES_C=0
  278. PKG_CHECK_MODULES([xerces_c],[xerces-c >= 3.1.1],[HAVE_XERCES_C=1],[HAVE_XERCES_C=0])
  279. XERCES_C_CFLAGS=${xerces_c_CFLAGS}
  280. XERCES_C_LIBS=${xerces_c_LIBS}
  281. if test ! -z "${with_xerces_c}" ; then
  282. if test ! -z "${PKGCONFIGPATHSAVE}" ; then
  283. export PKG_CONFIG_PATH="${PKGCONFIGPATHSAVE}"
  284. fi
  285. fi
  286. if test $HAVE_XERCES_C -eq 1 ; then
  287. BIOBAMBAM_HAVE_XERCES_C="#define BIOBAMBAM_HAVE_XERCES_C"
  288. BLASTNXMLTOBAM="blastnxmltobam"
  289. fi
  290. fi
  291. AC_ARG_WITH([gmp],
  292. [AS_HELP_STRING([--with-gmp@<:@=PATH@:>@], [path to installed gmp library @<:@default=no@:>@])],
  293. [with_gmp=${withval}],
  294. [with_gmp=no])
  295. BIOBAMBAM_HAVE_GMP=
  296. gmp_CFLAGS=
  297. gmp_LIBS=
  298. if test "${with_gmp}" != "no" ; then
  299. AC_MSG_CHECKING([whether we can compile a program using the gmp library])
  300. LDFLAGS_SAVE=${LDFLAGS}
  301. CPPFLAGS_SAVE=${CPPFLAGS}
  302. LIBS_SAVE=${LIBS}
  303. if test \( ! -z "${with_gmp}" \) -a \( "${with_gmp}" != "yes" \) ; then
  304. LDFLAGS="-L${with_gmp}/lib"
  305. CPPFLAGS="-I${with_gmp}/include"
  306. fi
  307. LIBS="-lgmp ${LIBS}"
  308. AC_LANG_PUSH([C++])
  309. AC_LINK_IFELSE([AC_LANG_SOURCE([
  310. #include <gmp.h>
  311. int main(int argc, char * argv[[]]) {
  312. return 0;
  313. }])],
  314. have_gmp=yes,
  315. have_gmp=no
  316. )
  317. AC_LANG_POP
  318. AC_MSG_RESULT($have_gmp)
  319. LDFLAGS=${LDFLAGS_SAVE}
  320. CPPFLAGS=${CPPFLAGS_SAVE}
  321. LIBS=${LIBS_SAVE}
  322. if test "${have_gmp}" = "yes" ; then
  323. if test "${with_gmp}" != "yes" ; then
  324. GMPLDFLAGS="-L${with_gmp}/lib"
  325. GMPCPPFLAGS="-I${with_gmp}/include"
  326. else
  327. GMPLDFLAGS=
  328. GMPCPPFLAGS=
  329. fi
  330. BIOBAMBAM_HAVE_GMP="#define BIOBAMBAM_HAVE_GMP"
  331. GMPLIBS="-lgmp"
  332. else
  333. GMPLDFLAGS=
  334. GMPCPPFLAGS=
  335. GMPLIBS=
  336. fi
  337. fi
  338. if test "${install_experimental}" = "yes" ; then
  339. BLASTXMLTOBAMINSTEXP=${BLASTNXMLTOBAM}
  340. else
  341. BLASTXMLTOBAMNOINSTEXP=${BLASTNXMLTOBAM}
  342. fi
  343. AC_ARG_ENABLE(install_uncommon,
  344. AS_HELP_STRING([--enable-install-uncommon],[enable installation of some uncommon programs (default no)]),
  345. [install_uncommon=${enableval}],[install_uncommon=no])
  346. UNCOMMON="bamfilter bamfilterbyname bamfixmatecoordinates bamfixmatecoordinatesnamesorted bamtoname bamdisthist fastabgzfextract bamheap bamfrontback bamrandomtag bamheap2 bamheap3 bamtagconversion fastqtobampar bambisect vcffilterinfo vcfpatchcontigprepend vcfconcat vcfsort filtergtf bamconsensus vcfreplacecontigs vcffiltersamples bamexploderg bamexondepth bamheadercat bammarkduplicatesoptdist vcfdiff bamsimpledepth bamdepthmerge bamcountflags vcffilterfilterflags vcfreplacecontigsmap fastaselectreg bamdifference bamaddne bamadapterhistogram bamsalvage"
  347. UNCOMMONINSTALLED=
  348. UNCOMMONUNINSTALLED=
  349. if test "${install_uncommon}" = "yes" ; then
  350. UNCOMMONINSTALLED="${UNCOMMON}"
  351. else
  352. UNCOMMONUNINSTALLED="${UNCOMMON}"
  353. fi
  354. AC_MSG_NOTICE([Using flags ${CFLAGS} for C compiler ${CC}])
  355. AC_MSG_NOTICE([Using flags ${CXXFLAGS} for C++ compiler ${CXX}])
  356. PACKAGE_NAME=${PACKAGE}
  357. PACKAGE_VERSION=${VERSION}
  358. AC_SUBST([PACKAGE_NAME])
  359. AC_SUBST([PACKAGE_VERSION])
  360. AC_SUBST([BAMBAM_CFLAGS])
  361. AC_SUBST([BAMBAM_LDFLAGS])
  362. AC_SUBST([BAMBAM_LIBS])
  363. # libmaus2
  364. AC_SUBST([LIBMAUS2CPPFLAGS])
  365. AC_SUBST([LIBMAUS2LIBS])
  366. #
  367. AC_SUBST([LIBMAUS2IOLIBDEFINE])
  368. AC_SUBST([LIBMAUS2IRODSDEFINE])
  369. #
  370. AC_SUBST([LIFTINGWAVELETTRANSFORMDEFINE])
  371. AC_SUBST([BAMREFDEPTHPEAKS])
  372. #
  373. AC_SUBST([BLASTXMLTOBAMINSTEXP])
  374. AC_SUBST([BLASTXMLTOBAMNOINSTEXP])
  375. AC_SUBST([TESTDIR])
  376. #
  377. AC_SUBST([xerces_c_CFLAGS])
  378. AC_SUBST([xerces_c_LIBS])
  379. AC_SUBST([BIOBAMBAM_HAVE_XERCES_C])
  380. AC_SUBST([BLASTNXMLTOBAM])
  381. AC_SUBST([BIOBAMBAM_HAVE_GMP])
  382. AC_SUBST([GMPLDFLAGS])
  383. AC_SUBST([GMPCPPFLAGS])
  384. AC_SUBST([GMPLIBS])
  385. AC_SUBST([HAVE_PTHREAD_MUTEX_RECURSIVE_NP])
  386. AC_SUBST([HAVE_PTHREAD_MUTEX_RECURSIVE])
  387. #
  388. AC_SUBST([UNCOMMON])
  389. AC_SUBST([UNCOMMONINSTALLED])
  390. AC_SUBST([UNCOMMONUNINSTALLED])
  391. #
  392. AC_OUTPUT(Makefile src/Makefile test/Makefile src/biobambam2/BamBamConfig.hpp)