1#
2# libtsm - build configuration script
3# Copyright (c) 2012-2013 David Herrmann <dh.herrmann@gmail.com>
4#
5
6AC_PREREQ(2.68)
7
8AC_INIT([libtsm],
9        [3],
10        [https://github.com/dvdhrm/libtsm/issues],
11        [libtsm],
12        [http://dvdhrm.github.io/libtsm])
13AC_CONFIG_SRCDIR([src/tsm_vte.c])
14AC_CONFIG_AUX_DIR([build-aux])
15AC_CONFIG_MACRO_DIR([m4])
16AC_CONFIG_HEADER(config.h)
17AC_USE_SYSTEM_EXTENSIONS
18AC_SYS_LARGEFILE
19AC_CANONICAL_HOST
20
21AM_INIT_AUTOMAKE([foreign 1.11 subdir-objects dist-xz no-dist-gzip tar-pax -Wall -Werror -Wno-portability])
22AM_SILENT_RULES([yes])
23
24AC_SUBST(PACKAGE_DESCRIPTION, ["terminal-emulator state machine"])
25
26#
27# Don't add a default "-g -O2" if CFLAGS wasn't specified. For debugging it is
28# often more convenient to have "-g -O0". You can still override it by
29# explicitly setting it on the command line.
30#
31
32: ${CFLAGS=""}
33
34AC_PROG_CC
35AC_PROG_CC_C99
36AM_PROG_CC_C_O
37m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
38AC_PROG_SED
39AC_PROG_MKDIR_P
40AC_PROG_LN_S
41AC_PROG_GREP
42AC_PROG_AWK
43
44LT_PREREQ(2.2)
45LT_INIT
46
47#
48# We need xkbcommon for keysym definitions. If it's not found, we use our own
49# private copy of xkbcommon-keysyms.h.
50#
51
52PKG_CHECK_MODULES([XKBCOMMON], [xkbcommon],
53                  [have_xkbcommon=yes], [have_xkbcommon=no])
54AC_SUBST(XKBCOMMON_CFLAGS)
55if test "x$have_xkbcommon" = "xyes" ; then
56        AC_DEFINE([BUILD_HAVE_XKBCOMMON], [1], [Have xkbcommon library])
57fi
58AM_CONDITIONAL([BUILD_HAVE_XKBCOMMON], [test "x$have_xkbcommon" = "xyes"])
59
60#
61# Test for "check" which we use for our test-suite. If not found, we disable
62# all tests.
63#
64
65PKG_CHECK_MODULES([CHECK], [check],
66                  [have_check=yes], [have_check=no])
67AC_SUBST(CHECK_CFLAGS)
68AC_SUBST(CHECK_LIBS)
69AM_CONDITIONAL([BUILD_HAVE_CHECK], [test "x$have_check" = "xyes"])
70
71#
72# debug mode
73# If --enable-debug is given, we enable several non-standard debug options. We
74# enable a lot of debug options by default, so this option is really only for
75# extended developer debug modes.
76#
77
78AC_MSG_CHECKING([whether to build with debugging on])
79AC_ARG_ENABLE([debug],
80              [AS_HELP_STRING([--enable-debug],
81                              [whether to build with debugging on])])
82if test "x$enable_debug" = "x" ; then
83        enable_debug="yes (default)"
84fi
85AC_MSG_RESULT([$enable_debug])
86
87if test "x${enable_debug% *}" = "xyes" ; then
88        enable_debug="yes"
89        AC_DEFINE([BUILD_ENABLE_DEBUG], [1], [Enable debug mode])
90else
91        enable_debug="no"
92        AC_DEFINE([NDEBUG], [1], [No Debug])
93fi
94AM_CONDITIONAL([BUILD_ENABLE_DEBUG],
95               [test "x$enable_debug" = "xyes"])
96
97#
98# Enable gcc compiler optimizations. We enable them by default but allow
99# disabling them for better backtraces during debugging.
100#
101
102AC_MSG_CHECKING([whether to enable code optimizations])
103AC_ARG_ENABLE([optimizations],
104              [AS_HELP_STRING([--disable-optimizations],
105                              [whether to disable code optimizations])])
106if test "x$enable_optimizations" = "x" ; then
107        enable_optimizations="yes (default)"
108fi
109AC_MSG_RESULT([$enable_optimizations])
110
111if test "x${enable_optimizations% *}" = "xyes" ; then
112        enable_optimizations="yes"
113else
114        enable_optimizations="no"
115fi
116AM_CONDITIONAL([BUILD_ENABLE_OPTIMIZATIONS],
117               [test "x$enable_optimizations" = "xyes"])
118
119#
120# Makefile vars
121# After everything is configured, we create all makefiles.
122#
123
124AC_CONFIG_FILES([Makefile
125                 docs/libtsm.pc])
126AC_OUTPUT
127
128#
129# Configuration output
130# Show configuration to the user so they can check whether everything was
131# configured as expected.
132#
133
134AC_MSG_NOTICE([Build configuration:
135
136               prefix: $prefix
137          exec-prefix: $exec_prefix
138               libdir: $libdir
139           includedir: $includedir
140
141  Miscellaneous Options:
142                debug: $enable_debug
143        optimizations: $enable_optimizations
144       building tests: $have_check
145
146        Run "${MAKE-make}" to start compilation process])
147