Merge branch 'maint' into next
[paraslash.git] / ggo / makefile
index 4988d6f..d7bfc4f 100644 (file)
@@ -1,54 +1,50 @@
 module_ggo_opts := --set-version="($(PACKAGE_STRING), $(codename))"
+$(cmdline_dir):
+       mkdir -p $(cmdline_dir)
 
-grab_client.cmdline.h grab_client.cmdline.c: $(ggo_dir)/grab_client.ggo
-       gengetopt $(module_ggo_opts) \
-               -S \
-               --set-package=grab \
-               --no-handle-help \
-               --no-handle-error \
-               --no-handle-version \
-               --arg-struct-name=grab_client_args_info \
-               --file-name=$(subst .ggo,,$(<F)).cmdline \
-               --func-name $(subst .ggo,,$(<F))_cmdline_parser < $<
-
-%_recv.cmdline.h %_recv.cmdline.c: $(ggo_dir)/%_recv.ggo
-       gengetopt $(module_ggo_opts) \
+$(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 < $<
 
-%_filter.cmdline.h %_filter.cmdline.c: $(ggo_dir)/%_filter.ggo
-       gengetopt $(module_ggo_opts) \
+$(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 < $<
-%_write.cmdline.h %_write.cmdline.c: $(ggo_dir)/%_write.ggo
-       gengetopt -S $(module_ggo_opts) \
+               --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 -S $(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 < $<
 
-%.cmdline.h %.cmdline.c: $(ggo_dir)/%.ggo
-       case $(<F) in client.ggo) O="--unamed-opts=command";; \
-               audioc.ggo) O="--unamed-opts=command";; \
-               fsck.ggo) O="--unamed-opts=table";; \
-               afh.ggo) O="--unamed-opts=audio_file";; \
-               recv.ggo) O="--no-handle-help";; \
-               filter.ggo) O="--no-handle-help";; \
-               write.ggo) O="--no-handle-help";; \
-               audiod.ggo) O="--no-handle-help";; \
-       esac; \
-       if test $(<F) != fsck.ggo; then O="$$O --conf-parser "; fi; \
-       gengetopt $$O \
-               --no-handle-version \
-               --file-name=$(*F).cmdline \
-               --func-name $(*F)_cmdline_parser \
-               --arg-struct-name=$(*F)_args_info \
-               --set-package="para_$(subst .cmdline,,$(*F))" \
-               --set-version="$(PACKAGE_VERSION)"  < $<
+define ggo-opts
+$(if $(filter recv filter write audiod,$(*F)), --no-handle-help) \
+$(if $(filter afh,$(*F)), --unamed-opts=audio_file) \
+$(if $(filter client audioc,$(*F)), --unamed-opts=command) \
+$(if $(filter fsck,$(*F)), --unamed-opts=table, --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)"
+endef
+
+$(cmdline_dir)/%.cmdline.h $(cmdline_dir)/%.cmdline.c: $(ggo_dir)/%.ggo | $(cmdline_dir)
+       @[ -z "$(Q)" ] || echo 'GGO $<'
+       $(Q) gengetopt $(ggo-opts) < $<
 
 $(ggo_dir)/server.ggo $(ggo_dir)/audiod.ggo: \
        $(ggo_dir)/loglevel.m4 $(ggo_dir)/color.m4 \
@@ -66,4 +62,5 @@ $(ggo_dir)/write.ggo: $(ggo_dir)/loglevel.m4
 $(ggo_dir)/client.ggo: $(ggo_dir)/loglevel.m4 $(ggo_dir)/config_file.m4
 
 $(ggo_dir)/%.ggo: $(ggo_dir)/%.m4 $(ggo_dir)/header.m4
-       (cd $(ggo_dir) && m4 $(<F)) > $@
+       @[ -z "$(Q)" ] || echo 'M4 $<'
+       $(Q) cd $(ggo_dir); m4 $(<F) > $(@F)