Fix configuring for Xft even when it's not present
authorJohn Ralls <jralls@ceridwen.us>
Tue, 21 Aug 2012 21:37:36 +0000 (14:37 -0700)
committerJohn Ralls <jralls@ceridwen.us>
Tue, 21 Aug 2012 21:49:39 +0000 (14:49 -0700)
Must declare have_xft=false before the pkg-check otherwise it's always
true. Then do the checks for Freetype and Xft, *then* check for Harfbuzz
and disable Freetype and Xft if it's not there. Finally set the
environment and config.h for Freetype and Xft.

configure.in

index bb2dfd0..6322fef 100644 (file)
@@ -226,17 +226,6 @@ AM_CONDITIONAL(CROSS_COMPILING, [test $cross_compiling = yes])
 
 
 #
-# Checks for HarfBuzz
-#
-have_harfbuzz=false
-PKG_CHECK_MODULES(HARFBUZZ, harfbuzz >= 0.9.3, have_harfbuzz=true, AC_MSG_RESULT([no]))
-AM_CONDITIONAL(HAVE_HARFBUZZ, $have_harfbuzz)
-if ! $have_harfbuzz; then
-       have_freetype=false
-       have_xft=false
-fi
-
-#
 # Check for fontconfig
 #
 have_fontconfig=false
@@ -245,7 +234,7 @@ if $have_harfbuzz ; then
 fi
 
 #
-# Checks for FreeType
+# Checks for FreeType. Set the environment after checking for HarfBuzz.
 #
 have_freetype=false
 if $have_fontconfig ; then
@@ -253,20 +242,38 @@ if $have_fontconfig ; then
   # enough for all the functions we use I guess.  No version check needed.
   PKG_CHECK_MODULES(FREETYPE, freetype2, have_freetype=true, AC_MSG_RESULT([no]))
 fi
+
+#
+# Checks for Xft/XRender. Set the environment after checking for HarfBuzz
+#
+have_xft=false
 if $have_freetype ; then
-  AC_DEFINE(HAVE_FREETYPE, 1, [Have FreeType 2 library])
-  # By freetype, we really always mean freetype+fontconfig
-  FREETYPE_CFLAGS="$FREETYPE_CFLAGS $FONTCONFIG_CFLAGS"
-  FREETYPE_LIBS="$FREETYPE_LIBS $FONTCONFIG_LIBS"
+  PKG_CHECK_MODULES(XFT, xft >= 2.0.0 xrender, have_xft=true, AC_MSG_RESULT([no]))
 fi
-AM_CONDITIONAL(HAVE_FREETYPE, $have_freetype)
 
 #
-# Checks for Xft/XRender
+# Checks for HarfBuzz, disables Freetype and Xft if it's not present.
+#
+have_harfbuzz=false
+PKG_CHECK_MODULES(HARFBUZZ, harfbuzz >= 0.9.3, have_harfbuzz=true, AC_MSG_RESULT([no]))
+AM_CONDITIONAL(HAVE_HARFBUZZ, $have_harfbuzz)
+if ! $have_harfbuzz; then
+       have_freetype=false
+       have_xft=false
+fi
+
+#
+# Now set the environment for Freetype and Xft. CFLAGS and LDFLAGS are
+# already set for each, but shouldn't matter since anything requiring
+# them will be ifdeffed or not built at all.
 #
 if $have_freetype ; then
-  PKG_CHECK_MODULES(XFT, xft >= 2.0.0 xrender, have_xft=true, AC_MSG_RESULT([no]))
+  AC_DEFINE(HAVE_FREETYPE, 1, [Have FreeType 2 library])
+  # By freetype, we really always mean freetype+fontconfig
+  FREETYPE_CFLAGS="$FREETYPE_CFLAGS $FONTCONFIG_CFLAGS"
+  FREETYPE_LIBS="$FREETYPE_LIBS $FONTCONFIG_LIBS"
 fi
+AM_CONDITIONAL(HAVE_FREETYPE, $have_freetype)
 if $have_xft ; then
   AC_DEFINE(HAVE_XFT, 1, [Have Xft library])
 fi