Am 30.05.2014 00:52 schrieb Stefan Tauner:
This code exists thanks to food for thought from Urja Rannikko.
Signed-off-by: Stefan Tauner stefan.tauner@alumni.tuwien.ac.at
Interesting, to say the least. The default parameter only applies if -p is not specified at all, so there are no unexpected side effects. The only complaint I have (except the question "who would want to use that") is that you can run make CONFIG_DEFAULT_PROGRAMMER_ARGS="foobar" without having to specify CONFIG_DEFAULT_PROGRAMMER as well. CONFIG_DEFAULT_PROGRAMMER_ARGS won't have any effect in that case during runtime, but that might surprise someone who specified it.
Hm. Maybe I should really ask who would want to use that... it's obviously not a feature distributions would use, although it seems some of them use CONFIG_DEFAULT_PROGRAMMER to keep the behavoir unchanged compared to previous releases.
Not opposed to it, but not really convinced either.
Regards, Carl-Daniel
diff --git a/Makefile b/Makefile index 346d46a..998979d 100644 --- a/Makefile +++ b/Makefile @@ -52,6 +52,11 @@ DOSLIBS_BASE ?= .. # evaluated below, namely those that enable/disable the various programmers). # Compilation will fail for unspecified values. CONFIG_DEFAULT_PROGRAMMER ?= PROGRAMMER_INVALID +# The following adds a default parameter for the default programmer set above (only). +CONFIG_DEFAULT_PROGRAMMER_ARGS ?= '' +# Example: compiling with +# make CONFIG_DEFAULT_PROGRAMMER=PROGRAMMER_SERPROG CONFIG_DEFAULT_PROGRAMMER_ARGS="dev=/dev/ttyUSB0:1500000" +# would make executing './flashrom' (almost) equivialent to './flashrom -p serprog:dev=/dev/ttyUSB0:1500000'.
# If your compiler spits out excessive warnings, run make WARNERROR=no # You shouldn't have to change this flag. @@ -471,6 +476,7 @@ CONFIG_INTERNAL_DMI ?= yes # Depending on the CONFIG_* variables set and verified above we set compiler flags and parameters below.
FEATURE_CFLAGS += -D'CONFIG_DEFAULT_PROGRAMMER=$(CONFIG_DEFAULT_PROGRAMMER)' +FEATURE_CFLAGS += -D'CONFIG_DEFAULT_PROGRAMMER_ARGS="$(CONFIG_DEFAULT_PROGRAMMER_ARGS)"'
ifeq ($(CONFIG_INTERNAL), yes) FEATURE_CFLAGS += -D'CONFIG_INTERNAL=1' diff --git a/cli_classic.c b/cli_classic.c index a32d55b..fc1b9ba 100644 --- a/cli_classic.c +++ b/cli_classic.c @@ -396,8 +396,10 @@ int main(int argc, char *argv[]) if (prog == PROGRAMMER_INVALID) { if (CONFIG_DEFAULT_PROGRAMMER != PROGRAMMER_INVALID) { prog = CONFIG_DEFAULT_PROGRAMMER;
msg_pinfo("Using default programmer \"%s\".\n",
programmer_table[CONFIG_DEFAULT_PROGRAMMER].name);
/* We need to strdup here because we free(pparam) unconditionally later. */
pparam = strdup(CONFIG_DEFAULT_PROGRAMMER_ARGS);
msg_pinfo("Using default programmer \"%s\" with arguments \"%s\".\n",
} else { msg_perr("Please select a programmer with the --programmer parameter.\n" "Previously this was not necessary because there was a default set.\n"programmer_table[CONFIG_DEFAULT_PROGRAMMER].name, pparam);