Simplify ggo makefile.
authorAndre Noll <maan@systemlinux.org>
Sun, 29 Jul 2012 18:51:18 +0000 (20:51 +0200)
committerAndre Noll <maan@systemlinux.org>
Mon, 27 Aug 2012 11:01:08 +0000 (13:01 +0200)
Currently we have three different targets for creating *_cmdline.[ch]
files. This is because receivers, filters and writers need slightly
different command line options.

This patch defines the common options in the ggo makefile and moves
additional parameters to the individual .m4 files so that a single
target to create *_cmdline.[ch] is now sufficient.

The name of the command line parsers of some filters and writers
changed due to this unification, so these are updated accordingly.

20 files changed:
alsa_write.c
amp_filter.c
ao_write.c
compress_filter.c
file_write.c
m4/gengetopt/afh.m4
m4/gengetopt/audioc.m4
m4/gengetopt/audiod.m4
m4/gengetopt/client.m4
m4/gengetopt/fade.m4
m4/gengetopt/filter.m4
m4/gengetopt/gui.m4
m4/gengetopt/makefile
m4/gengetopt/recv.m4
m4/gengetopt/server.m4
m4/gengetopt/write.m4
mp3dec_filter.c
oss_write.c
osx_write.c
prebuffer_filter.c

index 73c9b82..16497bd 100644 (file)
@@ -333,13 +333,13 @@ __malloc static void *alsa_parse_config_or_die(int argc, char **argv)
        struct alsa_write_args_info *conf = para_calloc(sizeof(*conf));
 
        /* exits on errors */
-       alsa_cmdline_parser(argc, argv, conf);
+       alsa_write_cmdline_parser(argc, argv, conf);
        return conf;
 }
 
 static void alsa_free_config(void *conf)
 {
-       alsa_cmdline_parser_free(conf);
+       alsa_write_cmdline_parser_free(conf);
 }
 
 /**
@@ -353,7 +353,7 @@ void alsa_write_init(struct writer *w)
 {
        struct alsa_write_args_info dummy;
 
-       alsa_cmdline_parser_init(&dummy);
+       alsa_write_cmdline_parser_init(&dummy);
        w->close = alsa_close;
        w->pre_select = alsa_write_pre_select;
        w->post_select = alsa_write_post_select;
@@ -363,5 +363,5 @@ void alsa_write_init(struct writer *w)
                .short_help = alsa_write_args_info_help,
                .detailed_help = alsa_write_args_info_detailed_help
        };
-       alsa_cmdline_parser_free(&dummy);
+       alsa_write_cmdline_parser_free(&dummy);
 }
index 7e88cc4..dd2c619 100644 (file)
@@ -38,7 +38,7 @@ static int amp_parse_config(int argc, char **argv, void **config)
        struct amp_filter_args_info *amp_conf = para_calloc(sizeof(*amp_conf));
        int ret = -E_AMP_SYNTAX;
 
-       if (amp_cmdline_parser(argc, argv, amp_conf))
+       if (amp_filter_cmdline_parser(argc, argv, amp_conf))
                goto err;
        ret = -ERRNO_TO_PARA_ERROR(EINVAL);
        if (amp_conf->amp_arg < 0)
@@ -123,7 +123,7 @@ err:
 
 static void amp_free_config(void *conf)
 {
-       amp_cmdline_parser_free(conf);
+       amp_filter_cmdline_parser_free(conf);
 }
 
 /**
@@ -135,7 +135,7 @@ void amp_filter_init(struct filter *f)
 {
        struct amp_filter_args_info dummy;
 
-       amp_cmdline_parser_init(&dummy);
+       amp_filter_cmdline_parser_init(&dummy);
        f->open = amp_open;
        f->close = amp_close;
        f->pre_select = generic_filter_pre_select;
index 165caa0..b1c344c 100644 (file)
@@ -342,13 +342,13 @@ __malloc static void *aow_parse_config_or_die(int argc, char **argv)
        struct ao_write_args_info *conf = para_calloc(sizeof(*conf));
 
        /* exits on errors */
-       ao_cmdline_parser(argc, argv, conf);
+       ao_write_cmdline_parser(argc, argv, conf);
        return conf;
 }
 
 static void aow_free_config(void *conf)
 {
-       ao_cmdline_parser_free(conf);
+       ao_write_cmdline_parser_free(conf);
 }
 
 /**
@@ -365,7 +365,7 @@ void ao_write_init(struct writer *w)
        ao_info **driver_list;
        char **dh; /* detailed help */
 
-       ao_cmdline_parser_init(&dummy);
+       ao_write_cmdline_parser_init(&dummy);
        w->close = aow_close;
        w->pre_select = aow_pre_select;
        w->post_select = aow_post_select;
@@ -411,7 +411,7 @@ void ao_write_init(struct writer *w)
        }
        dh[num_lines] = NULL;
        w->help.detailed_help = (const char **)dh;
-       ao_cmdline_parser_free(&dummy);
+       ao_write_cmdline_parser_free(&dummy);
        ao_shutdown();
 }
 
index 3dee5cc..49d6d66 100644 (file)
@@ -120,7 +120,7 @@ static int compress_parse_config(int argc, char **argv, void **config)
                = para_calloc(sizeof(*compress_conf));
 
        ret = -E_COMPRESS_SYNTAX;
-       if (compress_cmdline_parser(argc, argv, compress_conf))
+       if (compress_filter_cmdline_parser(argc, argv, compress_conf))
                goto err;
        *config = compress_conf;
        return 1;
@@ -142,7 +142,7 @@ static void compress_open(struct filter_node *fn)
 
 static void compress_free_config(void *conf)
 {
-       compress_cmdline_parser_free(conf);
+       compress_filter_cmdline_parser_free(conf);
 }
 
 /**
@@ -154,7 +154,7 @@ void compress_filter_init(struct filter *f)
 {
        struct compress_filter_args_info dummy;
 
-       compress_cmdline_parser_init(&dummy);
+       compress_filter_cmdline_parser_init(&dummy);
        f->open = compress_open;
        f->close = compress_close;
        f->pre_select = generic_filter_pre_select;
index 9817571..32f6c3a 100644 (file)
@@ -138,13 +138,13 @@ __malloc static void *file_write_parse_config_or_die(int argc, char **argv)
        struct file_write_args_info *conf = para_calloc(sizeof(*conf));
 
        /* exits on errors */
-       file_cmdline_parser(argc, argv, conf);
+       file_write_cmdline_parser(argc, argv, conf);
        return conf;
 }
 
 static void file_write_free_config(void *conf)
 {
-       file_cmdline_parser_free(conf);
+       file_write_cmdline_parser_free(conf);
 }
 
 /** the init function of the file writer */
@@ -152,7 +152,7 @@ void file_write_init(struct writer *w)
 {
        struct file_write_args_info dummy;
 
-       file_cmdline_parser_init(&dummy);
+       file_write_cmdline_parser_init(&dummy);
        w->pre_select = file_write_pre_select;
        w->post_select = file_write_post_select;
        w->parse_config_or_die = file_write_parse_config_or_die;
@@ -162,5 +162,5 @@ void file_write_init(struct writer *w)
                .short_help = file_write_args_info_help,
                .detailed_help = file_write_args_info_detailed_help
        };
-       file_cmdline_parser_free(&dummy);
+       file_write_cmdline_parser_free(&dummy);
 }
index 1cb4493..8adb29c 100644 (file)
@@ -1,4 +1,4 @@
-args "--unamed-opts=audio_file"
+args "--unamed-opts=audio_file --no-handle-version"
 
 include(header.m4)
 <qu>
index cb7ab03..736d707 100644 (file)
@@ -1,4 +1,4 @@
-args "--unamed-opts=command"
+args "--unamed-opts=command --conf-parser --no-handle-version"
 
 include(header.m4)
 <qu>
index f20bd10..5522a56 100644 (file)
@@ -1,4 +1,4 @@
-args "--no-handle-help"
+args "--no-handle-help --no-handle-version --conf-parser"
 
 include(header.m4)
 define(CURRENT_PROGRAM,para_audiod)
index 6b589dc..23f7c1e 100644 (file)
@@ -1,4 +1,4 @@
-args "--unamed-opts=command --no-handle-error"
+args "--unamed-opts=command --no-handle-error --conf-parser --no-handle-version"
 
 include(header.m4)
 define(CURRENT_PROGRAM,para_client)
index 80f8b73..ff4b451 100644 (file)
@@ -1,3 +1,5 @@
+args "--conf-parser --no-handle-version"
+
 section "General options"
 #########################
 
index f2efbc4..c7337be 100644 (file)
@@ -1,4 +1,4 @@
-args "--no-handle-help"
+args "--no-handle-help --no-handle-version --conf-parser"
 
 include(header.m4)
 include(loglevel.m4)
index 895229b..bafd325 100644 (file)
@@ -1,3 +1,5 @@
+args "--conf-parser --no-handle-version"
+
 include(header.m4)
 define(CURRENT_PROGRAM,para_gui)
 define(DEFAULT_CONFIG_FILE,~/.paraslash/gui.conf)
index cc5835c..c613816 100644 (file)
@@ -1,45 +1,15 @@
-module_ggo_opts := --set-version="($(PACKAGE_STRING), $(codename))"
-
-$(cmdline_dir)/%_recv.cmdline.h $(cmdline_dir)/%_recv.cmdline.c: $(ggo_dir)/%_recv.ggo | $(cmdline_dir)
-       @[ -z "$(Q)" ] || echo 'GGO $<'
-       $(Q) $(GENGETOPT) $(module_ggo_opts) \
-               --output-dir=$(cmdline_dir) \
-               --set-package=$(subst .ggo,,$(<F)) \
-               --arg-struct-name=$(subst .ggo,,$(<F))_args_info \
-               --file-name=$(subst .ggo,,$(<F)).cmdline \
-               --func-name $(subst .ggo,,$(<F))_cmdline_parser < $<
-
-$(cmdline_dir)/%_filter.cmdline.h $(cmdline_dir)/%_filter.cmdline.c: $(ggo_dir)/%_filter.ggo | $(cmdline_dir)
-       @[ -z "$(Q)" ] || echo 'GGO $<'
-       $(Q) $(GENGETOPT) $(module_ggo_opts) \
-               --output-dir=$(cmdline_dir) \
-               --set-package=$(subst .ggo,,$(<F)) \
-               --arg-struct-name=$(subst .ggo,,$(<F))_args_info \
-               --file-name=$(subst .ggo,,$(<F)).cmdline \
-               --func-name=$(subst _filter.ggo,,$(<F))_cmdline_parser < $<
-$(cmdline_dir)/%_write.cmdline.h $(cmdline_dir)/%_write.cmdline.c: $(ggo_dir)/%_write.ggo | $(cmdline_dir)
-       @[ -z "$(Q)" ] || echo 'GGO $<'
-       $(Q) $(GENGETOPT) $(module_ggo_opts) \
-               --output-dir=$(cmdline_dir) \
-               --set-package=$(subst .ggo,,$(<F)) \
-               --arg-struct-name=$(subst .ggo,,$(<F))_args_info \
-               --file-name=$(subst .ggo,,$(<F)).cmdline \
-               --func-name $(subst _write.ggo,,$(<F))_cmdline_parser < $<
-
-define ggo-opts
---conf-parser \
---output-dir=$(cmdline_dir) \
---no-handle-version \
---file-name=$(*F).cmdline \
---func-name=$(*F)_cmdline_parser \
---arg-struct-name=$(*F)_args_info \
---set-package="para_$(*F)" \
---set-version="$(PACKAGE_VERSION)"
+define ggo_opts
+       --output-dir=$(cmdline_dir) \
+       --set-version="$(PACKAGE_VERSION)" \
+       --arg-struct-name=$(*F)_args_info \
+       --file-name=$(*F).cmdline \
+       --func-name=$(*F)_cmdline_parser \
+       --set-package="para_$(*F)"
 endef
 
 $(cmdline_dir)/%.cmdline.h $(cmdline_dir)/%.cmdline.c: $(ggo_dir)/%.ggo | $(cmdline_dir)
        @[ -z "$(Q)" ] || echo 'GGO $<'
-       $(Q) $(GENGETOPT) $(ggo-opts) < $<
+       $(Q) $(GENGETOPT) $(ggo_opts) < $<
 
 $(ggo_dir)/server.ggo $(ggo_dir)/audiod.ggo: \
        $(m4_ggo_dir)/loglevel.m4 $(m4_ggo_dir)/color.m4 \
index 7bc7c10..c7b89fe 100644 (file)
@@ -1,4 +1,4 @@
-args "--no-handle-help"
+args "--no-handle-help --no-handle-version"
 
 include(header.m4)
 include(loglevel.m4)
index 8731561..24d344e 100644 (file)
@@ -1,3 +1,5 @@
+args "--conf-parser --no-handle-version"
+
 include(header.m4)
 define(CURRENT_PROGRAM,para_server)
 define(DEFAULT_CONFIG_FILE,~/.paraslash/server.conf)
index 325ce58..56698e1 100644 (file)
@@ -1,4 +1,4 @@
-args "--no-handle-help"
+args "--no-handle-help --no-handle-version"
 
 include(header.m4)
 include(loglevel.m4)
index b58c694..bcb1eca 100644 (file)
@@ -189,7 +189,7 @@ static int mp3dec_parse_config(int argc, char **argv, void **config)
 
        mp3_conf = para_calloc(sizeof(*mp3_conf));
        ret = -E_MP3DEC_SYNTAX;
-       if (mp3dec_cmdline_parser(argc, argv, mp3_conf))
+       if (mp3dec_filter_cmdline_parser(argc, argv, mp3_conf))
                goto err;
        *config = mp3_conf;
        return 1;
@@ -208,7 +208,7 @@ static int mp3dec_execute(struct btr_node *btrn, const char *cmd, char **result)
 
 static void mp3dec_free_config(void *conf)
 {
-       mp3dec_cmdline_parser_free(conf);
+       mp3dec_filter_cmdline_parser_free(conf);
 }
 /**
  * The init function of the mp3dec filter.
@@ -221,7 +221,7 @@ void mp3dec_filter_init(struct filter *f)
 {
        struct mp3dec_filter_args_info dummy;
 
-       mp3dec_cmdline_parser_init(&dummy);
+       mp3dec_filter_cmdline_parser_init(&dummy);
        f->open = mp3dec_open;
        f->close = mp3dec_close;
        f->parse_config = mp3dec_parse_config;
index 57e2387..d2dc963 100644 (file)
@@ -207,13 +207,13 @@ __malloc static void *oss_parse_config_or_die(int argc, char **argv)
        struct oss_write_args_info *conf = para_calloc(sizeof(*conf));
 
        /* exits on errors */
-       oss_cmdline_parser(argc, argv, conf);
+       oss_write_cmdline_parser(argc, argv, conf);
        return conf;
 }
 
 static void oss_free_config(void *conf)
 {
-       oss_cmdline_parser_free(conf);
+       oss_write_cmdline_parser_free(conf);
 }
 
 /**
@@ -227,7 +227,7 @@ void oss_write_init(struct writer *w)
 {
        struct oss_write_args_info dummy;
 
-       oss_cmdline_parser_init(&dummy);
+       oss_write_cmdline_parser_init(&dummy);
        w->close = oss_close;
        w->pre_select = oss_pre_select;
        w->post_select = oss_post_select;
@@ -237,5 +237,5 @@ void oss_write_init(struct writer *w)
                .short_help = oss_write_args_info_help,
                .detailed_help = oss_write_args_info_detailed_help
        };
-       oss_cmdline_parser_free(&dummy);
+       oss_write_cmdline_parser_free(&dummy);
 }
index 69a781c..8dcfb4c 100644 (file)
@@ -222,13 +222,13 @@ __malloc static void *osx_write_parse_config_or_die(int argc, char **argv)
        struct osx_write_args_info *conf = para_calloc(sizeof(*conf));
 
        /* exits on errors */
-       osx_cmdline_parser(argc, argv, conf);
+       osx_write_cmdline_parser(argc, argv, conf);
        return conf;
 }
 
 static void osx_free_config(void *conf)
 {
-       osx_cmdline_parser_free(conf);
+       osx_write_cmdline_parser_free(conf);
 }
 
 static void osx_write_close(struct writer_node *wn)
@@ -326,7 +326,7 @@ void osx_write_init(struct writer *w)
 {
        struct osx_write_args_info dummy;
 
-       osx_cmdline_parser_init(&dummy);
+       osx_write_cmdline_parser_init(&dummy);
        w->close = osx_write_close;
        w->pre_select = osx_write_pre_select;
        w->post_select = osx_write_post_select;
@@ -336,5 +336,5 @@ void osx_write_init(struct writer *w)
                .short_help = osx_write_args_info_help,
                .detailed_help = osx_write_args_info_detailed_help
        };
-       osx_cmdline_parser_free(&dummy);
+       osx_write_cmdline_parser_free(&dummy);
 }
index 9c6fda5..76ec7c7 100644 (file)
@@ -82,7 +82,7 @@ static int prebuffer_parse_config(int argc, char **argv, void **config)
                = para_calloc(sizeof(*prebuffer_conf));
        int ret = -E_PREBUFFER_SYNTAX;
 
-       if (prebuffer_cmdline_parser(argc, argv, prebuffer_conf))
+       if (prebuffer_filter_cmdline_parser(argc, argv, prebuffer_conf))
                goto err;
        ret = -ERRNO_TO_PARA_ERROR(EINVAL);
        if (prebuffer_conf->duration_arg < 0)
@@ -108,7 +108,7 @@ static void prebuffer_open(struct filter_node *fn)
 
 static void prebuffer_free_config(void *conf)
 {
-       prebuffer_cmdline_parser_free(conf);
+       prebuffer_filter_cmdline_parser_free(conf);
 }
 
 /**
@@ -120,7 +120,7 @@ void prebuffer_filter_init(struct filter *f)
 {
        struct prebuffer_filter_args_info dummy;
 
-       prebuffer_cmdline_parser_init(&dummy);
+       prebuffer_filter_cmdline_parser_init(&dummy);
        f->open = prebuffer_open;
        f->close = prebuffer_close;
        f->parse_config = prebuffer_parse_config;