Markus Mottl avatar Markus Mottl committed 8b85cc4

Improved build scripts for Windows

Comments (0)

Files changed (4)

+2007-07-12:  Improved build scripts for Windows.
+
+             Thanks to Christophe Troestler
+             <Christophe.Troestler@umh.ac.be> for the patch!
+
 2007-07-12:  Improved documentation for Win32 builds, and added some build
              scripts usable on Windows.
 
 2. Go to <http://www.pcre.org/>, download the latest pcre tarball
    (tested with 7.2), and unpack it (say in pcre-7.2).
 
-3. Copy the file make_pcre.ml (in directory pcre_make.win32) to pcre-7.2,
-   and set "lib" to the path where C include files are installed.
-   Then execute:
+3. Possibly modify make_pcre.ml (in directory pcre_make.win32) to set
+   the paths to your will.  The default is to install in the pcre/
+   subdirectory of the default OCaml library location and should be
+   fine for most cases.  (The C pcre library is small, you should not
+   worry about having multiple copies on your system.)
+
+4. Copy the file make_pcre.ml to pcre-7.2 and execute:
 
      ocaml make_pcre.ml
      make
 
    This will compile and install pcre.
 
-4. Go to the lib/ subdirectory of the directory where you unpacked
-   pcre-ocaml and type:
+5. Copy make_pcre.ml (yes the same as above!) to the lib/ subdirectory
+   of the directory where you unpacked pcre-ocaml, go into lib/ and
+   type:
 
      ocaml make_pcre.ml
      make
 
    This will compile and install pcre-ocaml.
 
-5. Optionally, go to the any example directory and type
+6. Optionally, go to the any example directory and type
 
      make
 
-   to compile them.
+   to compile the example there.
 
 Enjoy!
 
 Christophe Troestler and Markus Mottl
 
 July 12, 2007
+
-release-5-12-1
+release-5-12-2

pcre_make.win32/make_pcre.ml

 (* File: make_pcre.ml
+   Time-stamp: <2007-07-17 20:41:18 trch>
    Copyright (C) 2007, Christophe Troestler
 *)
 
+
 (** Run "ocaml make_pcre.ml" in the pcre source directory in order to
-    make a .bat file for compiling and installing pcre.
+    create a make.bat file for compiling and installing pcre.  Then do
+    the same in the lib/ directory of this ocaml-pcre tarball.
 
     To run the .bat file, you need MSVC and the MS SDK to installed
     and in your path.  For that, follow the instructions in the
 
 (* Whether to compile the C-pcre lib or the pcre-ocaml lib *)
 let make =
-  if Sys.file_exists "pcre.h.generic" || Sys.file_exists "pcre.h" then `Pcre
-  else `OCaml
+  if (Sys.file_exists "pcre.h.generic" || Sys.file_exists "pcre.h")
+    && (Sys.file_exists "config.h.generic" || Sys.file_exists "config.h")
+  then `Pcre
+  else if Sys.file_exists "pcre.ml" then `OCaml
+  else (
+    eprintf "\n**ERROR**: You must run this script in the C pcre \
+	source or in the lib\\\n           directory of ocaml-pcre.\n";
+    exit 1
+  )
+
 
 (**************************************************************************)
 
 let install fh files dir =
   let dir = Filename.quote dir in
   fprintf fh "mkdir %s \t>NUL\n" dir;
-  List.iter (fun f -> fprintf fh "copy \"%s\" %s\t>NUL\n" f dir) files
+  List.iter (fun f -> fprintf fh "copy \"%s\" %s\n" f dir) files
 
 let make_bat ?(fname="make.bat") body =
   let fh = open_out fname in
       let re = Str.regexp "^pcre_.*\\.c$" in
       let dir = Array.to_list(Sys.readdir ".") in
       let sources = List.filter (fun f -> Str.string_match re f 0) dir in
-      List.map (fun f -> Filename.chop_extension f) sources
+      let sources = List.map (fun f -> Filename.chop_extension f) sources in
+      (* "pcre_chartables" will only be created when make.bat is run *)
+      "pcre_chartables" :: sources
     in
     make_bat begin fun fh ->
+      (* Create pcre_chartables.c *)
       output_string fh "\n@REM Make chartables\n";
       fprintf fh "cl /nologo /DSUPPORT_UTF8 /DSUPPORT_UCP \
 	/D_CRT_SECURE_NO_DEPRECATE /I . dftables.c\n";
       let inc =
         sprintf "/I \"%s\" /I %s" install_h (Filename.quote ocamllib) in
       let pcre_lib = Filename.concat install_lib pcre_lib in
-      let pcre_dll = Filename.concat install_dll pcre_dll in
+(*       let pcre_dll = Filename.concat install_dll pcre_dll in *)
 
       cc_static fh ~ext:".s.obj" "pcre_stubs" ~flags:inc;
       mklib fh "libpcre_stubs.lib" ["pcre_stubs.s.obj"];
 (*         ["pcre_stubs.d.obj"; Filename.concat ocamllib "ocamlrun.lib"; *)
 (*          pcre_dll]; *)
 
-      let caml_sources = "pcre.ml pcre.mli" in
+      let caml_sources = "pcre.ml" in
       let pcre_lib = Filename.quote(Filename.quote pcre_lib) in
+      fprintf fh "ocamlc -c pcre.mli\n";
       fprintf fh "ocamlc -custom -a -o pcre.cma %s -ccopt %s \
 	-cclib -lpcre_stubs\n" caml_sources pcre_lib;
       fprintf fh "ocamlopt -a -o pcre.cmxa %s -ccopt %s \
       install fh ["libpcre_stubs.lib";
                   "pcre.mli"; "pcre.cmi"; "pcre.cma"; "pcre.cmxa"; "pcre.lib"]
         (Filename.concat ocamllib "pcre");
-      install fh ["dllpcre_stubs.dll"]
-        (Filename.concat ocamllib "stublibs");
+(*       install fh ["dllpcre_stubs.dll"] *)
+(*         (Filename.concat ocamllib "stublibs"); *)
     end;
     (*
      * Examples compilation scripts
       end
     ) ex;
   end
+
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.