configure.ac 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. AC_PREREQ([2.60])
  2. m4_define([RELEASE], 2.1.2)
  3. AC_INIT([mtd-utils], [RELEASE], [linux-mtd@lists.infradead.org], mtd-utils)
  4. AC_ARG_ENABLE([unit-tests],
  5. [AS_HELP_STRING([--enable-unit-tests], [Compile unit test programs])],
  6. [case "${enableval}" in
  7. yes) AM_CONDITIONAL([UNIT_TESTS], [true]) ;;
  8. no) AM_CONDITIONAL([UNIT_TESTS], [false]) ;;
  9. *) AC_MSG_ERROR([bad value ${enableval} for --enable-unit-tests]) ;;
  10. esac],
  11. [AM_CONDITIONAL([UNIT_TESTS], [false])])
  12. AM_COND_IF([UNIT_TESTS], [: ${CFLAGS=""}], [])
  13. AC_CONFIG_MACRO_DIR([m4])
  14. AM_INIT_AUTOMAKE([foreign subdir-objects dist-bzip2])
  15. AM_SILENT_RULES([yes])
  16. AC_PROG_LIBTOOL
  17. AC_DISABLE_STATIC
  18. AC_PROG_CC
  19. AC_PROG_INSTALL
  20. m4_ifndef([PKG_PROG_PKG_CONFIG],
  21. [m4_fatal([Could not locate the pkg-config autoconf
  22. macros. These are usually located in /usr/share/aclocal/pkg.m4.
  23. If your macros are in a different location, try setting the
  24. environment variable AL_OPTS="-I/other/macro/dir" before running
  25. ./autogen.sh or autoreconf again. Make sure pkg-config is installed.])])
  26. PKG_PROG_PKG_CONFIG
  27. ## compiler warnings
  28. UL_WARN_ADD([-Wall])
  29. UL_WARN_ADD([-Wextra])
  30. UL_WARN_ADD([-Wunused])
  31. UL_WARN_ADD([-Wmissing-prototypes])
  32. UL_WARN_ADD([-Wmissing-declarations])
  33. UL_WARN_ADD([-Wwrite-strings])
  34. UL_WARN_ADD([-Wjump-misses-init])
  35. UL_WARN_ADD([-Wuninitialized])
  36. UL_WARN_ADD([-Winit-self])
  37. UL_WARN_ADD([-Wlogical-op])
  38. UL_WARN_ADD([-Wunused-but-set-parameter])
  39. UL_WARN_ADD([-Wunused-but-set-variable])
  40. UL_WARN_ADD([-Wunused-parameter])
  41. UL_WARN_ADD([-Wunused-result])
  42. UL_WARN_ADD([-Wunused-variable])
  43. UL_WARN_ADD([-Wduplicated-cond])
  44. UL_WARN_ADD([-Wduplicated-branches])
  45. UL_WARN_ADD([-Wrestrict])
  46. UL_WARN_ADD([-Wnull-dereference])
  47. UL_WARN_ADD([-Wno-shadow])
  48. UL_WARN_ADD([-Wno-sign-compare])
  49. AC_SUBST([WARN_CFLAGS])
  50. ###### handle configure switches, select dependencies ######
  51. need_clock_gettime="no"
  52. need_pthread="no"
  53. need_uuid="no"
  54. need_zlib="no"
  55. need_lzo="no"
  56. need_zstd="no"
  57. need_xattr="no"
  58. need_cmocka="no"
  59. need_selinux="no"
  60. need_openssl="no"
  61. need_getrandom="no"
  62. AM_COND_IF([UNIT_TESTS], [
  63. need_cmocka="yes"
  64. ])
  65. AC_ARG_ENABLE([tests],
  66. [AS_HELP_STRING([--disable-tests], [Compile test programs])],
  67. [case "${enableval}" in
  68. yes) AM_CONDITIONAL([BUILD_TESTS], [true]) ;;
  69. no) AM_CONDITIONAL([BUILD_TESTS], [false]) ;;
  70. *) AC_MSG_ERROR([bad value ${enableval} for --disable-tests]) ;;
  71. esac],
  72. [AM_CONDITIONAL([BUILD_TESTS], [true])])
  73. AM_COND_IF([BUILD_TESTS], [
  74. need_clock_gettime="yes"
  75. need_pthread="yes"
  76. ])
  77. AC_ARG_ENABLE([install-tests],
  78. [AS_HELP_STRING([--enable-install-tests], [Install test programs])],
  79. [case "${enableval}" in
  80. yes) AM_CONDITIONAL([INSTALL_TESTS], [true]) ;;
  81. no) AM_CONDITIONAL([INSTALL_TESTS], [false]) ;;
  82. *) AC_MSG_ERROR([bad value ${enableval} for --enable-install-tests]) ;;
  83. esac],
  84. [AM_CONDITIONAL([INSTALL_TESTS], [false])])
  85. AM_COND_IF([INSTALL_TESTS],
  86. [AC_SUBST(testbindir, ["\$libexecpath"])],
  87. [AC_SUBST(testbindir, ["\".\""])])
  88. AC_ARG_ENABLE([lsmtd],
  89. [AS_HELP_STRING([--disable-lsmtd], [Do not build the lsmtd program])],
  90. [case "${enableval}" in
  91. yes) AM_CONDITIONAL([BUILD_LSMTD], [true]) ;;
  92. no) AM_CONDITIONAL([BUILD_LSMTD], [false]) ;;
  93. *) AC_MSG_ERROR([bad value ${enableval} for --disable-lsmtd]) ;;
  94. esac],
  95. [AM_CONDITIONAL([BUILD_LSMTD], [true])])
  96. AC_ARG_WITH([jffs],
  97. [AS_HELP_STRING([--without-jffs], [Disable jffsX utilities])],
  98. [case "${withval}" in
  99. yes) AM_CONDITIONAL([BUILD_JFFSX], [true]) ;;
  100. no) AM_CONDITIONAL([BUILD_JFFSX], [false]) ;;
  101. *) AC_MSG_ERROR([bad value ${withval} for --without-jffs]) ;;
  102. esac],
  103. [AM_CONDITIONAL([BUILD_JFFSX], [true])])
  104. AC_ARG_WITH([ubifs],
  105. [AS_HELP_STRING([--without-ubifs], [Disable ubifs utilities])],
  106. [case "${withval}" in
  107. yes) AM_CONDITIONAL([BUILD_UBIFS], [true]) ;;
  108. no) AM_CONDITIONAL([BUILD_UBIFS], [false]) ;;
  109. *) AC_MSG_ERROR([bad value ${withval} for --without-ubifs]) ;;
  110. esac],
  111. [AM_CONDITIONAL([BUILD_UBIFS], [true])])
  112. AM_COND_IF([BUILD_UBIFS], [
  113. need_uuid="yes"
  114. need_xattr="yes"
  115. need_zlib="yes"
  116. need_lzo="yes"
  117. need_zstd="yes"
  118. need_openssl="yes"
  119. need_getrandom="yes"
  120. ])
  121. AM_COND_IF([BUILD_JFFSX], [
  122. need_xattr="yes"
  123. need_zlib="yes"
  124. need_lzo="yes"
  125. ])
  126. AC_ARG_WITH([xattr],
  127. [AS_HELP_STRING([--without-xattr],
  128. [Disable support forextended file attributes])],
  129. [case "${withval}" in
  130. yes) ;;
  131. no) need_xattr="no" ;;
  132. *) AC_MSG_ERROR([bad value ${withval} for --without-xattr]) ;;
  133. esac])
  134. AC_ARG_WITH([lzo],
  135. [AS_HELP_STRING([--without-lzo], [Disable support for LZO compression])],
  136. [case "${withval}" in
  137. yes) ;;
  138. no) need_lzo="no" ;;
  139. *) AC_MSG_ERROR([bad value ${withval} for --without-lzo]) ;;
  140. esac])
  141. AC_ARG_WITH([zstd],
  142. [AS_HELP_STRING([--without-zstd], [Disable support for ZSTD compression])],
  143. [case "${withval}" in
  144. yes) ;;
  145. no) need_zstd="no" ;;
  146. *) AC_MSG_ERROR([bad value ${withval} for --without-zstd]) ;;
  147. esac])
  148. AC_ARG_WITH([selinux],
  149. [AS_HELP_STRING([--with-selinux],
  150. [Enable support for selinux extended attributes])],
  151. [case "${withval}" in
  152. yes) need_selinux="yes";;
  153. no) ;;
  154. *) AC_MSG_ERROR([bad value ${withval} for --with-selinux]) ;;
  155. esac])
  156. AC_ARG_WITH([crypto],
  157. [AS_HELP_STRING([--without-crypto],
  158. [Disable support for UBIFS crypto features])],
  159. [case "${withval}" in
  160. yes) ;;
  161. no) need_openssl="no";;
  162. *) AC_MSG_ERROR([bad value ${withval} for --without-crypto]) ;;
  163. esac])
  164. ##### search for dependencies #####
  165. clock_gettime_missing="no"
  166. pthread_missing="no"
  167. uuid_missing="no"
  168. zlib_missing="no"
  169. lzo_missing="no"
  170. zstd_missing="no"
  171. xattr_missing="no"
  172. cmocka_missing="no"
  173. selinux_missing="no"
  174. openssl_missing="no"
  175. getrandom_missing="no"
  176. if test "x$need_zlib" = "xyes"; then
  177. PKG_CHECK_MODULES(ZLIB, [zlib], [], [zlib_missing="yes"])
  178. fi
  179. if test "x$need_selinux" = "xyes"; then
  180. PKG_CHECK_MODULES(LIBSELINUX, [libselinux], [], [selinux_missing="yes"])
  181. fi
  182. if test "x$need_uuid" = "xyes"; then
  183. PKG_CHECK_MODULES(UUID, [uuid], [], [uuid_missing="yes"])
  184. fi
  185. if test "x$need_clock_gettime" = "xyes"; then
  186. AC_SEARCH_LIBS([clock_gettime], [rt posix4])
  187. AC_CHECK_FUNCS([clock_gettime], [], [clock_gettime_missing="yes"])
  188. fi
  189. if test "x$need_pthread" = "xyes"; then
  190. AX_PTHREAD([], [pthread_missing="yes"])
  191. fi
  192. if test "x$need_lzo" = "xyes"; then
  193. AC_ARG_VAR([LZO_CFLAGS], [C compiler flags for lzo])
  194. AC_ARG_VAR([LZO_LIBS], [linker flags for lzo])
  195. AC_CHECK_LIB([lzo2], [lzo1x_1_15_compress], [LZO_LIBS="-llzo2"],
  196. [AC_CHECK_LIB([lzo],[lzo1x_1_15_compress],[LZO_LIBS="-llzo"],
  197. [lzo_missing="yes"]
  198. )]
  199. )
  200. fi
  201. if test "x$need_zstd" = "xyes"; then
  202. PKG_CHECK_MODULES([ZSTD], [libzstd],, zstd_missing="yes")
  203. fi
  204. if test "x$need_xattr" = "xyes"; then
  205. AC_CHECK_HEADERS([sys/xattr.h], [], [xattr_missing="yes"])
  206. AC_CHECK_HEADERS([sys/acl.h], [], [xattr_missing="yes"])
  207. fi
  208. if test "x$need_selinux" = "xyes"; then
  209. AC_CHECK_HEADERS([selinux/selinux.h], [], [selinux_missing="yes"])
  210. AC_CHECK_HEADERS([selinux/label.h], [], [selinux_missing="yes"])
  211. fi
  212. if test "x$need_openssl" = "xyes"; then
  213. AC_CHECK_HEADER(openssl/rand.h)
  214. PKG_CHECK_MODULES(OPENSSL, [openssl], [], [openssl_missing="yes"])
  215. fi
  216. if test "x$need_getrandom" = "xyes"; then
  217. AC_CHECK_HEADERS([sys/random.h], [], [getrandom_missing="yes"])
  218. fi
  219. if test "x$need_cmocka" = "xyes"; then
  220. PKG_CHECK_MODULES(CMOCKA, [cmocka], [], [cmocka_missing="yes"])
  221. fi
  222. AC_CHECK_HEADERS([execinfo.h])
  223. ##### produce summary on dependencies #####
  224. dep_missing="no"
  225. if test "x$clock_gettime_missing" = "xyes"; then
  226. AC_MSG_WARN([cannot find clock_gettime function required for MTD tests])
  227. AC_MSG_NOTICE([building test programs can optionally be dissabled])
  228. dep_missing="yes"
  229. fi
  230. if test "x$pthread_missing" = "xyes"; then
  231. AC_MSG_WARN([cannot find pthread support required for test programs])
  232. AC_MSG_NOTICE([building test programs can optionally be dissabled])
  233. dep_missing="yes"
  234. fi
  235. if test "x$uuid_missing" = "xyes"; then
  236. AC_MSG_WARN([cannot find uuid library required for mkfs.ubifs])
  237. AC_MSG_NOTICE([mtd-utils can optionally be built without mkfs.ubifs])
  238. dep_missing="yes"
  239. fi
  240. if test "x$zlib_missing" = "xyes"; then
  241. AC_MSG_WARN([cannot find ZLIB library required for mkfs programs])
  242. AC_MSG_NOTICE([mtd-utils can optionally be built without mkfs.ubifs])
  243. AC_MSG_NOTICE([mtd-utils can optionally be built without mkfs.jffs2])
  244. dep_missing="yes"
  245. fi
  246. if test "x$lzo_missing" = "xyes"; then
  247. AC_MSG_WARN([cannot find LZO library required for mkfs programs])
  248. AC_MSG_NOTICE([mtd-utils can optionally be built without mkfs.ubifs])
  249. AC_MSG_NOTICE([mtd-utils can optionally be built without mkfs.jffs2])
  250. AC_MSG_NOTICE([mtd-utils can optionally be built without LZO support])
  251. dep_missing="yes"
  252. fi
  253. if test "x$zstd_missing" = "xyes"; then
  254. AC_MSG_WARN([cannot find ZSTD library required for mkfs program])
  255. AC_MSG_NOTICE([mtd-utils can optionally be built without mkfs.ubifs])
  256. AC_MSG_NOTICE([mtd-utils can optionally be built without ZSTD support])
  257. dep_missing="yes"
  258. fi
  259. if test "x$xattr_missing" = "xyes"; then
  260. AC_MSG_WARN([cannot find headers for extended attributes])
  261. AC_MSG_WARN([disabling XATTR support])
  262. need_xattr="no"
  263. fi
  264. if test "x$selinux_missing" = "xyes"; then
  265. AC_MSG_WARN([cannot find headers for selinux library])
  266. AC_MSG_WARN([disabling SELINUX support])
  267. need_selinux="no"
  268. fi
  269. if test "x$openssl_missing" = "xyes"; then
  270. AC_MSG_WARN([cannot find headers for OpenSSL library])
  271. AC_MSG_WARN([disabling OpenSSL support])
  272. need_openssl="no"
  273. fi
  274. if test "x$getrandom_missing" = "xyes"; then
  275. AC_MSG_WARN([cannot find headers for getrandom() function])
  276. AC_MSG_WARN([disabling UBIFS ubihealthd support])
  277. need_getrandom="no"
  278. fi
  279. if test "x$cmocka_missing" = "xyes"; then
  280. AC_MSG_WARN([cannot find CMocka library required for unit tests])
  281. AC_MSG_NOTICE([unit tests can optionally be disabled])
  282. dep_missing="yes"
  283. fi
  284. if test "x$dep_missing" = "xyes"; then
  285. AC_MSG_ERROR([missing one or more dependencies])
  286. fi
  287. ##### generate output #####
  288. AM_CONDITIONAL([WITHOUT_LZO], [test "x$need_lzo" != "xyes"])
  289. AM_CONDITIONAL([WITHOUT_ZSTD], [test "x$need_zstd" != "xyes"])
  290. AM_CONDITIONAL([WITHOUT_XATTR], [test "x$need_xattr" != "xyes"])
  291. AM_CONDITIONAL([WITH_SELINUX], [test "x$need_selinux" == "xyes"])
  292. AM_CONDITIONAL([WITH_CRYPTO], [test "x$need_openssl" == "xyes"])
  293. AM_CONDITIONAL([WITH_GETRANDOM], [test "x$need_getrandom" == "xyes"])
  294. AC_CHECK_SIZEOF([off_t])
  295. AC_CHECK_SIZEOF([loff_t])
  296. AC_CONFIG_HEADERS([include/config.h])
  297. AC_CONFIG_FILES([tests/fs-tests/fs_help_all.sh
  298. tests/fs-tests/fs_run_all.sh
  299. tests/fs-tests/stress/fs_stress00.sh
  300. tests/fs-tests/stress/fs_stress01.sh
  301. tests/ubi-tests/runubitests.sh
  302. tests/ubi-tests/ubi-stress-test.sh])
  303. AC_OUTPUT([Makefile])