xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Vincent Hanquez <vincent.hanquez@eu.citrix.com>
To: xen-devel@lists.xensource.com
Cc: Vincent Hanquez <vincent.hanquez@eu.citrix.com>
Subject: [PATCH 3/6] add compilation makefile to ocaml directory
Date: Mon,  1 Mar 2010 11:59:48 +0000	[thread overview]
Message-ID: <1267444791-4810-4-git-send-email-vincent.hanquez@eu.citrix.com> (raw)
In-Reply-To: <1267444791-4810-1-git-send-email-vincent.hanquez@eu.citrix.com>

[-- Attachment #1: Type: text/plain, Size: 446 bytes --]


Signed-off-by: Vincent Hanquez <vincent.hanquez@eu.citrix.com>
---
 tools/ocaml/Makefile       |   36 +++++++++++++++++
 tools/ocaml/Makefile.rules |   93 ++++++++++++++++++++++++++++++++++++++++++++
 tools/ocaml/common.make    |   28 +++++++++++++
 3 files changed, 157 insertions(+), 0 deletions(-)
 create mode 100644 tools/ocaml/Makefile
 create mode 100644 tools/ocaml/Makefile.rules
 create mode 100644 tools/ocaml/common.make


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0003-add-compilation-makefile-to-ocaml-directory.patch --]
[-- Type: text/x-patch; name="0003-add-compilation-makefile-to-ocaml-directory.patch", Size: 5488 bytes --]

diff --git a/tools/ocaml/Makefile b/tools/ocaml/Makefile
new file mode 100644
index 0000000..adc35b4
--- /dev/null
+++ b/tools/ocaml/Makefile
@@ -0,0 +1,36 @@
+XEN_ROOT = ../..
+include $(XEN_ROOT)/tools/Rules.mk
+
+SUBDIRS_LIBS = \
+	libs/uuid libs/stdext libs/mmap \
+	libs/log libs/xc libs/eventchn \
+	libs/xb libs/xs
+
+SUBDIRS_PROGRAMS = xenstored
+
+SUBDIRS = $(SUBDIRS_LIBS) $(SUBDIRS_PROGRAMS)
+
+.PHONY: all
+all: build
+
+.PHONY: build $(SUBDIRS)
+build: $(SUBDIRS)
+
+$(SUBDIRS):
+	@echo " === building $@"
+	@$(MAKE) --no-print-directory -C $@
+
+.PHONY: install install-libs install-program
+install: install-libs install-program
+
+install-program: $(SUBDIRS_PROGRAMS)
+	$(INSTALL_DIR) $(DESTDIR)$(SBINDIR)
+	$(INSTALL_PROG) xenstored/oxenstored $(DESTDIR)$(SBINDIR)
+
+install-libs: $(SUBDIRS_LIBS)
+
+.PHONY: clean
+clean:
+	@for dir in $(SUBDIRS); do \
+		$(MAKE) --no-print-directory -C $$dir clean; \
+	done
diff --git a/tools/ocaml/Makefile.rules b/tools/ocaml/Makefile.rules
new file mode 100644
index 0000000..ee06b73
--- /dev/null
+++ b/tools/ocaml/Makefile.rules
@@ -0,0 +1,93 @@
+ifdef V
+  ifeq ("$(origin V)", "command line")
+    BUILD_VERBOSE = $(V)
+  endif
+endif
+ifndef BUILD_VERBOSE
+  BUILD_VERBOSE = 0
+endif
+ifeq ($(BUILD_VERBOSE),1)
+  E = @true
+  Q =
+else
+  E = @echo
+  Q = @
+endif
+
+ALL_OCAML_OBJS ?= $(OBJS)
+
+%.cmo: %.ml
+	$(call quiet-command, $(OCAMLC) $(OCAMLCFLAGS) -c -o $@ $<,MLC,$@)
+
+%.cmi: %.mli
+	$(call quiet-command, $(OCAMLC) $(OCAMLCFLAGS) -c -o $@ $<,MLI,$@)
+
+%.cmx: %.ml
+	$(call quiet-command, $(OCAMLOPT) $(OCAMLOPTFLAGS) -c -o $@ $<,MLOPT,$@)
+
+%.ml: %.mll
+	$(call quiet-command, $(OCAMLLEX) -q -o $@ $<,MLLEX,$@)
+
+%.ml: %.mly
+	$(call quiet-command, $(OCAMLYACC) -q $<,MLYACC,$@)
+
+%.o: %.c
+	$(call quiet-command, $(CC) $(CFLAGS) -c -o $@ $<,CC,$@)
+
+META: META.in
+	sed 's/@VERSION@/$(VERSION)/g' < $< $o
+
+ALL_OCAML_OBJ_SOURCES=$(addsuffix .ml, $(ALL_OCAML_OBJS))
+
+.ocamldep.make: $(ALL_OCAML_OBJ_SOURCES) Makefile $(TOPLEVEL)/Makefile.rules
+	$(call quiet-command, $(OCAMLDEP) $(ALL_OCAML_OBJ_SOURCES) *.mli $o,MLDEP,)
+
+clean: $(CLEAN_HOOKS)
+	$(Q)rm -f *.o *.so *.a *.cmo *.cmi *.cma *.cmx *.cmxa *.annot $(LIBS) $(PROGRAMS) $(GENERATED_FILES) .ocamldep.make
+
+quiet-command = $(if $(V),$1,@printf " %-8s %s\n" "$2" "$3" && $1)
+
+mk-caml-lib-native = $(call quiet-command, $(OCAMLOPT) $(OCAMLOPTFLAGS) -a -o $1 $2 $3,MLA,$1)
+mk-caml-lib-bytecode = $(call quiet-command, $(OCAMLC) $(OCAMLCFLAGS) -a -o $1 $2 $3,MLA,$1)
+
+mk-caml-stubs = $(call quiet-command, $(OCAMLMKLIB) -o `basename $1 .a` $2,MKLIB,$1)
+mk-caml-lib-stubs = \
+	$(call quiet-command, $(AR) rcs $1 $2 && $(OCAMLMKLIB) -o `basename $1 .a | sed -e 's/^lib//'` $2,MKLIB,$1)
+
+# define a library target <name>.cmxa and <name>.cma
+define OCAML_LIBRARY_template
+ $(1).cmxa: lib$(1)_stubs.a $(foreach obj,$($(1)_OBJS),$(obj).cmx)
+	$(call mk-caml-lib-native,$$@, -cclib -l$(1)_stubs, $(foreach obj,$($(1)_OBJS),$(obj).cmx))
+ $(1).cma: $(foreach obj,$($(1)_OBJS),$(obj).cmo)
+	$(call mk-caml-lib-bytecode,$$@, -dllib dll$(1)_stubs.so -cclib -l$(1)_stubs, $$+)
+ $(1)_stubs.a: $(foreach obj,$$($(1)_C_OBJS),$(obj).o)
+	$(call mk-caml-stubs,$$@, $$+)
+ lib$(1)_stubs.a: $(foreach obj,$($(1)_C_OBJS),$(obj).o)
+	$(call mk-caml-lib-stubs,$$@, $$+)
+endef
+
+define OCAML_NOC_LIBRARY_template
+ $(1).cmxa: $(foreach obj,$($(1)_OBJS),$(obj).cmx)
+	$(call mk-caml-lib-native,$$@, , $(foreach obj,$($(1)_OBJS),$(obj).cmx))
+ $(1).cma: $(foreach obj,$($(1)_OBJS),$(obj).cmo)
+	$(call mk-caml-lib-bytecode,$$@, , $$+)
+endef
+
+define OCAML_PROGRAM_template
+ $(1): $(foreach obj,$($(1)_OBJS),$(obj).cmx) $($(1)_EXTRA_DEPS)
+	$(call quiet-command, $(OCAMLOPT) $(OCAMLOPTFLAGS) -o $$@ $($(1)_LIBS) $$+,MLBIN,$$@)
+ $(1).byte: $(foreach obj,$($(1)_OBJS),$(obj).cmo)
+	$(call quiet-command, $(OCAMLC) $(OCAMLCFLAGS) -o $$@ $($(1)_BYTE_LIBS) $$+,MLBIN,$$@)
+endef
+
+define C_PROGRAM_template
+ $(1): $(foreach obj,$($(1)_OBJS),$(obj).o)
+	$(call quiet-command, $(CC) $(CFLAGS) -o $$@ $$+,BIN,$$@)
+endef
+
+-include .ocamldep.make
+
+$(foreach lib,$(OCAML_LIBRARY),$(eval $(call OCAML_LIBRARY_template,$(lib))))
+$(foreach lib,$(OCAML_NOC_LIBRARY),$(eval $(call OCAML_NOC_LIBRARY_template,$(lib))))
+$(foreach p,$(OCAML_PROGRAM),$(eval $(call OCAML_PROGRAM_template,$(p))))
+$(foreach p,$(C_PROGRAM),$(eval $(call C_PROGRAM_template,$(p))))
diff --git a/tools/ocaml/common.make b/tools/ocaml/common.make
new file mode 100644
index 0000000..3b14dfb
--- /dev/null
+++ b/tools/ocaml/common.make
@@ -0,0 +1,28 @@
+CC ?= gcc
+OCAMLOPT ?= ocamlopt
+OCAMLC ?= ocamlc
+OCAMLMKLIB ?= ocamlmklib
+OCAMLDEP ?= ocamldep
+OCAMLLEX ?= ocamllex
+OCAMLYACC ?= ocamlyacc
+
+CFLAGS ?= -Wall -fPIC -O2
+
+XEN_ROOT ?= $(TOPLEVEL)/../xen-unstable.hg
+XEN_DIST_ROOT ?= $(XEN_ROOT)/dist/install
+CFLAGS += -I$(XEN_DIST_ROOT)/usr/include
+
+OCAMLOPTFLAG_G := $(shell $(OCAMLOPT) -h 2>&1 | sed -n 's/^  *\(-g\) .*/\1/p')
+OCAMLOPTFLAGS = $(OCAMLOPTFLAG_G) -ccopt "$(LDFLAGS)" -dtypes $(OCAMLINCLUDE) -cc $(CC) -w F -warn-error F
+OCAMLCFLAGS += -g $(OCAMLINCLUDE) -w F -warn-error F
+
+#LDFLAGS = -cclib -L./
+
+DESTDIR ?= /
+VERSION := echo 0.0
+
+OCAMLABI = $(shell $(OCAMLC) -version)
+OCAMLLIBDIR = $(shell $(OCAMLC) -where)
+OCAMLDESTDIR ?= $(OCAMLLIBDIR)
+
+o= >$@.new && mv -f $@.new $@

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel

  parent reply	other threads:[~2010-03-01 11:59 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-01 11:59 [RFC][PATCH 0/6] merge ocaml xenstored and dependencies Vincent Hanquez
2010-03-01 11:59 ` [PATCH 1/6] add ocaml libs (xc/xb/xs/eventchn) Vincent Hanquez
2010-03-01 11:59 ` [PATCH 2/6] add ocaml xenstored Vincent Hanquez
2010-03-01 11:59 ` Vincent Hanquez [this message]
2010-03-01 11:59 ` [PATCH 4/6] remove hook from external ocaml repository Vincent Hanquez
2010-03-01 11:59 ` [PATCH 5/6] add ocaml tools to build if defined. default to n Vincent Hanquez
2010-03-01 11:59 ` [PATCH 6/6] default ocaml tools config variable to y Vincent Hanquez

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1267444791-4810-4-git-send-email-vincent.hanquez@eu.citrix.com \
    --to=vincent.hanquez@eu.citrix.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).