From 8ddc656a3dd51556441852123da7c7181a4f5126 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9ric=20Marchal?= Date: Wed, 1 Feb 2012 14:30:08 +0100 Subject: [PATCH] Explain why the graphs are not produced Some messages have been added to explain what are the consequences of not building sarg with libgd. In addition, some more messages explain why the graphs are not rendered along with the report. It should help the users to track the graphs problems by themselves. --- configure.in | 17 +++++++++++++++-- getconf.c | 9 ++++++++- grepday.c | 11 +++++++++++ 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/configure.in b/configure.in index a5732e0..c8d6709 100644 --- a/configure.in +++ b/configure.in @@ -85,9 +85,16 @@ AS_HELP_STRING([--with-gd],[Compile with support for the graphical gd library]), [],[with_gd=check]) if ( test "x$with_gd" != "xno" ) ; then AC_CHECK_HEADERS(gd.h gdfontl.h gdfontt.h gdfonts.h gdfontmb.h gdfontg.h) - AC_CHECK_LIB(gd, gdImagePng,LIBS="-lgd ${LIBS}"; HAVE_GD_LIB="yes", HAVE_GD_LIB="") + if ( test "x$ac_cv_header_gd_h" == "xyes" ) ; then + AC_CHECK_LIB(gd, gdImagePng,LIBS="-lgd ${LIBS}"; HAVE_GD_LIB="yes", HAVE_GD_LIB="") + if ( test "x$HAVE_GD_LIB" != "xyes" ) ; then + AC_MSG_ERROR([ligbd is required to compile sarg with gd]) + fi + else + gd_status="not found" + fi else - AC_MSG_NOTICE([Not building with gd as requested on the configuration command line]) + gd_status="disabled" fi # Build with LDAP @@ -278,3 +285,9 @@ AC_SUBST(VERSION,"$PACKAGE_VERSION") AC_CONFIG_FILES([Makefile po/Makefile.in]) AC_OUTPUT + +if ( test "x$gd_status" == "xdisabled" ) ; then + AC_MSG_NOTICE([Not building with gd as requested on the configuration command line]) +elif ( test "x$gd_status" == "xnot found" ) ; then + AC_MSG_NOTICE([gd.h was not found so the graphs won't be available in the report]) +fi diff --git a/getconf.c b/getconf.c index e4326c5..22c544d 100644 --- a/getconf.c +++ b/getconf.c @@ -674,7 +674,14 @@ static void parmtest(char *buf) return; } - if (getparam_bool("graphs",buf,&Graphs)>0) return; + if (getparam_bool("graphs",buf,&Graphs)>0) { +#ifndef HAVE_GD + if (Graphs) + debugaz(_("No graphs available as sarg was not compiled with libgd. Set \"graphs\" to \"no\" in %s to disable this warning\n"), + ConfigFile); +#endif + return; + } if (getparam_string("graph_days_bytes_bar_color",buf,GraphDaysBytesBarColor,sizeof(GraphDaysBytesBarColor))>0) return; diff --git a/grepday.c b/grepday.c index 208de3e..ed83a03 100644 --- a/grepday.c +++ b/grepday.c @@ -633,6 +633,17 @@ static void greport_plot(const struct userinfostruct *uinfo,struct PlotStruct *p void greport_prepare(void) { #ifdef HAVE_GD + if (!Graphs) { + if (debugz) + debugaz(_("Graphs disabled as requested in %s\n"),ConfigFile); + return; + } + if (GraphFont[0]=='\0') { + if (debugz) + debugaz(_("Graphs disabled as no font names were provided in %s\n"),ConfigFile); + return; + } + if(access(GraphFont, R_OK) != 0) { debuga(_("(grepday) Fontname %s not found\n"),GraphFont); exit(EXIT_FAILURE); -- 2.47.2