summaryrefslogtreecommitdiff
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
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
-rw-r--r--byterun/.cvsignore1
-rw-r--r--byterun/.depend6
-rw-r--r--byterun/Makefile7
-rw-r--r--byterun/startup.c8
-rw-r--r--camlp4/etc/.cvsignore1
-rw-r--r--camlp4/etc/Makefile10
-rwxr-xr-xcamlp4/etc/mkcamlp4.sh.tpl3
-rw-r--r--debugger/main.ml23
-rw-r--r--otherlibs/labltk/browser/main.ml11
-rw-r--r--tools/ocamldep.ml11
-rw-r--r--tools/ocamlmklib.mlp8
-rw-r--r--toplevel/topmain.ml6
-rw-r--r--yacc/.cvsignore1
-rw-r--r--yacc/Makefile9
-rw-r--r--yacc/main.c10
15 files changed, 93 insertions, 22 deletions
diff --git a/byterun/.cvsignore b/byterun/.cvsignore
index 895cec3f58..90636dc158 100644
--- a/byterun/.cvsignore
+++ b/byterun/.cvsignore
@@ -2,6 +2,7 @@ jumptbl.h
primitives
prims.c
opnames.h
+version.h
ocamlrun
ocamlrund
ld.conf
diff --git a/byterun/.depend b/byterun/.depend
index c9b0e0990e..e5f2e4d986 100644
--- a/byterun/.depend
+++ b/byterun/.depend
@@ -113,7 +113,8 @@ startup.o: startup.c config.h ../config/m.h ../config/s.h compatibility.h \
alloc.h misc.h mlvalues.h backtrace.h callback.h custom.h debugger.h \
dynlink.h exec.h fail.h fix_code.h gc_ctrl.h instrtrace.h interp.h \
intext.h io.h memory.h gc.h major_gc.h freelist.h minor_gc.h osdeps.h \
- prims.h printexc.h reverse.h signals.h stacks.h sys.h startup.h
+ prims.h printexc.h reverse.h signals.h stacks.h sys.h startup.h \
+ version.h
str.o: str.c alloc.h compatibility.h misc.h config.h ../config/m.h \
../config/s.h mlvalues.h fail.h
sys.o: sys.c config.h ../config/m.h ../config/s.h compatibility.h alloc.h \
@@ -247,7 +248,8 @@ startup.d.o: startup.c config.h ../config/m.h ../config/s.h compatibility.h \
alloc.h misc.h mlvalues.h backtrace.h callback.h custom.h debugger.h \
dynlink.h exec.h fail.h fix_code.h gc_ctrl.h instrtrace.h interp.h \
intext.h io.h memory.h gc.h major_gc.h freelist.h minor_gc.h osdeps.h \
- prims.h printexc.h reverse.h signals.h stacks.h sys.h startup.h
+ prims.h printexc.h reverse.h signals.h stacks.h sys.h startup.h \
+ version.h
str.d.o: str.c alloc.h compatibility.h misc.h config.h ../config/m.h \
../config/s.h mlvalues.h fail.h
sys.d.o: sys.c config.h ../config/m.h ../config/s.h compatibility.h alloc.h \
diff --git a/byterun/Makefile b/byterun/Makefile
index f79365cad9..46a6cc64ce 100644
--- a/byterun/Makefile
+++ b/byterun/Makefile
@@ -101,6 +101,11 @@ jumptbl.h : instruct.h
sed -n -e '/^ /s/ \([A-Z]\)/ \&\&lbl_\1/gp' \
-e '/^}/q' instruct.h > jumptbl.h
+version.h : ../stdlib/sys.ml
+ sed -n -e 's/;;//' \
+ -e '/let *ocaml_version *= */s//#define OCAML_VERSION /p' \
+ <../stdlib/sys.ml >version.h
+
.SUFFIXES: .d.o
.c.d.o:
@@ -109,7 +114,7 @@ jumptbl.h : instruct.h
mv $*.o $*.d.o
@ if test -f $*.f.o; then mv $*.f.o $*.o; else :; fi
-depend : prims.c opnames.h jumptbl.h
+depend : prims.c opnames.h jumptbl.h version.h
gcc -MM $(BYTECCCOMPOPTS) *.c > .depend
gcc -MM $(BYTECCCOMPOPTS) -DDEBUG *.c | sed -e 's/\.o/.d.o/' >> .depend
diff --git a/byterun/startup.c b/byterun/startup.c
index d1c8c76b38..58904287e3 100644
--- a/byterun/startup.c
+++ b/byterun/startup.c
@@ -52,6 +52,7 @@
#include "stacks.h"
#include "sys.h"
#include "startup.h"
+#include "version.h"
#ifndef O_BINARY
#define O_BINARY 0
@@ -240,7 +241,12 @@ static int parse_command_line(char **argv)
break;
#endif
case 'v':
- caml_verb_gc = 0x001+0x004+0x008+0x010+0x020;
+ if (!strcmp (argv[i], "-version")){
+ printf ("The Objective Caml runtime, version " OCAML_VERSION "\n");
+ exit (0);
+ }else{
+ caml_verb_gc = 0x001+0x004+0x008+0x010+0x020;
+ }
break;
case 'p':
for (j = 0; caml_names_of_builtin_cprim[j] != NULL; j++)
diff --git a/camlp4/etc/.cvsignore b/camlp4/etc/.cvsignore
index 92c764cac9..50d8a8ea2f 100644
--- a/camlp4/etc/.cvsignore
+++ b/camlp4/etc/.cvsignore
@@ -2,5 +2,6 @@
camlp4o
camlp4sch
camlp4o.opt
+version.sh
mkcamlp4.sh
mkcamlp4.mpw
diff --git a/camlp4/etc/Makefile b/camlp4/etc/Makefile
index 0fd63dc693..a4de75dcf6 100644
--- a/camlp4/etc/Makefile
+++ b/camlp4/etc/Makefile
@@ -41,8 +41,14 @@ camlp4o.opt: $(CAMLP4OMX)
rm -f camlp4o.opt
cd ../camlp4; $(MAKE) optp4 CAMLP4OPT=../etc/camlp4o.opt CAMLP4M="-I ../etc $(CAMLP4OMX)"
-mkcamlp4.sh: mkcamlp4.sh.tpl
- sed -e "s!LIBDIR!$(LIBDIR)!g" mkcamlp4.sh.tpl > mkcamlp4.sh
+mkcamlp4.sh: mkcamlp4.sh.tpl version.sh
+ sed -e "s!LIBDIR!$(LIBDIR)!g" -e "/define VERSION/r version.sh" \
+ mkcamlp4.sh.tpl > mkcamlp4.sh
+
+version.sh : $(OTOP)/stdlib/sys.ml
+ sed -n -e 's/;;//' \
+ -e '/let *ocaml_version *= */s//VERSION=/p' \
+ <$(OTOP)/stdlib/sys.ml >version.sh
bootstrap_l:
../boot/camlp4 ./pa_$Lr.cmo ./q_phony.cmo -I ../boot pa_extend.cmo ./pr_r.cmo ./pr_extend.cmo ./pr_rp.cmo pa_$L.ml > tmp
diff --git a/camlp4/etc/mkcamlp4.sh.tpl b/camlp4/etc/mkcamlp4.sh.tpl
index 50c3ea61a7..995ad5bac3 100755
--- a/camlp4/etc/mkcamlp4.sh.tpl
+++ b/camlp4/etc/mkcamlp4.sh.tpl
@@ -4,12 +4,15 @@
OLIB="`ocamlc -where`"
LIB="LIBDIR/camlp4"
+# automatically define VERSION here:
+
INTERFACES=
OPTS=
INCL="-I ."
while test "" != "$1"; do
case "$1" in
-I) INCL="$INCL -I $2"; shift;;
+ -version) echo "mkcamlp4, version $VERSION"; exit;;
*)
j=`basename "$1" .cmi`
if test "$j.cmi" = "$1"; then
diff --git a/debugger/main.ml b/debugger/main.ml
index 1232c95494..76426c6ec6 100644
--- a/debugger/main.ml
+++ b/debugger/main.ml
@@ -89,20 +89,25 @@ let set_checkpoints n =
checkpoint_max_count := n
let set_directory dir =
Sys.chdir dir
-let set_emacs () =
- emacs := true
+let print_version () =
+ printf "The Objective Caml debugger, version %s@." Sys.ocaml_version;
+ exit 0;
+;;
-let speclist =
- ["-I", Arg.String add_include,
- "<dir> Add <dir> to the list of include directories";
- "-s", Arg.String set_socket,
- "<filename> Set the name of the communication socket";
+let speclist = [
"-c", Arg.Int set_checkpoints,
"<count> Set max number of checkpoints kept";
"-cd", Arg.String set_directory,
"<dir> Change working directory";
- "-emacs", Arg.Unit set_emacs,
- "For running the debugger under emacs"]
+ "-emacs", Arg.Set emacs,
+ "For running the debugger under emacs";
+ "-I", Arg.String add_include,
+ "<dir> Add <dir> to the list of include directories";
+ "-s", Arg.String set_socket,
+ "<filename> Set the name of the communication socket";
+ "-version", Arg.Unit print_version,
+ " Print version and exit";
+ ]
let main () =
try
diff --git a/otherlibs/labltk/browser/main.ml b/otherlibs/labltk/browser/main.ml
index 2ff17a5519..2bc122fe92 100644
--- a/otherlibs/labltk/browser/main.ml
+++ b/otherlibs/labltk/browser/main.ml
@@ -32,7 +32,7 @@ let rec get_incr key = function
[] -> raise Not_found
| (k, c, d) :: rem ->
if k = key then
- match c with Arg.Set _ | Arg.Clear _ -> false | _ -> true
+ match c with Arg.Set _ | Arg.Clear _ | Arg.Unit _ -> false | _ -> true
else get_incr key rem
let check ~spec argv =
@@ -48,6 +48,11 @@ let check ~spec argv =
open Printf
+let print_version () =
+ printf "The Objective Caml browser, version %s\n" Sys.ocaml_version;
+ exit 0;
+;;
+
let usage ~spec errmsg =
let b = Buffer.create 1024 in
bprintf b "%s\n" errmsg;
@@ -68,11 +73,13 @@ let _ =
"-labels", Arg.Clear Clflags.classic, " <obsolete>";
"-nolabels", Arg.Set Clflags.classic,
" Ignore non-optional labels in types";
+ "-oldui", Arg.Clear st, " Revert back to old UI";
"-pp", Arg.String (fun s -> Clflags.preprocessor := Some s),
"<command> Pipe sources through preprocessor <command>";
"-rectypes", Arg.Set Clflags.recursive_types,
" Allow arbitrary recursive types";
- "-oldui", Arg.Clear st, " Revert back to old UI";
+ "-version", Arg.Unit print_version,
+ " Print version and exit";
"-w", Arg.String (fun s -> Shell.warnings := s),
"<flags> Enable or disable warnings according to <flags>:\n\
\032 A/a enable/disable all warnings\n\
diff --git a/tools/ocamldep.ml b/tools/ocamldep.ml
index f0084732dd..2d98da141c 100644
--- a/tools/ocamldep.ml
+++ b/tools/ocamldep.ml
@@ -207,6 +207,11 @@ let file_dependencies source_file =
let usage = "Usage: ocamldep [-I <dir>] [-native] <files>"
+let print_version () =
+ printf "ocamldep, version %s@." Sys.ocaml_version;
+ exit 0;
+;;
+
let _ =
Clflags.classic := false;
add_to_load_path Filename.current_dir_name;
@@ -216,9 +221,11 @@ let _ =
"-native", Arg.Set native_only,
" Generate dependencies for a pure native-code project \
(no .cmo files)";
+ "-pp", Arg.String(fun s -> preprocessor := Some s),
+ "<command> Pipe sources through preprocessor <command>";
"-slash", Arg.Set force_slash,
" (for Windows) Use forward slash / instead of backslash \\ in file paths";
- "-pp", Arg.String(fun s -> preprocessor := Some s),
- "<command> Pipe sources through preprocessor <command>"
+ "-version", Arg.Unit print_version,
+ " Print version and exit";
] file_dependencies usage;
exit (if !error_occurred then 2 else 0)
diff --git a/tools/ocamlmklib.mlp b/tools/ocamlmklib.mlp
index 352f1da3e2..5a613eefe5 100644
--- a/tools/ocamlmklib.mlp
+++ b/tools/ocamlmklib.mlp
@@ -49,6 +49,11 @@ let chop_suffix = Filename.chop_suffix
exception Bad_argument of string
+let print_version () =
+ printf "ocamlmklib, version %s\n" Sys.ocaml_version;
+ exit 0;
+;;
+
let parse_arguments argv =
let i = ref 1 in
let next_arg () =
@@ -111,6 +116,8 @@ let parse_arguments argv =
rpath := chop_prefix s "-Wl,-R" :: !rpath
else if s = "-v" || s = "-verbose" then
verbose := true
+ else if s = "-version" then
+ print_version ()
else if starts_with s "-F" then
c_opts := s :: !c_opts
else if s = "-framework" then
@@ -152,6 +159,7 @@ Options are:
-Wl,-R<dir> Same as -dllpath <dir>
-F<dir> Specify a framework directory (MacOSX)
-framework <name> Use framework <name> (MacOSX)
+ -version Print version and exit
"
let command cmd =
diff --git a/toplevel/topmain.ml b/toplevel/topmain.ml
index 981b5cb83f..2e39c2b151 100644
--- a/toplevel/topmain.ml
+++ b/toplevel/topmain.ml
@@ -45,6 +45,11 @@ let file_argument name =
else exit 2
end
+let print_version () =
+ Printf.printf "The Objective Caml toplevel, version %s\n" Sys.ocaml_version;
+ exit 0;
+;;
+
let main () =
Arg.parse [
"-I", Arg.String(fun dir ->
@@ -60,6 +65,7 @@ let main () =
"-principal", Arg.Set principal, " Check principality of type inference";
"-rectypes", Arg.Set recursive_types, " Allow arbitrary recursive types";
"-unsafe", Arg.Set fast, " No bound checking on array and string access";
+ "-version", Arg.Unit print_version, " Print version and exit";
"-w", Arg.String (Warnings.parse_options false),
"<flags> Enable or disable warnings according to <flags>:\n\
\032 A/a enable/disable all warnings\n\
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':