You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

154 lines
6.0 KiB

  1. # -*- Autoconf -*-
  2. # Run autoreconf -fi to generate a configure script from this file.
  3. AC_PREREQ([2.69])
  4. AC_INIT([i3lock], [2.10], [https://github.com/i3/i3lock/issues])
  5. # For AX_EXTEND_SRCDIR
  6. AX_ENABLE_BUILDDIR
  7. AM_INIT_AUTOMAKE([foreign subdir-objects -Wall no-dist-gzip dist-bzip2])
  8. # Default to silent rules, use V=1 to get verbose compilation output.
  9. AM_SILENT_RULES([yes])
  10. # Make it possible to disable maintainer mode to disable re-generation of build
  11. # system files.
  12. AM_MAINTAINER_MODE([enable])
  13. AC_CONFIG_SRCDIR([i3lock.c])
  14. AC_CONFIG_HEADERS([config.h])
  15. AC_CONFIG_MACRO_DIR([m4])
  16. dnl Verify macros defined in m4/ such as AX_SANITIZERS are not present in the
  17. dnl output, i.e. are replaced as expected. This line results in a better error
  18. dnl message when using aclocal < 1.13 (which does not understand
  19. dnl AC_CONFIG_MACRO_DIR) without passing the -I m4 parameter.
  20. m4_pattern_forbid([AX_SANITIZERS])
  21. # Verify we are using GNU make because we use '%'-style pattern rules in
  22. # Makefile.am, which are a GNU make extension. Pull requests to replace
  23. # '%'-style pattern rules with a more portable alternative are welcome.
  24. AX_CHECK_GNU_MAKE
  25. AS_VAR_IF([_cv_gnu_make_command], [""], [AC_MSG_ERROR([the i3lock Makefile.am requires GNU make])])
  26. AX_EXTEND_SRCDIR
  27. AS_IF([test -d ${srcdir}/.git],
  28. [
  29. VERSION="$(git -C ${srcdir} describe --tags --abbrev=0)"
  30. I3LOCK_VERSION="$(git -C ${srcdir} describe --tags --always) ($(git -C ${srcdir} log --pretty=format:%cd --date=short -n1), branch \\\"$(git -C ${srcdir} describe --tags --always --all | sed s:heads/::)\\\")"
  31. # Mirrors what libi3/is_debug_build.c does:
  32. is_release=$(test $(echo "${I3LOCK_VERSION}" | cut -d '(' -f 1 | wc -m) -lt 10 && echo yes || echo no)
  33. ],
  34. [
  35. VERSION="$(cut -d '-' -f 1 ${srcdir}/I3LOCK_VERSION | cut -d ' ' -f 1)"
  36. I3LOCK_VERSION="$(sed -e 's/@<:@\"?\\@:>@/\\&/g' ${srcdir}/I3LOCK_VERSION)"
  37. is_release="$(grep -q non-git ${srcdir}/I3LOCK_VERSION && echo no || echo yes)"
  38. ])
  39. AC_SUBST([I3LOCK_VERSION], [$I3LOCK_VERSION])
  40. AC_DEFINE_UNQUOTED([I3LOCK_VERSION], ["${I3LOCK_VERSION}"], [i3lock version])
  41. AX_CODE_COVERAGE
  42. dnl is_release must be lowercase because AX_CHECK_ENABLE_DEBUG calls m4_tolower
  43. dnl on its fourth argument.
  44. AX_CHECK_ENABLE_DEBUG([yes], , [UNUSED_NDEBUG], [$is_release])
  45. AC_PROG_CC_C99
  46. # For strnlen() and vasprintf().
  47. AC_USE_SYSTEM_EXTENSIONS
  48. # Checks for typedefs, structures, and compiler characteristics.
  49. AC_CHECK_HEADER_STDBOOL
  50. dnl The error message should include the specific type which could not be
  51. dnl found, but I do not see a way to achieve that.
  52. AC_CHECK_TYPES([mode_t, off_t, pid_t, size_t, ssize_t], , [AC_MSG_FAILURE([cannot find required type])])
  53. # Checks for library functions.
  54. AC_FUNC_FORK
  55. AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
  56. AC_FUNC_STRNLEN
  57. AC_CHECK_FUNCS([atexit dup2 ftruncate getcwd gettimeofday localtime_r memchr memset mkdir rmdir setlocale socket strcasecmp strchr strdup strerror strncasecmp strndup strrchr strspn strstr strtol strtoul], , [AC_MSG_FAILURE([cannot find the $ac_func function, which i3lock requires])])
  58. # Checks for libraries.
  59. AC_SEARCH_LIBS([floor], [m], , [AC_MSG_FAILURE([cannot find the required floor() function despite trying to link with -lm])])
  60. # libev does not ship with a pkg-config file :(.
  61. AC_SEARCH_LIBS([ev_run], [ev], , [AC_MSG_FAILURE([cannot find the required ev_run() function despite trying to link with -lev])])
  62. AC_SEARCH_LIBS([shm_open], [rt])
  63. # Only disable PAM on OpenBSD where i3lock uses BSD Auth instead
  64. case "$host" in
  65. *-openbsd*)
  66. # Nothing yet.
  67. ;;
  68. *)
  69. AC_SEARCH_LIBS([pam_authenticate], [pam])
  70. ;;
  71. esac
  72. AC_SEARCH_LIBS([iconv_open], [iconv], , [AC_MSG_FAILURE([cannot find the required iconv_open() function despite trying to link with -liconv])])
  73. dnl Each prefix corresponds to a source tarball which users might have
  74. dnl downloaded in a newer version and would like to overwrite.
  75. PKG_CHECK_MODULES([XCB], [xcb xcb-xkb xcb-xinerama xcb-randr xcb-composite])
  76. PKG_CHECK_MODULES([XCB_IMAGE], [xcb-image])
  77. PKG_CHECK_MODULES([XCB_UTIL], [xcb-event xcb-util xcb-atom])
  78. PKG_CHECK_MODULES([XCB_UTIL_XRM], [xcb-xrm])
  79. PKG_CHECK_MODULES([XKBCOMMON], [xkbcommon xkbcommon-x11])
  80. PKG_CHECK_MODULES([CAIRO], [cairo])
  81. # Checks for programs.
  82. AC_PROG_AWK
  83. AC_PROG_CPP
  84. AC_PROG_INSTALL
  85. AC_PROG_MAKE_SET
  86. AC_PROG_RANLIB
  87. AC_PROG_LN_S
  88. AM_PROG_AR
  89. AX_FLAGS_WARN_ALL
  90. AX_CHECK_COMPILE_FLAG([-Wunused-value], [AX_APPEND_FLAG([-Wunused-value], [AM_CFLAGS])])
  91. AC_SUBST(AM_CFLAGS)
  92. # Checks for header files.
  93. AC_CHECK_HEADERS([fcntl.h float.h inttypes.h limits.h locale.h netinet/in.h paths.h stddef.h stdint.h stdlib.h string.h sys/param.h sys/socket.h sys/time.h unistd.h], , [AC_MSG_FAILURE([cannot find the $ac_header header, which i3lock requires])])
  94. AC_CONFIG_FILES([Makefile])
  95. # Enable address sanitizer for non-release builds. The performance hit is a
  96. # 50% increase of wallclock time for the testsuite on my machine.
  97. if test x$is_release = xyes; then
  98. default_sanitizers=
  99. else
  100. default_sanitizers=address
  101. fi
  102. AX_SANITIZERS(, [$default_sanitizers], [AC_DEFINE([I3LOCK_ASAN_ENABLED], [], [Enable ASAN])])
  103. AC_OUTPUT
  104. in_git_worktree=`git rev-parse --is-inside-work-tree 2>/dev/null`
  105. if [[ "$in_git_worktree" = "true" ]]; then
  106. git_dir=`git rev-parse --git-dir 2>/dev/null`
  107. srcdir=`dirname "$git_dir"`
  108. exclude_dir=`pwd | sed "s,^$srcdir,,g"`
  109. if ! grep -q "^$exclude_dir" "$git_dir/info/exclude"; then
  110. echo "$exclude_dir" >> "$git_dir/info/exclude"
  111. fi
  112. fi
  113. echo \
  114. "--------------------------------------------------------------------------------
  115. build configured:
  116. AS_HELP_STRING([i3lock version:], [`echo ${I3LOCK_VERSION} | sed 's,\\\\,,g'`])
  117. AS_HELP_STRING([is release version:], [${is_release}])
  118. AS_HELP_STRING([enable debug flags:], [${ax_enable_debug}])
  119. AS_HELP_STRING([code coverage:], [${CODE_COVERAGE_ENABLED}])
  120. AS_HELP_STRING([enabled sanitizers:], [${ax_enabled_sanitizers}])
  121. To compile, run:
  122. cd `pwd` && make -j8
  123. --------------------------------------------------------------------------------"