Permalink
Browse files

Add the os string in the main configuration file.

So 'opam config -var os' now returns the detected OS kind.
  • Loading branch information...
1 parent 0e5feaa commit 59a5c0781e7fffa4940148601dbf45c3c0ae04c2 @samoht samoht committed Sep 20, 2012
Showing with 15 additions and 3 deletions.
  1. +1 −0 src/client.ml
  2. +14 −3 src/globals.ml.in
View
@@ -298,6 +298,7 @@ let install_conf_ocaml_config t =
("user" , try (Unix.getpwuid (Unix.getuid ())).Unix.pw_name with _ -> "user");
("group", try (Unix.getgrgid (Unix.getgid ())).Unix.gr_name with _ -> "group");
("make" , !Globals.makecmd);
+ ("os" , Globals.os_string);
] in
let config = File.Dot_config.create vars in
View
@@ -63,7 +63,7 @@ let warning fmt =
) fmt
exception Exit of int
-
+
let error_and_exit fmt =
Printf.ksprintf (fun str ->
error "%s" str;
@@ -77,14 +77,15 @@ let msg fmt =
Printf.printf "%s%!" str
) fmt
-type os =
+type os =
| Darwin
| Linux
| FreeBSD
| OpenBSD
| Cygwin
| Win32
| Unix
+ | Other of string
let os = match Sys.os_type with
| "Unix" -> begin
@@ -97,7 +98,17 @@ let os = match Sys.os_type with
end
| "Win32" -> Win32
| "Cygwin" -> Cygwin
- | _ -> assert false
+ | s -> Other s
+
+let os_string = match os with
+ | Darwin -> "darwin"
+ | Linux -> "linux"
+ | FreeBSD
+ | OpenBSD -> "bsd"
+ | Cygwin -> "cygwin"
+ | Win32 -> "win32"
+ | Unix -> "unix"
+ | Other x -> x
let makecmd = ref (match os with FreeBSD | OpenBSD -> "gmake" | _ -> "make") (* WARNING check the result of "which gmake", "which make", ... *)

0 comments on commit 59a5c07

Please sign in to comment.