summaryrefslogtreecommitdiff
path: root/yacc
diff options
context:
space:
mode:
authorDamien Doligez <damien.doligez-inria.fr>2004-11-27 01:04:19 +0000
committerDamien Doligez <damien.doligez-inria.fr>2004-11-27 01:04:19 +0000
commit39f06c597a614b9cf8f6ff6ff677cced1d76dae5 (patch)
treeef817743a4874950a27fdee443855ac41097856a /yacc
parenta66d963bf79c980bd081eed7c4aee637a58d1413 (diff)
downloadocaml-39f06c597a614b9cf8f6ff6ff677cced1d76dae5.tar.gz
PR#3085 ajout option "-version"
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@6701 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'yacc')
-rw-r--r--yacc/.cvsignore1
-rw-r--r--yacc/Makefile9
-rw-r--r--yacc/main.c10
3 files changed, 17 insertions, 3 deletions
diff --git a/yacc/.cvsignore b/yacc/.cvsignore
index c27ac6f3cb..535d61a9dc 100644
--- a/yacc/.cvsignore
+++ b/yacc/.cvsignore
@@ -1,3 +1,4 @@
ocamlyacc
*.c.x
ocamlyacc.xcoff
+version.h
diff --git a/yacc/Makefile b/yacc/Makefile
index d1431d31f7..e831d5b137 100644
--- a/yacc/Makefile
+++ b/yacc/Makefile
@@ -27,8 +27,13 @@ all: ocamlyacc$(EXE)
ocamlyacc$(EXE): $(OBJS)
$(CC) $(CFLAGS) $(CCLINKFLAGS) -o ocamlyacc $(OBJS)
+version.h : ../stdlib/sys.ml
+ sed -n -e 's/;;//' \
+ -e '/let *ocaml_version *= */s//#define OCAML_VERSION /p' \
+ <../stdlib/sys.ml >version.h
+
clean:
- rm -f *.o ocamlyacc$(EXE) *~
+ rm -f *.o ocamlyacc$(EXE) *~ version.h
depend:
@@ -36,7 +41,7 @@ closure.o: defs.h
error.o: defs.h
lalr.o: defs.h
lr0.o: defs.h
-main.o: defs.h
+main.o: defs.h version.h
mkpar.o: defs.h
output.o: defs.h
reader.o: defs.h
diff --git a/yacc/main.c b/yacc/main.c
index 978aac0e0c..41e1cb7bc3 100644
--- a/yacc/main.c
+++ b/yacc/main.c
@@ -21,6 +21,8 @@
#include <unistd.h>
#endif
+#include "version.h"
+
char dflag;
char lflag;
char rflag;
@@ -163,7 +165,13 @@ void getargs(int argc, char **argv)
goto no_more_options;
case 'v':
- vflag = 1;
+ if (!strcmp (argv[i], "-version")){
+ printf ("The Objective Caml parser generator, version "
+ OCAML_VERSION "\n");
+ exit (0);
+ }else{
+ vflag = 1;
+ }
break;
case 'q':