From ea47466b4f75901ee5351dafd0778592f530eb4b Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Wed, 22 Jun 2011 23:34:50 +0000 Subject: [PATCH] autogenerate list of commands git-svn-id: https://urjtag.svn.sourceforge.net/svnroot/urjtag/trunk@1911 b68d4a1b-bc3d-0410-92ed-d4ac073336b7 --- urjtag/ChangeLog | 7 +++++ urjtag/src/cmd/Makefile.am | 25 +++++++++++++---- urjtag/src/cmd/cmd_list.h | 55 +++++--------------------------------- 3 files changed, 33 insertions(+), 54 deletions(-) diff --git a/urjtag/ChangeLog b/urjtag/ChangeLog index fbae6c24..84ead711 100644 --- a/urjtag/ChangeLog +++ b/urjtag/ChangeLog @@ -1,3 +1,10 @@ +2011-06-22 Mike Frysinger + + * src/cmd/Makefile.am: Autogenerate command list based on the source + files and store in generated_cmd_list.h. + * src/cmd/cmd_list.h: Remove hardcoded command list and include new + autogenerated header file. + 2011-06-17 Mike Frysinger * data/xilinx/PARTS: Add xilinx xc18v02pc44 parts by Steve Tell. diff --git a/urjtag/src/cmd/Makefile.am b/urjtag/src/cmd/Makefile.am index 2a7fcddb..45b23165 100644 --- a/urjtag/src/cmd/Makefile.am +++ b/urjtag/src/cmd/Makefile.am @@ -25,9 +25,7 @@ include $(top_srcdir)/Makefile.rules noinst_LTLIBRARIES = libcmd.la -libcmd_la_SOURCES = \ - cmd.h \ - cmd_list.h \ +all_cmd_files = \ cmd_frequency.c \ cmd_cable.c \ cmd_reset.c \ @@ -69,11 +67,28 @@ libcmd_la_SOURCES = \ cmd_pld.c if ENABLE_SVF -libcmd_la_SOURCES += cmd_svf.c +all_cmd_files += cmd_svf.c endif if ENABLE_BSDL -libcmd_la_SOURCES += cmd_bsdl.c +all_cmd_files += cmd_bsdl.c endif +libcmd_la_SOURCES = \ + cmd.h \ + cmd_list.h \ + $(all_cmd_files) + +cmd_list.h: generated_cmd_list.h +generated_cmd_list.h: $(all_cmd_files) + $(AM_V_GEN)set -e; \ + cmds=`$(SED) -n '/^const urj_cmd_t urj_cmd_/{s:.*urj_cmd_::;s: =.*::;p}' $^`; \ + for c in $$cmds ; do \ + printf '#ifndef URJ_CMD_SKIP_%s\n_URJ_CMD(%s)\n#endif\n' $$c $$c; \ + done > $@.tmp; \ + cmp -s $@ $@.tmp && rm -f $@.tmp || mv $@.tmp $@ + +EXTRA_DIST = generated_cmd_list.h +MAINTAINERCLEANFILES = generated_cmd_list.h + AM_CFLAGS = $(WARNINGCFLAGS) diff --git a/urjtag/src/cmd/cmd_list.h b/urjtag/src/cmd/cmd_list.h index 8aa6833a..648d9d69 100644 --- a/urjtag/src/cmd/cmd_list.h +++ b/urjtag/src/cmd/cmd_list.h @@ -31,56 +31,13 @@ * */ - -/* - * Please keep this list sorted alphabetically - */ - -_URJ_CMD(addpart) -_URJ_CMD(bfin) -_URJ_CMD(bit) -#ifdef ENABLE_BSDL -_URJ_CMD(bsdl) +#ifndef ENABLE_BSDL +#define URJ_CMD_SKIP_bsdl #endif -_URJ_CMD(bus) -_URJ_CMD(cable) -_URJ_CMD(debug) -_URJ_CMD(detect) -_URJ_CMD(detectflash) -_URJ_CMD(discovery) -_URJ_CMD(dr) -_URJ_CMD(endian) -_URJ_CMD(eraseflash) -_URJ_CMD(flashmem) -_URJ_CMD(frequency) -_URJ_CMD(get) -_URJ_CMD(help) -_URJ_CMD(idcode) -_URJ_CMD(include) -_URJ_CMD(initbus) -_URJ_CMD(instruction) -_URJ_CMD(part) -_URJ_CMD(peek) -_URJ_CMD(pld) -_URJ_CMD(pod) -_URJ_CMD(poke) -_URJ_CMD(print) -_URJ_CMD(quit) -_URJ_CMD(readmem) -_URJ_CMD(register) -_URJ_CMD(reset) -_URJ_CMD(salias) -_URJ_CMD(scan) -_URJ_CMD(script) -_URJ_CMD(set) -_URJ_CMD(shell) -_URJ_CMD(shift) -_URJ_CMD(signal) -#ifdef ENABLE_SVF -_URJ_CMD(svf) +#ifndef ENABLE_SVF +#define URJ_CMD_SKIP_svf #endif -_URJ_CMD(test) -_URJ_CMD(usleep) -_URJ_CMD(writemem) + +#include "generated_cmd_list.h" #undef _URJ_CMD