From f73b7385c2ed283394acba4673eb485414a502dd Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 10 Feb 2010 20:43:10 -0800 Subject: [PATCH] Build the ODT driver only if libxml2 is available. Reported by Michel Boaventura . --- INSTALL | 5 +++++ README | 2 +- configure.ac | 47 ++++++++++++++++++++++++++++++++---------- doc/invoking.texi | 3 +++ src/output/automake.mk | 4 +++- src/output/driver.c | 8 +++++-- 6 files changed, 54 insertions(+), 15 deletions(-) diff --git a/INSTALL b/INSTALL index 0f4f5c96..f391f563 100644 --- a/INSTALL +++ b/INSTALL @@ -66,6 +66,11 @@ Gnumeric files. * libxml2 (http://xmlsoft.org/). +Installing the following packages will allow your PSPP binary to write +OpenDocument text (ODT) files: + + * libxml2 (http://xmlsoft.org/). + The following packages are optional. * libncurses (http://www.gnu.org/software/ncurses/). Without it, diff --git a/README b/README index e54877a1..d1c78db2 100644 --- a/README +++ b/README @@ -4,7 +4,7 @@ is a free replacement for the proprietary program SPSS. PSPP development is ongoing. It already supports a large subset of SPSS's syntax. Its statistical procedure support is currently limited, but growing. At your option, PSPP will produce statistical -reports in ASCII, PostScript, PDF, HTML, or SVG formats. +reports in ASCII, PostScript, PDF, HTML, SVG, or OpenDocument formats. Instructions for PSPP installation are in INSTALL, including a list of prerequisite packages and other PSPP-specific information. Full diff --git a/configure.ac b/configure.ac index 491cfeac..4d6cab7c 100644 --- a/configure.ac +++ b/configure.ac @@ -126,18 +126,43 @@ if test x"$with_libpq" != x"no" ; then fi AM_CONDITIONAL(PSQL_SUPPORT, test -n "$PG_CONFIG") -dnl Checks needed for Gnumeric reader -gnm_support=yes; -PKG_CHECK_MODULES(LIBXML2, libxml-2.0,, - [PSPP_OPTIONAL_PREREQ([libxml2]); gnm_support=no;]); -AC_SEARCH_LIBS(gzopen,z,,[PSPP_OPTIONAL_PREREQ([zlib]); gnm_support=no;]) -AC_CHECK_HEADERS(zlib.h,,[PSPP_OPTIONAL_PREREQ([zlib]); gnm_support=no;]) - -if test x"$gnm_support" = x"yes" ; then - AC_DEFINE([GNM_SUPPORT], 1, - [Define to 1 if building in support for reading Gnumeric files.]) +dnl Check for libxml2 +PKG_CHECK_MODULES( + [LIBXML2], [libxml-2.0], + [HAVE_LIBXML2=yes], + [HAVE_LIBXML2=no + PSPP_OPTIONAL_PREREQ([libxml2])]) + +dnl Check for zlib. +AC_SEARCH_LIBS( + [gzopen], [z], + [HAVE_ZLIB=yes], + [HAVE_ZLIB=no + PSPP_OPTIONAL_PREREQ([zlib])]) +AC_CHECK_HEADERS( + [zlib.h], + [], + [HAVE_ZLIB=no + PSPP_OPTIONAL_PREREQ([zlib])]) + +dnl Gnumeric support requires libxml2 and zlib. +if test $HAVE_LIBXML2 = yes && test $HAVE_ZLIB = yes; then + GNM_SUPPORT=yes + AC_DEFINE( + [GNM_SUPPORT], [1], + [Define to 1 if building in support for reading Gnumeric files.]) +else + GNM_SUPPORT=no fi -AM_CONDITIONAL(GNM_SUPPORT, test x"$gnm_support" = x"yes") +AM_CONDITIONAL([GNM_SUPPORT], [test $GNM_SUPPORT = yes]) + +dnl ODT support requires libxml2. +if test $HAVE_LIBXML2 = yes; then + AC_DEFINE( + [ODT_SUPPORT], [1], + [Define to 1 if building in support for writing ODT files.]) +fi +AM_CONDITIONAL([ODT_SUPPORT], [test $HAVE_LIBXML2 = yes]) AC_ARG_WITH( gui_tools, diff --git a/doc/invoking.texi b/doc/invoking.texi index 86ddc31f..830d1764 100644 --- a/doc/invoking.texi +++ b/doc/invoking.texi @@ -360,6 +360,9 @@ To produce output as an OpenDocument text (ODT) document, specify @option{-o @var{file}} on the PSPP command line. If @var{file} does not end in @file{.odt}, you must also specify @option{-O format=odt}. +ODT support is only available if your installation of PSPP was +compiled with the libxml2 library. + The OpenDocument output format does not have any configurable options. @node Comma-Separated Value Output Options diff --git a/src/output/automake.mk b/src/output/automake.mk index 259f3b0e..e5781b0a 100644 --- a/src/output/automake.mk +++ b/src/output/automake.mk @@ -34,7 +34,6 @@ src_output_liboutput_la_SOURCES = \ src/output/message-item.h \ src/output/msglog.c \ src/output/msglog.h \ - src/output/odt.c \ src/output/options.c \ src/output/options.h \ src/output/output-item-provider.h \ @@ -68,5 +67,8 @@ src_output_liboutput_la_SOURCES += \ src/output/charts/roc-chart-cairo.c \ src/output/charts/scree-cairo.c endif +if ODT_SUPPORT +src_output_liboutput_la_SOURCES += src/output/odt.c +endif EXTRA_DIST += src/output/OChangeLog diff --git a/src/output/driver.c b/src/output/driver.c index 20364458..6d836354 100644 --- a/src/output/driver.c +++ b/src/output/driver.c @@ -246,8 +246,10 @@ output_driver_track_current_command (const struct output_item *output_item, extern const struct output_driver_factory txt_driver_factory; extern const struct output_driver_factory list_driver_factory; extern const struct output_driver_factory html_driver_factory; -extern const struct output_driver_factory odt_driver_factory; extern const struct output_driver_factory csv_driver_factory; +#ifdef ODT_SUPPORT +extern const struct output_driver_factory odt_driver_factory; +#endif #ifdef HAVE_CAIRO extern const struct output_driver_factory pdf_driver_factory; extern const struct output_driver_factory ps_driver_factory; @@ -259,8 +261,10 @@ static const struct output_driver_factory *factories[] = &txt_driver_factory, &list_driver_factory, &html_driver_factory, - &odt_driver_factory, &csv_driver_factory, +#ifdef ODT_SUPPORT + &odt_driver_factory, +#endif #ifdef HAVE_CAIRO &pdf_driver_factory, &ps_driver_factory, -- 2.30.2