From 89633512b2bfe6b903341fb12bfab65510ef0e9d Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sat, 31 Dec 2016 20:07:33 +0100 Subject: [PATCH] Remove *.cmd and command_util.bash. The four *.cmd files are no longer needed and can be removed, along with the script which transformed these files into C code. The directory for the generated files, $(build_dir)/cmdlist, can go away as well. With command_util.bash gone, the Makefile can also be cleaned up considerably. In particular, the ugly TOUPPER make function can be removed because it was only used by the command_util recipe. Moreover, The dependencies for the *.command_list.* files are no longer needed. Finally, the sed command which fixed up the dependencies in the *.d files can be simplified. --- Makefile.real | 43 +------ afs.cmd | 4 - audiod.cmd | 4 - command_util.bash | 291 ---------------------------------------------- play.cmd | 3 - server.cmd | 3 - 6 files changed, 2 insertions(+), 346 deletions(-) delete mode 100644 afs.cmd delete mode 100644 audiod.cmd delete mode 100755 command_util.bash delete mode 100644 play.cmd delete mode 100644 server.cmd diff --git a/Makefile.real b/Makefile.real index 53fa22fe..51459085 100644 --- a/Makefile.real +++ b/Makefile.real @@ -30,7 +30,6 @@ 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 lls_suite_dir := $(build_dir)/lls @@ -83,18 +82,9 @@ ifeq ($(findstring clean, $(MAKECMDGOALS)),) endif $(object_dir) $(man_dir) $(ggo_dir) $(cmdline_dir) $(dep_dir) $(m4depdir) \ - $(help2man_dir) $(cmdlist_dir) $(lls_suite_dir): + $(help2man_dir) $(lls_suite_dir): $(Q) $(MKDIR_P) $@ -# When in doubt, use brute force (Ken Thompson) -TOUPPER = \ -$(subst a,A,$(subst b,B,$(subst c,C,$(subst d,D,$(subst e,E,\ -$(subst f,F,$(subst g,G,$(subst h,H,$(subst i,I,$(subst j,J,\ -$(subst k,K,$(subst l,L,$(subst m,M,$(subst n,N,$(subst o,O,\ -$(subst p,P,$(subst q,Q,$(subst r,R,$(subst s,S,$(subst t,T,\ -$(subst u,U,$(subst v,V,$(subst w,W,$(subst x,X,$(subst y,Y,\ -$(subst z,Z,$1)))))))))))))))))))))))))) - CPPFLAGS += -DBINDIR='"$(bindir)"' CPPFLAGS += -DCOPYRIGHT_YEAR='"$(COPYRIGHT_YEAR)"' CPPFLAGS += -DBUILD_DATE='"$(build_date)"' @@ -102,7 +92,6 @@ CPPFLAGS += -DUNAME_RS='"$(uname_rs)"' CPPFLAGS += -DCC_VERSION='"$(cc_version)"' CPPFLAGS += -I/usr/local/include CPPFLAGS += -I$(cmdline_dir) -CPPFLAGS += -I$(cmdlist_dir) CPPFLAGS += -I$(lls_suite_dir) CPPFLAGS += $(lopsub_cppflags) @@ -149,32 +138,6 @@ else Q := @ endif -$(cmdlist_dir)/%.command_list.h: %.cmd %.c | $(cmdlist_dir) - @[ -z "$(Q)" ] || echo 'GEN $@' - $(Q) ./command_util.bash h < $< >$@ -$(cmdlist_dir)/%.command_list.man: %.cmd %.c | $(cmdlist_dir) - @[ -z "$(Q)" ] || echo 'GEN $@' - $(Q) ./command_util.bash man < $< > $@ -$(cmdlist_dir)/%.completion.h: %.cmd | $(cmdlist_dir) - @[ -z "$(Q)" ] || echo 'GEN $@' - $(Q) ./command_util.bash compl $(strip $(call TOUPPER,$(*F)))_COMPLETERS \ - $(strip $(call TOUPPER,$(*F)))_COMMANDS < $< > $@ - -$(cmdlist_dir)/server.command_list.h \ -$(cmdlist_dir)/server.command_list.man \ -$(cmdlist_dir)/server.completion.h \ -: command.c - -$(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 := $(lls_suite_dir)/server_cmd.lsg.man audiod_command_lists := $(lls_suite_dir)/audiod_cmd.lsg.man play_command_lists := $(lls_suite_dir)/play_cmd.lsg.man @@ -286,9 +249,7 @@ $(dep_dir)/%.d: %.c | $(dep_dir) @[ -z "$(Q)" ] || echo 'DEP $<' $(Q) $(CC) $(CPPFLAGS) -MM -MG -MP -MT $@ -MT $(object_dir)/$(*F).o $< \ | sed -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,\}.lsg.h\)@ $(lls_suite_dir)/\1@g" \ - -e "s@ \([a-zA-Z0-9_]\{1,\}\.completion.h\)@ $(cmdlist_dir)/\1@g" > $@ + -e "s@ \([a-zA-Z0-9_]\{1,\}.lsg.h\)@ $(lls_suite_dir)/\1@g" > $@ para_recv para_afh para_play para_server: LDFLAGS += $(id3tag_ldflags) para_write para_play para_audiod \ diff --git a/afs.cmd b/afs.cmd deleted file mode 100644 index f377a604..00000000 --- a/afs.cmd +++ /dev/null @@ -1,4 +0,0 @@ -BN: afs -SF: afs.c aft.c attribute.c -SN: list of afs commands -TM: mood lyr img pl diff --git a/audiod.cmd b/audiod.cmd deleted file mode 100644 index 69224970..00000000 --- a/audiod.cmd +++ /dev/null @@ -1,4 +0,0 @@ -BN: audiod -SF: audiod_command.c -SN: list of audiod commands ---- diff --git a/command_util.bash b/command_util.bash deleted file mode 100755 index 5e9dbcc7..00000000 --- a/command_util.bash +++ /dev/null @@ -1,291 +0,0 @@ -#!/usr/bin/env bash - -read_header() -{ - local key value i - - while read key value; do - case "$key" in - ---) - break - ;; - BN:) - base_name="$value" - ;; - SF:) - source_files="$value" - ;; - SN:) - section_name="$value" - ;; - TM:) - template_members="$value" - esac - done -} - -read_one_command() -{ - local line - - name_txt="" - desc_txt="" - usage_txt="" - help_txt="" - perms_txt="" - template=0 - template_name="" - template_prototype="" - while read key value; do - case "$key" in - ---) - break - ;; - N:) - name_txt="$value" - ;; - T:) - template_name="$value" - template=1 - ;; - O:) - template_prototype="$value" - template=1 - ;; - P:) - perms_txt="$value" - ;; - D:) - desc_txt="$value" - ;; - U:) - usage_txt="$value" - ;; - H:) - help_txt="${value}" - while read line; do - if test "$line" = "---"; then - break; - fi - line=${line#H:} - help_txt="$help_txt -${line# }" - done - break - ;; - esac - done - if test $template -eq 0; then - if test -n "$name_txt" -a -n "$desc_txt" -a -n "$usage_txt" \ - -a -n "$help_txt"; then - ret=1 - return - fi - else - if test -n "$template_name" -a -n "$template_prototype" \ - -a -n "$name_txt " -a -n "$template_members" \ - -a -n "$desc_txt" -a -n "$usage_txt" \ - -a -n "$help_txt"; then - ret=1 - return - fi - fi - if test -z "$name_txt" -a -z "$desc_txt" -a -z "$usage_txt" \ - -a -z "$help_txt"; then - ret=0 - return - fi - ret=-1 - #return - echo "!ERROR!" - echo "N: $name_txt" - echo "D: $desc_txt" - echo "S: $usage_txt" - echo "P: $perms_txt" - echo "H: $help_txt" - echo "O: $template_prototype" -} - -dump_man() -{ - if test $template -eq 0; then - echo ".SS \"$name_txt\"" - echo "$desc_txt" - echo - echo "\\fBUsage: \\fP$usage_txt" - else - for member in $template_members; do - local sed_cmd="sed -e s/@member@/$member/g" - local t_name_txt=$(echo $name_txt | $sed_cmd) - echo ".SS \"$t_name_txt\"" - done - echo "$desc_txt" | sed -e "s/@member@/{$(echo $template_members | sed -e 's/ / | /g')}/g" - echo - echo "\\fBUsage: \\fP" - echo - echo ".nf" - for member in $template_members; do - local sed_cmd="sed -e s/@member@/$member/g" - local t_usage_txt=$(echo $usage_txt | $sed_cmd) - printf "\t$t_usage_txt\n" - done - echo ".fi" - fi - echo - echo "$help_txt" | sed -e 's/^ //' - echo - if test -n "$perms_txt"; then - echo -n "\\fBpermissions:\\fP " - if test "$perms_txt" = "0"; then - echo "(none)" - else - echo "$perms_txt" - fi - fi - echo -} - - -com_man() -{ - echo "[$section_name]" - echo - while : ; do - read_one_command - if test $ret -lt 0; then - exit 1 - fi - if test $ret -eq 0; then - break - fi - dump_man - done -} - -cmd_handler_name() -{ - result="com_$name_txt," -} - -make_array_member() -{ - local TAB=' ' CR=' -' - local tmp - - result="{.name = \"$name_txt\", .handler = com_$name_txt, " - if test -n "$perms_txt"; then - result="$result .perms = $perms_txt," - fi - result="$result.description = \"$desc_txt\", .usage = \"$usage_txt\", \\$CR .help = " - tmp="$(printf "%s\n" "$help_txt" | sed -e 's/^/\"/g' -e 's/$/\\n\"/g' \ - -e "s/$TAB/\\\t/g" -e's/$/\\/g')" - result="$result$tmp$CR}, \\$CR" -} - -make_completion() -{ - local CR=' -' - result=" {.name = \"$name_txt\", .completer = ${name_txt}_completer}, \\$CR" -} - -template_loop() -{ - local loop_result= - - local t_name="$name_txt" - local t_perms="$perms_txt" - local t_desc="$desc_txt" - local t_usage="$usage_txt" - local t_help="$help_txt" - local t_source_files="$source_files" - local member - for member in $template_members; do - name_txt="${t_name//@member@/$member}" - perms_txt="${t_perms//@member@/$member}" - desc_txt="${t_desc//@member@/$member}" - usage_txt="${t_usage//@member@/$member}" - help_txt="${t_help//@member@/$member}" - prototype="${template_prototype//@member@/$member}" - result= - $1 - loop_result="$loop_result$result" - done - result="$loop_result" - # reset global variables - name_txt="$t_name" - perms_txt="$t_perms" - desc_txt="$t_desc" - usage_txt="$t_usage" - help_txt="$t_help" - source_files="$t_source_files" -} - -com_header() -{ - local array_members handlers= CR=' -' - - while : ; do - read_one_command - if test $ret -lt 0; then - exit 1 - fi - if test $ret -eq 0; then - break - fi - if test $template -eq 0; then - cmd_handler_name - handlers+="$result" - make_array_member - array_members="$array_members$result" - continue - fi - template_loop cmd_handler_name - handlers+="$result" - template_loop make_array_member - array_members="$array_members$result" - done - array_members="$array_members{.name = NULL} \\$CR" - echo "#define DEFINE_${base_name^^}_CMD_ARRAY $array_members" - echo "#define ${base_name^^}_COMMAND_HANDLERS ${handlers%,}" -} - -com_completion() -{ - - echo "#define $1 \\" - while : ; do - read_one_command - if test $ret -lt 0; then - exit 1 - fi - if test $ret -eq 0; then - break - fi - if test $template -eq 0; then - make_completion - printf "%s" "$result" - continue - fi - template_loop make_completion - printf "%s" "$result" - done - echo -} - -read_header -arg="$1" -shift -case "$arg" in - "h") - com_header - ;; - "man") - com_man $* - ;; - "compl") - com_completion $* - ;; -esac diff --git a/play.cmd b/play.cmd deleted file mode 100644 index 8cdc9b08..00000000 --- a/play.cmd +++ /dev/null @@ -1,3 +0,0 @@ -BN: play -SF: play.c -SN: list of commands diff --git a/server.cmd b/server.cmd deleted file mode 100644 index b7d0af1a..00000000 --- a/server.cmd +++ /dev/null @@ -1,3 +0,0 @@ -BN: server -SF: command.c -SN: list of server commands -- 2.39.2