1 m4_define([adg_version],[0.7.6])
2 m4_define([cpml_version],adg_version)
4 dnl How to handle {adg,cmpl}_lt_version (current:revision:age):
5 dnl - Code refactoring: bump revision only, don’t touch current nor age.
6 dnl - New interfaces: set revision to 0, bump current and age.
7 m4_define([adg_lt_version],[4:0:1])
8 m4_define([cpml_lt_version],[2:1:0])
10 m4_define([gtkdoc_prereq], [1.12] )dnl Support introspection annotations
11 m4_define([gobject_prereq], [2.10.1])dnl Required by GTypeInitiallyUnowned (glib 2.10.0 was broken)
12 m4_define([cairo_prereq], [1.7.4] )dnl Required by cairo_scaled_font_text_to_glyphs()
13 m4_define([gtk2_prereq], [2.18.0])dnl Required by gtk_widget_get_allocation()
14 m4_define([gtk3_prereq], [3.0.0] )dnl First stable release
15 m4_define([pangocairo_prereq],[1.10.0])dnl Cairo support in Pango
16 m4_define([gi_prereq], [1.0.0] )dnl First stable release
21 dnl autoconf 2.62 is required by GObject introspection:
22 dnl http://live.gnome.org/GObjectIntrospection/AutotoolsIntegration
24 AC_INIT([adg-1],adg_version,[http://dev.entidi.com/p/adg/],[adg],[http://adg.entidi.com/])
25 AC_CONFIG_SRCDIR([configure.ac])
26 AC_CONFIG_HEADERS([src/config.h])
27 AC_CONFIG_AUX_DIR([build])
28 AC_CONFIG_MACRO_DIR([build])
29 AM_INIT_AUTOMAKE([1.10 gnits no-dist-gzip dist-bzip2 -Wall -Wno-portability])
31 dnl m4 backward compatibility stuff
32 m4_ifdef([AM_SILENT_RULES],
33 [AM_SILENT_RULES([yes])],
34 [AC_SUBST([AM_V_GEN],[])])
35 m4_ifdef([AM_SUBST_NOTMAKE],[],
36 [AC_DEFUN([AM_SUBST_NOTMAKE],[_AM_SUBST_NOTMAKE($@)])])
37 m4_ifdef([AM_COND_IF],[],
38 [AC_DEFUN([AM_COND_IF],
39 [AS_IF([test -z "$$1_TRUE"],[$2],[$3])])])
41 AC_DEFUN([ADG_DEPENDENCY],
42 [EXTRADIR="$EXTRADIR --extra-dir=$($PKG_CONFIG --variable=prefix $1)/share/gtk-doc/html/$2"])
44 # Check for host information
79 AM_CONDITIONAL([OS_UNIX],[test "${guessed_host}" != "mingw"])
80 AM_CONDITIONAL([OS_WINDOWS],[test "${guessed_host}" = "mingw" -o "${guessed_host}" = "cygwin"])
88 AC_PATH_PROG([XSLTPROC],[xsltproc],[/usr/bin/xsltproc])
89 AC_PATH_PROG([GLIB_MKENUMS],[glib-mkenums],[/usr/bin/glib-mkenums])
90 AC_PATH_PROG([GLIB_GENMARSHAL],[glib-genmarshal],[/usr/bin/glib-genmarshal])
91 AC_PATH_PROG([GTESTER],[gtester],[/usr/bin/gtester])
92 AC_PATH_PROG([GTESTER_REPORT],[gtester-report],[/usr/bin/gtester-report])
93 AC_PATH_PROG([GLADE3],[glade-3],[/usr/bin/glade-3])
95 AC_PATH_PROG([TAR],[tar],[/usr/bin/tar])
97 AC_PATH_PROG([BZIP2],[bzip2],[/usr/bin/bzip2])
100 # Check for coverage build
102 dnl Coverage with gcov is available only for GNU gcc
103 AS_IF([test "x$GNU" != "xyes"],
104 [AC_ARG_ENABLE([gcov],
105 [AS_HELP_STRING([--enable-gcov],
106 [enable coverage build @<:@default=no@:>@])],
107 [],[enable_gcov=no])])
108 AS_IF([test "x$enable_gcov" = "xyes"],
110 AC_CHECK_TOOL([GCOV],[gcov],[/usr/bin/gcov])
111 CFLAGS="$CFLAGS --coverage"
112 LDFLAGS="$LDFLAGS --coverage"])
113 AM_CONDITIONAL([ENABLE_GCOV],[test "x$enable_gcov" = "xyes"])
116 # Check for libraries
118 AC_CHECK_LIB([m],[cos])
120 dnl On Windows, GLib 2.16 is required by _adg_dgettext() for the
121 dnl g_win32_get_package_installation_directory_of_module() API.
122 dnl On other platforms, it just needs to be in sync with GObject.
123 AM_COND_IF([OS_WINDOWS],
124 [AC_PATH_PROG([MAKENSIS],[makensis],[/usr/bin/makensis])
125 AC_PATH_PROG([WINE],[wine])
126 AC_ARG_VAR([WINDRES],[Command for Windows resources manipulation])
127 AC_CHECK_TOOL([WINDRES],[windres])
129 [glib_prereq=]gobject_prereq)
132 # Libtool initialization
134 AC_MSG_CHECKING([which libtool initialization strategy to adopt])
135 AC_MSG_RESULT([m4_ifset([LT_INIT],[LT-INIT],[AC-PROG-LIBTOOL])])
137 [LT_INIT([disable-static win32-dll])],
145 dnl The following macro is required in order to be able to use
146 dnl autopoint (formerly called gettextize) from autoreconf.
147 dnl The argument is a trade-off between modern and supported.
148 AM_GNU_GETTEXT_VERSION([0.17])
150 AM_GNU_GETTEXT([external])
151 AC_SUBST([ADG_API_PACKAGE],AC_PACKAGE_TARNAME)
152 AC_SUBST([GETTEXT_PACKAGE],[${ADG_API_PACKAGE}])
153 AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE],["${ADG_API_PACKAGE}"],
154 [Define to the domain used by gettext.])
157 # Check for required packages
159 PKG_CHECK_MODULES([GLIB],[glib-2.0 >= ]${glib_prereq},
160 [glib_postfix=" (glib-$($PKG_CONFIG --modversion glib-2.0))"])
161 ADG_DEPENDENCY([glib-2.0],[glib])
162 PKG_CHECK_MODULES([GOBJECT],[gobject-2.0 >= ]gobject_prereq)
163 ADG_DEPENDENCY([gobject-2.0],[gobject])
164 PKG_CHECK_MODULES([CAIRO],[cairo >= ]cairo_prereq)
165 ADG_DEPENDENCY([cairo],[cairo])
168 # Check for optional packages
171 AC_ARG_ENABLE([pango],
172 [AS_HELP_STRING([--enable-pango],
173 [use pango for rendering text @<:@default=check@:>@])],
174 [],[enable_pango=check])
175 AS_IF([test "x${enable_pango}" != "xno"],
176 [PKG_CHECK_MODULES([PANGO],[pangocairo >= ]pangocairo_prereq,
178 AC_DEFINE_UNQUOTED([PANGO_ENABLED],[1],
179 [Defined if the pango support is enabled.])
180 ADG_DEPENDENCY([pangocairo],[pango])
181 pango_postfix=" (pangocairo-$($PKG_CONFIG --modversion pangocairo))"],
182 [AS_IF([test "x${enable_pango}" = "xyes"],
183 [AC_MSG_ERROR([${PANGO_PKG_ERRORS} and pango support requested])],
184 [enable_pango=no])])])
185 AM_CONDITIONAL([HAVE_PANGO],[test "x${enable_pango}" = "xyes"])
189 [AS_HELP_STRING([--with-gtk@<:@=gtk2/gtk3@:>@],
190 [include GTK+ specific widgets @<:@default=check@:>@])],
192 AS_CASE(["${with_gtk}"],
193 [gtk2], [gtk2_pkg=yes; gtk3_pkg=no],
194 [gtk3], [gtk2_pkg=no; gtk3_pkg=yes],
195 [check|yes], [gtk2_pkg=yes; gtk3_pkg=yes],
196 [no], [gtk2_pkg=no; gtk3_pkg=no],
197 [AC_MSG_ERROR([Invalid option passed to --with-gtk])])
199 # GTK+ autodetection, giving precedence to GTK+3
200 AS_IF([test "x${gtk3_pkg}" = "xyes"],
201 [PKG_CHECK_MODULES([GTK3],[gtk+-3.0 >= ]gtk3_prereq,
203 ADG_DEPENDENCY([gtk+-3.0],[gtk3])],
205 AS_IF([test "x${gtk2_pkg}" = "xyes" -a "x${gtk_pkg}" = "x"],
206 [PKG_CHECK_MODULES([GTK2],[gtk+-2.0 >= ]gtk2_prereq,
208 ADG_DEPENDENCY([gtk+-2.0],[gtk2])],
210 AS_IF([test "x${gtk_pkg}" != "x"],[with_gtk=${gtk_pkg}])
212 # Handle "check" graceful degradation
213 AS_IF([test "x${with_gtk}" = "xcheck"],[with_gtk=no])
216 AS_IF([test "x${with_gtk}" != "xno" -a "x${gtk_pkg}" = "x"],
217 [AC_MSG_ERROR([GTK+ support explicitely required but no valid GTK+ found])])
219 AS_IF([test "x${with_gtk}" = "xgtk3"],
220 [gtk_postfix=" (gtk+-$($PKG_CONFIG --modversion gtk+-3.0))"
221 AC_DEFINE_UNQUOTED([GTK3_ENABLED],[1],
222 [Defined if the GTK+3 support is enabled.])])
223 AS_IF([test "x${with_gtk}" = "xgtk2"],
224 [gtk_postfix=" (gtk+-$($PKG_CONFIG --modversion gtk+-2.0))"
225 AC_DEFINE_UNQUOTED([GTK2_ENABLED],[1],
226 [Defined if the GTK+2 support is enabled.])])
228 AM_CONDITIONAL([HAVE_GTK], [test "x${with_gtk}" != "xno"])
229 AM_CONDITIONAL([HAVE_GTK2],[test "x${with_gtk}" = "xgtk2"])
230 AM_CONDITIONAL([HAVE_GTK3],[test "x${with_gtk}" = "xgtk3"])
232 dnl Glade catalog dir
233 AC_ARG_WITH(glade_catalogdir,
234 [AS_HELP_STRING([--with-glade-catalogdir@<:@=DIR@:>@],
235 [where to install the glade catalogs @<:@default=check@:>@])],
236 [],[with_glade_catalogdir=check])
238 # Both "check" and "yes" mean gladeui autodetection,
239 # but "yes" will fail on gladeui not found
240 AS_IF([test "x${with_glade_catalogdir}" = "xcheck" -o "x${with_glade_catalogdir}" = "xyes"],
243 # gladeui autodetection, giving precedence to gladeui-2.0 if possible
244 AS_IF([test "x${glade_pkg}" = "xcheck" -a "x${with_gtk}" != "xgtk2"],
245 [PKG_CHECK_MODULES([GLADEUI2],[gladeui-2.0],[glade_pkg=gladeui-2.0],[:])])
246 AS_IF([test "x${glade_pkg}" = "xcheck"],
247 [PKG_CHECK_MODULES([GLADEUI1],[gladeui-1.0],[glade_pkg=gladeui-1.0],[:])])
248 AS_IF([test "x${glade_pkg}" != "x" -a "x${glade_pkg}" != "xcheck"],
249 [NTD_UNEXPAND([${glade_pkg}],
251 [with_glade_catalogdir="${NTD_UNEXPANDED}"],
252 [AC_MSG_ERROR([${glade_pkg} found but pkg-config file invalid])])])
254 # Handle "yes" failure
255 AS_IF([test "x${glade_pkg}" = "xcheck" -a "x${with_glade_catalogdir}" = "xyes"],
256 [AC_MSG_ERROR([Glade support explicitely required but no valid gladeui found])])
258 # Handle "check" graceful degradation
259 AS_IF([test "x${glade_pkg}" = "xcheck" -a "x${with_glade_catalogdir}" = "xcheck"],
260 [with_glade_catalogdir=no])
262 AM_CONDITIONAL([HAVE_GLADE],[test "x${with_glade_catalogdir}" != "xno"])
263 AM_COND_IF([HAVE_GLADE],
266 Glade catalog dir: ${with_glade_catalogdir}"],
269 AC_SUBST([GLADE_CATALOGDIR],${with_glade_catalogdir})
272 GTK_DOC_CHECK(gtkdoc_prereq)
273 AS_IF([test "x$enable_gtk_doc" = "xyes"],
274 [gtkdoc_postfix=" (gtk-doc-$($PKG_CONFIG --modversion gtk-doc))"])
276 dnl GObject introspection
277 GOBJECT_INTROSPECTION_CHECK(gi_prereq)
279 [AS_HELP_STRING([--with-girdir=DIR],
280 [where the gir files are installed @<:@default=check@:>@])],
281 [],[with_girdir=check])
282 AS_IF([test "x${enable_introspection}" = "xyes" -a "x${with_girdir}" = "xcheck"],
283 [NTD_UNEXPAND([gobject-introspection-1.0],
285 [with_girdir="${NTD_UNEXPANDED}"])])
286 AC_SUBST([GIRDIR],${with_girdir})
287 AC_ARG_WITH(typelibdir,
288 [AS_HELP_STRING([--with-typelibdir=DIR],
289 [where the typelib files are installed @<:@default=check@:>@])],
290 [],[with_typelibdir=check])
291 AS_IF([test "x${enable_introspection}" = "xyes" -a "x${with_typelibdir}" = "xcheck"],
292 [NTD_UNEXPAND([gobject-introspection-1.0],
294 [with_typelibdir="${NTD_UNEXPANDED}"])])
295 AC_SUBST([TYPELIBDIR],${with_typelibdir})
296 AM_COND_IF([HAVE_INTROSPECTION],
297 [report_introspection="
298 Where to install gir files: ${with_girdir}
299 Where to install the typelib files: ${with_typelibdir}"],
300 [report_introspection=""])
302 dnl If introspection is used GObject support in cairo must be enabled,
303 dnl that is the cairo-gobject library must be present. That support
304 dnl was introduced since cairo 1.10.0.
305 PKG_CHECK_MODULES([CAIRO_GOBJECT],[cairo-gobject],
306 [AC_DEFINE_UNQUOTED([CAIRO_GOBJECT_ENABLED],[1],
307 [Defined if GObject support in cairo is present.])],
308 [AS_IF([test "x${enable_introspection}" = "xyes"],
309 [AC_MSG_ERROR([GObject introspection requires the cairo-gobject library])])])
311 dnl GLib test framework
312 AC_ARG_ENABLE([test_framework],
313 [AS_HELP_STRING([--enable-test-framework],
314 [enable GLib test framework @<:@default=check@:>@])],
315 [],[enable_test_framework=check])
316 AS_IF([test "x$enable_gcov" = "xyes"], [enable_test_framework=yes])
317 AS_IF([test "x${enable_test_framework}" != "xno"],
318 [PKG_CHECK_EXISTS([glib-2.0 >= 2.16.0],
319 [enable_test_framework=yes],
320 [AS_IF([test "x${enable_test_framework}" = "xyes"],
321 [AC_MSG_ERROR([The test framework needs glib2-2.16.0 or later])],
322 [enable_test_framework=no])])])
323 AM_CONDITIONAL([HAVE_TEST_FRAMEWORK],[test "x${enable_test_framework}" = "xyes"])
326 # Check for compiler characteristics
331 # Windows substitutions for NSis installer
333 dnl Get the USRDIR from gobject-2.0.pc: all the dependencies *must* be
334 dnl installed under the same prefix.
335 USRDIR="$($PKG_CONFIG --variable=prefix gobject-2.0)"
337 AM_SUBST_NOTMAKE([USRDIR])
339 dnl -win$PACKAGE_ARCH will be appended to the installer file name
340 AS_IF([test "x${host_cpu}" = "xx86_64"],[PACKAGE_ARCH=64],[PACKAGE_ARCH=32])
341 AC_SUBST([PACKAGE_ARCH])
344 # Additional substitutions
346 dnl The GObject dependency can be made optional by skipping
347 dnl the building of the GObject wrappers.
348 CPML_REQUIRES='cairo >= cairo_prereq gobject-2.0 >= gobject_prereq'
349 AM_COND_IF([HAVE_PANGO],
350 [ADG_REQUIRES='pangocairo >= pangocairo_prereq'
352 #include <pango/pango.h>
353 #include "adg/adg-text.h"
354 #include "adg/adg-pango-style.h"
356 [ADG_REQUIRES='gobject-2.0 >= gobject_prereq'
357 ADG_H_ADDITIONAL=''])
358 AM_COND_IF([HAVE_GTK3],[ADG_REQUIRES='gtk+-3.0 >= gtk3_prereq'])
359 AM_COND_IF([HAVE_GTK2],[ADG_REQUIRES='gtk+-2.0 >= gtk2_prereq'])
360 AM_COND_IF([HAVE_GTK],
361 [ADG_H_ADDITIONAL="${ADG_H_ADDITIONAL}
363 #include \"adg/adg-gtk-utils.h\"
364 #include \"adg/adg-gtk-area.h\"
365 #include \"adg/adg-gtk-layout.h\"
367 ADG_CANVAS_H_ADDITIONAL='
370 void adg_canvas_set_paper (AdgCanvas *canvas,
371 const gchar *paper_name,
372 GtkPageOrientation orientation);
373 void adg_canvas_set_page_setup (AdgCanvas *canvas,
374 GtkPageSetup *page_setup);
375 GtkPageSetup * adg_canvas_get_page_setup (AdgCanvas *canvas);
377 [ADG_CANVAS_H_ADDITIONAL=''])
379 AC_SUBST([CPML_LT_VERSION],cpml_lt_version)
380 AC_SUBST([CPML_REQUIRES])
381 AC_SUBST([ADG_LT_VERSION],adg_lt_version)
382 AC_SUBST([ADG_REQUIRES])
383 AC_SUBST([ADG_H_ADDITIONAL])
384 AC_SUBST([ADG_CANVAS_H_ADDITIONAL])
386 AM_SUBST_NOTMAKE([CPML_REQUIRES])
387 AM_SUBST_NOTMAKE([ADG_REQUIRES])
388 AM_SUBST_NOTMAKE([ADG_H_ADDITIONAL])
389 AM_SUBST_NOTMAKE([ADG_CANVAS_H_ADDITIONAL])
391 dnl CPML compiler flags and library dependencies
392 CPML_CFLAGS="$CAIRO_CFLAGS $GOBJECT_CFLAGS"
393 CPML_LIBS="$CAIRO_LIBS $GOBJECT_LIBS"
394 AC_SUBST([CPML_CFLAGS])
395 AC_SUBST([CPML_LIBS])
397 dnl ADG compiler flags and library dependencies
398 ADG_CFLAGS="$CAIRO_GOBJECT_CFLAGS"
399 ADG_LIBS="$CAIRO_GOBJECT_LIBS"
400 AM_COND_IF([HAVE_PANGO],
401 [ADG_CFLAGS="$PANGO_CFLAGS $ADG_CFLAGS"
402 ADG_LIBS="$PANGO_LIBS $ADG_LIBS"])
403 AM_COND_IF([HAVE_GTK2],
404 [ADG_CFLAGS="$GTK2_CFLAGS $ADG_CFLAGS"
405 ADG_LIBS="$GTK2_LIBS $ADG_LIBS"])
406 AM_COND_IF([HAVE_GTK3],
407 [ADG_CFLAGS="$GTK3_CFLAGS $ADG_CFLAGS"
408 ADG_LIBS="$GTK3_LIBS $ADG_LIBS"])
409 AC_SUBST([ADG_CFLAGS])
417 AC_CONFIG_FILES([build/Custom.nsh
423 src/cpml/tests/Makefile
428 src/adg/tests/Makefile
435 docs/cpml/bookinfo.xml
437 docs/adg/bookinfo.xml])
438 AC_CONFIG_FILES([demo/adg-glade],[chmod +x demo/adg-glade])
444 AC_MSG_NOTICE([generating report
446 AC_PACKAGE_NAME adg_version will be built with the following options:
447 ----------------------------------------------------------
448 CPML library to use: internal (cpml-adg_version)
449 Build pango based entities: ${enable_pango}${pango_postfix}
450 GTK+ support: ${with_gtk}${gtk_postfix}
451 Install glade catalogs: ${enable_glade}${report_glade}
452 Build API reference: ${enable_gtk_doc}${gtkdoc_postfix}
453 GObject instrospection: ${enable_introspection}${report_introspection}
454 Test coverage build: ${enable_gcov}
455 Test framework support: ${enable_test_framework}${glib_postfix}