From 966e29db3b9ce9c6e028a93282aedcfc4c79bbca Mon Sep 17 00:00:00 2001 From: Stephen Williams Date: Fri, 27 Nov 2009 09:25:50 -0800 Subject: [PATCH] Unify the version stamp in the version_*.h header files. Try to put all the version stamps into common version_base.h and version_stamp.h header files. All the source programs then get their version from these header files. Also handle the version stamps in the man pages by using the version_*.h header file contents to edit the version strings in the man page title bar markers. --- .gitignore | 5 ++ Makefile.in | 26 ++++--- driver-vpi/Makefile.in | 6 +- driver-vpi/{res.rc => res.rc.in} | 4 +- driver/Makefile.in | 18 +++-- driver/{iverilog.man => iverilog.man.in} | 2 +- driver/main.c | 3 +- iverilog-vpi.man => iverilog-vpi.man.in | 2 +- ivlpp/Makefile.in | 2 +- ivlpp/main.c | 3 +- main.cc | 3 +- tgt-null/null.c | 3 +- tgt-stub/stub.c | 3 +- tgt-vhdl/vhdl.cc | 3 +- tgt-vvp/vvp.c | 3 +- version.c | 88 ++++++++++++++++++++++++ version_base.h | 19 +++++ version_base.in | 7 -- vpi/vams_simparam.c | 5 +- vvp/Makefile.in | 14 ++-- vvp/main.cc | 3 +- vvp/{vvp.man => vvp.man.in} | 2 +- 22 files changed, 177 insertions(+), 47 deletions(-) rename driver-vpi/{res.rc => res.rc.in} (90%) rename driver/{iverilog.man => iverilog.man.in} (99%) rename iverilog-vpi.man => iverilog-vpi.man.in (98%) create mode 100644 version.c create mode 100644 version_base.h delete mode 100644 version_base.in rename vvp/{vvp.man => vvp.man.in} (99%) diff --git a/.gitignore b/.gitignore index 1a71c96964..5382365148 100644 --- a/.gitignore +++ b/.gitignore @@ -62,6 +62,11 @@ dep # Program created files /vvp/tables.cc +/iverilog-vpi.man +/driver-vpi/res.rc +/driver/iverilog.man +/vvp/vvp.man + # The executables. *.exe /driver/iverilog diff --git a/Makefile.in b/Makefile.in index 9c4d93f172..6a1dc9d0a3 100644 --- a/Makefile.in +++ b/Makefile.in @@ -55,6 +55,7 @@ mandir = @mandir@ dllib=@DLLIB@ CC = @CC@ +HOSTCC = @CC@ CXX = @CXX@ INSTALL = @INSTALL@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ @@ -71,7 +72,7 @@ CXXFLAGS = -Wall @CXXFLAGS@ PICFLAGS = @PICFLAG@ LDFLAGS = @rdynamic@ @LDFLAGS@ -all: dep config.h _pli_types.h version.h ivl@EXEEXT@ +all: dep config.h _pli_types.h version_tag.h ivl@EXEEXT@ $(foreach dir,$(SUBDIRS),$(MAKE) -C $(dir) $@ && ) true # In the windows world, the installer will need a dosify program to @@ -96,10 +97,11 @@ ifeq (@MINGW32@,no) (cd driver-vpi ; $(MAKE) $@) endif rm -f *.o parse.cc parse.h lexor.cc - rm -f ivl.exp iverilog-vpi.pdf iverilog-vpi.ps parse.output + rm -f ivl.exp iverilog-vpi.man iverilog-vpi.pdf iverilog-vpi.ps parse.output rm -f syn-rules.output dosify.exe ivl@EXEEXT@ check.vvp rm -f lexor_keyword.cc libivl.a libvpi.a iverilog-vpi syn-rules.cc rm -rf dep + rm version.exe distclean: clean $(foreach dir,$(SUBDIRS),$(MAKE) -C $(dir) $@ && ) true @@ -184,6 +186,9 @@ iverilog-vpi: iverilog-vpi.sh Makefile chmod +x $@ endif +version.exe: $(srcdir)/version.c $(srcdir)/version_base.h version_tag.h + $(HOSTCC) -o version.exe -I. -I$(srcdir) $(srcdir)/version.c + dep: mkdir dep @@ -211,17 +216,16 @@ lexor_keyword.o: lexor_keyword.cc parse.h lexor_keyword.cc: lexor_keyword.gperf gperf -o -i 7 -C -k 1-4,$$ -L ANSI-C -H keyword_hash -N check_identifier -t $(srcdir)/lexor_keyword.gperf > lexor_keyword.cc || (rm -f lexor_keyword.cc ; false) -iverilog-vpi.ps: $(srcdir)/iverilog-vpi.man - $(MAN) -t $(srcdir)/iverilog-vpi.man > iverilog-vpi.ps +iverilog-vpi.man: $(srcdir)/iverilog-vpi.man.in version.exe + ./version.exe `head -1 $(srcdir)/iverilog-vpi.man.in`'\n' > $@ + tail +2 $(srcdir)/iverilog-vpi.man.in >> $@ + +iverilog-vpi.ps: iverilog-vpi.man + $(MAN) -t iverilog-vpi.man > iverilog-vpi.ps iverilog-vpi.pdf: iverilog-vpi.ps $(PS2PDF) iverilog-vpi.ps iverilog-vpi.pdf -# The version.h header file is the concatenation of a relatively static -# base version and the detailed version tag. -version.h: $(srcdir)/version_base.in version_tag.h - cat $(srcdir)/version_base.in version_tag.h > version.h - # For VERSION_TAG in driver/main.c, first try git-describe, then look for a # version.h file in the source tree (included in snapshots and releases), and # finally use nothing. @@ -299,8 +303,8 @@ $(includedir)/acc_user.h: $(srcdir)/acc_user.h $(includedir)/veriuser.h: $(srcdir)/veriuser.h $(INSTALL_DATA) $(srcdir)/veriuser.h "$(DESTDIR)$(includedir)/veriuser.h" -$(mandir)/man1/iverilog-vpi$(suffix).1: $(srcdir)/iverilog-vpi.man - $(INSTALL_DATA) $(srcdir)/iverilog-vpi.man "$(DESTDIR)$(mandir)/man1/iverilog-vpi$(suffix).1" +$(mandir)/man1/iverilog-vpi$(suffix).1: iverilog-vpi.man + $(INSTALL_DATA) iverilog-vpi.man "$(DESTDIR)$(mandir)/man1/iverilog-vpi$(suffix).1" $(prefix)/iverilog-vpi$(suffix).pdf: iverilog-vpi.pdf $(INSTALL_DATA) iverilog-vpi.pdf "$(DESTDIR)$(prefix)/iverilog-vpi$(suffix).pdf" diff --git a/driver-vpi/Makefile.in b/driver-vpi/Makefile.in index 3420c17dea..5b7278f9fc 100644 --- a/driver-vpi/Makefile.in +++ b/driver-vpi/Makefile.in @@ -50,7 +50,7 @@ all: iverilog-vpi@EXEEXT@ check: all clean: - rm -f *.o config.h iverilog-vpi@EXEEXT@ + rm -f *.o config.h iverilog-vpi@EXEEXT@ res.rc distclean: clean rm -f Makefile config.log @@ -74,6 +74,10 @@ config.h: $(srcdir)/config.h.in Makefile -e 's;@SHARED@;@shared@;' $< > $@ # Windows specific... +res.rc: $(srcdir)/res.rc.in ../version.exe + sed -e 's;@PRODUCTVERSION@;'`../version.exe '%M,%m,%n,0'`';' \ + $(srcdir)/res.rc.in > $@ + res.o: res.rc windres -i res.rc -o res.o # diff --git a/driver-vpi/res.rc b/driver-vpi/res.rc.in similarity index 90% rename from driver-vpi/res.rc rename to driver-vpi/res.rc.in index 2cfa1941f3..6d287839e8 100755 --- a/driver-vpi/res.rc +++ b/driver-vpi/res.rc.in @@ -10,7 +10,7 @@ LANGUAGE 9, 4 1 VERSIONINFO FILEVERSION 2002,11,13,0 - PRODUCTVERSION 0,7,0,0 + PRODUCTVERSION @PRODUCTVERSION@ FILEFLAGSMASK 0x3fL FILEFLAGS 0x2L FILEOS 0x40004L @@ -28,7 +28,7 @@ BEGIN VALUE "LegalCopyright", "Copyright 2002 Gus Baldauf\0" VALUE "OriginalFilename", "iverilog-vpi.exe\0" VALUE "ProductName", "Icarus Verilog\0" - VALUE "ProductVersion", "0, 7, 0, 0\0" + VALUE "ProductVersion", "@PRODUCTVERSION@\0" END END BLOCK "VarFileInfo" diff --git a/driver/Makefile.in b/driver/Makefile.in index 84da8d38cd..5edfabcf3d 100644 --- a/driver/Makefile.in +++ b/driver/Makefile.in @@ -45,13 +45,13 @@ CPPFLAGS = -I. -I.. -I$(srcdir)/.. -I$(srcdir) @CPPFLAGS@ @DEFS@ CFLAGS = -Wall @CFLAGS@ LDFLAGS = @LDFLAGS@ -all: dep iverilog@EXEEXT@ +all: dep iverilog@EXEEXT@ iverilog.man check: all clean: rm -f *.o cflexor.c cfparse.c cfparse.h cfparse.output - rm -f iverilog@EXEEXT@ iverilog.pdf iverilog.ps + rm -f iverilog@EXEEXT@ iverilog.man iverilog.pdf iverilog.ps rm -rf dep distclean: clean @@ -78,14 +78,18 @@ dep: $(CC) $(CPPFLAGS) $(CFLAGS) -MD -c $< -o $*.o mv $*.d dep -main.o: main.c globals.h ../version.h Makefile +main.o: main.c globals.h ../version_base.h ../version_tag.h Makefile $(CC) $(CPPFLAGS) $(CFLAGS) -MD -c -DIVL_ROOT='"@libdir@/ivl$(suffix)"' -DIVL_INC='"@includedir@"' -DIVL_LIB='"@libdir@"' -DDLLIB='"@DLLIB@"' $(srcdir)/main.c mv $*.d dep cflexor.o: cflexor.c cfparse.h -iverilog.ps: $(srcdir)/iverilog.man - $(MAN) -t $(srcdir)/iverilog.man > iverilog.ps +iverilog.man: $(srcdir)/iverilog.man.in ../version.exe + ../version.exe `head -1 $(srcdir)/iverilog.man.in`'\n' > $@ + tail +2 $(srcdir)/iverilog.man.in >> $@ + +iverilog.ps: iverilog.man + $(MAN) -t iverilog.man > iverilog.ps iverilog.pdf: iverilog.ps $(PS2PDF) iverilog.ps iverilog.pdf @@ -112,8 +116,8 @@ install: all installdirs $(bindir)/iverilog$(suffix)@EXEEXT@ $(INSTALL_DOC) $(bindir)/iverilog$(suffix)@EXEEXT@: ./iverilog@EXEEXT@ $(INSTALL_PROGRAM) ./iverilog@EXEEXT@ "$(DESTDIR)$(bindir)/iverilog$(suffix)@EXEEXT@" -$(mandir)/man1/iverilog$(suffix).1: $(srcdir)/iverilog.man - $(INSTALL_DATA) $(srcdir)/iverilog.man "$(DESTDIR)$(mandir)/man1/iverilog$(suffix).1" +$(mandir)/man1/iverilog$(suffix).1: iverilog.man + $(INSTALL_DATA) iverilog.man "$(DESTDIR)$(mandir)/man1/iverilog$(suffix).1" $(prefix)/iverilog$(suffix).pdf: iverilog.pdf $(INSTALL_DATA) iverilog.pdf "$(DESTDIR)$(prefix)/iverilog$(suffix).pdf" diff --git a/driver/iverilog.man b/driver/iverilog.man.in similarity index 99% rename from driver/iverilog.man rename to driver/iverilog.man.in index acc17bf5c1..96cc7949ed 100644 --- a/driver/iverilog.man +++ b/driver/iverilog.man.in @@ -1,4 +1,4 @@ -.TH iverilog 1 "October 28th, 2009" "" "Version 0.10.devel" +.TH iverilog 1 "October 28th, 2009" "" "Version %M.%m.%n %E" .SH NAME iverilog - Icarus Verilog compiler diff --git a/driver/main.c b/driver/main.c index d471a0ed0a..d30b5aa0fe 100644 --- a/driver/main.c +++ b/driver/main.c @@ -18,7 +18,8 @@ */ # include "config.h" -# include "version.h" +# include "version_base.h" +# include "version_tag.h" const char NOTICE[] = " This program is free software; you can redistribute it and/or modify\n" diff --git a/iverilog-vpi.man b/iverilog-vpi.man.in similarity index 98% rename from iverilog-vpi.man rename to iverilog-vpi.man.in index f6e40aa4ae..ad870cb1ba 100644 --- a/iverilog-vpi.man +++ b/iverilog-vpi.man.in @@ -1,4 +1,4 @@ -.TH iverilog-vpi 1 "April 17th, 2009" "" "Version 0.10.devel" +.TH iverilog-vpi 1 "April 17th, 2009" "" "Version %M.%m.%n %E" .SH NAME iverilog-vpi - Compile front end for VPI modules diff --git a/ivlpp/Makefile.in b/ivlpp/Makefile.in index 955c818329..b56b4f1278 100644 --- a/ivlpp/Makefile.in +++ b/ivlpp/Makefile.in @@ -74,4 +74,4 @@ uninstall: rm -f "$(DESTDIR)$(libdir)/ivl$(suffix)/ivlpp@EXEEXT@" lexor.o: lexor.c globals.h -main.o: main.c globals.h ../version.h +main.o: main.c globals.h ../version_base.h ../version_tag.h diff --git a/ivlpp/main.c b/ivlpp/main.c index 96587c8614..bec4789d7d 100644 --- a/ivlpp/main.c +++ b/ivlpp/main.c @@ -18,7 +18,8 @@ const char COPYRIGHT[] = */ # include "config.h" -# include "version.h" +# include "version_base.h" +# include "version_tag.h" const char NOTICE[] = " This program is free software; you can redistribute it and/or modify\n" diff --git a/main.cc b/main.cc index 7f3b8ead2c..f1f98626c6 100644 --- a/main.cc +++ b/main.cc @@ -20,7 +20,8 @@ const char COPYRIGHT[] = */ # include "config.h" -# include "version.h" +# include "version_base.h" +# include "version_tag.h" const char NOTICE[] = " This program is free software; you can redistribute it and/or modify\n" diff --git a/tgt-null/null.c b/tgt-null/null.c index f1810f0602..c99f6ca85a 100644 --- a/tgt-null/null.c +++ b/tgt-null/null.c @@ -17,7 +17,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -# include "version.h" +# include "version_base.h" +# include "version_tag.h" # include "config.h" # include diff --git a/tgt-stub/stub.c b/tgt-stub/stub.c index d1d745978d..8b0a77fdd1 100644 --- a/tgt-stub/stub.c +++ b/tgt-stub/stub.c @@ -24,7 +24,8 @@ * understand the behavior of the core as it uses a target module. */ -# include "version.h" +# include "version_base.h" +# include "version_tag.h" # include "config.h" # include "priv.h" # include diff --git a/tgt-vhdl/vhdl.cc b/tgt-vhdl/vhdl.cc index 59213d4efc..9c025a3c2e 100644 --- a/tgt-vhdl/vhdl.cc +++ b/tgt-vhdl/vhdl.cc @@ -18,7 +18,8 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "version.h" +#include "version_base.h" +#include "version_tag.h" #include "vhdl_target.h" #include "state.hh" diff --git a/tgt-vvp/vvp.c b/tgt-vvp/vvp.c index 8f0cb882e8..fba834998c 100644 --- a/tgt-vvp/vvp.c +++ b/tgt-vvp/vvp.c @@ -17,7 +17,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -# include "version.h" +# include "version_base.h" +# include "version_tag.h" # include "vvp_priv.h" # include # include diff --git a/version.c b/version.c new file mode 100644 index 0000000000..810679bcd8 --- /dev/null +++ b/version.c @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2009 Stephen Williams (steve@icarus.com) + * + * This source code is free software; you can redistribute it + * and/or modify it in source code form under the terms of the GNU + * General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ + +# include "version_base.h" +# include "version_tag.h" +# include +# include + +static void run_string(const char*txt) +{ + const char*cp = txt; + while (*cp) { + if (cp[0] == '%' && cp[1] != 0) { + switch (cp[1]) { + case 'M': + fprintf(stdout, "%u", VERSION_MAJOR1); + break; + case 'm': + fprintf(stdout, "%u", VERSION_MAJOR2); + break; + case 'n': + fprintf(stdout, "%u", VERSION_MINOR); + break; + case 'E': + fprintf(stdout, "%s", VERSION_EXTRA); + break; + case 'T': + fprintf(stdout, "%s", VERSION_TAG); + break; + case '%': + putc('%', stdout); + break; + default: + break; + } + cp += 2; + + } else if (cp[0] == '\\' && cp[1] != 0) { + switch (cp[1]) { + case 'n': + putc('\n', stdout); + break; + default: + putc(cp[1], stdout); + break; + } + cp += 2; + + } else { + putc(cp[0], stdout); + cp += 1; + } + } +} + +int main(int argc, char*argv[]) +{ + int idx; + + if (argc == 1) { + printf("%s\n", VERSION); + return 0; + } + + run_string(argv[1]); + for (idx = 2 ; idx < argc ; idx += 1) { + printf(" "); + run_string(argv[idx]); + } + + return 0; +} diff --git a/version_base.h b/version_base.h new file mode 100644 index 0000000000..ce10b6b6ec --- /dev/null +++ b/version_base.h @@ -0,0 +1,19 @@ +#ifndef VERSION +/* + * Edit this definition in version_base.in to define the base version + * number for the compiled result. + */ +# define VERSION_MAJOR1 0 +# define VERSION_MAJOR2 10 +# define VERSION_MINOR 0 +# define VERSION_EXTRA "(devel)" + +/* This is a concatenation of MAJOR1.MAJOR2 that is used by + vams_simparam.c to make a double value. */ +# define VERSION_MAJOR 0.10 + +# define VERSION_STRINGIFY(x) #x +# define VERSION_STR(a,b,extra) VERSION_STRINGIFY(a.b) " " extra + +#define VERSION VERSION_STR(VERSION_MAJOR,VERSION_MINOR,VERSION_EXTRA) +#endif diff --git a/version_base.in b/version_base.in deleted file mode 100644 index 7ad8422771..0000000000 --- a/version_base.in +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef VERSION -/* - * Edit this definition in version_base.in to define the base version - * number for the compiled result. - */ -#define VERSION "0.10.0 (devel)" -#endif diff --git a/vpi/vams_simparam.c b/vpi/vams_simparam.c index 6d5922abe8..87ac2e6f03 100644 --- a/vpi/vams_simparam.c +++ b/vpi/vams_simparam.c @@ -26,6 +26,7 @@ #include #include #include "sys_priv.h" +#include "version_base.h" /* Once we have real string objects replace this with a dynamic string. */ #define MAX_STRING_RESULT 1024 @@ -149,9 +150,9 @@ static PLI_INT32 simparam_calltf(PLI_BYTE8 *name_ext) } else if (strcmp(param, "shrink") == 0) { retval = 0.0; /* Nothing for now. */ } else if (strcmp(param, "simulatorSubversion") == 0) { - retval = 0.0; + retval = VERSION_MINOR; } else if (strcmp(param, "simulatorVersion") == 0) { - retval = 0.10; + retval = VERSION_MAJOR; } else if (strcmp(param, "sourceScaleFactor") == 0) { retval = 0.0; /* Nothing for now. */ } else if (strcmp(param, "tnom") == 0) { diff --git a/vvp/Makefile.in b/vvp/Makefile.in index a46a246d23..631731af67 100644 --- a/vvp/Makefile.in +++ b/vvp/Makefile.in @@ -54,11 +54,11 @@ dllib=@DLLIB@ MDIR1 = -DMODULE_DIR1=\"$(libdir)/ivl$(suffix)/.\" -all: dep vvp@EXEEXT@ libvpi.a +all: dep vvp@EXEEXT@ libvpi.a vvp.man clean: rm -f *.o *~ parse.cc parse.h lexor.cc tables.cc - rm -rf dep vvp@EXEEXT@ libvpi.a parse.output vvp.pdf vvp.exp + rm -rf dep vvp@EXEEXT@ libvpi.a parse.output vvp.man vvp.pdf vvp.exp distclean: clean rm -f Makefile config.log @@ -131,7 +131,11 @@ parse.h: parse.cc lexor.cc: $(srcdir)/lexor.lex $(LEX) -s -olexor.cc $(srcdir)/lexor.lex -vvp.pdf: $(srcdir)/vvp.man +vvp.man: $(srcdir)/vvp.man.in ../version.exe + ../version.exe `head -1 $(srcdir)/vvp.man.in`'\n' > $@ + tail +2 $(srcdir)/vvp.man.in >> $@ + +vvp.pdf: vvp.man $(MAN) -t $(srcdir)/vvp.man | $(PS2PDF) - vvp.pdf ifeq (@MINGW32@,yes) @@ -167,8 +171,8 @@ $(bindir)/vvp$(suffix)@EXEEXT@: ./vvp@EXEEXT@ $(libdir)/libvpi$(suffix).a : ./libvpi.a $(INSTALL_DATA) libvpi.a "$(DESTDIR)$(libdir)/libvpi$(suffix).a" -$(mandir)/man1/vvp$(suffix).1: $(srcdir)/vvp.man - $(INSTALL_DATA) $(srcdir)/vvp.man "$(DESTDIR)$(mandir)/man1/vvp$(suffix).1" +$(mandir)/man1/vvp$(suffix).1: vvp.man + $(INSTALL_DATA) vvp.man "$(DESTDIR)$(mandir)/man1/vvp$(suffix).1" $(prefix)/vvp$(suffix).pdf: vvp.pdf $(INSTALL_DATA) vvp.pdf "$(DESTDIR)$(prefix)/vvp$(suffix).pdf" diff --git a/vvp/main.cc b/vvp/main.cc index ece1faf533..3e9785b8db 100644 --- a/vvp/main.cc +++ b/vvp/main.cc @@ -17,7 +17,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -# include "version.h" +# include "version_base.h" +# include "version_tag.h" # include "config.h" # include "parse_misc.h" # include "compile.h" diff --git a/vvp/vvp.man b/vvp/vvp.man.in similarity index 99% rename from vvp/vvp.man rename to vvp/vvp.man.in index 3524bc02ea..02ab5b6d76 100644 --- a/vvp/vvp.man +++ b/vvp/vvp.man.in @@ -1,4 +1,4 @@ -.TH vvp 1 "April 17th, 2009" "" "Version 0.10.devel" +.TH vvp 1 "April 17th, 2009" "" "Version %M.%m.%n %E" .SH NAME vvp - Icarus Verilog vvp runtime engine