Merge pull request #1331 from rhabacker/version-base-fixup

Move the use of version.exe to the build system
This commit is contained in:
Cary R. 2026-04-30 08:02:07 -07:00 committed by GitHub
commit 03cac78504
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
16 changed files with 96 additions and 142 deletions

View File

@ -17,7 +17,7 @@ the "make version" target, or automatically if the version_tag.h
file doesn't exist at all. This implies that a "make version" is
something worth doing when you do a "git pull" or create commits.
The files below are now edited by the Makefile and the version.exe program:
The files below are now edited by the Makefile:
* iverilog-vpi.man -- The .TH tag has a version string
* driver/iverilog.man -- The .TH tag has a version string

View File

@ -373,7 +373,5 @@ Next, compile with the command::
$ make
The configure generated the cross compiler flags, but there are a few
bits that need to be compiled with the native compiler. (version.exe
for example is used by the build process but is not installed.) The
The configure generated the cross compiler flags. The
configure script should have gotten all that right.

View File

@ -36,6 +36,8 @@ prefix = @prefix@
exec_prefix = @exec_prefix@
srcdir = @srcdir@
datarootdir = @datarootdir@
VERSION_MAJOR = @VERSION_MAJOR@
VERSION_MINOR = @VERSION_MINOR@
SUBDIRS = ivlpp vhdlpp vvp vpi tgt-null tgt-stub tgt-vvp \
tgt-vhdl tgt-vlog95 tgt-pcb tgt-blif tgt-sizer driver
@ -132,7 +134,7 @@ O = main.o async.o design_dump.o discipline.o dup_expr.o elaborate.o \
PGate.o PGenerate.o PModport.o PNamedItem.o PPackage.o PScope.o PSpec.o PTimingCheck.o \
PTask.o PUdp.o PWire.o Statement.o AStatement.o $M $(FF) $(TT)
all: dep config.h _pli_types.h version_tag.h ivl@EXEEXT@ version.exe iverilog-vpi.man
all: dep config.h _pli_types.h version_tag.h version_base.h ivl@EXEEXT@ iverilog-vpi.man
$(foreach dir,$(SUBDIRS),$(MAKE) -C $(dir) $@ && ) true
# In the windows world, the installer will need a dosify program to
@ -167,11 +169,10 @@ clean:
$(foreach dir,$(SUBDIRS),$(MAKE) -C $(dir) $@ && ) true
rm -f *.o parse.cc parse.h lexor.cc
rm -f ivl.exp iverilog-vpi.man iverilog-vpi.pdf iverilog-vpi.ps
rm -f iverilog_man.ps iverilog_man.pdf iverilog_man_`./version.exe %M_%n`.pdf
rm -f iverilog_man.ps iverilog_man.pdf iverilog_man_$(VERSION_MAJOR)_$(VERSION_MINOR).pdf
rm -f parse.output syn-rules.output dosify$(BUILDEXT) ivl@EXEEXT@ check.vvp
rm -f lexor_keyword.cc libivl.a libvpi.a iverilog-vpi syn-rules.cc
rm -f lexor_keyword.cc libivl.a libvpi.a iverilog-vpi syn-rules.cc version_base.h
rm -rf dep
rm -f version.exe
distclean: clean
$(foreach dir,$(SUBDIRS),$(MAKE) -C $(dir) $@ && ) true
@ -251,8 +252,8 @@ iverilog-vpi: $(srcdir)/iverilog-vpi.sh Makefile
chmod +x $@
endif
version.exe: $(srcdir)/version.c $(srcdir)/version_base.h version_tag.h
$(BUILDCC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o version.exe -I. -I$(srcdir) $(srcdir)/version.c
version_base.h: $(srcdir)/version_base.h.in config.status
./config.status --file=$@
%.o: %.cc config.h | dep
$(CXX) $(CPPFLAGS) $(CXXFLAGS) @DEPENDENCY_FLAG@ -c $< -o $*.o
@ -280,9 +281,8 @@ lexor_keyword.o: lexor_keyword.cc parse.h
lexor_keyword.cc: $(srcdir)/lexor_keyword.gperf
gperf -o -i 7 -C -k 1-4,6,9,$$ -H keyword_hash -N check_identifier -t $< > $@ || (rm -f $@ ; false)
iverilog-vpi.man: $(srcdir)/iverilog-vpi.man.in version.exe
./version.exe `head -1 $<`'\n' > $@
tail -n +2 $< >> $@
iverilog-vpi.man: $(srcdir)/iverilog-vpi.man.in config.status
./config.status --file=$@
iverilog-vpi.ps: iverilog-vpi.man
$(MAN) -t ./$< > $@
@ -293,9 +293,9 @@ iverilog-vpi.pdf: iverilog-vpi.ps
iverilog_man.ps: driver/iverilog.man vvp/vvp.man iverilog-vpi.man
$(GROFF) -man -rC1 -rD1 -T ps $^ > $@
iverilog_man.pdf: iverilog_man.ps version.exe
iverilog_man.pdf: iverilog_man.ps
$(PS2PDF) $< $@
cp $@ iverilog_man_`./version.exe %M_%n`.pdf
cp $@ iverilog-vpi.man_$(VERSION_MAJOR)_$(VERSION_MINOR).pdf
# For VERSION_TAG in driver/main.c, first try git-describe, then look for a
# release_tag.h file in the source tree (included in snapshots and releases),

View File

@ -1,7 +1,20 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT
AC_CONFIG_MACRO_DIRS([m4])
dnl Define project version
m4_define([VER_MAJOR], [14])
m4_define([VER_MINOR], [0])
m4_define([VER_EXTRA], [devel])
AC_INIT([iverilog], [VER_MAJOR.VER_MINOR (VER_EXTRA)])
AC_SUBST([VERSION_MAJOR], [VER_MAJOR])
AC_SUBST([VERSION_MINOR], [VER_MINOR])
AC_SUBST([VERSION_EXTRA], [" (VER_EXTRA)"])
AC_SUBST([VERSION], ["VER_MAJOR.VER_MINOR (VER_EXTRA)"])
# used in res.rc
AC_SUBST([PRODUCTVERSION], ["VER_MAJOR,VER_MINOR,0,0"])
AC_CONFIG_SRCDIR([netlist.h])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_HEADERS([_pli_types.h])
@ -390,5 +403,31 @@ then
AC_MSG_ERROR(cannot configure white space in libdir: $libdir)
fi
AC_MSG_RESULT(ok)
AC_CONFIG_FILES([Makefile ivlpp/Makefile vhdlpp/Makefile vvp/Makefile vpi/Makefile driver/Makefile driver-vpi/Makefile cadpli/Makefile libveriuser/Makefile tgt-null/Makefile tgt-stub/Makefile tgt-vvp/Makefile tgt-vhdl/Makefile tgt-fpga/Makefile tgt-verilog/Makefile tgt-pal/Makefile tgt-vlog95/Makefile tgt-pcb/Makefile tgt-blif/Makefile tgt-sizer/Makefile])
AC_CONFIG_FILES([
Makefile
cadpli/Makefile
driver-vpi/Makefile
driver-vpi/res.rc
driver/Makefile
driver/iverilog.man
iverilog-vpi.man
ivlpp/Makefile
libveriuser/Makefile
tgt-blif/Makefile
tgt-fpga/Makefile
tgt-null/Makefile
tgt-pal/Makefile
tgt-pcb/Makefile
tgt-sizer/Makefile
tgt-stub/Makefile
tgt-verilog/Makefile
tgt-vhdl/Makefile
tgt-vlog95/Makefile
tgt-vvp/Makefile
version_base.h
vhdlpp/Makefile
vpi/Makefile
vvp/Makefile
vvp/vvp.man
])
AC_OUTPUT

View File

@ -95,9 +95,8 @@ else
endif
# Windows specific...
res.rc: $(srcdir)/res.rc.in ../version.exe
sed -e 's;@PRODUCTVERSION@;'`../version.exe '%M,%n,0,0'`';' \
$(srcdir)/res.rc.in > $@
res.rc: $(srcdir)/res.rc.in ../config.status
cd ..; ./config.status --file=driver-vpi/$@
res.o: res.rc
$(WINDRES) -i res.rc -o res.o

View File

@ -96,15 +96,14 @@ cfparse%c cfparse%h: $(srcdir)/cfparse%y
$(CC) $(CPPFLAGS) $(CFLAGS) @DEPENDENCY_FLAG@ -c $< -o $*.o
mv $*.d dep
main.o: main.c globals.h $(srcdir)/../version_base.h ../version_tag.h Makefile | dep
main.o: main.c globals.h ../version_base.h ../version_tag.h Makefile | dep
$(CC) $(CPPFLAGS) $(CFLAGS) @DEPENDENCY_FLAG@ -c -DIVL_ROOT='"@libdir@/ivl$(suffix)"' -DIVL_SUFFIX='"$(suffix)"' -DIVL_INC='"@includedir@"' -DIVL_LIB='"@libdir@"' -DDLLIB='"@DLLIB@"' -DIVL_INCLUDE_INSTALL_DIR="\"$(realpath $(DESTDIR)/$(includedir))\"" $(srcdir)/main.c
mv $*.d dep
cflexor.o: cflexor.c cfparse.h
iverilog.man: $(srcdir)/iverilog.man.in ../version.exe
../version.exe `head -1 $<`'\n' > $@
tail -n +2 $< >> $@
iverilog.man: $(srcdir)/iverilog.man.in ../config.status
cd ..; ./config.status --file=driver/$@
iverilog.ps: iverilog.man
$(MAN) -t ./$< > $@

View File

@ -1,4 +1,4 @@
.TH iverilog 1 "Jan 13th, 2026" "" "Version %M.%n%E"
.TH iverilog 1 "Jan 13th, 2026" "" "Version @VERSION@"
.SH NAME
iverilog - Icarus Verilog compiler

View File

@ -1,4 +1,4 @@
.TH iverilog-vpi 1 "Jan 13th, 2026" "" "Version %M.%n%E"
.TH iverilog-vpi 1 "Jan 13th, 2026" "" "Version @VERSION@"
.SH NAME
iverilog-vpi - Compile front end for VPI modules

View File

@ -89,4 +89,4 @@ uninstall:
rm -f "$(DESTDIR)$(libdir)/ivl$(suffix)/ivlpp@EXEEXT@"
lexor.o: lexor.c globals.h
main.o: main.c globals.h $(srcdir)/../version_base.h ../version_tag.h
main.o: main.c globals.h ../version_base.h ../version_tag.h

View File

@ -5,10 +5,10 @@
#
# 1. It creates a new branch with the proper name.
#
# 2. It then updates the version_base.h to match this version. It likely
# 2. It then updates the configure.ac to match this version. It likely
# already does, but it is incorrectly marked as devel instead of stable.
#
# 3. It updates the default suffix in aclocal.m4 to match the branch.
# 3. It updates the default suffix in m4/ax_enable_suffix.m4 to match the branch.
#
# Now manually push the new branch to the master repository.
#
@ -27,7 +27,8 @@ case $1 in
esac
major=$1
minor=0
extra="stable"
branch="v${major}-branch"
branch_exists=`git ls-remote --heads origin $branch`
@ -39,16 +40,17 @@ fi
echo "Creating branch $branch"
git checkout -b $branch
echo "Updating version_base.h..."
sed -i -E "s/(define\s+VERSION_MAJOR\s+).*/\1$major/" version_base.h
sed -i -E "s/(define\s+VERSION_MINOR\s+).*/\10/" version_base.h
sed -i -E "s/(define\s+VERSION_EXTRA\s+).*/\1\" \(stable\)\"/" version_base.h
file=configure.ac
echo "Updating $file..."
sed -i -E "s/(m4_define\(\[VER_MAJOR\],[[:space:]]*\[)[^]]*(\]\))/\1$major\2/" $file
sed -i -E "s/(m4_define\(\[VER_MINOR\],[[:space:]]*\[)[^]]*(\]\))/\1$minor\2/" $file
sed -i -E "s/(m4_define\(\[VER_EXTRA\],[[:space:]]*\[)[^]]*(\]\))/\1$extra\2/" $file
echo "Updating aclocal.m4..."
sed -i -E "s/(install_suffix='-)dev/\1$major/" aclocal.m4
echo "Updating m4/ax_enable_suffix.m4..."
sed -i -E "s/(install_suffix='-)dev/\1$major/" m4/ax_enable_suffix.m4
echo "Adding updated files to the new branch..."
git add version_base.h aclocal.m4
git add configure.ac m4/ax_enable_suffix.m4
git commit -m "Creating new branch $branch"
echo "Done"

View File

@ -4,10 +4,10 @@
# based on the first and second argument passed to the script, which should
# be the desired major and minor numbers for the release. Before creating the
# tag, autoconf.sh will be run to create the configure and lexor_keyword.cc
# files, the version_base.h and verilog.spec files will be updated to reflect
# the new release ID and a release_tag.h file will be created in the top level
# directory to provide the VERSION_TAG macro. After creating the tag, the
# configure, lexor_keywords.cc, and release_tag.h files will be deleted.
# files, the verilog.spec file will be updated to reflect the new release ID
# and a release_tag.h file will be created in the top level directory to
# provide the VERSION_TAG macro. After creating the tag, the configure,
# lexor_keywords.cc, and release_tag.h files will be deleted.
#
# The complete steps to publish a release are:
#
@ -44,6 +44,13 @@ if [ -n "$tag_exists" ] ; then
exit 1
fi
extra="stable"
file=configure.ac
echo "Updating $file..."
sed -i -E "s/(m4_define\(\[VER_MAJOR\],[[:space:]]*\[)[^]]*(\]\))/\1$major\2/" $file
sed -i -E "s/(m4_define\(\[VER_MINOR\],[[:space:]]*\[)[^]]*(\]\))/\1$minor\2/" $file
sed -i -E "s/(m4_define\(\[VER_EXTRA\],[[:space:]]*\[)[^]]*(\]\))/\1$extra\2/" $file
echo "Executing autoconf.sh..."
sh autoconf.sh
if [ $? -ne 0 ] ; then
@ -51,11 +58,6 @@ if [ $? -ne 0 ] ; then
exit 1
fi
echo "Updating version_base.h..."
sed -i -E "s/(define\s+VERSION_MAJOR\s+).*/\1$major/" version_base.h
sed -i -E "s/(define\s+VERSION_MINOR\s+).*/\1$minor/" version_base.h
sed -i -E "s/(define\s+VERSION_EXTRA\s+).*/\1\" \(stable\)\"/" version_base.h
echo "Updating verilog.spec..."
sed -i -E "s/(define\s+major\s+).*/\1$major/" verilog.spec
sed -i -E "s/(define\s+minor\s+).*/\1$minor/" verilog.spec
@ -66,7 +68,7 @@ echo "#define VERSION_TAG \"$tag\"" > release_tag.h
echo "Adding files and creating the tag..."
git add -f configure lexor_keyword.cc vhdlpp/lexor_keyword.cc
git add version_base.h verilog.spec release_tag.h
git add configure.ac verilog.spec release_tag.h
git commit -m "Creating release $tag"
git tag -a -m "Release $major.$minor" $tag

View File

@ -1,6 +1,6 @@
#!/bin/sh
# This script manually creates a version.h file.
# This script manually creates a version_tag.h file.
#
# It is used when creating a MinGW executable from a Cygwin
# hosted git repository. It assumes that git is available.

View File

@ -1,85 +0,0 @@
/*
* Copyright (c) 2009-2015 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "version_base.h"
# include "version_tag.h"
# include <stdio.h>
# include <string.h>
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, "%d", VERSION_MAJOR);
break;
case 'n':
fprintf(stdout, "%d", 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;
}

View File

@ -1,16 +1,17 @@
#ifndef VERSION
/*
* Edit this definition in version_base.in to define the base version
* number for the compiled result.
* This file is generated from version_base.h.in by the build system
*
* WARNING! All changes made in this file will be lost when recompiling!
*/
# define VERSION_MAJOR 14
# define VERSION_MINOR 0
#define VERSION_MAJOR @VERSION_MAJOR@
#define VERSION_MINOR @VERSION_MINOR@
/*
* This will be appended to the version. Use this to mark development
* versions and the like.
*/
# define VERSION_EXTRA " (devel)"
# define VERSION_EXTRA "@VERSION_EXTRA@"
# define VERSION_STRINGIFY(x) #x
# define VERSION_STR(a,b,extra) VERSION_STRINGIFY(a.b) extra

View File

@ -186,9 +186,8 @@ parse%cc parse%h: $(srcdir)/parse%y
lexor.cc: $(srcdir)/lexor.lex
$(LEX) -s -o$@ $<
vvp.man: $(srcdir)/vvp.man.in ../version.exe
../version.exe `head -1 $<`'\n' > $@
tail -n +2 $< >> $@
vvp.man: $(srcdir)/vvp.man.in ../config.status
cd ..; ./config.status --file=vvp/$@
vvp.ps: vvp.man
$(MAN) -t ./$< > $@

View File

@ -1,4 +1,4 @@
.TH vvp 1 "Jan 13th, 2026" "" "Version %M.%n %E"
.TH vvp 1 "Jan 13th, 2026" "" "Version @VERSION@"
.SH NAME
vvp - Icarus Verilog vvp runtime engine