acinclude.m4 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568
  1. dnl MC_UNDELFS_CHECKS
  2. dnl Check for ext2fs undel support.
  3. dnl Set shell variable ext2fs_undel to "yes" if we have it,
  4. dnl "no" otherwise. May define USE_EXT2FSLIB for cpp.
  5. dnl Will set EXT2FS_UNDEL_LIBS to required libraries.
  6. AC_DEFUN([MC_UNDELFS_CHECKS], [
  7. ext2fs_undel=no
  8. EXT2FS_UNDEL_LIBS=
  9. AC_CHECK_HEADERS([ext2fs/ext2_fs.h linux/ext2_fs.h], [ext2_fs_h=yes; break])
  10. if test x$ext2_fs_h = xyes; then
  11. AC_CHECK_HEADERS([ext2fs/ext2fs.h], [ext2fs_ext2fs_h=yes], ,
  12. [
  13. #include <stdio.h>
  14. #ifdef HAVE_EXT2FS_EXT2_FS_H
  15. #include <ext2fs/ext2_fs.h>
  16. #else
  17. #undef umode_t
  18. #include <linux/ext2_fs.h>
  19. #endif
  20. ])
  21. if test x$ext2fs_ext2fs_h = xyes; then
  22. AC_DEFINE(USE_EXT2FSLIB, 1,
  23. [Define to enable undelete support on ext2])
  24. ext2fs_undel=yes
  25. EXT2FS_UNDEL_LIBS="-lext2fs -lcom_err"
  26. AC_CHECK_TYPE(ext2_ino_t, ,
  27. [AC_DEFINE(ext2_ino_t, ino_t,
  28. [Define to ino_t if undefined.])],
  29. [
  30. #include <errno.h>
  31. #include <stdio.h>
  32. #include <fcntl.h>
  33. #include <stdlib.h>
  34. #ifdef HAVE_EXT2FS_EXT2_FS_H
  35. #include <ext2fs/ext2_fs.h>
  36. #else
  37. #undef umode_t
  38. #include <linux/ext2_fs.h>
  39. #endif
  40. #include <ext2fs/ext2fs.h>
  41. ])
  42. fi
  43. fi
  44. ])
  45. dnl MC_EXTFS_CHECKS
  46. dnl Check for tools used in extfs scripts.
  47. AC_DEFUN([MC_EXTFS_CHECKS], [
  48. AC_PATH_PROG([ZIP], [zip], [/usr/bin/zip])
  49. AC_PATH_PROG([UNZIP], [unzip], [/usr/bin/unzip])
  50. AC_CACHE_CHECK([for zipinfo code in unzip], [mc_cv_have_zipinfo],
  51. [mc_cv_have_zipinfo=no
  52. if $UNZIP -Z </dev/null >/dev/null 2>&1; then
  53. mc_cv_have_zipinfo=yes
  54. fi])
  55. if test "x$mc_cv_have_zipinfo" = xyes; then
  56. HAVE_ZIPINFO=1
  57. else
  58. HAVE_ZIPINFO=0
  59. fi
  60. AC_SUBST([HAVE_ZIPINFO])
  61. AC_PATH_PROG([PERL], [perl], [/usr/bin/perl])
  62. ])
  63. dnl MC_MCSERVER_CHECKS
  64. dnl Check how mcserver should check passwords.
  65. dnl Possible methods are PAM, pwdauth and crypt.
  66. dnl The later works with both /etc/shadow and /etc/passwd.
  67. dnl If PAM is found, other methods are not checked.
  68. AC_DEFUN([MC_MCSERVER_CHECKS], [
  69. dnl Check if PAM can be used for mcserv
  70. AC_CHECK_LIB(dl, dlopen, [LIB_DL="-ldl"])
  71. AC_CHECK_LIB(pam, pam_start, [
  72. AC_DEFINE(HAVE_PAM, 1,
  73. [Define if PAM (Pluggable Authentication Modules) is available])
  74. MCSERVLIBS="-lpam $LIB_DL"
  75. mcserv_pam=yes], [], [$LIB_DL])
  76. dnl Check for crypt() - needed for both /etc/shadow and /etc/passwd.
  77. if test -z "$mcserv_pam"; then
  78. dnl Check for pwdauth() - used on SunOS.
  79. AC_CHECK_FUNCS([pwdauth])
  80. dnl Check for crypt()
  81. AC_CHECK_HEADERS([crypt.h], [crypt_header=yes])
  82. if test -n "$crypt_header"; then
  83. save_LIBS="$LIBS"
  84. LIBS=
  85. AC_SEARCH_LIBS(crypt, [crypt crypt_i], [mcserv_auth=crypt])
  86. MCSERVLIBS="$LIBS"
  87. LIBS="$save_LIBS"
  88. if test -n "$mcserv_auth"; then
  89. AC_DEFINE(HAVE_CRYPT, 1,
  90. [Define to use crypt function in mcserv])
  91. dnl Check for shadow passwords
  92. AC_CHECK_HEADERS([shadow.h shadow/shadow.h],
  93. [shadow_header=yes; break])
  94. if test -n "$shadow_header"; then
  95. save_LIBS="$LIBS"
  96. LIBS="$MCSERVLIBS"
  97. AC_SEARCH_LIBS(getspnam, [shadow], [mcserv_auth=shadow])
  98. MCSERVLIBS="$LIBS"
  99. LIBS="$save_LIBS"
  100. if test -n "$mcserv_auth"; then
  101. AC_DEFINE(HAVE_SHADOW, 1,
  102. [Define to use shadow passwords for mcserv])
  103. fi
  104. fi
  105. fi
  106. fi
  107. fi
  108. AC_SUBST(MCSERVLIBS)
  109. ])
  110. dnl MC_VFS_CHECKS
  111. dnl Check for various functions needed by libvfs.
  112. dnl This has various effects:
  113. dnl Sets MC_VFS_LIBS to libraries required
  114. dnl Sets vfs_flags to "pretty" list of vfs implementations we include.
  115. dnl Sets shell variable use_vfs to yes (default, --with-vfs) or
  116. dnl "no" (--without-vfs).
  117. dnl Private define
  118. AC_DEFUN([MC_WITH_VFS],[
  119. MC_EXTFS_CHECKS
  120. vfs_flags="cpiofs, extfs, tarfs"
  121. use_net_code=false
  122. AC_ARG_ENABLE([netcode],
  123. [ --enable-netcode Support for networking [[yes]]])
  124. if test "x$enable_netcode" != xno; then
  125. dnl FIXME: network checks should probably be in their own macro.
  126. AC_SEARCH_LIBS(socket, [xnet bsd socket inet], [have_socket=yes])
  127. if test x$have_socket = xyes; then
  128. AC_SEARCH_LIBS(gethostbyname, [bsd socket inet netinet])
  129. AC_CHECK_MEMBERS([struct linger.l_linger], , , [
  130. #include <sys/types.h>
  131. #include <sys/socket.h>
  132. ])
  133. AC_CHECK_FUNCS(pmap_set, , [
  134. AC_CHECK_LIB(rpc, pmap_set, [
  135. LIBS="-lrpc $LIBS"
  136. AC_DEFINE(HAVE_PMAP_SET)
  137. ])])
  138. AC_CHECK_FUNCS(pmap_getport pmap_getmaps rresvport)
  139. dnl add for source routing support setsockopt
  140. AC_CHECK_HEADERS(rpc/pmap_clnt.h, , , [
  141. #include <sys/types.h>
  142. #include <sys/socket.h>
  143. #include <netinet/in.h>
  144. #include <rpc/rpc.h>
  145. #include <rpc/pmap_prot.h>
  146. ])
  147. dnl
  148. dnl mcfs support
  149. dnl
  150. AC_ARG_WITH(mcfs,
  151. [ --with-mcfs Support mc-specific networking file system [[no]]],
  152. [if test "x$withval" != "xno"; then
  153. AC_DEFINE(WITH_MCFS, 1, [Define to enable mc-specific networking file system])
  154. vfs_flags="$vfs_flags, mcfs"
  155. use_mcfs=yes
  156. MC_MCSERVER_CHECKS
  157. fi]
  158. )
  159. vfs_flags="$vfs_flags, ftpfs, fish"
  160. use_net_code=true
  161. fi
  162. fi
  163. dnl
  164. dnl Samba support
  165. dnl
  166. use_smbfs=
  167. AC_ARG_WITH(samba,
  168. [ --with-samba Support smb virtual file system [[no]]],
  169. [if test "x$withval" != "xno"; then
  170. AC_DEFINE(WITH_SMBFS, 1, [Define to enable VFS over SMB])
  171. vfs_flags="$vfs_flags, smbfs"
  172. use_smbfs=yes
  173. fi
  174. ])
  175. if test -n "$use_smbfs"; then
  176. #################################################
  177. # set Samba configuration directory location
  178. configdir="/etc"
  179. AC_ARG_WITH(configdir,
  180. [ --with-configdir=DIR Where the Samba configuration files are [[/etc]]],
  181. [ case "$withval" in
  182. yes|no)
  183. #
  184. # Just in case anybody does it
  185. #
  186. AC_MSG_WARN([--with-configdir called without argument - will use default])
  187. ;;
  188. * )
  189. configdir="$withval"
  190. ;;
  191. esac]
  192. )
  193. AC_SUBST(configdir)
  194. AC_ARG_WITH(codepagedir,
  195. [ --with-codepagedir=DIR Where the Samba codepage files are],
  196. [ case "$withval" in
  197. yes|no)
  198. #
  199. # Just in case anybody does it
  200. #
  201. AC_MSG_WARN([--with-codepagedir called without argument - will use default])
  202. ;;
  203. esac]
  204. )
  205. fi
  206. dnl
  207. dnl Ext2fs undelete support
  208. dnl
  209. AC_ARG_WITH(ext2undel,
  210. [ --with-ext2undel Compile with ext2 undelete code [[yes if found]]],
  211. [if test x$withval != xno; then
  212. if test x$withval != xyes; then
  213. LDFLAGS="$LDFLAGS -L$withval/lib"
  214. CPPFLAGS="$CPPFLAGS -I$withval/include"
  215. fi
  216. AC_EXT2_UNDEL
  217. fi],[
  218. dnl Default: detect
  219. AC_CHECK_LIB(ext2fs, ext2fs_close, [AC_EXT2_UNDEL], , [-lcom_err])
  220. ])
  221. AC_DEFINE(USE_VFS, 1, [Define to enable VFS support])
  222. if $use_net_code; then
  223. AC_DEFINE(USE_NETCODE, 1, [Define to use networked VFS])
  224. fi
  225. ])
  226. AC_DEFUN([MC_VFS_CHECKS],[
  227. use_vfs=yes
  228. AC_ARG_WITH(vfs,
  229. [ --with-vfs Compile with the VFS code [[yes]]],
  230. use_vfs=$withval
  231. )
  232. case $use_vfs in
  233. yes) MC_WITH_VFS;;
  234. no) use_vfs=no;;
  235. *) use_vfs=no;;
  236. dnl Should we issue a warning?
  237. esac
  238. ])
  239. dnl
  240. dnl Filesystem information detection
  241. dnl
  242. dnl To get information about the disk, mount points, etc.
  243. dnl
  244. AC_DEFUN([AC_GET_FS_INFO], [
  245. AC_CHECK_HEADERS([fcntl.h utime.h])
  246. gl_LIST_MOUNTED_FILE_SYSTEMS([
  247. AC_DEFINE(HAVE_INFOMOUNT_LIST, 1,
  248. [Define if the list of mounted filesystems can be determined])],
  249. [AC_MSG_WARN([could not determine how to read list of mounted fs])])
  250. gl_FSUSAGE
  251. gl_FSTYPENAME
  252. ])
  253. dnl
  254. dnl Try using termcap database and link with libtermcap if possible.
  255. dnl
  256. AC_DEFUN([MC_USE_TERMCAP], [
  257. screen_msg="$screen_msg with termcap database"
  258. AC_MSG_NOTICE([using S-Lang screen library with termcap])
  259. AC_DEFINE(USE_TERMCAP, 1, [Define to use termcap database])
  260. AC_CHECK_LIB(termcap, tgoto, [MCLIBS="$MCLIBS -ltermcap"], , [$LIBS])
  261. ])
  262. dnl
  263. dnl Check if private functions are available for linking
  264. dnl
  265. AC_DEFUN([MC_SLANG_PRIVATE], [
  266. AC_CACHE_CHECK([if S-Lang exports private functions],
  267. [mc_cv_slang_private], [
  268. ac_save_LIBS="$LIBS"
  269. LIBS="$LIBS -lslang"
  270. AC_TRY_LINK([
  271. #ifdef HAVE_SLANG_SLANG_H
  272. #include <slang/slang.h>
  273. #else
  274. #include <slang.h>
  275. #endif
  276. #if SLANG_VERSION >= 10000
  277. extern unsigned int SLsys_getkey (void);
  278. #else
  279. extern unsigned int _SLsys_getkey (void);
  280. #endif
  281. ], [
  282. #if SLANG_VERSION >= 10000
  283. _SLsys_getkey ();
  284. #else
  285. SLsys_getkey ();
  286. #endif
  287. ],
  288. [mc_cv_slang_private=yes],
  289. [mc_cv_slang_private=no])
  290. LIBS="$ac_save_LIBS"
  291. ])
  292. if test x$mc_cv_slang_private = xyes; then
  293. AC_DEFINE(HAVE_SLANG_PRIVATE, 1,
  294. [Define if private S-Lang functions are available])
  295. fi
  296. ])
  297. dnl
  298. dnl Check if the installed S-Lang library uses termcap
  299. dnl
  300. AC_DEFUN([MC_SLANG_TERMCAP], [
  301. AC_CACHE_CHECK([if S-Lang uses termcap], [mc_cv_slang_termcap], [
  302. ac_save_LIBS="$LIBS"
  303. LIBS="$LIBS -lslang"
  304. AC_TRY_LINK([
  305. #ifdef HAVE_SLANG_SLANG_H
  306. #include <slang/slang.h>
  307. #else
  308. #include <slang.h>
  309. #endif
  310. ],
  311. [SLtt_get_terminfo(); SLtt_tgetflag("");],
  312. [mc_cv_slang_termcap=no],
  313. [mc_cv_slang_termcap=yes])
  314. LIBS="$ac_save_LIBS"
  315. ])
  316. if test x$mc_cv_slang_termcap = xyes; then
  317. MC_USE_TERMCAP
  318. fi
  319. ])
  320. dnl
  321. dnl Common code for MC_WITH_SLANG
  322. dnl
  323. AC_DEFUN([_MC_WITH_XSLANG], [
  324. screen_type=slang
  325. AC_DEFINE(HAVE_SLANG, 1,
  326. [Define to use S-Lang library for screen management])
  327. ])
  328. dnl
  329. dnl Check if the system S-Lang library can be used.
  330. dnl If not, and $1 is "strict", exit.
  331. dnl
  332. AC_DEFUN([MC_WITH_SLANG], [
  333. with_screen=slang
  334. dnl Check the header
  335. slang_h_found=
  336. AC_CHECK_HEADERS([slang.h slang/slang.h],
  337. [slang_h_found=yes; break])
  338. if test -z "$slang_h_found"; then
  339. AC_MSG_ERROR([Slang header not found])
  340. fi
  341. dnl Check if termcap is needed.
  342. dnl This check must be done before anything is linked against S-Lang.
  343. if test x$with_screen = xslang; then
  344. MC_SLANG_TERMCAP
  345. fi
  346. dnl Check the library
  347. if test x$with_screen = xslang; then
  348. AC_CHECK_LIB([slang], [SLang_init_tty], [MCLIBS="$MCLIBS -lslang"],
  349. AC_MSG_ERROR([Slang library not found]), ["$MCLIBS"])
  350. fi
  351. dnl Unless external S-Lang was requested, reject S-Lang with UTF-8 hacks
  352. if test x$with_screen = xslang; then
  353. AC_CHECK_LIB(
  354. [slang],
  355. [SLsmg_write_nwchars],
  356. [AC_MSG_ERROR([Rejecting S-Lang with UTF-8 support, it's not fully supported yet])])
  357. fi
  358. if test x$with_screen = xslang; then
  359. MC_SLANG_PRIVATE
  360. screen_type=slang
  361. screen_msg="S-Lang library (installed on the system)"
  362. else
  363. AC_MSG_ERROR([S-Lang library not found])
  364. fi
  365. _MC_WITH_XSLANG
  366. ])
  367. dnl
  368. dnl Use the ncurses library. It can only be requested explicitly,
  369. dnl so just fail if anything goes wrong.
  370. dnl
  371. dnl If ncurses exports the ESCDELAY variable it should be set to 0
  372. dnl or you'll have to press Esc three times to dismiss a dialog box.
  373. dnl
  374. AC_DEFUN([MC_WITH_NCURSES], [
  375. dnl has_colors() is specific to ncurses, it's not in the old curses
  376. save_LIBS="$LIBS"
  377. ncursesw_found=
  378. LIBS=
  379. AC_SEARCH_LIBS([addwstr], [ncursesw ncurses curses], [MCLIBS="$MCLIBS $LIBS";ncursesw_found=yes],
  380. [AC_MSG_WARN([Cannot find ncurses library, that support wide characters])])
  381. if test -z "$ncursesw_found"; then
  382. LIBS=
  383. AC_SEARCH_LIBS([has_colors], [ncurses curses], [MCLIBS="$MCLIBS $LIBS"],
  384. [AC_MSG_ERROR([Cannot find ncurses library])])
  385. fi
  386. dnl Check the header
  387. ncurses_h_found=
  388. AC_CHECK_HEADERS([ncursesw/curses.h ncurses/curses.h ncurses.h curses.h],
  389. [ncurses_h_found=yes; break])
  390. if test -z "$ncurses_h_found"; then
  391. AC_MSG_ERROR([Cannot find ncurses header file])
  392. fi
  393. screen_type=ncurses
  394. screen_msg="ncurses library"
  395. AC_DEFINE(USE_NCURSES, 1,
  396. [Define to use ncurses for screen management])
  397. AC_CACHE_CHECK([for ESCDELAY variable],
  398. [mc_cv_ncurses_escdelay],
  399. [AC_TRY_LINK([], [
  400. extern int ESCDELAY;
  401. ESCDELAY = 0;
  402. ],
  403. [mc_cv_ncurses_escdelay=yes],
  404. [mc_cv_ncurses_escdelay=no])
  405. ])
  406. if test "$mc_cv_ncurses_escdelay" = yes; then
  407. AC_DEFINE(HAVE_ESCDELAY, 1,
  408. [Define if ncurses has ESCDELAY variable])
  409. fi
  410. AC_CHECK_FUNCS(resizeterm)
  411. LIBS="$save_LIBS"
  412. ])
  413. dnl
  414. dnl Use the ncurses library. It can only be requested explicitly,
  415. dnl so just fail if anything goes wrong.
  416. dnl
  417. dnl If ncurses exports the ESCDELAY variable it should be set to 0
  418. dnl or you'll have to press Esc three times to dismiss a dialog box.
  419. dnl
  420. AC_DEFUN([MC_WITH_NCURSESW], [
  421. dnl has_colors() is specific to ncurses, it's not in the old curses
  422. save_LIBS="$LIBS"
  423. LIBS=
  424. AC_SEARCH_LIBS([has_colors], [ncursesw], [MCLIBS="$MCLIBS $LIBS"],
  425. [AC_MSG_ERROR([Cannot find ncursesw library])])
  426. dnl Check the header
  427. ncurses_h_found=
  428. AC_CHECK_HEADERS([ncursesw/curses.h],
  429. [ncursesw_h_found=yes; break])
  430. if test -z "$ncursesw_h_found"; then
  431. AC_MSG_ERROR([Cannot find ncursesw header file])
  432. fi
  433. screen_type=ncursesw
  434. screen_msg="ncursesw library"
  435. AC_DEFINE(USE_NCURSESW, 1,
  436. [Define to use ncursesw for screen management])
  437. AC_CACHE_CHECK([for ESCDELAY variable],
  438. [mc_cv_ncursesw_escdelay],
  439. [AC_TRY_LINK([], [
  440. extern int ESCDELAY;
  441. ESCDELAY = 0;
  442. ],
  443. [mc_cv_ncursesw_escdelay=yes],
  444. [mc_cv_ncursesw_escdelay=no])
  445. ])
  446. if test "$mc_cv_ncursesw_escdelay" = yes; then
  447. AC_DEFINE(HAVE_ESCDELAY, 1,
  448. [Define if ncursesw has ESCDELAY variable])
  449. fi
  450. AC_CHECK_FUNCS(resizeterm)
  451. LIBS="$save_LIBS"
  452. ])
  453. dnl
  454. dnl Check for ext2fs recovery code
  455. dnl
  456. AC_DEFUN([AC_EXT2_UNDEL], [
  457. MC_UNDELFS_CHECKS
  458. if test "$ext2fs_undel" = yes; then
  459. AC_MSG_NOTICE([using ext2fs file recovery code])
  460. vfs_flags="${vfs_flags}, undelfs"
  461. use_undelfs=yes
  462. MCLIBS="$MCLIBS $EXT2FS_UNDEL_LIBS"
  463. else
  464. AC_MSG_NOTICE([not using ext2fs file recovery code])
  465. fi
  466. ])
  467. dnl
  468. dnl Check whether the g_module_* family of functions works
  469. dnl on this system. We need to know that at the compile time to
  470. dnl decide whether to link with X11.
  471. dnl
  472. AC_DEFUN([AC_G_MODULE_SUPPORTED], [
  473. AC_CACHE_CHECK([if gmodule functionality is supported], mc_cv_g_module_supported, [
  474. ac_save_CFLAGS="$CFLAGS"
  475. ac_save_LIBS="$LIBS"
  476. CFLAGS="$CFLAGS $GMODULE_CFLAGS"
  477. LIBS="$GMODULE_LIBS $LIBS"
  478. AC_TRY_RUN([
  479. #include <gmodule.h>
  480. int main ()
  481. {
  482. int ret = (g_module_supported () == TRUE) ? 0 : 1;
  483. return ret;
  484. }
  485. ],
  486. [mc_cv_g_module_supported=yes],
  487. [mc_cv_g_module_supported=no],
  488. [mc_cv_g_module_supported=no]
  489. )
  490. CFLAGS="$ac_save_CFLAGS"
  491. LIBS="$ac_save_LIBS"
  492. ])
  493. if test "$mc_cv_g_module_supported" = yes; then
  494. AC_DEFINE(HAVE_GMODULE, 1,
  495. [Define if gmodule functionality is supported])
  496. fi
  497. ])