diff --git a/configure.ac b/configure.ac index cbef03a..5b0ce95 100644 --- a/configure.ac +++ b/configure.ac @@ -69,8 +69,18 @@ AC_TYPE_UINT32_T AC_FUNC_ERROR_AT_LINE AC_CHECK_FUNCS([\ __fpending \ + open_memstream \ posix_fadvise \ ]) +AC_CHECK_DECL([strndupa]) + +AS_IF([test "x$ac_cv_func_open_memstream" = "xyes" && test "x$ac_cv_have_decl_strndupa" == "xyes"], [ + build_mustach=yes + AC_DEFINE([BUILD_MUSTACH], [1], [build mustach support]) +], [ + build_mustach=no +]) +AM_CONDITIONAL([ENABLE_MUSTACH], [test "x$build_mustach" = xyes]) AC_MSG_CHECKING([if the compiler supports __builtin_expect]) AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[ diff --git a/src/Makemodule.am b/src/Makemodule.am index 46ca5a3..d0bbba5 100644 --- a/src/Makemodule.am +++ b/src/Makemodule.am @@ -13,9 +13,13 @@ dhcpd_pools_SOURCES = \ src/dhcpd-pools.h \ src/getdata.c \ src/hash.c \ - src/mustach-dhcpd-pools.c \ - src/mustach.c \ - src/mustach.h \ src/other.c \ src/output.c \ src/sort.c + +if ENABLE_MUSTACH +dhcpd_pools_SOURCES += \ + src/mustach-dhcpd-pools.c \ + src/mustach.c \ + src/mustach.h +endif diff --git a/src/dhcpd-pools.c b/src/dhcpd-pools.c index 4389e20..6ac3ac6 100644 --- a/src/dhcpd-pools.c +++ b/src/dhcpd-pools.c @@ -127,7 +127,9 @@ int main(int argc, char **argv) {"reverse", no_argument, NULL, 'r'}, {"output", required_argument, NULL, 'o'}, {"limit", required_argument, NULL, 'L'}, +#ifdef BUILD_MUSTACH {"mustach", required_argument, NULL, OPT_MUSTACH}, +#endif {"version", no_argument, NULL, 'v'}, {"help", no_argument, NULL, 'h'}, {"snet-alarms", no_argument, NULL, OPT_SNET_ALARMS}, @@ -227,10 +229,12 @@ int main(int argc, char **argv) config.header_limit = return_limit(optarg[0]); config.number_limit = return_limit(optarg[1]); break; +#ifdef BUILD_MUSTACH case OPT_MUSTACH: config.mustach_template = optarg; output_format = 'm'; break; +#endif case OPT_COLOR: config.color_mode = parse_color_mode(optarg); if (config.color_mode == color_unknown) diff --git a/src/other.c b/src/other.c index 2f31fcc..b8a4634 100644 --- a/src/other.c +++ b/src/other.c @@ -567,6 +567,9 @@ void __attribute__ ((__noreturn__)) usage(int status) fputs( " j for json\n", out); fputs( " J for json with active lease details\n", out); fputs( " c for comma separated values\n", out); +#ifdef BUILD_MUSTACH + fputs( " --mustach=tmpl output using mustach template file\n", out); +#endif fputs( " -s, --sort=[nimcptTe] sort ranges by\n", out); fputs( " n name\n", out); fputs( " i IP\n", out); diff --git a/src/output.c b/src/output.c index 5c86d54..e858a96 100644 --- a/src/output.c +++ b/src/output.c @@ -1267,9 +1267,11 @@ int output_analysis(const char c) case 'c': ret = output_csv(); break; +#ifdef BUILD_MUSTACH case 'm': ret = mustach_dhcpd_pools(); break; +#endif default: error(EXIT_FAILURE, 0, "unknown output format: '%c'", c); } diff --git a/tests/Makemodule.am b/tests/Makemodule.am index 252d638..4256ae1 100644 --- a/tests/Makemodule.am +++ b/tests/Makemodule.am @@ -18,7 +18,6 @@ TESTS = \ tests/full-json \ tests/full-xml \ tests/leading0 \ - tests/mustach \ tests/one-ip \ tests/one-line \ tests/range4 \ @@ -29,6 +28,11 @@ TESTS = \ tests/v6 \ tests/v6-perfdata +if ENABLE_MUSTACH +TESTS += \ + tests/mustach +endif + EXTRA_DIST += \ tests/confs \ tests/expected \