Markus Mottl avatar Markus Mottl committed 08f7faa

Merged Christophe's Windows patches

Comments (0)

Files changed (4)

 examples/lin_reg/lin_reg
 examples/svd/svd
 RE:lib/.*[012345678]_[SDCZ]*\.mli?
+*.exe
+*.dll
+
+           The native Win32 port built with Mingw
+           --------------------------------------
+
+In addition to the cygwin packages recommended for the standard OCaml
+installation (http://camlcvs.inria.fr/cgi-bin/cvsweb/ocaml/README.win32),
+download "make" and "lapack".
+
+Modify Makefile.conf to include the full path of the lapack libraries, e.g.:
+
+  export LIBDIRS := c:/cygwin/lib
+
+Open a cygwin shell, go to the directory where you downloaded Lacaml
+and type "make".
+
+To install, type "make install".  You need findlib.  We recommend
+version > 1.2.3 because it compiles seamlessly under cygwin-mingw.
+
+To uninstall, just issue "make uninstall" or use findlib.
+
+You can compile the examples with "make examples".  To try them, you
+need to install Lacaml first.  (You can also go to an example
+sub-directory and issue "make nc" to compile it to native code.  You
+can then run the program without needing to install Lacaml first.)
+
+
+           The native Win32 port built with MSVC
+           -------------------------------------
+
+A standalone version of LAPACK for windows can be downloaded at
+<http://icl.cs.utk.edu/lapack-for-windows/>.  If you you have a tested
+procedure how to compile Lacaml with that version of LAPACK, send us
+an email!
 
 ####################  variables depending on your OCaml-installation
 
+SYSTEM=$(shell ocamlc -config 2>/dev/null|grep system|sed 's/system: //')
+    # This may be
+    # - mingw
+    # - win32
+    # - cygwin
+    # - some other string means Unix
+    # - empty means ocamlc does not support -config
+
+ifeq ($(SYSTEM),mingw)
+  MINGW=1
+endif
+ifeq ($(SYSTEM),win32)
+  MSVC=1
+endif
+
 ifdef MINGW
   export MINGW
   WIN32   := 1
   CFLAGS_WIN32 := -mno-cygwin
+  # The default value 'cc' makes 'ocamlc -cc "cc"' raises the error 'The 
+  # NTVDM CPU has encountered an illegal instruction'.
+  CC := gcc
+  # The OCaml C header files use this flag:
+  CFLAGS += -D__MINGW32__
 endif
 ifdef MSVC
   export MSVC
 $(DLLSONAME):		$(OBJ_LINK)
 			$(CC) $(CFLAGS) $(CFLAGS_WIN32) $(OBJ_LINK) -shared -o $@ \
 			-Wl,--whole-archive $(wildcard $(foreach dir,$(LIBDIRS),$(CLIBS:%=$(dir)/lib%.a))) \
-			 $(OCAMLLIBPATH)/ocamlrun.a \
+			 '$(OCAMLLIBPATH)/ocamlrun.a' \
 			-Wl,--export-all-symbols \
-			-Wl,--no-whole-archive
+			-Wl,--no-whole-archive \
+			-Wl,--allow-multiple-definition \
+			-Wl,--enable-auto-import
 else
 ifdef MSVC
 $(DLLSONAME):		$(OBJ_LINK)
 			link /NOLOGO /DLL /OUT:$@ $(OBJ_LINK) \
 			 $(wildcard $(foreach dir,$(LIBDIRS),$(CLIBS:%=$(dir)/%.lib))) \
-			 $(OCAMLLIBPATH)/ocamlrun.lib
+			 '$(OCAMLLIBPATH)/ocamlrun.lib'
 
 else
 $(DLLSONAME):		$(OBJ_LINK)
 
 NO_CUSTOM = y
 
+SYSTEM=$(shell ocamlc -config 2>/dev/null|grep system|sed 's/system: //')
+
 ifeq ($(shell uname), Darwin)
   BLAS =
   LAPACK =
   OCAMLMKLIB_FLAGS = -framework vecLib
   OCAMLBLDFLAGS = -ccopt "-framework vecLib"
 else
+ifeq ($(SYSTEM), mingw)
+  # exp10 does not exists under cywin-mingw
+  EXP10 = exp10.c
+  NO_CUSTOM =
+  # Useless for now:
+  INSTALL_DLL = lacaml_stubs.dll
+else
   EXP10 =
 endif
+endif
 
 OCAMLMAKEFILE := ../OCamlMakefile
 
 
 # Generation rules for precision-dependent C-code
 %2_S_c.o:	%_SD_c.c
-	$(CC) -c $(CFLAGS) $(CINCFLAGS) -I$(OCAMLLIBPATH) $< -o $@
+	$(CC) -c $(CFLAGS) $(CINCFLAGS) -I'$(OCAMLLIBPATH)' $< -o $@
 
 %2_D_c.o:	%_SD_c.c
-	$(CC) -c -DLACAML_DOUBLE $(CFLAGS) $(CINCFLAGS) -I$(OCAMLLIBPATH) \
+	$(CC) -c -DLACAML_DOUBLE $(CFLAGS) $(CINCFLAGS) -I'$(OCAMLLIBPATH)' \
 		$< -o $@
 
 %2_C_c.o:	%_CZ_c.c
 	$(CC) -c -DLACAML_COMPLEX $(CFLAGS) $(CINCFLAGS) \
-		-I$(OCAMLLIBPATH) $< -o $@
+		-I'$(OCAMLLIBPATH)' $< -o $@
 
 %2_Z_c.o:	%_CZ_c.c
 	$(CC) -c -DLACAML_COMPLEX -DLACAML_DOUBLE $(CFLAGS) $(CINCFLAGS) \
-		-I$(OCAMLLIBPATH) $< -o $@
+		-I'$(OCAMLLIBPATH)' $< -o $@
 
 %4_S_c.o:	%_SDCZ_c.c
-	$(CC) -c $(CFLAGS) $(CINCFLAGS) -I$(OCAMLLIBPATH) $< -o $@
+	$(CC) -c $(CFLAGS) $(CINCFLAGS) -I'$(OCAMLLIBPATH)' $< -o $@
 
 %4_D_c.o:	%_SDCZ_c.c
-	$(CC) -c -DLACAML_DOUBLE $(CFLAGS) $(CINCFLAGS) -I$(OCAMLLIBPATH) \
+	$(CC) -c -DLACAML_DOUBLE $(CFLAGS) $(CINCFLAGS) -I'$(OCAMLLIBPATH)' \
 		$< -o $@
 
 %4_C_c.o:	%_SDCZ_c.c
 	$(CC) -c -DLACAML_COMPLEX $(CFLAGS) $(CINCFLAGS) \
-		-I$(OCAMLLIBPATH) $< -o $@
+		-I'$(OCAMLLIBPATH)' $< -o $@
 
 %4_Z_c.o:	%_SDCZ_c.c
 	$(CC) -c -DLACAML_COMPLEX -DLACAML_DOUBLE $(CFLAGS) $(CINCFLAGS) \
-		-I$(OCAMLLIBPATH) $< -o $@
+		-I'$(OCAMLLIBPATH)' $< -o $@
 
 # Generation rules for precision-dependent OCaml-code
 %2_S.mli:	%_SD.mli
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.