implement sample config printing support
authorPhil Sutter <phil@nwl.cc>
Fri, 12 Dec 2008 14:33:25 +0000 (15:33 +0100)
committerPhil Sutter <phil@nwl.cc>
Fri, 12 Dec 2008 14:38:01 +0000 (15:38 +0100)
This patch makes Conky print a sample config when being called with the
'-C' flag.

A short test showed an increase of ~10kbytes of the conky binary's size.

.gitignore
configure.ac.in
src/Makefile.am
src/conky.c

index b9c5f88..2bc946e 100644 (file)
@@ -27,6 +27,7 @@ src/stamp-h1
 src/.deps/
 src/build.h
 src/config.h
+src/defconfig.h
 src/*.o
 conky-*.tar.*
 doc/*.html
index 6becb80..ee750ed 100644 (file)
@@ -91,6 +91,20 @@ AC_SUBST(BUILD_ARCH)
 
 
 dnl
+dnl CONFIG_OUTPUT option
+dnl
+
+AC_ARG_ENABLE([config_output],
+             AC_HELP_STRING([--enable-config-output],
+                            [enable printing a default config if requested @<:@default=no@:>@]),
+             [want_config_output="$enableval"], [want_config_output=no])
+
+AM_CONDITIONAL(BUILD_CONFIG_OUTPUT, test x$want_config_output = xyes)
+if test x$want_config_output = xyes; then
+       AC_DEFINE(CONFIG_OUTPUT, 1, [Define if you want default config printing support])
+fi
+
+dnl
 dnl OWN_WINDOW option
 dnl
 
index 98a7497..6ee8448 100644 (file)
@@ -27,6 +27,15 @@ INCLUDES = -DSYSTEM_CONFIG_FILE=\"$(sysconfdir)/conky/conky.conf\"
 
 bin_PROGRAMS = conky
 
+if BUILD_CONFIG_OUTPUT
+config_output = defconfig.h
+conky_DEPENDENCIES = $(config_output)
+BUILT_SOURCES = $(config_output)
+CLEANFILES = $(config_output)
+$(config_output): ../doc/conky.conf
+       sh ../text2c.sh $< $@ defconfig
+endif
+
 if BUILD_AUDACIOUS
 audacious = audacious.c audacious.h
 endif
@@ -100,6 +109,7 @@ nvidia = nvidia.c nvidia.h
 endif
 
 conky_SOURCES =                \
+       $(config_output)        \
        $(audacious)            \
        $(bmpx)                 \
        common.c                \
@@ -135,6 +145,7 @@ conky_LDFLAGS =                             \
        -lm
 
 EXTRA_DIST =                   \
+       $(config_output)        \
        audacious.c             \
        audacious.h             \
        bmpx.c                  \
index 3d38823..2957d8f 100644 (file)
 #include <iconv.h>
 #endif
 
+#ifdef CONFIG_OUTPUT
+#include "defconfig.h"
+#endif
+
 #include "build.h"
 
 #include "temphelper.h"
@@ -9094,6 +9098,9 @@ static const char *getopt_string = "vVqdDt:u:i:hc:"
 #ifdef HAVE_XDBE
        "b"
 #endif
+#ifdef CONFIG_OUTPUT
+       "C"
+#endif
 #endif /* X11 */
        ;
 
@@ -9102,6 +9109,9 @@ static const struct option longopts[] = {
        { "version", 0, NULL, 'V' },
        { "debug", 0, NULL, 'D' },
        { "config", 1, NULL, 'c' },
+#ifdef CONFIG_OUTPUT
+       { "print-config", 0, NULL, 'C' },
+#endif
        { "daemonize", 0, NULL, 'd' },
 #ifdef X11
        { "alignment", 1, NULL, 'a' },
@@ -9181,6 +9191,11 @@ int main(int argc, char **argv)
                        case 'h':
                                print_help(argv[0]);
                                return 0;
+#ifdef CONFIG_OUTPUT
+                       case 'C':
+                               print_defconfig();
+                               return 0;
+#endif
 #ifdef X11
                        case 'w':
                                window.window = strtol(optarg, 0, 0);