From d24be2bf64f06d08ec09e97743fda4b3d118ec80 Mon Sep 17 00:00:00 2001 From: Stefano Zacchiroli Date: Fri, 4 Nov 2005 09:34:24 +0000 Subject: [PATCH] "towards a distribution of matita" changes: - @USER_HOME@, @USER_NAME@ no longer hard coded at configure time - added support for tilde expansion in configuration file - added support for runtime overriding of RT_BASE_DIR - better configure.ac, can now configure RT_BASE_DIR, debugging, and distribution defaults --- helm/matita/buildTimeConf.ml.in | 11 ++++++--- helm/matita/configure.ac | 33 +++++++++++++++++++-------- helm/matita/matita.conf.xml.sample.in | 13 +++++++---- helm/matita/matita.ml | 7 +++--- helm/matita/matitaInit.ml | 11 +++++++++ helm/matita/matitamake.ml | 2 +- 6 files changed, 56 insertions(+), 21 deletions(-) diff --git a/helm/matita/buildTimeConf.ml.in b/helm/matita/buildTimeConf.ml.in index 85418121f..abb1aff4e 100644 --- a/helm/matita/buildTimeConf.ml.in +++ b/helm/matita/buildTimeConf.ml.in @@ -24,7 +24,7 @@ *) let debug = @DEBUG@;; -let version = "0.0.1";; +let version = "@MATITA_VERSION";; let undo_history_size = 10;; let console_history_size = 100;; let browser_history_size = 100;; @@ -34,7 +34,13 @@ let blank_uri = "about:blank";; let current_proof_uri = "about:current_proof";; let default_font_size = 10;; let script_font = "Monospace";; -let runtime_base_dir = "@RT_BASE_DIR@";; + + (** may be overridden with MATITA_RT_BASE_DIR environment variable, useful for + * binary distribution installed in user home directories *) +let runtime_base_dir = + try + Sys.getenv "MATITA_RT_BASE_DIR" + with Not_found -> "@RT_BASE_DIR@";; let images_dir = runtime_base_dir ^ "/icons" let gtkrc_file = runtime_base_dir ^ "/matita.gtkrc" @@ -45,6 +51,5 @@ let coq_notation_script = runtime_base_dir ^ "/coq.moo" let matita_conf = runtime_base_dir ^ "/matita.conf.xml" let closed_xml = runtime_base_dir ^ "/closed.xml" let gtkmathview_conf = runtime_base_dir ^ "/gtkmathview.matita.conf.xml" - let matitamake_makefile_template = runtime_base_dir ^ "/template_makefile.in" diff --git a/helm/matita/configure.ac b/helm/matita/configure.ac index 4f8c991d1..d20bf2192 100644 --- a/helm/matita/configure.ac +++ b/helm/matita/configure.ac @@ -1,5 +1,11 @@ AC_INIT(matitaTypes.ml) +# Distribution settings (i.e. settings to be manipulated before a release) +DEBUG_DEFAULT="true" +RT_BASE_DIR_DEFAULT="`pwd`" +MATITA_VERSION="0.0.1" +# End of distribution settings + AC_CHECK_PROG(HAVE_OCAMLC, ocamlc, yes, no) if test $HAVE_OCAMLC = "no"; then AC_MSG_ERROR(could not find ocamlc) @@ -87,21 +93,31 @@ OCAMLFIND_COMMANDS="" if test "$OCAMLFIND_COMMANDS" != ""; then OCAMLFIND="OCAMLFIND_COMMANDS='$OCAMLFIND_COMMANDS' $OCAMLFIND" fi + +AC_MSG_CHECKING(--enable-debug argument) AC_ARG_ENABLE(debug, - [ --enable-debug Turn on debugging], - [case "${enableval}" in + [ --enable-debug Turn on debugging], + [GIVEN="yes"; + case "${enableval}" in yes) DEBUG=true ;; no) DEBUG=false ;; *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;; esac], - [DEBUG=true]) + [GIVEN="no"; DEBUG="$DEBUG_DEFAULT"]) +MSG=$GIVEN if test "$DEBUG" = "true"; then - echo "debugging enabled" + MSG="$MSG, debugging enabled." +else + MSG="$MSG, debugging disabled." fi +AC_MSG_RESULT($MSG) -RT_BASE_DIR=`pwd` -USER_HOME=`pwd` #should be `echo $HOME` -USER_NAME=`echo $USER` +AC_MSG_CHECKING(--with-runtime-dir argument) +AC_ARG_WITH(runtime-dir, + [ --with-runtime-dir Runtime directory (current working directory if not given)], + [ RT_BASE_DIR="${withval}" ], + [ RT_BASE_DIR="$RT_BASE_DIR_DEFAULT" ]) +AC_MSG_RESULT($RT_BASE_DIR) AC_SUBST(CAMLP4O) AC_SUBST(DEBUG) @@ -115,8 +131,7 @@ AC_SUBST(HAVE_OCAMLOPT) AC_SUBST(LABLGLADECC) AC_SUBST(OCAMLFIND) AC_SUBST(RT_BASE_DIR) -AC_SUBST(USER_HOME) -AC_SUBST(USER_NAME) +AC_SUBST(MATITA_VERSION) AC_OUTPUT([ matita.conf.xml.sample diff --git a/helm/matita/matita.conf.xml.sample.in b/helm/matita/matita.conf.xml.sample.in index 0087d604f..b932b7ca9 100644 --- a/helm/matita/matita.conf.xml.sample.in +++ b/helm/matita/matita.conf.xml.sample.in @@ -1,11 +1,16 @@ +
+ ~ + + +
true true cic:/matita/ - @USER_HOME@/.matita - @USER_NAME@ + $(user.home)/.matita + $(user.name) false
@@ -16,7 +21,7 @@ matita
- @USER_HOME@/.matita/getter/cache + $(user.home)/.matita/getter/cache /projects/helm/xml/dtd cic:/ @@ -24,7 +29,7 @@ cic:/matita/ - file://@USER_HOME@/.matita/xml/matita/ + file://$(user.home)/.matita/xml/matita/
diff --git a/helm/matita/matita.ml b/helm/matita/matita.ml index dd8d6d83d..da09fb27d 100644 --- a/helm/matita/matita.ml +++ b/helm/matita/matita.ml @@ -121,10 +121,6 @@ let _ = addDebugItem "print selections" (fun () -> let cicMathView = MatitaMathView.cicMathView_instance () in List.iter MatitaLog.debug (cicMathView#string_of_selections)); - addDebugItem "dump getter settings" (fun _ -> - prerr_endline (Http_getter_env.env_to_string ())); - addDebugItem "getter: getalluris" (fun _ -> - List.iter prerr_endline (Http_getter.getalluris ())); addDebugItem "dump script status" script#dump; addDebugItem "dump configuration file to ./foo.conf.xml" (fun _ -> Helm_registry.save_to "./foo.conf.xml"); @@ -168,6 +164,9 @@ let _ = (fun _ -> let nb = gui#main#hintNotebook in nb#goto_page ((nb#current_page + 1) mod 3)); + addDebugItem "print runtime dir" + (fun _ -> + prerr_endline BuildTimeConf.runtime_base_dir); end (** Debugging }}} *) diff --git a/helm/matita/matitaInit.ml b/helm/matita/matitaInit.ml index 9ea9e07d2..1e9ebe2dd 100644 --- a/helm/matita/matitaInit.ml +++ b/helm/matita/matitaInit.ml @@ -40,10 +40,21 @@ let wants s l = let already_configured s l = List.for_all (fun item -> List.exists (fun x -> x = item) l) s +let tilde_expand_key k = + try + Helm_registry.set k (HExtlib.tilde_expand (Helm_registry.get k)) + with Helm_registry.Key_not_found _ -> () + let load_configuration init_status = if not (already_configured [ConfigurationFile] init_status) then begin Helm_registry.load_from BuildTimeConf.matita_conf; + if not (Helm_registry.has "user.name") then begin + let login = (Unix.getpwuid (Unix.getuid ())).Unix.pw_name in + Helm_registry.set "user.name" login + end; + tilde_expand_key "matita.basedir"; + tilde_expand_key "user.home"; ConfigurationFile::init_status end else diff --git a/helm/matita/matitamake.ml b/helm/matita/matitamake.ml index 46b194bda..96fdbfb28 100644 --- a/helm/matita/matitamake.ml +++ b/helm/matita/matitamake.ml @@ -26,7 +26,7 @@ module MK = MatitamakeLib ;; let main () = - Helm_registry.load_from BuildTimeConf.matita_conf; + MatitaInit.load_configuration_file (); MK.initialize (); let usage = ref (fun () -> ()) in let dev_of_name name = -- 2.39.2