]> git.sur5r.net Git - i3/i3/blob - configure.ac
Merge pull request #2629 from nmschulte/next
[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.13], [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 dnl Verify macros defined in m4/ such as AX_SANITIZERS are not present in the
19 dnl output, i.e. are replaced as expected. This line results in a better error
20 dnl message when using aclocal < 1.13 (which does not understand
21 dnl AC_CONFIG_MACRO_DIR) without passing the -I m4 parameter.
22 m4_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.
27 AX_CHECK_GNU_MAKE
28 AS_VAR_IF([_cv_gnu_make_command], [""], [AC_MSG_ERROR([the i3 Makefile.am requires GNU make])])
29
30 AX_EXTEND_SRCDIR
31
32 AS_IF([test -d ${srcdir}/.git],
33       [
34         VERSION="$(git -C ${srcdir} describe --tags --abbrev=0)"
35         I3_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 "${I3_VERSION}" | cut -d '(' -f 1 | wc -m) -lt 10 && echo yes || echo no)
38       ],
39       [
40         VERSION="$(cut -d '-' -f 1 ${srcdir}/I3_VERSION | cut -d ' ' -f 1)"
41         I3_VERSION="$(sed -e 's/@<:@\"?\\@:>@/\\&/g' ${srcdir}/I3_VERSION)"
42         is_release="$(grep -q non-git ${srcdir}/I3_VERSION && echo no || echo yes)"
43       ])
44 AC_SUBST([I3_VERSION], [$I3_VERSION])
45 MAJOR_VERSION="$(echo ${VERSION} | cut -d '.' -f 1)"
46 MINOR_VERSION="$(echo ${VERSION} | cut -d '.' -f 2)"
47 PATCH_VERSION="$(echo ${VERSION} | cut -d '.' -f 3)"
48 AS_IF([test "x${PATCH_VERSION}" = x], [PATCH_VERSION=0])
49 AC_DEFINE_UNQUOTED([I3_VERSION], ["${I3_VERSION}"], [i3 version])
50 AC_DEFINE_UNQUOTED([MAJOR_VERSION], [${MAJOR_VERSION}], [i3 major version])
51 AC_DEFINE_UNQUOTED([MINOR_VERSION], [${MINOR_VERSION}], [i3 minor version])
52 AC_DEFINE_UNQUOTED([PATCH_VERSION], [${PATCH_VERSION}], [i3 patch version])
53
54 AX_CODE_COVERAGE
55
56 dnl is_release must be lowercase because AX_CHECK_ENABLE_DEBUG calls m4_tolower
57 dnl on its fourth argument.
58 AX_CHECK_ENABLE_DEBUG([yes], , [UNUSED_NDEBUG], [$is_release])
59
60 AC_PROG_CC_C99
61
62 AC_DEFINE_UNQUOTED(SYSCONFDIR, "`eval echo $sysconfdir`", [Location of system configuration files])
63
64 # For strnlen() and vasprintf().
65 AC_USE_SYSTEM_EXTENSIONS
66
67 # Checks for typedefs, structures, and compiler characteristics.
68 AC_CHECK_HEADER_STDBOOL
69 dnl The error message should include the specific type which could not be
70 dnl found, but I do not see a way to achieve that.
71 AC_CHECK_TYPES([mode_t, off_t, pid_t, size_t, ssize_t], , [AC_MSG_FAILURE([cannot find required type])])
72
73 # Checks for library functions.
74 AC_FUNC_FORK
75 AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
76 AC_FUNC_STRNLEN
77 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])])
78
79 # Checks for libraries.
80
81 AC_SEARCH_LIBS([floor], [m], , [AC_MSG_FAILURE([cannot find the required floor() function despite trying to link with -lm])])
82
83 # libev does not ship with a pkg-config file :(.
84 AC_SEARCH_LIBS([ev_run], [ev], , [AC_MSG_FAILURE([cannot find the required ev_run() function despite trying to link with -lev])])
85
86 AC_SEARCH_LIBS([shm_open], [rt])
87
88 AC_SEARCH_LIBS([iconv_open], [iconv], , [AC_MSG_FAILURE([cannot find the required iconv_open() function despite trying to link with -liconv])])
89
90 AX_PTHREAD
91
92 dnl Each prefix corresponds to a source tarball which users might have
93 dnl downloaded in a newer version and would like to overwrite.
94 PKG_CHECK_MODULES([LIBSN], [libstartup-notification-1.0])
95 PKG_CHECK_MODULES([XCB], [xcb xcb-xkb xcb-xinerama xcb-randr])
96 PKG_CHECK_MODULES([XCB_UTIL], [xcb-event xcb-util])
97 PKG_CHECK_MODULES([XCB_UTIL_CURSOR], [xcb-cursor])
98 PKG_CHECK_MODULES([XCB_UTIL_KEYSYMS], [xcb-keysyms])
99 PKG_CHECK_MODULES([XCB_UTIL_WM], [xcb-icccm])
100 PKG_CHECK_MODULES([XCB_UTIL_XRM], [xcb-xrm])
101 PKG_CHECK_MODULES([XKBCOMMON], [xkbcommon xkbcommon-x11])
102 PKG_CHECK_MODULES([YAJL], [yajl])
103 PKG_CHECK_MODULES([LIBPCRE], [libpcre >= 8.10])
104 PKG_CHECK_MODULES([PANGOCAIRO], [cairo >= 1.14.4 pangocairo])
105
106 # Checks for programs.
107 AC_PROG_AWK
108 AC_PROG_CPP
109 AC_PROG_INSTALL
110 AC_PROG_MAKE_SET
111 AC_PROG_RANLIB
112 AC_PROG_LN_S
113
114 AC_PATH_PROG([PATH_ASCIIDOC], [asciidoc])
115 AC_PATH_PROG([PATH_XMLTO], [xmlto])
116 AC_PATH_PROG([PATH_POD2MAN], [pod2man])
117
118 AM_CONDITIONAL([BUILD_MANS], [test x$PATH_ASCIIDOC != x && test x$PATH_XMLTO != x && test x$PATH_POD2MAN != x])
119 AM_CONDITIONAL([BUILD_DOCS], [test x$PATH_ASCIIDOC != x])
120
121 AM_PROG_AR
122
123 AX_FLAGS_WARN_ALL
124 AX_CHECK_COMPILE_FLAG([-Wunused-value], [AX_APPEND_FLAG([-Wunused-value], [AM_CFLAGS])])
125 AC_SUBST(AM_CFLAGS)
126
127 # Checks for header files.
128 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])])
129
130 AC_CONFIG_FILES([Makefile testcases/lib/i3test.pm man/asciidoc.conf])
131 AC_CONFIG_FILES([testcases/complete-run.pl], [chmod +x testcases/complete-run.pl])
132
133 # Enable address sanitizer for non-release builds. The performance hit is a
134 # 50% increase of wallclock time for the testsuite on my machine.
135 if test x$is_release = xyes; then
136         default_sanitizers=
137 else
138         default_sanitizers=address
139 fi
140 AX_SANITIZERS(, [$default_sanitizers], [AC_DEFINE([I3_ASAN_ENABLED], [], [Enable ASAN])])
141
142 AC_OUTPUT
143
144 if test -z "${BUILD_DOCS_TRUE}"; then
145         print_BUILD_DOCS=yes
146 else
147         print_BUILD_DOCS=no
148 fi
149
150
151 if test -z "${BUILD_MANS_TRUE}"; then
152         print_BUILD_MANS=yes
153 else
154         print_BUILD_MANS=no
155 fi
156
157 in_git_worktree=`git rev-parse --is-inside-work-tree 2>/dev/null`
158 if [[ "$in_git_worktree" = "true" ]]; then
159         git_dir=`git rev-parse --git-dir 2>/dev/null`
160         srcdir=`dirname "$git_dir"`
161         exclude_dir=`pwd | sed "s,^$srcdir,,g"`
162         if ! grep -q "^$exclude_dir" "$git_dir/info/exclude"; then
163                 echo "$exclude_dir" >> "$git_dir/info/exclude"
164         fi
165 fi
166
167 echo \
168 "--------------------------------------------------------------------------------
169 build configured:
170
171 AS_HELP_STRING([i3 version:], [`echo ${I3_VERSION} | sed 's,\\\\,,g'`])
172 AS_HELP_STRING([is release version:], [${is_release}])
173
174 AS_HELP_STRING([build manpages:], [${print_BUILD_MANS}])
175 AS_HELP_STRING([build docs:], [${print_BUILD_DOCS}])
176 AS_HELP_STRING([enable debug flags:], [${ax_enable_debug}])
177 AS_HELP_STRING([code coverage:], [${CODE_COVERAGE_ENABLED}])
178 AS_HELP_STRING([enabled sanitizers:], [${ax_enabled_sanitizers}])
179
180 To compile, run:
181
182   cd `pwd` && make -j8
183 --------------------------------------------------------------------------------"