summaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
authorSimeon Simeonov2020-03-12 12:30:51 +0100
committerSimeon Simeonov2020-03-12 12:30:51 +0100
commit69a05d516bd0c7e369a0ba1fb78aac57a5ea26f2 (patch)
tree87e37110ea0e328533a41c3b16b64036ff132641 /configure.ac
Initial commit for the last i3lock commit at this time f3b061233e28ad0cf920c9421adc2459b6920812
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac154
1 files changed, 154 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..474f750
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,154 @@
1# -*- Autoconf -*-
2# Run autoreconf -fi to generate a configure script from this file.
3
4AC_PREREQ([2.69])
5AC_INIT([i3lock], [2.12], [https://github.com/i3/i3lock/issues])
6# For AX_EXTEND_SRCDIR
7AX_ENABLE_BUILDDIR
8AM_INIT_AUTOMAKE([foreign subdir-objects -Wall no-dist-gzip dist-bzip2])
9# Default to silent rules, use V=1 to get verbose compilation output.
10AM_SILENT_RULES([yes])
11# Make it possible to disable maintainer mode to disable re-generation of build
12# system files.
13AM_MAINTAINER_MODE([enable])
14AC_CONFIG_SRCDIR([i3lock.c])
15AC_CONFIG_HEADERS([config.h])
16AC_CONFIG_MACRO_DIR([m4])
17
18dnl Verify macros defined in m4/ such as AX_SANITIZERS are not present in the
19dnl output, i.e. are replaced as expected. This line results in a better error
20dnl message when using aclocal < 1.13 (which does not understand
21dnl AC_CONFIG_MACRO_DIR) without passing the -I m4 parameter.
22m4_pattern_forbid([AX_SANITIZERS])
23
24# Verify we are using GNU make because we use '%'-style pattern rules in
25# Makefile.am, which are a GNU make extension. Pull requests to replace
26# '%'-style pattern rules with a more portable alternative are welcome.
27AX_CHECK_GNU_MAKE
28AS_VAR_IF([_cv_gnu_make_command], [""], [AC_MSG_ERROR([the i3lock Makefile.am requires GNU make])])
29
30AX_EXTEND_SRCDIR
31
32AS_IF([test -d ${srcdir}/.git],
33 [
34 VERSION="$(git -C ${srcdir} describe --tags --abbrev=0)"
35 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/::)\\\")"
36 # Mirrors what libi3/is_debug_build.c does:
37 is_release=$(test $(echo "${I3LOCK_VERSION}" | cut -d '(' -f 1 | wc -m) -lt 10 && echo yes || echo no)
38 ],
39 [
40 VERSION="$(cut -d '-' -f 1 ${srcdir}/I3LOCK_VERSION | cut -d ' ' -f 1)"
41 I3LOCK_VERSION="$(sed -e 's/@<:@\"?\\@:>@/\\&/g' ${srcdir}/I3LOCK_VERSION)"
42 is_release="$(grep -q non-git ${srcdir}/I3LOCK_VERSION && echo no || echo yes)"
43 ])
44AC_SUBST([I3LOCK_VERSION], [$I3LOCK_VERSION])
45AC_DEFINE_UNQUOTED([I3LOCK_VERSION], ["${I3LOCK_VERSION}"], [i3lock version])
46
47AX_CODE_COVERAGE
48
49dnl is_release must be lowercase because AX_CHECK_ENABLE_DEBUG calls m4_tolower
50dnl on its fourth argument.
51AX_CHECK_ENABLE_DEBUG([yes], , [UNUSED_NDEBUG], [$is_release])
52
53AC_PROG_CC_C99
54
55# For strnlen() and vasprintf().
56AC_USE_SYSTEM_EXTENSIONS
57
58# Checks for typedefs, structures, and compiler characteristics.
59AC_CHECK_HEADER_STDBOOL
60dnl The error message should include the specific type which could not be
61dnl found, but I do not see a way to achieve that.
62AC_CHECK_TYPES([mode_t, off_t, pid_t, size_t, ssize_t], , [AC_MSG_FAILURE([cannot find required type])])
63
64# Checks for library functions.
65AC_FUNC_FORK
66AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
67AC_FUNC_STRNLEN
68AC_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])])
69
70# Checks for libraries.
71
72AC_SEARCH_LIBS([floor], [m], , [AC_MSG_FAILURE([cannot find the required floor() function despite trying to link with -lm])])
73
74# libev does not ship with a pkg-config file :(.
75AC_SEARCH_LIBS([ev_run], [ev], , [AC_MSG_FAILURE([cannot find the required ev_run() function despite trying to link with -lev])])
76
77AC_SEARCH_LIBS([shm_open], [rt])
78
79# Only disable PAM on OpenBSD where i3lock uses BSD Auth instead
80case "$host" in
81 *-openbsd*)
82 # Nothing yet.
83 ;;
84 *)
85 AC_SEARCH_LIBS([pam_authenticate], [pam])
86 ;;
87esac
88
89AC_SEARCH_LIBS([iconv_open], [iconv], , [AC_MSG_FAILURE([cannot find the required iconv_open() function despite trying to link with -liconv])])
90
91dnl Each prefix corresponds to a source tarball which users might have
92dnl downloaded in a newer version and would like to overwrite.
93PKG_CHECK_MODULES([XCB], [xcb xcb-xkb xcb-xinerama xcb-randr])
94PKG_CHECK_MODULES([XCB_IMAGE], [xcb-image])
95PKG_CHECK_MODULES([XCB_UTIL], [xcb-event xcb-util xcb-atom])
96PKG_CHECK_MODULES([XCB_UTIL_XRM], [xcb-xrm])
97PKG_CHECK_MODULES([XKBCOMMON], [xkbcommon xkbcommon-x11])
98PKG_CHECK_MODULES([CAIRO], [cairo])
99
100# Checks for programs.
101AC_PROG_AWK
102AC_PROG_CPP
103AC_PROG_INSTALL
104AC_PROG_MAKE_SET
105AC_PROG_RANLIB
106AC_PROG_LN_S
107
108AM_PROG_AR
109
110AX_FLAGS_WARN_ALL
111AX_CHECK_COMPILE_FLAG([-Wunused-value], [AX_APPEND_FLAG([-Wunused-value], [AM_CFLAGS])])
112AC_SUBST(AM_CFLAGS)
113
114# Checks for header files.
115AC_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])])
116
117AC_CONFIG_FILES([Makefile])
118
119# Enable address sanitizer for non-release builds. The performance hit is a
120# 50% increase of wallclock time for the testsuite on my machine.
121if test x$is_release = xyes; then
122 default_sanitizers=
123else
124 default_sanitizers=address
125fi
126AX_SANITIZERS(, [$default_sanitizers], [AC_DEFINE([I3LOCK_ASAN_ENABLED], [], [Enable ASAN])])
127
128AC_OUTPUT
129
130in_git_worktree=`git rev-parse --is-inside-work-tree 2>/dev/null`
131if [[ "$in_git_worktree" = "true" ]]; then
132 git_dir=`git rev-parse --git-dir 2>/dev/null`
133 srcdir=`dirname "$git_dir"`
134 exclude_dir=`pwd | sed "s,^$srcdir,,g"`
135 if ! grep -q "^$exclude_dir" "$git_dir/info/exclude"; then
136 echo "$exclude_dir" >> "$git_dir/info/exclude"
137 fi
138fi
139
140echo \
141"--------------------------------------------------------------------------------
142build configured:
143
144AS_HELP_STRING([i3lock version:], [`echo ${I3LOCK_VERSION} | sed 's,\\\\,,g'`])
145AS_HELP_STRING([is release version:], [${is_release}])
146
147AS_HELP_STRING([enable debug flags:], [${ax_enable_debug}])
148AS_HELP_STRING([code coverage:], [${CODE_COVERAGE_ENABLED}])
149AS_HELP_STRING([enabled sanitizers:], [${ax_enabled_sanitizers}])
150
151To compile, run:
152
153 cd `pwd` && make -j8
154--------------------------------------------------------------------------------"