diff --git a/.gitignore b/.gitignore index d2508b8b..97d5faf6 100644 --- a/.gitignore +++ b/.gitignore @@ -41,6 +41,7 @@ y.* initial.c sigmsgs.c token.h +version.h es esdump testrun diff --git a/Makefile.in b/Makefile.in index 92385e95..2daed66b 100644 --- a/Makefile.in +++ b/Makefile.in @@ -66,7 +66,7 @@ OFILES = access.o closure.o conv.o dict.o eval.o except.o fd.o gc.o glob.o \ sigmsgs.o signal.o split.o status.o str.o syntax.o term.o token.o \ tree.o util.o var.o vec.o version.o y.tab.o OTHER = Makefile parse.y mksignal -GEN = esdump y.tab.c y.tab.h y.output token.h sigmsgs.c initial.c +GEN = esdump y.tab.c y.tab.h y.output token.h version.h sigmsgs.c initial.c SIGFILES = @SIGFILES@ @@ -109,6 +109,9 @@ y.tab.c y.tab.h : parse.y token.h : y.tab.h -cmp -s y.tab.h token.h || cp y.tab.h token.h +version.h : mkversion .git/index + sh $(srcdir)/mkversion > version.h + initial.c : esdump $(srcdir)/initial.es ./esdump < $(srcdir)/initial.es > initial.c @@ -140,7 +143,7 @@ open.o : open.c es.h config.h stdenv.h opt.o : opt.c es.h config.h stdenv.h prim.o : prim.c es.h config.h stdenv.h prim.h prim-ctl.o : prim-ctl.c es.h config.h stdenv.h prim.h -prim-etc.o : prim-etc.c es.h config.h stdenv.h prim.h +prim-etc.o : prim-etc.c es.h config.h stdenv.h prim.h version.h prim-io.o : prim-io.c es.h config.h stdenv.h gc.h prim.h prim-sys.o : prim-sys.c es.h config.h stdenv.h prim.h print.o : print.c es.h config.h stdenv.h print.h @@ -156,4 +159,4 @@ tree.o : tree.c es.h config.h stdenv.h gc.h util.o : util.c es.h config.h stdenv.h var.o : var.c es.h config.h stdenv.h gc.h var.h term.h vec.o : vec.c es.h config.h stdenv.h gc.h -version.o : version.c es.h config.h stdenv.h +version.o : version.c es.h config.h stdenv.h version.h diff --git a/es.h b/es.h index 472e88ee..fed97473 100644 --- a/es.h +++ b/es.h @@ -373,7 +373,7 @@ extern int opentty(void); /* version.c */ -extern const char * const version; +extern const List * const version; /* gc.c -- see gc.h for more */ diff --git a/initial.es b/initial.es index 452c18d3..4e89bec2 100644 --- a/initial.es +++ b/initial.es @@ -767,4 +767,5 @@ noexport = noexport pid signals apid bqstatus fn-%dispatch path home matchexpr # is printed in the header comment in initial.c; nobody really # wants to look at initial.c anyway. -result es initial state built in `/bin/pwd on `/bin/date for <=$&version +let ((version date) = <=$&version) + result es initial state generated from version $version from $date diff --git a/mkversion b/mkversion new file mode 100755 index 00000000..b72becba --- /dev/null +++ b/mkversion @@ -0,0 +1,7 @@ +#!/bin/sh + +v=$(git describe --tags 2>/dev/null) +d=$(git show --no-patch --format=%ci | cut -f1 -d' ') + +echo "#define VERSION \"$v\"" +echo "#define VERSION_DATE \"$d\"" diff --git a/prim-etc.c b/prim-etc.c index 95ea607d..c8c2e360 100644 --- a/prim-etc.c +++ b/prim-etc.c @@ -4,6 +4,7 @@ #include "es.h" #include "prim.h" +#include "version.h" PRIM(result) { return list; @@ -33,7 +34,7 @@ PRIM(setnoexport) { } PRIM(version) { - return mklist(mkstr((char *) version), NULL); + return (List *)version; } PRIM(exec) { diff --git a/version.c b/version.c index 2c16f0e4..f8c19e6b 100644 --- a/version.c +++ b/version.c @@ -1,3 +1,10 @@ #include "es.h" -static const char id[] = "@(#)es version 0.9.2 2-Mar-2022"; -const char * const version = id + (sizeof "@(#)" - 1); +#include "term.h" +#include "version.h" + +static const Term + version_date_term = { VERSION_DATE, NULL }, + version_term = { VERSION, NULL }; +static const List vdl = { (Term *) &version_date_term, NULL }; +static const List versionstruct = { (Term *) &version_term, (List *)&vdl }; +const List * const version = &versionstruct;