summaryrefslogtreecommitdiff
path: root/configure.in
blob: dd8e58ec36de65cb9faad66ef4a046edf190818e (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

# 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], [2])
m4_define([ccss_version_micro], [0])
### For the release:
# m4_define([ccss_version_extra], [])
### On trunk:
m4_define([ccss_version_extra], [.trunk])
m4_define([ccss_version],
    [ccss_version_major.ccss_version_minor.ccss_version_micro[]ccss_version_extra])

AC_INIT([libccss], [ccss_version])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_HEADERS([ccss/ccss-features.h])
AC_CONFIG_SRCDIR([ccss/ccss-stylesheet.c])

AM_INIT_AUTOMAKE
AM_MAINTAINER_MODE

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])


### 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)


### 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 ###

# Guessing a version.
ccss_cairo_reqs='cairo >= 1.4'
ccss_cairo_pkgs=

PKG_CHECK_EXISTS([ $ccss_cairo_reqs ],
[
  with_cairo="yes"
  ccss_cairo_pkgs="$ccss_cairo_pkgs $ccss_cairo_reqs"
],[
  with_cairo="no"
])

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


# Guessing a version.
rsvg_reqs='librsvg-2.0 >= 2.16'
PKG_CHECK_EXISTS([ $rsvg_reqs ],
[
  with_rsvg="yes"
  ccss_cairo_pkgs="$ccss_cairo_pkgs $rsvg_reqs"
],[
  with_rsvg="no"
])

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


soup_reqs='libsoup-2.4'
PKG_CHECK_EXISTS([ $soup_reqs ],
[
  with_soup="yes"
  ccss_cairo_pkgs="$ccss_cairo_pkgs $soup_reqs"
],[
  with_soup="no"
])

if test "$with_soup" = "yes"; then
  AC_DEFINE([CCSS_WITH_SOUP], [1], [URI parsing support through libsoup])
fi
AM_CONDITIONAL([CCSS_WITH_SOUP], [test "$with_soup" = "yes"])


if test "$with_cairo" = "yes"; then
  ccss_cairo_pkgs="$ccss_pkgs $ccss_cairo_pkgs"
  PKG_CHECK_MODULES(CCSS_CAIRO, $ccss_cairo_pkgs)
fi
# AC_SUBST([CCSS_CAIRO_CFLAGS]) # set further down
AC_SUBST([CCSS_CAIRO_LIBS])
AC_SUBST([CCSS_CAIRO_DEPS], $ccss_cairo_pkgs)


### ccss-clutter ###

ccss_clutter_reqs='clutter-cairo-0.8'
ccss_clutter_pkgs=

PKG_CHECK_EXISTS([ $ccss_clutter_reqs ],
[
  with_clutter="yes"
  ccss_clutter_pkgs="$ccss_clutter_pkgs $ccss_clutter_reqs"
],[
  with_clutter="no"
])

if test "$with_clutter" = "yes"; then
  AC_DEFINE([CCSS_WITH_CLUTTER], [1], [Support for clutter-cairo (experimental)])
fi
AM_CONDITIONAL([CCSS_WITH_CLUTTER], [test "$with_clutter" = "yes"])
AC_SUBST([ccss_with_clutter], [$with_clutter])

if test "$with_clutter" = "yes"; then
  ccss_clutter_pkgs="$ccss_cairo_pkgs $ccss_clutter_pkgs"
  PKG_CHECK_MODULES(CCSS_CLUTTER, $ccss_clutter_pkgs)
fi
# AC_SUBST([CCSS_CLUTTER_CFLAGS]) # set further down
AC_SUBST([CCSS_CLUTTER_LIBS])
AC_SUBST([CCSS_CLUTTER_DEPS], $ccss_clutter_pkgs)


### ccss-gtk ###

# Gtk+ 2.10 was the first with color scheme support, so we want it.
ccss_gtk_reqs='gtk+-2.0 >= 2.10.0'
ccss_gtk_pkgs=

PKG_CHECK_EXISTS([ $ccss_gtk_reqs ],
[
  with_gtk="yes"
  ccss_gtk_pkgs="$ccss_gtk_pkgs $ccss_gtk_reqs"
],[
  with_gtk="no"
])

if test "$with_gtk" = "yes"; then
  AC_DEFINE([CCSS_WITH_GTK], [1], [Support for drawing Gtk+ primitives like `box-gap'])
fi
AM_CONDITIONAL([CCSS_WITH_GTK], [test "$with_gtk" = "yes"])
AC_SUBST([ccss_with_gtk], [$with_gtk])

if test "$with_gtk" = "yes"; then
  ccss_gtk_pkgs="$ccss_cairo_pkgs $ccss_gtk_pkgs"
  PKG_CHECK_MODULES(CCSS_GTK, $ccss_gtk_pkgs)
fi
# AC_SUBST([CCSS_GTK_CFLAGS]) # set further down
AC_SUBST([CCSS_GTK_LIBS])
AC_SUBST([CCSS_GTK_DEPS], $ccss_gtk_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}"
# FIXME: use above line when cairo split is complete.
CCSS_CFLAGS="${CCSS_CAIRO_CFLAGS} ${extra_cflags}"
AC_SUBST([CCSS_CFLAGS])

CCSS_COMPAT_CFLAGS=$(echo ${CCSS_CFLAGS} | sed 's,-pedantic,,g')
AC_SUBST([CCSS_COMPAT_CFLAGS])

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

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

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

AC_CONFIG_FILES([
  Makefile
  libccss-1.pc
  cccss/Makefile
  ccss/Makefile
  ccss-gtk/Makefile
  doc/Makefile
  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:                      $with_cairo
    Support for SVG images       $with_rsvg (requires $rsvg_reqs)
    Support for SVG fragments    $with_soup (WIP, requires $soup_reqs)

ccss-clutter:                    $with_clutter (experimental, requires $ccss_clutter_reqs)

ccss-gtk:                        $with_gtk
"