From fc16e6c98742b4ebe6d3130f0f56ac143806c084 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sun, 20 Apr 2014 02:03:09 +0000 Subject: [PATCH] build: Introduce cmdlist_dir. This puts all files generated by command_util.bash into a new subdirectory inside the build directory. This way we don't need to special-case these files any more in .gitignore, Doxyfile, make clean. The compiler and depend.sh need to know this directory, so we add -I$(cmdlist_dir) to CPPFLAGS and introduce a new parameter for depend.sh. To prevent cpp from including stale versions of the *command_list.h files in the top level directory (left over from a previous build) this commit renames the generated files slightly. For example, audiod_completion.h becomes audiod.completion.h. --- .gitignore | 3 --- Doxyfile | 4 ++-- Makefile.real | 43 ++++++++++++++++++++++++++++--------------- audioc.c | 2 +- audiod_command.c | 2 +- client.c | 4 ++-- command.c | 4 ++-- depend.sh | 12 +++++++++--- play.c | 6 +++--- 9 files changed, 48 insertions(+), 32 deletions(-) diff --git a/.gitignore b/.gitignore index d340f207..b9190f28 100644 --- a/.gitignore +++ b/.gitignore @@ -14,8 +14,6 @@ config.log config.status Makefile TODO -*_command_list.h -*_command_list.man paraslash-git.tar.bz2 web/dia/overview.pdf *.swp @@ -25,4 +23,3 @@ confdefs.h conftest conftest.c git-version.h -*_completion.h diff --git a/Doxyfile b/Doxyfile index 239cd262..4f9743c7 100644 --- a/Doxyfile +++ b/Doxyfile @@ -621,8 +621,8 @@ EXCLUDE_SYMLINKS = NO EXCLUDE_PATTERNS = *.cmdline.* \ gcc-compat.h \ fade.c \ - *_command_list.h \ - *_completion.h + *.command_list.h \ + *.completion.h # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the diff --git a/Makefile.real b/Makefile.real index 58761a7b..f391d26e 100644 --- a/Makefile.real +++ b/Makefile.real @@ -21,6 +21,7 @@ object_dir := $(build_dir)/objects dep_dir := $(build_dir)/deps man_dir := $(build_dir)/man/man1 cmdline_dir := $(build_dir)/cmdline +cmdlist_dir := $(build_dir)/cmdlist m4depdir := $(build_dir)/m4deps help2man_dir := $(build_dir)/help2man hostbin_dir := $(build_dir)/host/bin @@ -68,7 +69,7 @@ ifeq ($(findstring clean, $(MAKECMDGOALS)),) endif $(object_dir) $(man_dir) $(ggo_dir) $(cmdline_dir) $(dep_dir) $(m4depdir) \ - $(help2man_dir) $(hostbin_dir): + $(help2man_dir) $(hostbin_dir) $(cmdlist_dir): $(Q) $(MKDIR_P) $@ # When in doubt, use brute force (Ken Thompson) @@ -88,6 +89,7 @@ CPPFLAGS += -DMAIN_INPUT_FILE_IS_$(*F) CPPFLAGS += $(arch_cppflags) CPPFLAGS += -I/usr/local/include CPPFLAGS += -I$(cmdline_dir) +CPPFLAGS += -I$(cmdlist_dir) CFLAGS += -Os CFLAGS += -Wuninitialized @@ -123,24 +125,36 @@ else Q := @ endif -%_command_list.h: %.cmd %.c +$(cmdlist_dir)/%.command_list.h: %.cmd %.c | $(cmdlist_dir) @[ -z "$(Q)" ] || echo 'GEN $@' $(Q) ./command_util.bash h < $< >$@ -%_command_list.man: %.cmd %.c +$(cmdlist_dir)/%.command_list.man: %.cmd %.c | $(cmdlist_dir) @[ -z "$(Q)" ] || echo 'GEN $@' $(Q) ./command_util.bash man < $< > $@ -%_completion.h: %.cmd %.c +$(cmdlist_dir)/%.completion.h: %.cmd %.c | $(cmdlist_dir) @[ -z "$(Q)" ] || echo 'GEN $@' $(Q) ./command_util.bash compl $(strip $(call TOUPPER,$(*F)))_COMPLETERS \ $(strip $(call TOUPPER,$(*F)))_COMMANDS < $< > $@ -server_command_list.h server_command_list.man server_completion.h: command.c -afs_command_list.h afs_command_list.man afs_completion.h: afs.c aft.c attribute.c -audiod_command_list.h audiod_command_list.man audiod_completion.h: audiod_command.c +$(cmdlist_dir)/server.command_list.h \ +$(cmdlist_dir)/server.command_list.man \ +$(cmdlist_dir)/server.completion.h \ +: command.c -server_command_lists := server_command_list.man afs_command_list.man -audiod_command_lists := audiod_command_list.man -play_command_lists := play_command_list.man +$(cmdlist_dir)/afs.command_list.h \ +$(cmdlist_dir)/afs.command_list.man \ +$(cmdlist_dir)/afs.completion.h \ +: afs.c aft.c attribute.c + +$(cmdlist_dir)/audiod,command_list.h \ +$(cmdlist_dir)/audiod,command_list.man \ +$(cmdlist_dir)/audiod,completion.h \ +: audiod_command.c + +server_command_lists := $(cmdlist_dir)/server.command_list.man \ + $(cmdlist_dir)/afs.command_list.man +audiod_command_lists := $(cmdlist_dir)/audiod.command_list.man +play_command_lists := $(cmdlist_dir)/play.command_list.man $(man_dir)/para_server.1: $(server_command_lists) $(man_dir)/para_audiod.1: $(audiod_command_lists) @@ -230,15 +244,15 @@ $(object_dir)/%.cmdline.o: $(cmdline_dir)/%.cmdline.c $(cmdline_dir)/%.cmdline.h @[ -z "$(Q)" ] || echo 'CC $<' $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $< -$(dep_dir)/%.cmdline.d: $(cmdline_dir)/%.cmdline.c error2.h | $(dep_dir) +$(dep_dir)/%.cmdline.d: $(cmdline_dir)/%.cmdline.c error2.h | $(dep_dir) $(cmdlist_dir) @[ -z "$(Q)" ] || echo 'DEP $<' $(Q) ./depend.sh $(dep_dir) $(object_dir) $(cmdline_dir) \ - $(CPPFLAGS) $< > $@ + $(cmdlist_dir) $(CPPFLAGS) $< > $@ -$(dep_dir)/%.d: %.c error2.h | $(dep_dir) +$(dep_dir)/%.d: %.c error2.h | $(dep_dir) $(cmdlist_dir) @[ -z "$(Q)" ] || echo 'DEP $<' $(Q) ./depend.sh $(dep_dir) $(object_dir) $(cmdline_dir) \ - $(CPPFLAGS) $< > $@ + $(cmdlist_dir) $(CPPFLAGS) $< > $@ para_recv para_afh para_play para_server: LDFLAGS += $(id3tag_ldflags) para_write para_play para_audiod: LDFLAGS += $(ao_ldflags) $(core_audio_ldflags) @@ -302,7 +316,6 @@ clean: clean2: clean @[ -z "$(Q)" ] || echo 'CLEAN2' - $(Q) rm -f *_command_list.* *_completion.h $(Q) rm -rf $(build_dir) distclean: clean2 test-clean @[ -z "$(Q)" ] || echo 'DISTCLEAN' diff --git a/audioc.c b/audioc.c index 001619d5..a2bfeb19 100644 --- a/audioc.c +++ b/audioc.c @@ -72,7 +72,7 @@ fail: #include "sched.h" #include "buffer_tree.h" #include "interactive.h" -#include "audiod_completion.h" +#include "audiod.completion.h" static struct sched sched; diff --git a/audiod_command.c b/audiod_command.c index 2aae0d80..df8f3936 100644 --- a/audiod_command.c +++ b/audiod_command.c @@ -30,7 +30,7 @@ #include "write.h" #include "fd.h" #include "version.h" -#include "audiod_command_list.h" +#include "audiod.command_list.h" extern struct sched sched; extern char *stat_item_values[NUM_STAT_ITEMS]; diff --git a/client.c b/client.c index 4c4806f9..2159117e 100644 --- a/client.c +++ b/client.c @@ -35,8 +35,8 @@ __printf_2_3 void (*para_log)(int, const char*, ...) = stderr_log; #ifdef HAVE_READLINE #include "interactive.h" -#include "server_completion.h" -#include "afs_completion.h" +#include "server.completion.h" +#include "afs.completion.h" struct exec_task { struct task *task; diff --git a/command.c b/command.c index db28b39d..80584510 100644 --- a/command.c +++ b/command.c @@ -35,8 +35,8 @@ #include "fd.h" #include "ipc.h" #include "user_list.h" -#include "server_command_list.h" -#include "afs_command_list.h" +#include "server.command_list.h" +#include "afs.command_list.h" #include "signal.h" #include "version.h" diff --git a/depend.sh b/depend.sh index c6424daa..80a6d40b 100755 --- a/depend.sh +++ b/depend.sh @@ -4,10 +4,12 @@ # the given input file and parse the output to add a *.d target with the same # dependencies. -# The first three arguments to that script are special: $1 is the +# The first four arguments to that script are special: $1 is the # dependency directory and $2 is the object directory. These are used # to prefix the .d and .o targets respectively. $3 is the directory -# that contains the *.cmdline.h files generated by gengetopt. +# that contains the *.cmdline.h files generated by gengetopt. Similarly, +# $4 is the command list directory which contains all files generated by +# the command_util script. # As gcc outputs the dependencies on the *.cmdline.h files either as # foo.cmdline.h or as $cmdline_dir/foo.cmdline.h, depending on whether the @@ -16,10 +18,14 @@ dep_dir="$1" object_dir="$2" cmdline_dir="$3" +cmdlist_dir="$4" +shift shift shift shift LC_ALL=C cc -MM -MG "$@" \ | sed -e "s@^\(.*\)\.o:@$dep_dir/\1.d $object_dir/\1.o:@" \ - -e "s@[ ^]\([a-zA-Z0-9_]\{1,\}\.cmdline.h\)@ $cmdline_dir/\1@g" + -e "s@[ ^]\([a-zA-Z0-9_]\{1,\}\.cmdline.h\)@ $cmdline_dir/\1@g" \ + -e "s@[ ^]\([a-zA-Z0-9_]\{1,\}\.command_list.h\)@ $cmdlist_dir/\1@g" \ + -e "s@[ ^]\([a-zA-Z0-9_]\{1,\}\.completion.h\)@ $cmdlist_dir/\1@g" diff --git a/play.c b/play.c index 9fc49e37..5e8c1cfc 100644 --- a/play.c +++ b/play.c @@ -633,7 +633,7 @@ static char **get_mapped_keyseqs(void) return result; } -#include "play_completion.h" +#include "play.completion.h" /* defines one command of para_play */ @@ -645,11 +645,11 @@ struct pp_command { const char *help; }; -#include "play_command_list.h" +#include "play.command_list.h" static struct pp_command pp_cmds[] = {DEFINE_PLAY_CMD_ARRAY}; #define FOR_EACH_COMMAND(c) for (c = 0; pp_cmds[c].name; c++) -#include "play_completion.h" +#include "play.completion.h" static struct i9e_completer pp_completers[]; I9E_DUMMY_COMPLETER(jmp); -- 2.39.2