cairo/build/enable.ac

429 lines
14 KiB
Text
Raw Normal View History

2008-09-04 16:00:40 -04:00
dnl
dnl These are the facilities for enable/disabling various backends/features,
dnl and for collecting CFLAGS/LIBS and generating per backend/feature .pc
dnl files, assembling list of source files to compile, and creating
dnl cairo-features.h and other generated files.
dnl
dnl ===========================================================================
dnl
dnl cairo_cache_version should be increased every time that the backend
dnl detection stuff changes in a way that removing the config.cache file may be
dnl needed for correct operation. (this is only for the backend detection
dnl changes; it doesn't have any effect on any other cached thing.)
dnl
m4_define(cairo_cache_version, 4)
dnl ===========================================================================
dnl
dnl Define a macro to enable features
dnl - Macro: _CAIRO_ENABLE_FULL (NAMESPACE, NAME, ARG, FEATURE_NAME, DEFAULT, WHAT, COMMANDS)
dnl
dnl where:
dnl
dnl NAMESPACE is the sub-namespace in function names, eg. "ft" for cairo_ft_...
dnl NAME is the human-readable name of the backend, eg. "FreeType font"
dnl ARG is what enables the backend, eg. "freetype" for --enable-freetype
dnl FEATURE_NAME is the feature conditional, eg. CAIRO_HAS_FT_FONT
dnl WHAT is the type of feature:
dnl "surface" for surface backends
dnl "font" for font backends
dnl "functions" for set of functions
dnl "" for private configurations
dnl DEFAULT is the default state of the backend:
dnl "no" for experimental backends, eg. your favorite new backend
dnl "yes" for mandatory backends, eg. png
dnl "auto" for other supported backends, eg. xlib
dnl COMMANDS are run to check whether the backend can be enabled. Their
dnl result may be cached, so user should not count on them being run.
dnl They should set use_$(NAMESPACE) to something other than yes if the
dnl backend cannot be built, eg. "no (requires SomeThing)". It then
dnl should also set $(NAMESPACE)_REQUIRES/CFLAGS/LIBS/...
dnl appropriately. Look at the macro definition for more details,
dnl or ask if in doubt.
dnl
AC_DEFUN([_CAIRO_ENABLE_FULL],
[ AC_ARG_ENABLE([$3],
AS_HELP_STRING([--enable-$3=@<:@no/auto/yes@:>@],
[Enable cairo's $2 backend @<:@default=$6@:>@]),
enable_$1=$enableval, enable_$1=$6)
case $enable_$1 in
no)
use_$1="no (disabled, use --enable-$3 to enable)"
;;
yes|auto)
if test "x$cairo_cv_backend_[]$1[]_cache_version" != "x[]cairo_cache_version"; then
# cached results for this backend (if any) are stale. force rechecking.
unset cairo_cv_backend_[]$1[]_use
fi
AC_CACHE_CHECK([for cairo's $2 backend], cairo_cv_backend_[]$1[]_use,
[
echo
use_[]$1=yes
$1[]_REQUIRES=$ac_env_[]$1[]_REQUIRES_value
$1[]_CFLAGS=$ac_env_[]$1[]_CFLAGS_value
$1[]_LIBS=$ac_env_[]$1[]_LIBS_value
$1[]_NONPKGCONFIG_CFLAGS=$ac_env_[]$1[]_NONPKGCONFIG_CFLAGS_value
$1[]_NONPKGCONFIG_LIBS=$ac_env_[]$1[]_NONPKGCONFIG_LIBS_value
$1[]_BASE=cairo
$7
cairo_cv_backend_[]$1[]_use=$use_[]$1
cairo_cv_backend_[]$1[]_cache_version=cairo_cache_version
cairo_cv_backend_[]$1[]_requires=$[]$1[]_REQUIRES
cairo_cv_backend_[]$1[]_cflags=$[]$1[]_CFLAGS
cairo_cv_backend_[]$1[]_libs=$[]$1[]_LIBS
cairo_cv_backend_[]$1[]_nonpkgconfig_cflags=$[]$1[]_NONPKGCONFIG_CFLAGS
cairo_cv_backend_[]$1[]_nonpkgconfig_libs=$[]$1[]_NONPKGCONFIG_LIBS
cairo_cv_backend_[]$1[]_base=$[]$1[]_BASE
AC_MSG_CHECKING([whether cairo's $2 backend could be enabled])
])
use_[]$1=$cairo_cv_backend_[]$1[]_use
$1[]_BASE=$cairo_cv_backend_[]$1[]_base
$1[]_REQUIRES="$cairo_cv_backend_[]$1[]_requires "
$1[]_CFLAGS="$cairo_cv_backend_[]$1[]_cflags "
$1[]_LIBS="$cairo_cv_backend_[]$1[]_libs "
$1[]_NONPKGCONFIG_CFLAGS="$cairo_cv_backend_[]$1[]_nonpkgconfig_cflags "
$1[]_NONPKGCONFIG_LIBS="$cairo_cv_backend_[]$1[]_nonpkgconfig_libs "
# null the ones that only have space
test "x$$1[]_REQUIRES" = "x " && $1[]_REQUIRES=""
test "x$$1[]_CFLAGS" = "x " && $1[]_CFLAGS=""
test "x$$1[]_LIBS" = "x " && $1[]_LIBS=""
test "x$$1[]_NONPKGCONFIG_CFLAGS" = "x " && $1[]_NONPKGCONFIG_CFLAGS=""
test "x$$1[]_NONPKGCONFIG_LIBS" = "x " && $1[]_NONPKGCONFIG_LIBS=""
AS_IF([test "x$enable_$1" = "xyes" -a "x$use_$1" != xyes],
[
AC_MSG_ERROR([requested $2 backend could not be enabled])
])
;;
*)
AC_MSG_ERROR([invalid argument passed to --enable-$3: $use_$1, should be one of @<:@no/auto/yes@:>@])
;;
esac
if test "x$use_$1" = xyes; then
CAIRO_FEATURES="$4 $CAIRO_FEATURES"
CAIRO_REQUIRES="$$1_REQUIRES$CAIRO_REQUIRES"
CAIRO_CFLAGS="$$1_NONPKGCONFIG_CFLAGS$$1_CFLAGS$CAIRO_CFLAGS"
CAIRO_LIBS="$$1_NONPKGCONFIG_LIBS$$1_LIBS$CAIRO_LIBS"
CAIRO_NONPKGCONFIG_CFLAGS="$$1_NONPKGCONFIG_CFLAGS$CAIRO_NONPKGCONFIG_CFLAGS"
CAIRO_NONPKGCONFIG_LIBS="$$1_NONPKGCONFIG_LIBS$CAIRO_NONPKGCONFIG_LIBS"
m4_define([cairo_backend_pc], m4_bpatsubst(src/cairo-$1.pc,_,-))
AC_CONFIG_FILES(cairo_backend_pc():src/cairo-backend.pc.in,
[
$SED -i -e "
s,@backend_name@,$1,g;
s,@Backend_Name@,$2,g;
s,@BACKEND_BASE@,$$1_BASE,g;
s,@BACKEND_REQUIRES@,$$1_REQUIRES,g;
s%@BACKEND_NONPKGCONFIG_LIBS@%$$1_NONPKGCONFIG_LIBS%g;
s,@BACKEND_NONPKGCONFIG_CFLAGS@,$$1_NONPKGCONFIG_CFLAGS,g;
" "]cairo_backend_pc()[" ||
AC_MSG_ERROR(failed to update ]cairo_backend_pc()[)
],[
SED='$SED'
$1_BASE='$$1_BASE'
$1_REQUIRES='$$1_REQUIRES'
$1_NONPKGCONFIG_LIBS='$$1_NONPKGCONFIG_LIBS'
$1_NONPKGCONFIG_CFLAGS='$$1_NONPKGCONFIG_CFLAGS'
])
fi
AM_CONDITIONAL($4, test "x$use_$1" = xyes)
dnl Collect list of all supported but disabled features
AS_IF([test "x$use_$1" != xyes -a "x$6" != xno],
[
CAIRO_NO_FEATURES="$4 $CAIRO_NO_FEATURES"
])
dnl Collect list of all (un)supported features and cairo headers
AS_IF([test "x$6" = xno],
[
CAIRO_CONFIG_AMAKE=$CAIRO_CONFIG_AMAKE'
unsupported_cairo_headers += $(cairo_$1_headers)'
CAIRO_CONFIG_WIN32=$CAIRO_CONFIG_WIN32'
unsupported_cairo_headers += $(cairo_$1_headers)'
],[
CAIRO_SUPPORTED_FEATURES="$4 $CAIRO_SUPPORTED_FEATURES"
CAIRO_CONFIG_AMAKE=$CAIRO_CONFIG_AMAKE'
supported_cairo_headers += $(cairo_$1_headers)'
CAIRO_CONFIG_WIN32=$CAIRO_CONFIG_WIN32'
supported_cairo_headers += $(cairo_$1_headers)'
])
dnl Collect list of all/enabled cairo source files
CAIRO_CONFIG_AMAKE=$CAIRO_CONFIG_AMAKE'
all_cairo_pkgconf += $(cairo_$1_pkgconf)
all_cairo_headers += $(cairo_$1_headers)
all_cairo_private += $(cairo_$1_private)
all_cairo_sources += $(cairo_$1_sources)
if $4
enabled_cairo_pkgconf += $(cairo_$1_pkgconf)
enabled_cairo_headers += $(cairo_$1_headers)
enabled_cairo_private += $(cairo_$1_private)
enabled_cairo_sources += $(cairo_$1_sources)
endif
'
CAIRO_CONFIG_WIN32=$CAIRO_CONFIG_WIN32'
all_cairo_pkgconf += $(cairo_$1_pkgconf)
all_cairo_headers += $(cairo_$1_headers)
all_cairo_private += $(cairo_$1_private)
all_cairo_sources += $(cairo_$1_sources)
ifeq ($($4),1)
enabled_cairo_pkgconf += $(cairo_$1_pkgconf)
enabled_cairo_headers += $(cairo_$1_headers)
enabled_cairo_private += $(cairo_$1_private)
enabled_cairo_sources += $(cairo_$1_sources)
endif
'
dnl Collect warning message for enabled unsupported backends
AS_IF([test "x$use_$1" = xyes -a "x$6" = xno],
[
CAIRO_WARNING_MESSAGE="$CAIRO_WARNING_MESSAGE
*** The $2 backend 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 $2-backend specific API.
"
])
dnl Collect warning message for disabled recommended backends
AS_IF([test "x$use_$1" != xyes -a "x$6" = xyes],
[
CAIRO_WARNING_MESSAGE="$CAIRO_WARNING_MESSAGE
*** It is strictly recommended that you do NOT disable
*** the $2 backend.
"
])
])
m4_pattern_allow(^CAIRO_HAS_)
m4_define([_CAIRO_BUILD_FEATURE_NAME_NORMALIZED],
[CAIRO_HAS_[$1]m4_bmatch([$1],[$2$],,[$2])])
m4_define([_CAIRO_BUILD_FEATURE_NAME],
[_CAIRO_BUILD_FEATURE_NAME_NORMALIZED(m4_translit([$1],[a-z_ -],[A-Z___]),m4_translit(m4_ifval([$2],[ $2]),[a-z_ -],[A-Z___]))])
dnl Like _CAIRO_ENABLE*, but takes an object type too
AC_DEFUN([_CAIRO_ENABLE],
[_CAIRO_ENABLE_FULL(
m4_translit([$1],[A-Z_ -],[a-z___]),
[$2],
m4_translit([$1],[A-Z_ -],[a-z---]),
_CAIRO_BUILD_FEATURE_NAME([$1],[$3]),
[$3],
[$4],
[$5]
)])
dnl ===========================================================================
dnl
dnl Define macros to enable various features.
dnl - Macro: CAIRO_ENABLE_* (NAMESPACE, NAME, DEFAULT, COMMANDS)
dnl
dnl where:
dnl
dnl NAMESPACE is the sub-namespace in function names, eg. "ft" for cairo_ft_...
dnl NAME is the human-readable name of the feature, eg. "FreeType"
dnl DEFAULT is the default state of the backend:
dnl "no" for experimental backends, eg. your favorite new backend
dnl "yes" for mandatory backends, eg. png
dnl "auto" for other supported backends, eg. xlib
dnl COMMANDS are run to check whether the feature can be enabled. Their
dnl result may be cached, so user should not count on them being run.
dnl They should set use_$(NAMESPACE) to something other than yes if the
dnl backend cannot be built, eg. "no (requires SomeThing)". It then
dnl should also set $(NAMESPACE)_REQUIRES/CFLAGS/LIBS/...
dnl appropriately. Look at the macro definition for more details,
dnl or ask if in doubt.
dnl
AC_DEFUN([CAIRO_ENABLE],
[_CAIRO_ENABLE([$1],[$2],,[$3],[$4])])
AC_DEFUN([CAIRO_ENABLE_SURFACE_BACKEND],
[_CAIRO_ENABLE([$1],[$2 surface backend],surface,[$3],[$4])])
AC_DEFUN([CAIRO_ENABLE_FONT_BACKEND],
[_CAIRO_ENABLE([$1],[$2 font backend],font,[$3],[$4])])
AC_DEFUN([CAIRO_ENABLE_FUNCTIONS],
[_CAIRO_ENABLE([$1],[$2 functions],functions,[$3],[$4])])
dnl ===========================================================================
dnl
dnl Report
dnl
dnl Accumulator for warning messages
m4_pattern_allow(^CAIRO_WARNING_MESSAGE$)
CAIRO_WARNING_MESSAGE=""
AC_DEFUN([CAIRO_REPORT],
[
V="$CAIRO_VERSION_MAJOR.$CAIRO_VERSION_MINOR.$CAIRO_VERSION_MICRO"
echo ""
echo "cairo (version $V [[$CAIRO_RELEASE_STATUS]]) will be compiled with the following surface backends:"
echo " Image: yes (always builtin)"
echo " Xlib: $use_xlib"
echo " Xlib Xrender: $use_xlib_xrender"
echo " Quartz: $use_quartz"
echo " Quartz-image: $use_quartz_image"
echo " XCB: $use_xcb"
echo " Win32: $use_win32"
echo " OS2: $use_os2"
echo " PostScript: $use_ps"
echo " PDF: $use_pdf"
echo " SVG: $use_svg"
echo " glitz: $use_glitz"
echo " BeOS: $use_beos"
echo " DirectFB: $use_directfb"
echo ""
echo "the following font backends:"
echo " User: yes (always builtin)"
echo " FreeType: $use_ft"
echo " Win32: $use_win32_font"
echo " Quartz: $use_quartz_font"
echo ""
echo "the following features:"
echo " PNG functions: $use_png"
echo ""
echo "and the following debug options:"
echo " gcov support: $use_gcov"
echo " test surfaces: $use_test_surfaces"
echo " ps testing: $test_ps"
echo " pdf testing: $test_pdf"
echo " svg testing: $test_svg"
if test x"$use_win32" = "xyes"; then
echo " win32 printing testing: $test_win32_printing"
fi
echo ""
echo "using CFLAGS:"
echo $CAIRO_CFLAGS
echo ""
if test x"$use_ft" != "xyes" && \
test x"$use_win32_font" != "xyes" && \
test x"$use_quartz_font" != "xyes" ; then
AC_MSG_ERROR([Cairo requires at least one font backend.
Please install freetype and fontconfig, then try again:
http://freetype.org/ http://fontconfig.org/
])
fi
echo "$CAIRO_WARNING_MESSAGE"
])
dnl ===========================================================================
dnl
dnl All .pc files are generated automatically except for this one
dnl
AC_CONFIG_FILES([src/cairo.pc])
dnl ===========================================================================
dnl
dnl pkg-config requires, non-pkgconfig cflags and libs, and total cflags and libs
dnl
dnl Accumulators
CAIRO_REQUIRES=""
CAIRO_NONPKGCONFIG_CFLAGS=""
2008-09-04 16:00:40 -04:00
CAIRO_NONPKGCONFIG_LIBS="$LIBS"
CAIRO_CFLAGS=$CAIRO_NONPKGCONFIG_CFLAGS
CAIRO_LIBS=$CAIRO_NONPKGCONFIG_LIBS
dnl Substitute
AC_SUBST(CAIRO_REQUIRES)
AC_SUBST(CAIRO_NONPKGCONFIG_CFLAGS)
AC_SUBST(CAIRO_NONPKGCONFIG_LIBS)
AC_SUBST(CAIRO_CFLAGS)
AC_SUBST(CAIRO_LIBS)
dnl ===========================================================================
dnl
dnl Generate {src,boilerplate}/Config.mk{,.win32}
dnl
dnl Accumulators
m4_pattern_allow(^CAIRO_CONFIG_AMAKE$)
CAIRO_CONFIG_AMAKE='# Generated by configure. Do not edit.
include $(top_srcdir)/src/Sources.mk
enabled_cairo_pkgconf = cairo.pc
enabled_cairo_headers = $(cairo_headers)
enabled_cairo_private = $(cairo_private)
enabled_cairo_sources = $(cairo_sources)
all_cairo_pkgconf =
all_cairo_headers = $(cairo_headers)
all_cairo_private = $(cairo_private)
all_cairo_sources = $(cairo_sources)
supported_cairo_headers = $(cairo_headers)
unsupported_cairo_headers =
'
m4_pattern_allow(^CAIRO_CONFIG_WIN32$)
2008-09-04 17:22:07 -04:00
CAIRO_CONFIG_WIN32=$CAIRO_CONFIG_AMAKE
dnl Generate
CAIRO_CONFIG_COMMANDS([$srcdir/src/Config.mk],
[echo "$CAIRO_CONFIG_AMAKE"],
[CAIRO_CONFIG_AMAKE='$CAIRO_CONFIG_AMAKE'])
CAIRO_CONFIG_COMMANDS([$srcdir/src/Config.mk.win32],
[echo "$CAIRO_CONFIG_WIN32"],
[CAIRO_CONFIG_WIN32='$CAIRO_CONFIG_WIN32'])
dnl ===========================================================================
dnl
dnl List of enabled, supported but disabled, and all supported features
dnl
dnl Accumulators
m4_pattern_allow(^CAIRO_FEATURES$)
CAIRO_FEATURES=""
m4_pattern_allow(^CAIRO_NO_FEATURES$)
CAIRO_NO_FEATURES=""
m4_pattern_allow(^CAIRO_SUPPORTED_FEATURES$)
CAIRO_SUPPORTED_FEATURES=""
dnl Generate src/cairo-features.h and src/cairo-supported-features.h
CAIRO_CONFIG_COMMANDS([src/cairo-features.h],
[
echo '/* Generated by configure. Do not edit. */'
echo '#ifndef CAIRO_FEATURES_H'
echo '#define CAIRO_FEATURES_H'
echo ''
for FEATURE in $CAIRO_FEATURES; do
echo "#define $FEATURE 1"
done | LANG=C sort
echo ''
for FEATURE in $CAIRO_NO_FEATURES; do
echo "/*#undef $FEATURE */"
done | LANG=C sort
echo ''
echo '#endif'
],[
CAIRO_FEATURES='$CAIRO_FEATURES'
CAIRO_NO_FEATURES='$CAIRO_NO_FEATURES'
])
2008-09-03 20:50:26 -04:00
CAIRO_CONFIG_COMMANDS([$srcdir/src/cairo-supported-features.h],
[
echo '/* Generated by configure. Do not edit. */'
echo '#ifndef CAIRO_SUPPORTED_FEATURES_H'
echo '#define CAIRO_SUPPORTED_FEATURES_H'
echo ''
echo '/* This is a dummy header, to trick gtk-doc only */'
echo ''
for FEATURE in $CAIRO_SUPPORTED_FEATURES; do
echo "#define $FEATURE 1"
done
echo ''
echo '#endif'
],[
CAIRO_SUPPORTED_FEATURES='$CAIRO_SUPPORTED_FEATURES'
])