From 3126bfee333b5c635dc60a54265936af06117f6a Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Sat, 5 Jan 2008 15:16:31 +0000 Subject: Build libvirt and examples on Windows (MinGW). * aclocal.m4: Add AC_CHECK_OCAML_MODULE to check for OCaml modules directly (without ocamlfind being needed). * configure.ac: Remove requirement for ocamlfind. * config.guess, config.sub: Ship these files to guess host, build and target. * libvirt/Makefile.in, examples/Makefile.in: Change these so they don't require ocamlfind, do the right thing on MinGW. * Make.rules.in: Make.rules is now generated from this file. File can use ocamlfind or direct ocaml commands as available. * .hgignore: Ignore some generated files on Windows. --- libvirt/.depend | 8 ++--- libvirt/Makefile.in | 77 +++++++++++++++++++++++++++++++++++-------- libvirt/libvirt.ml | 0 libvirt/libvirt.mli | 0 libvirt/libvirt_c.c | 0 libvirt/libvirt_version.ml.in | 0 libvirt/libvirt_version.mli | 0 7 files changed, 68 insertions(+), 17 deletions(-) mode change 100644 => 100755 libvirt/.depend mode change 100644 => 100755 libvirt/Makefile.in mode change 100644 => 100755 libvirt/libvirt.ml mode change 100644 => 100755 libvirt/libvirt.mli mode change 100644 => 100755 libvirt/libvirt_c.c mode change 100644 => 100755 libvirt/libvirt_version.ml.in mode change 100644 => 100755 libvirt/libvirt_version.mli (limited to 'libvirt') diff --git a/libvirt/.depend b/libvirt/.depend old mode 100644 new mode 100755 index 5556d96..9e564ce --- a/libvirt/.depend +++ b/libvirt/.depend @@ -1,4 +1,4 @@ -libvirt.cmo: libvirt.cmi -libvirt.cmx: libvirt.cmi -libvirt_version.cmo: libvirt_version.cmi -libvirt_version.cmx: libvirt_version.cmi +libvirt.cmo: libvirt.cmi +libvirt.cmx: libvirt.cmi +libvirt_version.cmo: libvirt_version.cmi +libvirt_version.cmx: libvirt_version.cmi diff --git a/libvirt/Makefile.in b/libvirt/Makefile.in old mode 100644 new mode 100755 index 8eb2f93..53b25b0 --- a/libvirt/Makefile.in +++ b/libvirt/Makefile.in @@ -15,37 +15,88 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -CFLAGS := @CFLAGS@ \ +WIN32 = @WIN32@ + +CFLAGS = @CFLAGS@ \ -I.. \ - -I$(shell ocamlc -where) \ - -Wall -Werror \ - -fPIC \ - -g -LDFLAGS := @LDFLAGS@ + -I"$(shell ocamlc -where)" \ + @DEBUG@ @WARNINGS@ @CFLAGS_FPIC@ +LDFLAGS = @LDFLAGS@ +# -L"$(shell ocamlc -where)" + +OCAMLC = @OCAMLC@ +OCAMLOPT = @OCAMLOPT@ +OCAMLFIND = @OCAMLFIND@ +OCAMLMKLIB = @OCAMLMKLIB@ +ifneq ($(OCAMLFIND),) OCAMLCPACKAGES := -package unix OCAMLCFLAGS := -g OCAMLCLIBS := -linkpkg +else +OCAMLCINCS := +OCAMLCFLAGS := -g +OCAMLCLIBS := unix.cma +endif -OCAMLOPTPACKAGES := $(OCAMLCPACKAGES) OCAMLOPTFLAGS := +ifneq ($(OCAMLFIND),) +OCAMLOPTPACKAGES := $(OCAMLCPACKAGES) OCAMLOPTLIBS := $(OCAMLCLIBS) +else +OCAMLOPTINCS := $(OCAMLCINCS) +OCAMLOPTLIBS := unix.cmxa +endif export LIBRARY_PATH=. export LD_LIBRARY_PATH=. -BYTE_TARGETS := libvirt.cma -OPT_TARGETS := libvirt.cmxa +BYTE_TARGETS := mllibvirt.cma +OPT_TARGETS := mllibvirt.cmxa all: $(BYTE_TARGETS) opt: $(OPT_TARGETS) -libvirt.cma: libvirt_c.o libvirt.cmo libvirt_version.cmo - ocamlmklib -o mllibvirt $^ $(LDFLAGS) -lvirt +COBJS := libvirt.cmo libvirt_version.cmo +OPTOBJS := libvirt.cmx libvirt_version.cmx + +ifneq ($(OCAMLMKLIB),) +# Good, we can just use ocamlmklib +mllibvirt.cma: libvirt_c.o $(COBJS) + $(OCAMLMKLIB) -o mllibvirt $^ $(LDFLAGS) -lvirt + +mllibvirt.cmxa: libvirt_c.o $(OPTOBJS) + $(OCAMLMKLIB) -o mllibvirt $^ $(LDFLAGS) -lvirt + +else +ifeq ($(WIN32),yes) +# Ugh, MinGW doesn't have ocamlmklib. This technique is copied from the +# example in OCaml distribution, otherlibs/win32unix/Makefile.nt + +mllibvirt.cma: dllmllibvirt.dll libmllibvirt.a $(COBJS) + $(OCAMLC) -a -linkall -o $@ $(COBJS) \ + -dllib -lmllibvirt -cclib -lmllibvirt -cclib "$(LDFLAGS) -lvirt" + +mllibvirt.cmxa: libmllibvirt.a $(OPTOBJS) + $(OCAMLOPT) -a -linkall -o $@ $(OPTOBJS) \ + -cclib -lmllibvirt -cclib "$(LDFLAGS) -lvirt" + +dllmllibvirt.dll: libvirt_c.o + $(CC) -shared -o $@ $^ \ + $(LDFLAGS) "$(shell ocamlc -where)"/ocamlrun.a -lvirt + +libmllibvirt.a: libvirt_c.o + ar rc $@ $^ + ranlib $@ -libvirt.cmxa: libvirt_c.o libvirt.cmx libvirt_version.cmx - ocamlmklib -o mllibvirt $^ $(LDFLAGS) -lvirt +else +# Don't know how to build a library on this platform. +$(BYTE_TARGETS) $(OPT_TARGETS): + echo "Error: ocamlmklib missing, and no known way to build libraries on this platform" + exit 1 +endif +endif libvirt.cmo: libvirt.cmi libvirt.cmi: libvirt.mli diff --git a/libvirt/libvirt.ml b/libvirt/libvirt.ml old mode 100644 new mode 100755 diff --git a/libvirt/libvirt.mli b/libvirt/libvirt.mli old mode 100644 new mode 100755 diff --git a/libvirt/libvirt_c.c b/libvirt/libvirt_c.c old mode 100644 new mode 100755 diff --git a/libvirt/libvirt_version.ml.in b/libvirt/libvirt_version.ml.in old mode 100644 new mode 100755 diff --git a/libvirt/libvirt_version.mli b/libvirt/libvirt_version.mli old mode 100644 new mode 100755 -- cgit