1# AC_OPENMP requires autoconf >= 2.62.
2AC_PREREQ(2.62)
3
4
5## Canonical version number components ##
6
7# API version: see https://github.com/mypaint/libmypaint/wiki/Versioning
8# See http://semver.org/ for what this means.
9
10m4_define([libmypaint_api_major], [1])
11m4_define([libmypaint_api_minor], [6])
12m4_define([libmypaint_api_micro], [1])
13m4_define([libmypaint_api_prerelease], [])  # may be blank
14
15# ABI version. Changes independently of API version.
16# See: https://autotools.io/libtool/version.html
17# https://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
18# The rules are fiddly, and are summarized here.
19
20# NOTE: Due to the use of the ``-release`` flag, prior to the 1.6.1 release,
21# the ABI version fields were not used in a meaningful way, since the SONAME
22# differed even for ABI-compatible versions of the library.
23
24# Increment if any public interfaces have been
25# added/removed/changed since the last release.
26m4_define([libmypaint_abi_current], [0])
27
28# Set to 0 if ``current`` is incremented, otherwise increment
29# if the __code__ has changed at all since the last release.
30m4_define([libmypaint_abi_revision], [0])
31
32# Set to 0 if any public interfaces have been removed/changed since the last release,
33# otherwise increment if any public interfaces have been __added__.
34m4_define([libmypaint_abi_age], [0])  # inc only if changes backward compat
35
36
37## Derivative version macros ##
38
39# The full version is "major.minor.micro[-prerelease]".
40
41m4_define([libmypaint_version],
42          [libmypaint_api_major.libmypaint_api_minor.libmypaint_api_micro])
43m4_define([libmypaint_version_full],
44          [libmypaint_api_major().libmypaint_api_minor().libmypaint_api_micro()m4_bpatsubst(libmypaint_api_prerelease(), [^\(.\)], [-\1])])
45
46# The API "platform" or "intercompatibility" version.
47#
48# This one is used for library name prefixes, for introspection
49# namespace versions, for gettext domains, and basically anything that
50# needs to change when backwards or forwards API compatibility changes.
51# Another way of thinking about it: it allows meaningful side by side
52# installations of libmypaint.
53
54m4_define([libmypaint_api_platform_version],
55          [libmypaint_api_major.libmypaint_api_minor])
56
57
58## Dependencies ##
59m4_define([introspection_required_version], [1.32.0])
60
61AC_INIT([libmypaint],
62        [libmypaint_version_full],
63        [https://github.com/mypaint/libmypaint/issues],
64        [libmypaint],
65        [https://github.com/mypaint/libmypaint])
66
67AC_CONFIG_HEADERS([config.h])
68AC_CONFIG_MACRO_DIR([m4macros])
69
70AM_INIT_AUTOMAKE([no-define dist-xz no-dist-gzip
71                  -Wall -Werror
72                  subdir-objects
73                  foreign])
74
75LIBMYPAINT_MAJOR_VERSION=libmypaint_api_major
76LIBMYPAINT_MINOR_VERSION=libmypaint_api_minor
77LIBMYPAINT_MICRO_VERSION=libmypaint_api_micro
78LIBMYPAINT_VERSION=libmypaint_version
79LIBMYPAINT_VERSION_FULL=libmypaint_version_full
80LIBMYPAINT_API_PLATFORM_VERSION=libmypaint_api_platform_version
81LIBMYPAINT_API_PLATFORM_VERSION_UL=m4_bpatsubst(libmypaint_api_platform_version(), [[^A-Za-z0-9]], [_])
82LIBMYPAINT_ABI_VERSION_INFO=libmypaint_abi_current:libmypaint_abi_revision:libmypaint_abi_age
83
84AC_SUBST(LIBMYPAINT_MAJOR_VERSION)
85AC_SUBST(LIBMYPAINT_MINOR_VERSION)
86AC_SUBST(LIBMYPAINT_MICRO_VERSION)
87AC_SUBST(LIBMYPAINT_PRERELEASE_VERSION)
88AC_SUBST(LIBMYPAINT_VERSION)
89AC_SUBST(LIBMYPAINT_VERSION_FULL)
90AC_SUBST(LIBMYPAINT_API_PLATFORM_VERSION)
91AC_SUBST(LIBMYPAINT_API_PLATFORM_VERSION_UL)
92AC_SUBST(LIBMYPAINT_ABI_VERSION_INFO)
93
94AC_PROG_CC
95AC_PROG_CC_C99
96AM_PROG_AR
97
98AC_PROG_INSTALL
99
100# Initialize libtool (default: shared library only).
101LT_PREREQ([2.2])
102LT_INIT([disable-static win32-dll])
103
104# Initialize maintainer mode
105AM_MAINTAINER_MODE([enable])
106
107# Check for pkg-config
108PKG_PROG_PKG_CONFIG(0.16)
109
110
111## Check host and platform ##
112
113AC_CANONICAL_HOST
114
115AC_MSG_CHECKING([for platform])
116platform_win32=no
117platform_osx=no
118case "$host_os" in
119  mingw* | cygwin*)
120     AC_MSG_RESULT([win32])
121     platform_win32=yes
122     ;;
123  darwin*)
124     AC_MSG_RESULT([osx])
125     platform_osx=yes
126     ;;
127  *)
128     AC_MSG_RESULT([unix])
129esac
130AM_CONDITIONAL(PLATFORM_WIN32, test "$platform_win32" = "yes")
131AM_CONDITIONAL(PLATFORM_OSX, test "x$platform_osx" = xyes)
132
133# Define strdup() in string.h under glibc >= 2.10 (POSIX.1-2008)
134CFLAGS="-D_POSIX_C_SOURCE=200809L $CFLAGS"
135
136## Debug ##
137AC_MSG_CHECKING([whether to turn on debugging])
138AC_ARG_ENABLE(debug,
139              AS_HELP_STRING([--enable-debug],
140                             [turn on debugging (default=no)])
141)
142
143if eval "test x$enable_debug = xyes"; then
144  AC_MSG_RESULT([yes])
145  CPPDEFINES='HEAVY_DEBUG $CPPDEFINES'
146  CCFLAGS='-O0 $CCFLAGS'
147  LINKFLAGS='-O0 $LINKFLAGS'
148else
149  AC_MSG_RESULT([no])
150  CCFLAGS='-O3 $CCFLAGS'
151  LINKFLAGS='-O3 $LINKFLAGS'
152fi
153
154## Profiling ##
155AC_MSG_CHECKING([whether to turn on profiling])
156AC_ARG_ENABLE(profiling,
157  AS_HELP_STRING([--enable-profiling],
158    [turn on profiling (default=no)])
159)
160
161if eval "test x$enable_profiling = xyes"; then
162  AC_MSG_RESULT([yes])
163  CCFLAGS='-pg $CCFLAGS'
164else
165  AC_MSG_RESULT([no])
166fi
167
168## Variables for pkg-config file ##
169PKG_CONFIG_REQUIRES=""
170
171## OpenMP ##
172AC_ARG_ENABLE(openmp,
173  AS_HELP_STRING([--enable-openmp],
174    [compile with OpenMP (default=no)]),
175  [AC_OPENMP([CFLAGS="$CFLAGS $OPENMP_CFLAGS"])]
176)
177
178AC_SUBST(OPENMP_CFLAGS)
179
180## gperftools ##
181AC_ARG_ENABLE(gperftools,
182  AS_HELP_STRING([--enable-gperftools],
183    [enable gperftools in build, for profiling (default=no)])
184)
185
186have_libprofiler="no"
187if test "x$enable_gperftools" = xyes; then
188  PKG_CHECK_MODULES(LIBPROFILER, libprofiler,
189                    have_libprofiler="yes")
190fi
191AM_CONDITIONAL(HAVE_GPERFTOOLS, test "x$have_libprofiler" = "xyes")
192
193## Docs ##
194AC_ARG_ENABLE(docs,
195  AS_HELP_STRING([--enable-docs],
196    [enable documentation build (default=no)])
197)
198
199if test "x$enable_docs" = xyes; then
200  AC_CHECK_PROGS(DOXYGEN, doxygen)
201  AS_IF(test "x$DOXYGEN" != "x", [],
202    [AC_MSG_ERROR([doxygen is required to build the documentation]);
203     AS_EXIT([1])
204    ])
205fi
206AM_CONDITIONAL(ENABLE_DOCS, test "x$DOXYGEN" != "x")
207
208## json-c ##
209PKG_CHECK_MODULES(JSON, json-c,
210                  have_json_c="yes", have_json_c="no")
211
212if test "x$have_json_c" = xno; then
213  AC_MSG_WARN([Could not find 'json-c', trying legacy 'json' instead])
214  PKG_CHECK_MODULES(JSON, json)
215  PKG_CONFIG_REQUIRES="json"
216else
217  PKG_CONFIG_REQUIRES="json-c"
218fi
219
220AC_SUBST(JSON_LIBS)
221AC_SUBST(JSON_CFLAGS)
222
223## Standard maths functions ##
224AC_SEARCH_LIBS([floorf], [m], [], AC_MSG_ERROR([no floorf]))
225AC_SEARCH_LIBS([powf], [m], [], AC_MSG_ERROR([no powf]))
226AC_SEARCH_LIBS([expf], [m], [], AC_MSG_ERROR([no expf]))
227AC_SEARCH_LIBS([fabsf], [m], [], AC_MSG_ERROR([no fabsf]))
228
229## Additional compile flags ##
230
231AX_CHECK_COMPILE_FLAG([-fsanitize=undefined],
232  [test x$enable_debug = xyes && CFLAGS="-fsanitize=undefined $CFLAGS"],
233  [], [-Werror], [])
234AX_CHECK_LINK_FLAG([-fsanitize=undefined],
235  [test x$enable_debug = xyes && LDFLAGS="-fsanitize=undefined $LDFLAGS"],
236  [], [-Werror], [])
237
238## Internationalization ##
239AC_ARG_ENABLE(i18n,
240  AS_HELP_STRING([--disable-i18n],
241    [disable internationalization (default=no)])
242)
243
244if test "x$enable_i18n" != "xno"; then
245  enable_i18n="yes"
246  GETTEXT_PACKAGE=libmypaint
247  AC_SUBST(GETTEXT_PACKAGE)
248  AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE",
249                     [The prefix for our gettext translation domains.])
250  AC_SUBST(GETTEXT_PACKAGE)
251  IT_PROG_INTLTOOL
252  AM_GLIB_GNU_GETTEXT
253
254  dnl Debian: stdlib
255  dnl Windows, and OSX: -lintl
256  AC_SEARCH_LIBS([dgettext], [intl], [], AC_MSG_ERROR([no dgettext]))
257fi
258AM_CONDITIONAL(HAVE_I18N, test "x$enable_i18n" = "xyes")
259
260GOBJECT_INTROSPECTION_CHECK(introspection_required_version)
261
262## glib ##
263AC_ARG_WITH(glib,
264  AS_HELP_STRING([--with-glib],
265    [use glib (forced on by introspection)])
266)
267
268use_glib() {
269    test "x$with_glib" = xyes || test "x$found_introspection" = xyes
270}
271
272if use_glib; then
273  PKG_CHECK_MODULES(GLIB, gobject-2.0)
274  AC_DEFINE(MYPAINT_CONFIG_USE_GLIB, 1, [Define to 1 if glib is used])
275  PKG_CONFIG_REQUIRES="$PKG_CONFIG_REQUIRES gobject-2.0"
276else
277  AC_DEFINE(MYPAINT_CONFIG_USE_GLIB, 0, [Define to 1 if glib is used])
278fi
279AM_CONDITIONAL(WITH_GLIB, use_glib)
280
281## GEGL - NOT REQUIRED TO BUILD, NOT USED BY ANY MAJOR PROJECT ##
282AC_ARG_ENABLE(gegl,
283  AS_HELP_STRING([--enable-gegl],
284    [enable GEGL based code in build (yes|no, default=no)])
285)
286
287DOXYGEN_EXCLUDED=
288if eval "test x$enable_gegl = xyes"; then
289  AC_MSG_NOTICE([Checking whether gegl-0.4 or gegl-0.3 is available])
290  # Prioritize gegl-0.4
291  PKG_CHECK_MODULES(GEGL, gegl-0.4, [GEGL_VERSION=0.4], [
292  # Fall back to gegl-0.3
293    PKG_CHECK_MODULES(GEGL, gegl-0.3, [GEGL_VERSION=0.3])
294])
295AC_SUBST(GEGL_VERSION)
296else
297  DOXYGEN_EXCLUDED="../gegl/"
298fi
299AM_CONDITIONAL(ENABLE_GEGL, test "x$enable_gegl" = "xyes")
300AC_SUBST(DOXYGEN_EXCLUDED)
301
302# Set pkg-config variables before generation.
303AC_SUBST(PKG_CONFIG_REQUIRES)
304
305AC_CONFIG_FILES([
306  doc/Doxyfile
307  doc/Makefile
308  gegl/libmypaint-gegl.pc:gegl/libmypaint-gegl.pc.in
309  gegl/Makefile
310  libmypaint.pc:libmypaint.pc.in
311  Makefile
312  po/Makefile.in
313  tests/Makefile
314  tests/gegl/Makefile
315])
316
317AC_OUTPUT
318
319echo ""
320echo "  Configured libmypaint $LIBMYPAINT_VERSION_FULL"
321
322if test -n "$GEGL_VERSION"; then
323  echo "  Using gegl-$GEGL_VERSION"
324fi
325
326echo ""
327
328