build: include cpml-demo icons in NSIS installer
[adg.git] / configure.ac
blobaa99897636200f23639f13328ed6f8f32b688c54
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
19 # Initialization
21 dnl autoconf 2.62 is required by GObject introspection:
22 dnl http://live.gnome.org/GObjectIntrospection/AutotoolsIntegration
23 AC_PREREQ([2.62])
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
46 AC_CANONICAL_HOST
47 case "${host}" in
48   *-*-linux*)
49     guessed_host=linux
50     ;;
51   *-*-freebsd*)
52     guessed_host=freebsd
53     ;;
54   *-*-mingw*)
55     guessed_host=mingw
56     ;;
57   *-*-solaris*)
58     guessed_host=solaris
59     ;;
60   *-*-darwin*)
61     guessed_host=darwin
62     ;;
63   *-*-beos*)
64     guessed_host=beos
65     ;;
66   *-*-cygwin*)
67     guessed_host=cygwin
68     ;;
69   *-*-minix*)
70     guessed_host=minix
71     ;;
72   *-*-aix*)
73     guessed_host=aix
74     ;;
75   *)
76     guessed_host=unknown
77     ;;
78 esac
79 AM_CONDITIONAL([OS_UNIX],[test "${guessed_host}" != "mingw"])
80 AM_CONDITIONAL([OS_WINDOWS],[test "${guessed_host}" = "mingw" -o "${guessed_host}" = "cygwin"])
83 # Check for programs
85 AC_PROG_CC
86 AC_PROG_SED
87 PKG_PROG_PKG_CONFIG
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])
94 AC_ARG_VAR([TAR])
95 AC_PATH_PROG([TAR],[tar],[/usr/bin/tar])
96 AC_ARG_VAR([BZIP2])
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"],
109       [AC_ARG_VAR([GCOV])
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])
121 dnl GLib 2.16 is required by _adg_dgettext() for
122 dnl g_win32_get_package_installation_directory_of_module()
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])
128             PKG_CHECK_MODULES([GLIB],[glib-2.0 >= 2.16])])
131 # Libtool initialization
133 AC_MSG_CHECKING([which libtool initialization strategy to adopt])
134 AC_MSG_RESULT([m4_ifset([LT_INIT],[LT-INIT],[AC-PROG-LIBTOOL])])
135 m4_ifset([LT_INIT],
136          [LT_INIT([disable-static win32-dll])],
137          [AC_DISABLE_STATIC
138           AC_LIBTOOL_WIN32_DLL
139           AC_PROG_LIBTOOL])
142 # I18n
144 dnl The following macro is required in order to be able to use
145 dnl autopoint (formerly called gettextize) from autoreconf.
146 dnl The argument is a trade-off between modern and supported.
147 AM_GNU_GETTEXT_VERSION([0.17])
149 AM_GNU_GETTEXT([external])
150 AC_SUBST([ADG_API_PACKAGE],AC_PACKAGE_TARNAME)
151 AC_SUBST([GETTEXT_PACKAGE],[${ADG_API_PACKAGE}])
152 AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE],["${ADG_API_PACKAGE}"],
153                    [Define to the domain used by gettext.])
156 # Check for required packages
158 PKG_CHECK_MODULES([GLIB],[glib-2.0])
159 ADG_DEPENDENCY([glib-2.0],[glib])
160 PKG_CHECK_MODULES([GOBJECT],[gobject-2.0 >= ]gobject_prereq)
161 ADG_DEPENDENCY([gobject-2.0],[gobject])
162 PKG_CHECK_MODULES([CAIRO],[cairo >= ]cairo_prereq)
163 ADG_DEPENDENCY([cairo],[cairo])
166 # Check for optional packages
168 dnl PangoCairo
169 AC_ARG_ENABLE([pango],
170               [AS_HELP_STRING([--enable-pango],
171                               [use pango for rendering text @<:@default=check@:>@])],
172               [],[enable_pango=check])
173 AS_IF([test "x${enable_pango}" != "xno"],
174       [PKG_CHECK_MODULES([PANGO],[pangocairo >= ]pangocairo_prereq,
175                          [enable_pango=yes
176                           AC_DEFINE_UNQUOTED([PANGO_ENABLED],[1],
177                                              [Defined if the pango support is enabled.])
178                           ADG_DEPENDENCY([pangocairo],[pango])],
179                          [AS_IF([test "x${enable_pango}" = "xyes"],
180                                 [AC_MSG_ERROR([${PANGO_PKG_ERRORS} and pango support requested])],
181                                 [enable_pango=no])])])
182 AM_CONDITIONAL([HAVE_PANGO],[test "x${enable_pango}" = "xyes"])
184 dnl GTK+ support
185 AC_ARG_WITH(gtk,
186             [AS_HELP_STRING([--with-gtk@<:@=gtk2/gtk3@:>@],
187                             [include GTK+ specific widgets @<:@default=check@:>@])],
188             [],[with_gtk=check])
189 AS_CASE(["${with_gtk}"],
190         [gtk2],      [gtk2_pkg=yes; gtk3_pkg=no],
191         [gtk3],      [gtk2_pkg=no;  gtk3_pkg=yes],
192         [check|yes], [gtk2_pkg=yes; gtk3_pkg=yes],
193         [no],        [gtk2_pkg=no;  gtk3_pkg=no],
194         [AC_MSG_ERROR([Invalid option passed to --with-gtk])])
196 # GTK+ autodetection, giving precedence to GTK+3
197 AS_IF([test "x${gtk3_pkg}" = "xyes"],
198       [PKG_CHECK_MODULES([GTK3],[gtk+-3.0 >= ]gtk3_prereq,
199                          [gtk_pkg=gtk3
200                           ADG_DEPENDENCY([gtk+-3.0],[gtk3])],
201                          [:])])
202 AS_IF([test "x${gtk2_pkg}" = "xyes" -a "x${gtk_pkg}" = "x"],
203       [PKG_CHECK_MODULES([GTK2],[gtk+-2.0 >= ]gtk2_prereq,
204                          [gtk_pkg=gtk2
205                           ADG_DEPENDENCY([gtk+-2.0],[gtk2])],
206                          [:])])
207 AS_IF([test "x${gtk_pkg}" != "x"],[with_gtk=${gtk_pkg}])
209 # Handle "check" graceful degradation
210 AS_IF([test "x${with_gtk}" = "xcheck"],[with_gtk=no])
212 # Handle failures
213 AS_IF([test "x${with_gtk}" != "xno" -a "x${gtk_pkg}" = "x"],
214       [AC_MSG_ERROR([GTK+ support explicitely required but no valid GTK+ found])])
216 AS_IF([test "x${with_gtk}" = "xgtk3"],
217       [AC_DEFINE_UNQUOTED([GTK3_ENABLED],[1],
218                           [Defined if the GTK+3 support is enabled.])])
219 AS_IF([test "x${with_gtk}" = "xgtk2"],
220       [AC_DEFINE_UNQUOTED([GTK2_ENABLED],[1],
221                           [Defined if the GTK+2 support is enabled.])])
223 AM_CONDITIONAL([HAVE_GTK], [test "x${with_gtk}" != "xno"])
224 AM_CONDITIONAL([HAVE_GTK2],[test "x${with_gtk}" = "xgtk2"])
225 AM_CONDITIONAL([HAVE_GTK3],[test "x${with_gtk}" = "xgtk3"])
227 dnl Glade catalog dir
228 AC_ARG_WITH(glade_catalogdir,
229             [AS_HELP_STRING([--with-glade-catalogdir@<:@=DIR@:>@],
230                             [where to install the glade catalogs @<:@default=check@:>@])],
231             [],[with_glade_catalogdir=check])
233 # Both "check" and "yes" mean gladeui autodetection,
234 # but "yes" will fail on gladeui not found
235 AS_IF([test "x${with_glade_catalogdir}" = "xcheck" -o "x${with_glade_catalogdir}" = "xyes"],
236       [glade_pkg=check])
238 # gladeui autodetection, giving precedence to gladeui-2.0 if possible
239 AS_IF([test "x${glade_pkg}" = "xcheck" -a "x${with_gtk}" != "xgtk2"],
240       [PKG_CHECK_MODULES([GLADEUI2],[gladeui-2.0],[glade_pkg=gladeui-2.0],[:])])
241 AS_IF([test "x${glade_pkg}" = "xcheck"],
242       [PKG_CHECK_MODULES([GLADEUI1],[gladeui-1.0],[glade_pkg=gladeui-1.0],[:])])
243 AS_IF([test "x${glade_pkg}" != "x" -a "x${glade_pkg}" != "xcheck"],
244       [NTD_UNEXPAND([${glade_pkg}],
245                     [catalogdir],
246                     [with_glade_catalogdir="${NTD_UNEXPANDED}"],
247                     [AC_MSG_ERROR([${glade_pkg} found but pkg-config file invalid])])])
249 # Handle "yes" failure
250 AS_IF([test "x${glade_pkg}" = "xcheck" -a "x${with_glade_catalogdir}" = "xyes"],
251       [AC_MSG_ERROR([Glade support explicitely required but no valid gladeui found])])
253 # Handle "check" graceful degradation
254 AS_IF([test "x${glade_pkg}" = "xcheck" -a "x${with_glade_catalogdir}" = "xcheck"],
255       [with_glade_catalogdir=no])
257 AM_CONDITIONAL([HAVE_GLADE],[test "x${with_glade_catalogdir}" != "xno"])
258 AM_COND_IF([HAVE_GLADE],
259            [enable_glade=yes
260             report_glade="
261                   Glade catalog dir: ${with_glade_catalogdir}"],
262            [enable_glade=no
263             report_glade=""])
264 AC_SUBST([GLADE_CATALOGDIR],${with_glade_catalogdir})
266 dnl gtk-doc
267 GTK_DOC_CHECK(gtkdoc_prereq)
269 dnl GObject introspection
270 GOBJECT_INTROSPECTION_CHECK(gi_prereq)
271 AC_ARG_WITH(girdir,
272             [AS_HELP_STRING([--with-girdir=DIR],
273                             [where the gir files are installed @<:@default=check@:>@])],
274             [],[with_girdir=check])
275 AS_IF([test "x${enable_introspection}" = "xyes" -a "x${with_girdir}" = "xcheck"],
276       [NTD_UNEXPAND([gobject-introspection-1.0],
277                     [girdir],
278                     [with_girdir="${NTD_UNEXPANDED}"])])
279 AC_SUBST([GIRDIR],${with_girdir})
280 AC_ARG_WITH(typelibdir,
281             [AS_HELP_STRING([--with-typelibdir=DIR],
282                             [where the typelib files are installed @<:@default=check@:>@])],
283             [],[with_typelibdir=check])
284 AS_IF([test "x${enable_introspection}" = "xyes" -a "x${with_typelibdir}" = "xcheck"],
285       [NTD_UNEXPAND([gobject-introspection-1.0],
286                     [typelibdir],
287                     [with_typelibdir="${NTD_UNEXPANDED}"])])
288 AC_SUBST([TYPELIBDIR],${with_typelibdir})
289 AM_COND_IF([HAVE_INTROSPECTION],
290            [report_introspection="
291          Where to install gir files: ${with_girdir}
292  Where to install the typelib files: ${with_typelibdir}"],
293            [report_introspection=""])
295 dnl If introspection is used GObject support in cairo must be enabled,
296 dnl that is the cairo-gobject library must be present. That support
297 dnl was introduced since cairo 1.10.0.
298 PKG_CHECK_MODULES([CAIRO_GOBJECT],[cairo-gobject],
299                   [AC_DEFINE_UNQUOTED([CAIRO_GOBJECT_ENABLED],[1],
300                                       [Defined if GObject support in cairo is present.])],
301                   [AS_IF([test "x${enable_introspection}" = "xyes"],
302                          [AC_MSG_ERROR([GObject introspection requires the cairo-gobject library])])])
304 dnl GLib test framework
305 AC_ARG_ENABLE([test_framework],
306               [AS_HELP_STRING([--enable-test-framework],
307                               [enable GLib test framework @<:@default=check@:>@])],
308               [],[enable_test_framework=check])
309 AS_IF([test "x$enable_gcov" = "xyes"], [enable_test_framework=yes])
310 AS_IF([test "x${enable_test_framework}" != "xno"],
311       [PKG_CHECK_EXISTS([glib-2.0 >= 2.16.0],
312                         [enable_test_framework=yes],
313                         [AS_IF([test "x${enable_test_framework}" = "xyes"],
314                                [AC_MSG_ERROR([The test framework needs glib2-2.16.0 or later])],
315                                [enable_test_framework=no])])])
316 AM_CONDITIONAL([HAVE_TEST_FRAMEWORK],[test "x${enable_test_framework}" = "xyes"])
319 # Check for compiler characteristics
321 AC_C_CONST
324 # Windows substitutions for NSis installer
326 dnl Get the USRDIR from gobject-2.0.pc: all the dependencies *must* be
327 dnl installed under the same prefix.
328 USRDIR="$($PKG_CONFIG --variable=prefix gobject-2.0)"
329 AC_SUBST([USRDIR])
330 AM_SUBST_NOTMAKE([USRDIR])
332 dnl -win$PACKAGE_ARCH will be appended to the installer file name
333 AS_IF([test "x${host_cpu}" = "xx86_64"],[PACKAGE_ARCH=64],[PACKAGE_ARCH=32])
334 AC_SUBST([PACKAGE_ARCH])
337 # Additional substitutions
339 dnl The GObject dependency can be made optional by skipping
340 dnl the building of the GObject wrappers.
341 CPML_REQUIRES='cairo >= cairo_prereq gobject-2.0 >= gobject_prereq'
342 AM_COND_IF([HAVE_PANGO],
343       [ADG_REQUIRES='pangocairo >= pangocairo_prereq'
344        ADG_H_ADDITIONAL='
345 #include <pango/pango.h>
346 #include "adg/adg-text.h"
347 #include "adg/adg-pango-style.h"
349       [ADG_REQUIRES='gobject-2.0 >= gobject_prereq'
350        ADG_H_ADDITIONAL=''])
351 AM_COND_IF([HAVE_GTK3],[ADG_REQUIRES='gtk+-3.0 >= gtk3_prereq'])
352 AM_COND_IF([HAVE_GTK2],[ADG_REQUIRES='gtk+-2.0 >= gtk2_prereq'])
353 AM_COND_IF([HAVE_GTK],
354            [ADG_H_ADDITIONAL="${ADG_H_ADDITIONAL}
355 #include <gtk/gtk.h>
356 #include \"adg/adg-gtk-utils.h\"
357 #include \"adg/adg-gtk-area.h\"
358 #include \"adg/adg-gtk-layout.h\"
360             ADG_CANVAS_H_ADDITIONAL='
361 #include <gtk/gtk.h>
363 void            adg_canvas_set_paper            (AdgCanvas      *canvas,
364                                                  const gchar    *paper_name,
365                                                  GtkPageOrientation orientation);
366 void            adg_canvas_set_page_setup       (AdgCanvas      *canvas,
367                                                  GtkPageSetup   *page_setup);
368 GtkPageSetup *  adg_canvas_get_page_setup       (AdgCanvas      *canvas);
370            [ADG_CANVAS_H_ADDITIONAL=''])
372 AC_SUBST([CPML_LT_VERSION],cpml_lt_version)
373 AC_SUBST([CPML_REQUIRES])
374 AC_SUBST([ADG_LT_VERSION],adg_lt_version)
375 AC_SUBST([ADG_REQUIRES])
376 AC_SUBST([ADG_H_ADDITIONAL])
377 AC_SUBST([ADG_CANVAS_H_ADDITIONAL])
379 AM_SUBST_NOTMAKE([CPML_REQUIRES])
380 AM_SUBST_NOTMAKE([ADG_REQUIRES])
381 AM_SUBST_NOTMAKE([ADG_H_ADDITIONAL])
382 AM_SUBST_NOTMAKE([ADG_CANVAS_H_ADDITIONAL])
384 dnl CPML compiler flags and library dependencies
385 CPML_CFLAGS="$CAIRO_CFLAGS $GOBJECT_CFLAGS"
386 CPML_LIBS="$CAIRO_LIBS $GOBJECT_LIBS"
387 AC_SUBST([CPML_CFLAGS])
388 AC_SUBST([CPML_LIBS])
390 dnl ADG compiler flags and library dependencies
391 ADG_CFLAGS="$CAIRO_GOBJECT_CFLAGS"
392 ADG_LIBS="$CAIRO_GOBJECT_LIBS"
393 AM_COND_IF([HAVE_PANGO],
394            [ADG_CFLAGS="$PANGO_CFLAGS $ADG_CFLAGS"
395             ADG_LIBS="$PANGO_LIBS $ADG_LIBS"])
396 AM_COND_IF([HAVE_GTK2],
397            [ADG_CFLAGS="$GTK2_CFLAGS $ADG_CFLAGS"
398             ADG_LIBS="$GTK2_LIBS $ADG_LIBS"])
399 AM_COND_IF([HAVE_GTK3],
400            [ADG_CFLAGS="$GTK3_CFLAGS $ADG_CFLAGS"
401             ADG_LIBS="$GTK3_LIBS $ADG_LIBS"])
402 AC_SUBST([ADG_CFLAGS])
403 AC_SUBST([ADG_LIBS])
405 AC_SUBST([EXTRADIR])
408 # Generation
410 AC_CONFIG_FILES([build/Custom.nsh
411                  Makefile
412                  src/Makefile
413                  src/cpml/cpml-1.pc
414                  src/cpml/Makefile
415                  src/cpml/tests/Makefile
416                  src/adg/adg-1.pc
417                  src/adg.h
418                  src/adg/Makefile
419                  src/adg/adg-canvas.h
420                  src/adg/tests/Makefile
421                  demo/Makefile
422                  demo/cpml-demo.ui
423                  demo/adg-demo.ui
424                  po/Makefile.in
425                  docs/Makefile
426                  docs/cpml/Makefile
427                  docs/cpml/bookinfo.xml
428                  docs/adg/Makefile
429                  docs/adg/bookinfo.xml])
430 AC_CONFIG_FILES([demo/adg-glade],[chmod +x demo/adg-glade])
431 AC_OUTPUT
434 # Report
436 AC_MSG_NOTICE([generating report
438 AC_PACKAGE_NAME adg_version will be built with the following options:
439 ----------------------------------------------------------
440                 CPML library to use: internal (cpml-adg_version)
441          Build pango based entities: ${enable_pango}
442                        GTK+ support: ${with_gtk}
443              Install glade catalogs: ${enable_glade}${report_glade}
444                 Build API reference: ${enable_gtk_doc}
445              GObject instrospection: ${enable_introspection}${report_introspection}
446                 Test coverage build: ${enable_gcov}
447              Test framework support: ${enable_test_framework}