From 2736663b21ab8edfeb4980c8fd7d2ba92aa78163 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 30 Oct 2023 02:01:21 +0000 Subject: [PATCH 1/2] Add avrdude_conf_version to grammar --- src/avrdude.conf.in | 19 ++++++++++--------- src/config.c | 2 ++ src/config_gram.y | 6 ++++++ src/developer_opts.c | 2 +- src/doc/avrdude.texi | 3 +++ src/lexer.l | 1 + src/libavrdude.h | 1 + src/main.c | 2 ++ 8 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/avrdude.conf.in b/src/avrdude.conf.in index 62609329f..db781b0bb 100644 --- a/src/avrdude.conf.in +++ b/src/avrdude.conf.in @@ -2,13 +2,17 @@ # # AVRDUDE Configuration File # -# This file contains configuration data used by AVRDUDE which describes -# the programming hardware pinouts and also provides part definitions. + +avrdude_conf_version = "@AVRDUDE_FULL_VERSION@"; + +# This file contains AVRDUDE's default configuration data describing +# programming hardware pinouts and part definitions. Normally, it +# requires AVRDUDE be of the same or higher version than above string. # AVRDUDE's -C command line option specifies the location of the -# configuration file. The -c option names the programmer configuration -# which must match one of the entry's id parameter. The -p option -# identifies which part AVRDUDE is going to be programming and must match -# one of the parts' id parameters. +# configuration file. The -c option names the programmer configuration +# which must match one of the entry's id parameter. The -p option +# identifies which part AVRDUDE is going to be programming and must +# match one of the parts' id parameters. # # DO NOT MODIFY THIS FILE. Modifications will be overwritten the next # time a "make install" is run. For user-specific additions, use the @@ -432,9 +436,6 @@ # ATmega8 0x76 # ATmega169 0x78 -# Buildtime configuration -avrdude_version = "@AVRDUDE_FULL_VERSION@"; - # # Overall avrdude defaults; suitable for ~/.config/avrdude/avrdude.rc # diff --git a/src/config.c b/src/config.c index c6ea0cffe..6b401d8e1 100644 --- a/src/config.c +++ b/src/config.c @@ -36,6 +36,8 @@ #include "config_gram.h" +const char *avrdude_conf_version; + const char *default_programmer; const char *default_parallel; const char *default_serial; diff --git a/src/config_gram.y b/src/config_gram.y index d300fbcbd..310e2e85c 100644 --- a/src/config_gram.y +++ b/src/config_gram.y @@ -74,6 +74,7 @@ static int pin_name; %token K_ALIAS %token K_ALLOW_SUBSHELLS +%token K_AVRDUDE_CONF_VERSION %token K_BUFF %token K_CONNTYPE %token K_DEDICATED @@ -213,6 +214,11 @@ def : part_def TKN_SEMI | + K_AVRDUDE_CONF_VERSION TKN_EQUAL TKN_STRING TKN_SEMI { + avrdude_conf_version = cache_string($3->value.string); + free_token($3); + } | + K_DEFAULT_PROGRAMMER TKN_EQUAL TKN_STRING TKN_SEMI { default_programmer = cache_string($3->value.string); free_token($3); diff --git a/src/developer_opts.c b/src/developer_opts.c index 189b557ae..98c52028b 100644 --- a/src/developer_opts.c +++ b/src/developer_opts.c @@ -849,7 +849,7 @@ void dev_output_pgm_part(int dev_opt_c, const char *programmer, int dev_opt_p, c char *p; dev_print_comment(cfg_get_prologue()); - + dev_info("avrdude_conf_version = %s;\n\n", p = cfg_escape(avrdude_conf_version)); free(p); dev_info("default_programmer = %s;\n", p = cfg_escape(default_programmer)); free(p); dev_info("default_parallel = %s;\n", p = cfg_escape(default_parallel)); free(p); dev_info("default_serial = %s;\n", p = cfg_escape(default_serial)); free(p); diff --git a/src/doc/avrdude.texi b/src/doc/avrdude.texi index 4a17f0092..de300799f 100644 --- a/src/doc/avrdude.texi +++ b/src/doc/avrdude.texi @@ -2843,6 +2843,9 @@ the executable. @table @code +@item avrdude_conf_version = "@var{build-time-version}"; +Automatically set during the build process. + @item default_parallel = "@var{default-parallel-device}"; Assign the default parallel port device. Can be overridden using the @option{-P} option. diff --git a/src/lexer.l b/src/lexer.l index 2daa809eb..93dce2ee9 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -181,6 +181,7 @@ INF [Ii][Nn][Ff]([Ii][Nn][Ii][Tt][Yy])? alias { yylval=NULL; return K_ALIAS; } allow_subshells { yylval=NULL; return K_ALLOW_SUBSHELLS; } allowfullpagebitstream { yylval=NULL; ccap(); return K_ALLOWFULLPAGEBITSTREAM; } +avrdude_conf_version { yylval=NULL; return K_AVRDUDE_CONF_VERSION; } buff { yylval=NULL; ccap(); return K_BUFF; } chip_erase { yylval=new_token(K_CHIP_ERASE); ccap(); return K_CHIP_ERASE; } connection_type { yylval=NULL; ccap(); return K_CONNTYPE; } diff --git a/src/libavrdude.h b/src/libavrdude.h index 8910c9764..0e957756e 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -1181,6 +1181,7 @@ void walk_programmer_types(/*LISTID programmer_types,*/ walk_programmer_types_cb extern LISTID part_list; extern LISTID programmers; +extern const char *avrdude_conf_version; extern const char *default_programmer; extern const char *default_parallel; extern const char *default_serial; diff --git a/src/main.c b/src/main.c index df4e0f673..b872ed8ab 100644 --- a/src/main.c +++ b/src/main.c @@ -571,6 +571,8 @@ int main(int argc, char * argv []) progname[strlen(progname)-4] = 0; } + avrdude_conf_version = ""; + default_programmer = ""; default_parallel = ""; default_serial = ""; From 685d9bcf776bc06817de345123d041c31c78ab64 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 30 Oct 2023 10:43:26 +0000 Subject: [PATCH 2/2] Add AVRDUDE_FULL_VERSION to configure.ac --- src/configure.ac | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/configure.ac b/src/configure.ac index a67dac281..9f4f0cb11 100644 --- a/src/configure.ac +++ b/src/configure.ac @@ -543,8 +543,9 @@ AC_CONFIG_FILES([ Makefile ]) -# Pass into avrdude.conf.in -AVRDUDE_FULL_VERSION='$(VERSION)' +# Pass version number into avrdude.conf +AVRDUDE_FULL_VERSION=$PACKAGE_VERSION +AC_SUBST(AVRDUDE_FULL_VERSION, $AVRDUDE_FULL_VERSION) # The procedure to create avrdude.conf involves two steps. First, # normal autoconf substitution will be applied, resulting in