summaryrefslogtreecommitdiff
path: root/configure.in
blob: 8f8d35f34b538dc9bc0bd8fb676f8547ef3492a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373

# This script follows 
# http://www.gnu.org/software/autoconf/manual/html_node/Autoconf-Input-Layout.html#Autoconf-Input-Layout
# Please keep it like that.

# Guessing some version.
AC_PREREQ(2.54)

m4_define([ccss_version_major], [0])
m4_define([ccss_version_minor], [5])
m4_define([ccss_version_micro], [1])
m4_define([ccss_version_extra], [])
m4_define([ccss_version],
    [ccss_version_major.ccss_version_minor.ccss_version_micro[]ccss_version_extra])

m4_define([ccss_cairo_appearance_module_interface_version], [0.4])

AC_INIT([ccss], [ccss_version])
AC_CONFIG_AUX_DIR([build])
AC_CONFIG_MACRO_DIR([build])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_SRCDIR([ccss/ccss-stylesheet.c])

AM_INIT_AUTOMAKE

dnl Version info for libraries = CURRENT:REVISION:AGE
dnl
dnl Within each x.y.*, ABI is maintained backward and _forward_ compatible.
dnl (As a consequence, no exported function may be added.)
dnl So it's enough to have one interface number per each x.y.* branch.
dnl
dnl OTOH, we are not able to keep ABI strictly backward compatible throughout
dnl the whole x.*.*.
dnl The easiest way is to declare no ABI compatibility, ie. AGE is always 0.
dnl
m4_define([version_iface],
	m4_eval(100 * ccss_version_major + ccss_version_minor))

AC_SUBST([VERSION_INFO], [version_iface:ccss_version_micro:0])
AC_SUBST([CCSS_VERSION_MAJOR], [ccss_version_major])
AC_SUBST([CCSS_VERSION_MINOR], [ccss_version_minor])
AC_SUBST([CCSS_VERSION_MICRO], [ccss_version_micro])

### Checks for configure arguments. ############################################

AC_ARG_ENABLE([debug], 
  [AS_HELP_STRING([--enable-debug], [enable debug code])], 
[
  enable_debug="$enableval"
],[
  enable_debug="no"
])

if test "$enable_debug" == "yes"; then
  AC_DEFINE([CCSS_DEBUG], [1], [enable debug code])
  CFLAGS="-g -O0 ${CFLAGS}"
fi
AM_CONDITIONAL([CCSS_DEBUG], test "$enable_debug" == "yes")


# So usually one just sets CFLAGS for this, but a configure 
# arguments lets us force this when running `make distcheck'.
AC_ARG_ENABLE([werror], 
  [AS_HELP_STRING([--enable-werror], [bail on warnings])], 
[
  if test "$enableval" == "yes"; then
    CFLAGS="$CFLAGS -Werror"
  fi  
])



### Checks for programs. #######################################################

AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET

# Should be replaced by LT_INIT, which apparently doesn't work.
# Try again some time.
AC_DISABLE_STATIC
AC_LIBTOOL_WIN32_DLL
AC_PROG_LIBTOOL 

# gtk-doc
gtk_doc_installed=true
#ifdef([GTK_DOC_CHECK],[GTK_DOC_CHECK([1.0])],[gtk_doc_installed=false])
# I would have liked to conditionalize this, but 
# that appears to break other things http://bugzilla.gnome.org/show_bug.cgi?id=156399
GTK_DOC_CHECK([1.0])
AM_CONDITIONAL(GTK_DOC_INSTALLED, $gtk_doc_installed)

# hardwire-enable testing
enable_glibtest="yes"
AM_CONDITIONAL(ENABLE_GLIB_TEST, test "$enable_glibtest" = "yes")


### Checks for libraries. ######################################################


### ccss ###

ccss_reqs='glib-2.0 libcroco-0.6'
ccss_pkgs=

# See http://bugzilla.gnome.org/show_bug.cgi?id=553937 .
PKG_CHECK_EXISTS([ libcroco-0.6 >= 0.6.2 ],
[
  enable_libcroco_workaround="no"
],[
  enable_libcroco_workaround="yes"
])
if test "$enable_libcroco_workaround" = "yes"; then
  AC_DEFINE([CCSS_ENABLE_LIBCROCO_WORKAROUND], [1], [Work around libcroco issue #553937])
fi

# Unconditional requirement.
ccss_pkgs=${ccss_reqs}

PKG_CHECK_MODULES([CCSS], $ccss_pkgs)

# AC_SUBST([CCSS_CFLAGS]) # set further down
AC_SUBST([CCSS_LIBS])
AC_SUBST([CCSS_DEPS], $ccss_pkgs)


### ccss-cairo ###

ccss_cairo_reqs='cairo >= 1.4'
ccss_cairo_pkgs=

AC_ARG_ENABLE([ccss-cairo],
              [AS_HELP_STRING([--disable-ccss-cairo], [disable the build of ccss-cairo.])],
[
  want_cairo="$enableval"
], [
  want_cairo="yes"
])

if test "$want_cairo" = "yes"; then
  ccss_cairo_pkgs="$ccss_pkgs $ccss_cairo_reqs"
  AC_DEFINE([CCSS_WITH_CAIRO], [1], [Cairo drawing support])
fi
AM_CONDITIONAL([CCSS_WITH_CAIRO], [test "$want_cairo" = "yes"])
AC_SUBST([ccss_with_cairo], [$want_cairo])


### use librsvg?

ccss_cairo_rsvg_reqs='librsvg-2.0 >= 2.16'

AC_ARG_WITH([rsvg],
            [AS_HELP_STRING([--without-rsvg], [ccss-cairo: do not build SVG image support.])],
[
  want_rsvg="$withval"  
], [
  want_rsvg="yes"
])

if test "$want_rsvg" = "yes"; then
  ccss_cairo_pkgs="$ccss_cairo_pkgs $ccss_cairo_rsvg_reqs"
  AC_DEFINE([CCSS_WITH_RSVG], [1], [SVG support through librsvg])
fi
AM_CONDITIONAL([CCSS_WITH_RSVG], [test "$want_rsvg" = "yes"])
AC_SUBST([ccss_with_rsvg], [$want_rsvg])


### use libsoup?

want_soup="no"
if test "$want_rsvg" = "yes"; then

  ccss_cairo_soup_reqs='libsoup-2.4 librsvg-2.0 >= 2.22.4'

  AC_ARG_WITH([soup],
              [AS_HELP_STRING([--without-soup], [ccss-cairo: do not build SVG fragment support.])],
  [
    want_soup="$withval"  
  ], [
    want_soup="yes"
  ])

fi

if test "$want_soup" = "yes"; then
  ccss_cairo_pkgs="$ccss_cairo_pkgs $ccss_cairo_soup_reqs"
  AC_DEFINE([CCSS_WITH_SOUP], [1], [SVG fragment support through libsoup and librsvg-2.0 >= 2.22.4])
fi
AM_CONDITIONAL([CCSS_WITH_SOUP], [test "$want_soup" = "yes"])
AC_SUBST([ccss_with_soup], [$want_soup])


### check
if test "$want_cairo" = "yes"; then
  PKG_CHECK_MODULES([CCSS_CAIRO], $ccss_cairo_pkgs)
fi

# AC_SUBST([CCSS_CAIRO_CFLAGS]) # set further down
CCSS_CAIRO_LIBS="${CCSS_CAIRO_LIBS} "'$(top_builddir)/ccss/libccss-1.la'
AC_SUBST([CCSS_CAIRO_LIBS])
AC_SUBST([CCSS_CAIRO_DEPS], "$ccss_cairo_pkgs ccss-1")

CCSS_CAIRO_APPEARANCE_MODULE_INTERFACE_VERSION=ccss_cairo_appearance_module_interface_version
AC_SUBST([CCSS_CAIRO_APPEARANCE_MODULE_INTERFACE_VERSION])
CCSS_CAIRO_APPEARANCE_MODULE_PATH="${libdir}/ccss-1/$CCSS_CAIRO_APPEARANCE_MODULE_INTERFACE_VERSION"
AC_SUBST([CCSS_CAIRO_APPEARANCE_MODULE_PATH])


### ccss-gtk ###

ccss_gtk_reqs='gtk+-2.0 >= 2.10'
ccss_gtk_pkgs=

AC_ARG_ENABLE([ccss-gtk],
              [AS_HELP_STRING([--disable-ccss-gtk], [disable the build of ccss-gtk.])],
[
  want_gtk="$enableval"
], [
  want_gtk="yes"
])

if test "$want_gtk" = "yes"; then
  ccss_gtk_pkgs="$ccss_cairo_pkgs $ccss_gtk_reqs"
  AC_DEFINE([CCSS_WITH_GTK], [1], [Gtk+ toolkit support])
fi
AM_CONDITIONAL([CCSS_WITH_GTK], [test "$want_gtk" = "yes"])
AC_SUBST([ccss_with_gtk], [$want_gtk])


### check
if test "$want_gtk" = "yes"; then
  PKG_CHECK_MODULES([CCSS_GTK], $ccss_gtk_pkgs)
fi

# AC_SUBST([CCSS_GTK_CFLAGS]) # set further down
CCSS_GTK_LIBS="${CCSS_GTK_LIBS} "'$(top_builddir)/ccss/libccss-1.la $(top_builddir)/ccss-cairo/libccss-cairo-1.la'
AC_SUBST([CCSS_GTK_LIBS])
AC_SUBST([CCSS_GTK_DEPS], "$ccss_gtk_reqs ccss-cairo-1")


### examples ###

ccss_examples_reqs='gtk+-2.0 >= 2.10 librsvg-2.0'
ccss_examples_pkgs=

AC_ARG_ENABLE([examples],
              [AS_HELP_STRING([--disable-examples], [disable the build of examples.])],
[
  want_examples="$enableval"
], [
  want_examples="yes"
])

if test "$want_examples" = "yes"; then
  ccss_examples_pkgs="$ccss_cairo_pkgs $ccss_examples_reqs"
  AC_DEFINE([CCSS_WITH_EXAMPLES], [1], [Build examples.])
fi
AM_CONDITIONAL([CCSS_WITH_EXAMPLES], [test "$want_examples" = "yes"])
AC_SUBST([ccss_with_examples], [$want_examples])

### check

if test "$want_examples" = "yes"; then
  PKG_CHECK_MODULES([CCSS_EXAMPLES], $ccss_examples_pkgs)
fi

# AC_SUBST([CCSS_EXAMPLES_CFLAGS]) # set further down
AC_SUBST([CCSS_EXAMPLES_LIBS])
AC_SUBST([CCSS_EXAMPLES_DEPS], $ccss_examples_pkgs)



### Checks for header files. ###################################################

AC_HEADER_STDC
AC_CHECK_HEADERS([stdbool.h stddef.h stdint.h stdio.h stdlib.h string.h])



### Checks for typedefs, structures, and compiler characteristics. #############

AC_C_CONST

extra_cflags=
if test "$GCC" = "yes"; then
  orig_cflags=${CFLAGS}
  for option in -std=c99 -pedantic -Wall -Wbitwise -Wcast-to-as			\
    -Wchar-subscripts -Wdeclaration-after-statement -Wdefault-bitfield-sign	\
    -Wdo-while -Wmissing-declarations -Wmissing-noreturn -Wmissing-prototypes	\
    -Wnested-externs -Wno-pointer-sign -Wparen-string -Wpointer-arith		\
    -Wptr-subtraction-blows -Wreturn-void -Wsign-compare -Wstrict-prototypes	\
    -Wtypesign -Wwrite-strings ; do
    SAVE_CFLAGS="$CFLAGS"
    CFLAGS="$CFLAGS $option"
    AC_MSG_CHECKING([whether gcc understands $option])
    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[has_option=yes],[has_option=no])
    if test $has_option = no; then
      CFLAGS="$SAVE_CFLAGS"
    else
      extra_cflags="${extra_cflags} $option"
    fi
    AC_MSG_RESULT($has_option)
    unset has_option
    unset SAVE_CFLAGS
  done
  unset option
  CFLAGS=${orig_cflags}
fi

CCSS_CFLAGS="${CCSS_CFLAGS} ${extra_cflags}"
AC_SUBST([CCSS_CFLAGS])

CCSS_CAIRO_CFLAGS="${CCSS_CAIRO_CFLAGS} ${extra_cflags}"
AC_SUBST([CCSS_CAIRO_CFLAGS])

CCSS_GTK_CFLAGS="${CCSS_GTK_CFLAGS} ${extra_cflags}"
AC_SUBST([CCSS_GTK_CFLAGS])

CCSS_EXAMPLES_CFLAGS="${CCSS_EXAMPLES_CFLAGS} ${extra_cflags}"
AC_SUBST([CCSS_EXAMPLES_CFLAGS])

SHAVE_INIT([build])

AC_CONFIG_FILES([
  Makefile

  build/Makefile
  build/shave
  build/shave-libtool

  ccss-1.pc
  ccss/Makefile
  ccss-doc/Makefile
  ccss-doc/version.xml
  ccss-tests/Makefile

  ccss-cairo-1.pc
  ccss-cairo/Makefile
  ccss-cairo-doc/Makefile
  ccss-cairo-doc/version.xml

  ccss-gtk-1.pc
  ccss-gtk/Makefile
  ccss-gtk-doc/Makefile
  ccss-gtk-doc/version.xml

  examples/Makefile
])
AC_OUTPUT

echo "
Configuration
-------------

Configuration:
    Build debugging code         $enable_debug

ccss:                            yes
    Workaround for #553937       $enable_libcroco_workaround (see bugzilla.gnome.org)

ccss-cairo:                      $want_cairo (requires $ccss_cairo_reqs)
    Support for SVG images       $want_rsvg (requires $ccss_cairo_rsvg_reqs)
    Support for SVG fragments    $want_soup (requires $ccss_cairo_soup_reqs)
    Appearance module path       $CCSS_CAIRO_APPEARANCE_MODULE_PATH

ccss-gtk:                        $want_gtk (requires $ccss_gtk_reqs)

examples:                        $want_examples (requires $ccss_examples_reqs)
"