]> git.sur5r.net Git - i3/i3/blob - configure.ac
9e61d997b51022cd0f10dbd41ccf9e6282864bc0
[i3/i3] / configure.ac
1 #                                               -*- Autoconf -*-
2 # Run autoreconf -fi to generate a configure script from this file.
3
4 AC_PREREQ([2.69])
5 AC_INIT([i3], [4.12], [https://github.com/i3/i3/issues])
6 # For AX_EXTEND_SRCDIR
7 AX_ENABLE_BUILDDIR
8 AM_INIT_AUTOMAKE([foreign subdir-objects -Wall no-dist-gzip dist-bzip2])
9 # Default to silent rules, use V=1 to get verbose compilation output.
10 AM_SILENT_RULES([yes])
11 # Make it possible to disable maintainer mode to disable re-generation of build
12 # system files.
13 AM_MAINTAINER_MODE([enable])
14 AC_CONFIG_SRCDIR([libi3/ipc_recv_message.c])
15 AC_CONFIG_HEADERS([config.h])
16 AC_CONFIG_MACRO_DIR([m4])
17
18 # Verify we are using GNU make because we use '%'-style pattern rules in
19 # Makefile.am, which are a GNU make extension. Pull requests to replace
20 # '%'-style pattern rules with a more portable alternative are welcome.
21 AX_CHECK_GNU_MAKE
22 AS_VAR_IF([_cv_gnu_make_command], [""], [AC_MSG_ERROR([the i3 Makefile.am requires GNU make])])
23
24 AX_EXTEND_SRCDIR
25
26 AS_IF([test -d ${srcdir}/.git],
27       [
28         VERSION="$(git describe --tags --abbrev=0)"
29         I3_VERSION="$(git describe --tags --always) ($(git log --pretty=format:%cd --date=short -n1), branch \\\"$(git describe --tags --always --all | sed s:heads/::)\\\")"
30         # Mirrors what libi3/is_debug_build.c does:
31         is_release=$(test $(echo "${I3_VERSION}" | cut -d '(' -f 1 | wc -m) -lt 10 && echo yes || echo no)
32       ],
33       [
34         VERSION="$(cut -d '-' -f 1 ${srcdir}/I3_VERSION | cut -d ' ' -f 1)"
35         I3_VERSION="$(sed -e 's/@<:@\"?\\@:>@/\\&/g' ${srcdir}/I3_VERSION)"
36         is_release="$(grep -q non-git ${srcdir}/I3_VERSION && echo no || echo yes)"
37       ])
38 AC_SUBST([I3_VERSION], [$I3_VERSION])
39 MAJOR_VERSION="$(echo ${VERSION} | cut -d '.' -f 1)"
40 MINOR_VERSION="$(echo ${VERSION} | cut -d '.' -f 2)"
41 PATCH_VERSION="$(echo ${VERSION} | cut -d '.' -f 3)"
42 AS_IF([test "x${PATCH_VERSION}" = x], [PATCH_VERSION=0])
43 AC_DEFINE_UNQUOTED([I3_VERSION], ["${I3_VERSION}"], [i3 version])
44 AC_DEFINE_UNQUOTED([MAJOR_VERSION], [${MAJOR_VERSION}], [i3 major version])
45 AC_DEFINE_UNQUOTED([MINOR_VERSION], [${MINOR_VERSION}], [i3 minor version])
46 AC_DEFINE_UNQUOTED([PATCH_VERSION], [${PATCH_VERSION}], [i3 patch version])
47
48 AX_CODE_COVERAGE
49
50 dnl is_release must be lowercase because AX_CHECK_ENABLE_DEBUG calls m4_tolower
51 dnl on its fourth argument.
52 AX_CHECK_ENABLE_DEBUG([yes], , [UNUSED_NDEBUG], [$is_release])
53
54 AC_PROG_CC_C99
55
56 AC_DEFINE_UNQUOTED(SYSCONFDIR, "`eval echo $sysconfdir`", [Location of system configuration files])
57
58 # For strnlen() and vasprintf().
59 AC_USE_SYSTEM_EXTENSIONS
60
61 # Checks for typedefs, structures, and compiler characteristics.
62 AC_CHECK_HEADER_STDBOOL
63 dnl The error message should include the specific type which could not be
64 dnl found, but I do not see a way to achieve that.
65 AC_CHECK_TYPES([mode_t, off_t, pid_t, size_t, ssize_t], , [AC_MSG_FAILURE([cannot find required type])])
66
67 # Checks for library functions.
68 AC_FUNC_FORK
69 AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
70 AC_FUNC_STRNLEN
71 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 i3 requires])])
72
73 # Checks for libraries.
74
75 AC_SEARCH_LIBS([floor], [m], , [AC_MSG_FAILURE([cannot find the required floor() function despite trying to link with -lm])])
76
77 # libev does not ship with a pkg-config file :(.
78 AC_SEARCH_LIBS([ev_run], [ev], , [AC_MSG_FAILURE([cannot find the required ev_run() function despite trying to link with -lev])])
79
80 AC_SEARCH_LIBS([shm_open], [rt])
81
82 AX_PTHREAD
83
84 dnl Each prefix corresponds to a source tarball which users might have
85 dnl downloaded in a newer version and would like to overwrite.
86 PKG_CHECK_MODULES([LIBSN], [libstartup-notification-1.0])
87 PKG_CHECK_MODULES([XCB], [xcb xcb-xkb xcb-xinerama xcb-randr])
88 PKG_CHECK_MODULES([XCB_UTIL], [xcb-event xcb-util])
89 PKG_CHECK_MODULES([XCB_UTIL_CURSOR], [xcb-cursor])
90 PKG_CHECK_MODULES([XCB_UTIL_KEYSYMS], [xcb-keysyms])
91 PKG_CHECK_MODULES([XCB_UTIL_WM], [xcb-icccm])
92 PKG_CHECK_MODULES([XCB_UTIL_XRM], [xcb-xrm])
93 PKG_CHECK_MODULES([XKBCOMMON], [xkbcommon xkbcommon-x11])
94 PKG_CHECK_MODULES([YAJL], [yajl])
95 PKG_CHECK_MODULES([LIBPCRE], [libpcre >= 8.10])
96 PKG_CHECK_MODULES([PANGOCAIRO], [cairo >= 1.14.4 pangocairo])
97
98 # Checks for programs.
99 AC_PROG_AWK
100 AC_PROG_CPP
101 AC_PROG_INSTALL
102 AC_PROG_MAKE_SET
103 AC_PROG_RANLIB
104 AC_PROG_LN_S
105
106 AC_PATH_PROG([PATH_ASCIIDOC], [asciidoc])
107 AC_PATH_PROG([PATH_XMLTO], [xmlto])
108 AC_PATH_PROG([PATH_POD2MAN], [pod2man])
109
110 AM_CONDITIONAL([BUILD_MANS], [test x$PATH_ASCIIDOC != x && test x$PATH_XMLTO != x && test x$PATH_POD2MAN != x])
111 AM_CONDITIONAL([BUILD_DOCS], [test x$PATH_ASCIIDOC != x])
112
113 AM_PROG_AR
114
115 AX_FLAGS_WARN_ALL
116 AX_CHECK_COMPILE_FLAG([-Wunused-value], [AX_APPEND_FLAG([-Wunused-value], [AM_CFLAGS])])
117 AC_SUBST(AM_CFLAGS)
118
119 # Checks for header files.
120 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 i3 requires])])
121
122 AC_CONFIG_FILES([Makefile testcases/lib/i3test.pm man/asciidoc.conf])
123 AC_CONFIG_FILES([testcases/complete-run.pl], [chmod +x testcases/complete-run.pl])
124
125 # Enable address sanitizer for non-release builds. The performance hit is a
126 # 50% increase of wallclock time for the testsuite on my machine.
127 if test x$is_release = xyes; then
128         default_sanitizers=
129 else
130         default_sanitizers=address
131 fi
132 AX_SANITIZERS(, [$default_sanitizers], [AC_DEFINE([I3_ASAN_ENABLED], [], [Enable ASAN])])
133
134 AC_OUTPUT
135
136 if test -z "${BUILD_DOCS_TRUE}"; then
137         print_BUILD_DOCS=yes
138 else
139         print_BUILD_DOCS=no
140 fi
141
142
143 if test -z "${BUILD_MANS_TRUE}"; then
144         print_BUILD_MANS=yes
145 else
146         print_BUILD_MANS=no
147 fi
148
149 git_dir=`git rev-parse --git-dir 2>/dev/null`
150 if test -n "$git_dir"; then
151         srcdir=`dirname "$git_dir"`
152         exclude_dir=`pwd | sed "s,^$srcdir,,g"`
153         if ! grep -q "^$exclude_dir" "$git_dir/info/exclude"; then
154                 echo "$exclude_dir" >> "$git_dir/info/exclude"
155         fi
156 fi
157
158 echo \
159 "--------------------------------------------------------------------------------
160 build configured:
161
162 AS_HELP_STRING([i3 version:], [`echo ${I3_VERSION} | sed 's,\\\\,,g'`])
163 AS_HELP_STRING([is release version:], [${is_release}])
164
165 AS_HELP_STRING([build manpages:], [${print_BUILD_MANS}])
166 AS_HELP_STRING([build docs:], [${print_BUILD_DOCS}])
167 AS_HELP_STRING([enable debug flags:], [${ax_enable_debug}])
168 AS_HELP_STRING([code coverage:], [${CODE_COVERAGE_ENABLED}])
169 AS_HELP_STRING([enabled sanitizers:], [${ax_enabled_sanitizers}])
170
171 To compile, run:
172
173   cd `pwd` && make -j8
174 --------------------------------------------------------------------------------"