2009-12-07 Rolf Bjarne Kvinge <RKvinge@novell.com>
[moon.git] / cairo / build / configure.ac.features
blobf56cd0df4e6471dc745bb893b320752c4025bfb3
2 dnl
3 dnl Define macros to enable various features.
4 dnl  - Macro: CAIRO_ENABLE_* (ID, NAME, DEFAULT, COMMANDS)
5 dnl
6 dnl where:
7 dnl
8 dnl     ID is the feature id, eg. "ft" for cairo_ft_...
9 dnl     NAME is the human-readable name of the feature, eg. "FreeType"
10 dnl     DEFAULT is the default state of the feature:
11 dnl             "no" for experimental backends, eg. your favorite new backend
12 dnl             "yes" for mandatory backends, eg. png
13 dnl             "auto" for other supported backends, eg. xlib
14 dnl     COMMANDS are run to check whether the feature can be enabled.  Their
15 dnl             result may be cached, so user should not count on them being run.
16 dnl             They should set use_$(ID) to something other than yes if the
17 dnl             feature cannot be built, eg. "no (requires SomeThing)".  It then
18 dnl             should also set $(ID)_REQUIRES/CFLAGS/LIBS/...
19 dnl             appropriately.  Look at the macro definition for more details,
20 dnl             or ask if in doubt.
21 dnl
23 AC_DEFUN([CAIRO_ENABLE],
24         [_CAIRO_ENABLE([$1],    [$2],                   ,               [$3],[$4])])dnl
26 AC_DEFUN([CAIRO_ENABLE_SURFACE_BACKEND],
27         [_CAIRO_ENABLE([$1],    [$2 surface backend],   surface,        [$3],[$4])])dnl
29 AC_DEFUN([CAIRO_ENABLE_FONT_BACKEND],
30         [_CAIRO_ENABLE([$1],    [$2 font backend],      font,           [$3],[$4])])dnl
32 AC_DEFUN([CAIRO_ENABLE_FUNCTIONS],
33         [_CAIRO_ENABLE([$1],    [$2 functions],         functions,      [$3],[$4])])dnl
36 dnl
37 dnl Define cr_feature_pc and friends ala other cr_feature_* macros
38 dnl
39 m4_define([cr_pc_modname],
40         [[cairo-]m4_translit([$1],_,-)])dnl
41 m4_define([cr_feature_pc],
42         [cr_pc_modname(cr_feature)[.pc]])dnl
43 m4_define([cr_feature_uninstalled_pc],
44         [cr_pc_modname(cr_feature)[-uninstalled.pc]])dnl
47 dnl ===========================================================================
48 dnl
49 dnl Hooks
50 dnl
51 dnl ===========================================================================
54 dnl ===========================================================================
55 dnl
56 dnl Generate {src,boilerplate}/Makefile.{am,win32}.config
57 dnl
59 CAIRO_INIT_MAKEFILES([build])
60 CAIRO_CONFIG_MAKEFILE([cairo], [src])dnl
61 dnl CAIRO_CONFIG_MAKEFILE([cairo_boilerplate], [boilerplate])dnl
62 CAIRO_MAKEFILE_INCLUDE(*,[Makefile.sources])dnl
63 dnl An empty line per feature for readability
64 CAIRO_MAKEFILE_ACCUMULATE_FEATURE(*,*,*,*,[])dnl
67 dnl Collect list of all supported public headers
68 CAIRO_MAKEFILE_ACCUMULATE(*,
69 [supported_$1_headers = $($1_headers)]dnl
70 )dnl
71 CAIRO_MAKEFILE_ACCUMULATE_FEATURE(*,*,!no,!,
72 [supported_$1_headers += $($1_$2_headers)]dnl
73 )dnl
75 dnl Collect list of all unsupported public headers
76 CAIRO_MAKEFILE_ACCUMULATE(*,
77 [unsupported_$1_headers =]dnl
78 )dnl
79 CAIRO_MAKEFILE_ACCUMULATE_FEATURE(*,*,no,!,
80 [unsupported_$1_headers += $($1_$2_headers)]dnl
81 )dnl
83 dnl Collect list of source files for all public features
84 CAIRO_MAKEFILE_ACCUMULATE(*,
85 [dnl
86 all_$1_files = $(all_$1_headers) $(all_$1_private) $(all_$1_sources)
87 all_$1_headers = $($1_headers)
88 all_$1_private = $($1_private)
89 all_$1_sources = $($1_sources)
90 ])dnl
91 CAIRO_MAKEFILE_ACCUMULATE_FEATURE(*,*,*,!,
92 [dnl
93 all_$1_headers += $($1_$2_headers)
94 all_$1_private += $($1_$2_private)
95 all_$1_sources += $($1_$2_sources)]dnl
96 )dnl
98 dnl Collect list of source files for enabled public features
99 CAIRO_MAKEFILE_ACCUMULATE(*,
100 [dnl
101 enabled_$1_files = $(enabled_$1_headers) $(enabled_$1_private) $(enabled_$1_sources)
102 enabled_$1_headers = $($1_headers)
103 enabled_$1_private = $($1_private)
104 enabled_$1_sources = $($1_sources)
105 ])dnl
106 CAIRO_MAKEFILE_ACCUMULATE_FEATURE(*,yes,*,!,
107 [dnl
108 enabled_$1_headers += $($1_$2_headers)
109 enabled_$1_private += $($1_$2_private)
110 enabled_$1_sources += $($1_$2_sources)]dnl
111 )dnl
113 dnl No public headers for private features
115 dnl Collect list of source files for all private features
116 CAIRO_MAKEFILE_ACCUMULATE_FEATURE(*,*,*,,
117 [dnl
118 all_$1_private += $($1_$2_private) $($1_$2_headers)
119 all_$1_sources += $($1_$2_sources)]dnl
120 )dnl
122 dnl Collect list of source files for enabled private features
123 CAIRO_MAKEFILE_ACCUMULATE_FEATURE(*,yes,*,,
124 [dnl
125 enabled_$1_private += $($1_$2_private) $($1_$2_headers)
126 enabled_$1_sources += $($1_$2_sources)]dnl
127 )dnl
130 dnl ===========================================================================
132 dnl Generate .pc files
135 dnl All .pc files are generated automatically except for this one
136 AC_CONFIG_FILES([src/cairo.pc])dnl
137 AC_CONFIG_FILES([cairo-uninstalled.pc:src/cairo-uninstalled.pc.in])dnl
139 dnl pkg-config requires, non-pkgconfig cflags and libs, and total cflags and libs
140 CAIRO_FEATURE_VARS_REGISTER([BASE],[cairo])dnl
141 CAIRO_ACCUMULATED_FEATURE_VARS_REGISTER([REQUIRES],,[ ])dnl
142 CAIRO_ACCUMULATED_FEATURE_VARS_REGISTER([CFLAGS NONPKGCONFIG_CFLAGS],,[ ])dnl
143 CAIRO_ACCUMULATED_FEATURE_VARS_REGISTER([LIBS NONPKGCONFIG_LIBS],,[ ],[$LIBS])dnl
144 AC_SUBST(CAIRO_REQUIRES)dnl
145 AC_SUBST(CAIRO_CFLAGS)dnl
146 AC_SUBST(CAIRO_NONPKGCONFIG_CFLAGS)dnl
147 AC_SUBST(CAIRO_LIBS)dnl
148 AC_SUBST(CAIRO_NONPKGCONFIG_LIBS)dnl
150 dnl add non-pkgconfig values
151 AC_CONFIG_COMMANDS_PRE(
152 [dnl
153 CAIRO_CFLAGS="$CAIRO_CFLAGS $CAIRO_NONPKGCONFIG_CFLAGS"
154 CAIRO_LIBS="$CAIRO_LIBS $CAIRO_NONPKGCONFIG_LIBS"
155 ])dnl
157 m4_define([_CAIRO_FEATURE_CONFIG_PKGCONFIG_FILE],
158 [dnl
159         AC_CONFIG_FILES([$3:$4],
160         [dnl
161                 mv "$3" "$3.tmp" &&
162                 $SED "dnl
163                 s%@FEATURE_PC@%]cr_pc_modname([$1])[%g;dnl
164                 s%@FEATURE_NAME@%$2%g;dnl
165                 s%@FEATURE_BASE@%$$1_BASE%g;dnl
166                 s%@FEATURE_REQUIRES@%$$1_REQUIRES%g;dnl
167                 s%@FEATURE_NONPKGCONFIG_LIBS@%$$1_NONPKGCONFIG_LIBS%g;dnl
168                 s%@FEATURE_NONPKGCONFIG_CFLAGS@%$$1_NONPKGCONFIG_CFLAGS%g;dnl
169                 " < "$3.tmp" > "$3" && rm -f "$3.tmp" ||
170                 AC_MSG_ERROR(failed to update $3)
171         ],[dnl
172                 SED='$SED'
173                 $1_BASE='$$1_BASE'
174                 $1_REQUIRES='$$1_REQUIRES'
175                 $1_NONPKGCONFIG_LIBS='$$1_NONPKGCONFIG_LIBS'
176                 $1_NONPKGCONFIG_CFLAGS='$$1_NONPKGCONFIG_CFLAGS'
177         ])dnl
178 ])dnl
180 dnl Generate .pc files for enabled non-builtin public features
181 CAIRO_FEATURE_HOOK_REGISTER(yes,!always,!,
182 [dnl
183         _CAIRO_FEATURE_CONFIG_PKGCONFIG_FILE(
184                 [$1],
185                 cr_feature_name,
186                 [src/]cr_feature_pc,
187                 [src/cairo-features.pc.in]
188         )dnl
189 ])dnl
191 dnl Generate -uninstalled.pc files for enabled non-builtin public features
192 CAIRO_FEATURE_HOOK_REGISTER(yes,!always,!,
193 [dnl
194         _CAIRO_FEATURE_CONFIG_PKGCONFIG_FILE(
195                 [$1],
196                 cr_feature_name,
197                 cr_feature_uninstalled_pc,
198                 [src/cairo-features-uninstalled.pc.in]
199         )dnl
200 ])dnl
203 dnl Collect list of .pc files for all non-builtin public features
204 CAIRO_MAKEFILE_ACCUMULATE(cairo,
205 [all_$1_pkgconf = cairo.pc])dnl
206 CAIRO_MAKEFILE_ACCUMULATE_FEATURE(cairo,*,!always,!,
207 [all_$1_pkgconf += cr_feature_pc])dnl
209 dnl Collect list of .pc files for enabled non-builtin public features
210 CAIRO_MAKEFILE_ACCUMULATE(cairo,
211 [enabled_$1_pkgconf = cairo.pc])dnl
212 CAIRO_MAKEFILE_ACCUMULATE_FEATURE(cairo,yes,!always,!,
213 [enabled_$1_pkgconf += cr_feature_pc])dnl
216 dnl ===========================================================================
218 dnl Generate src/cairo-features.h, src/cairo-supported-features.h, and
219 dnl src/cairo-features-win32.h
222 dnl Collect list of enabled public features
223 CAIRO_ACCUMULATORS_REGISTER(FEATURES,[ ])dnl
224 CAIRO_FEATURE_HOOK_REGISTER(yes,*,!,dnl
225 [dnl
226         CAIRO_ACCUMULATE(FEATURES, cr_feature_tag)dnl
227 ])dnl
228 dnl Collect list of all supported public features
229 CAIRO_ACCUMULATORS_REGISTER(SUPPORTED_FEATURES,[ ])dnl
230 CAIRO_FEATURE_HOOK_REGISTER(*,!no,!,dnl
231 [dnl
232         CAIRO_ACCUMULATE(SUPPORTED_FEATURES, cr_feature_tag)
233 ])dnl
234 dnl Collect list of all supported disabled public features
235 CAIRO_ACCUMULATORS_REGISTER(NO_FEATURES,[ ])dnl
236 CAIRO_FEATURE_HOOK_REGISTER(no,!no,!,
237 [dnl
238         CAIRO_ACCUMULATE(NO_FEATURES, cr_feature_tag)
239 ])dnl
241 dnl Generate src/cairo-features.h
242 CAIRO_CONFIG_COMMANDS([src/cairo-features.h],
243 [dnl
244         echo '/* Generated by configure.  Do not edit. */'
245         echo '#ifndef CAIRO_FEATURES_H'
246         echo '#define CAIRO_FEATURES_H'
247         echo ''
248         for FEATURE in $CAIRO_FEATURES; do
249                 echo "#define $FEATURE 1"
250         done | LANG=C sort
251         echo ''
252         for FEATURE in $CAIRO_NO_FEATURES; do
253                 echo "/*#undef $FEATURE */"
254         done | LANG=C sort
255         echo ''
256         echo '#endif'
257 ],[dnl
258         CAIRO_FEATURES='$CAIRO_FEATURES'
259         CAIRO_NO_FEATURES='$CAIRO_NO_FEATURES'
260 ])dnl
261 dnl Generate src/cairo-supported-features.h
262 CAIRO_CONFIG_COMMANDS([$srcdir/src/cairo-supported-features.h],
263 [dnl
264         echo '/* Generated by configure.  Do not edit. */'
265         echo '#ifndef CAIRO_SUPPORTED_FEATURES_H'
266         echo '#define CAIRO_SUPPORTED_FEATURES_H'
267         echo ''
268         echo '/* This is a dummy header, to trick gtk-doc only */'
269         echo ''
270         for FEATURE in $CAIRO_SUPPORTED_FEATURES; do
271                 echo "#define $FEATURE 1"
272         done
273         echo ''
274         echo '#endif'
275 ],[dnl
276         CAIRO_SUPPORTED_FEATURES='$CAIRO_SUPPORTED_FEATURES'
277 ])dnl
279 dnl For enabled private features just define them in config.h.  No fanfare!
280 CAIRO_FEATURE_HOOK_REGISTER(yes,*,,
281 [dnl
282         AC_DEFINE(cr_feature_tag, 1, [Define to 1 to enable cairo's ]cr_feature_name[ feature])
283 ])dnl
286 dnl Generate build/Makefile.win32.features-h that generates src/cairo-features.h
287 CAIRO_CONFIG_MAKEFILE_PRIVATE_WIN32([win32_features_h],[build],[features-h])
289 CAIRO_MAKEFILE_ACCUMULATE([win32_features_h],
290 [src/cairo-features.h: build/Makefile.win32.features
291         @echo "Generating src/cairo-features.h"
292         @echo "/* Generated by Makefile.win32.  Do not edit. */" > src/cairo-features.h
293         @echo "[#]ifndef CAIRO_FEATURES_H" >> src/cairo-features.h
294         @echo "[#]define CAIRO_FEATURES_H 1" >> src/cairo-features.h]dnl
296 AC_CONFIG_COMMANDS_PRE(
297 [dnl
298         CAIRO_MAKEFILE_ACCUMULATE([win32_features_h], [ @echo "[#]endif" >>  src/cairo-features.h])
299 ])dnl
300 CAIRO_MAKEFILE_ACCUMULATE_FEATURE([win32_features_h],yes,*,*,dnl
301 [       @echo "[#]define cr_feature_tag 1" >> src/cairo-features.h]dnl
302 )dnl
305 dnl ===========================================================================
307 dnl Report
310 CAIRO_ACCUMULATORS_REGISTER([WARNING_MESSAGE],m4_newline()m4_newline)dnl
312 dnl Collect warning message for enabled unsupported public features
313 CAIRO_FEATURE_HOOK_REGISTER(yes,no,!,
314 [dnl
315         CAIRO_ACCUMULATE([WARNING_MESSAGE], CAIRO_TEXT_WRAP([The ]cr_feature_name[ feature is still under active development and is included in this release only as a preview. It does NOT fully work yet and incompatible changes may yet be made to ]cr_feature_name[ specific API.], [--- ]))
316 ])dnl
318 dnl Collect warning message for disabled recommended features
319 CAIRO_FEATURE_HOOK_REGISTER(no,yes,*,
320 [dnl
321         CAIRO_ACCUMULATE([WARNING_MESSAGE], CAIRO_TEXT_WRAP([It is strictly recommended that you do NOT disable the ]cr_feature_name[ feature.], [+++ ]))
322 ])dnl
325 dnl Collect enabled native surface/font backend features
326 CAIRO_ACCUMULATORS_REGISTER([NATIVE_SURFACE_BACKENDS])dnl
327 CAIRO_ACCUMULATORS_REGISTER([NATIVE_FONT_BACKENDS])dnl
328 CAIRO_FEATURE_HOOK_REGISTER(yes,auto,surface,
329 [dnl
330         CAIRO_ACCUMULATE([NATIVE_SURFACE_BACKENDS], [$1])
331 ])dnl
332 CAIRO_FEATURE_HOOK_REGISTER(yes,auto,font,
333 [dnl
334         CAIRO_ACCUMULATE([NATIVE_FONT_BACKENDS], [$1])
335 ])dnl
337 dnl Collect warning message if no native surface/font backend feature enabled
338 AC_CONFIG_COMMANDS_PRE(dnl
339 [dnl
340         AS_IF([test -z "$CAIRO_NATIVE_SURFACE_BACKENDS"],dnl
341         [dnl
342                 CAIRO_ACCUMULATE([WARNING_MESSAGE], CAIRO_TEXT_WRAP([It is strictly recommended that you enable the native surface backend feature for your platform.], [*** ]))
343         ])
344         AS_IF([test -z "$CAIRO_NATIVE_FONT_BACKENDS"],dnl
345         [dnl
346                 CAIRO_ACCUMULATE([WARNING_MESSAGE], CAIRO_TEXT_WRAP([It is strictly recommended that you enable the native font backend feature for your platform.], [*** ]))
347         ])
348 ])dnl
351 AC_DEFUN([CAIRO_REPORT],
352 [dnl
353         if test -z "$CAIRO_NATIVE_FONT_BACKENDS"; then
354            AC_MSG_ERROR([Cairo requires at least one native font backend.  Please install FreeType and fontconfig and try again.])
355         fi
357         V="$CAIRO_VERSION_MAJOR.$CAIRO_VERSION_MINOR.$CAIRO_VERSION_MICRO"
358         echo ""
359         echo "cairo (version $V [[$CAIRO_RELEASE_STATUS]]) will be compiled with:"
360         echo ""
361         echo "The following surface backends:"
362         echo "  Image:         yes (always builtin)"
363         echo "  Xlib:          $use_xlib"
364         echo "  Xlib Xrender:  $use_xlib_xrender"
365         echo "  Quartz:        $use_quartz"
366         echo "  Quartz-image:  $use_quartz_image"
367         echo "  XCB:           $use_xcb"
368         echo "  Win32:         $use_win32"
369         echo "  OS2:           $use_os2"
370         echo "  PostScript:    $use_ps"
371         echo "  PDF:           $use_pdf"
372         echo "  SVG:           $use_svg"
373         echo "  glitz:         $use_glitz"
374         echo "  BeOS:          $use_beos"
375         echo "  DirectFB:      $use_directfb"
376         echo ""
377         echo "The following font backends:"
378         echo "  User:          yes (always builtin)"
379         echo "  FreeType:      $use_ft"
380         echo "  Win32:         $use_win32_font"
381         echo "  Quartz:        $use_quartz_font"
382         echo ""
383         echo "The following functions:"
384         echo "  PNG functions: $use_png"
385         echo ""
386         echo "And the following internal features:"
387         echo "  gcov support:  $use_gcov"
388         echo "  test surfaces: $use_test_surfaces"
389         echo "  ps testing:    $test_ps"
390         echo "  pdf testing:   $test_pdf"
391         echo "  svg testing:   $test_svg"
392         if test x"$use_win32" = "xyes"; then
393                 echo "  win32 printing testing:    $test_win32_printing"
394         fi
395         echo "$CAIRO_WARNING_MESSAGE"
396         echo ""
397 ])dnl