From mboxrd@z Thu Jan 1 00:00:00 1970 From: Vincent Hanquez Subject: [PATCH 3/6] add compilation makefile to ocaml directory Date: Mon, 1 Mar 2010 11:59:48 +0000 Message-ID: <1267444791-4810-4-git-send-email-vincent.hanquez@eu.citrix.com> References: <1267444791-4810-1-git-send-email-vincent.hanquez@eu.citrix.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------1.7.0" Return-path: In-Reply-To: <1267444791-4810-1-git-send-email-vincent.hanquez@eu.citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com Cc: Vincent Hanquez List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. --------------1.7.0 Content-Type: text/plain; charset=UTF-8; format=fixed Content-Transfer-Encoding: quoted-printable Signed-off-by: Vincent Hanquez --- 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 --------------1.7.0 Content-Type: text/x-patch; name="0003-add-compilation-makefile-to-ocaml-directory.patch" Content-Disposition: attachment; filename="0003-add-compilation-makefile-to-ocaml-directory.patch" Content-Transfer-Encoding: quoted-printable 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 =3D ../.. +include $(XEN_ROOT)/tools/Rules.mk + +SUBDIRS_LIBS =3D \ + libs/uuid libs/stdext libs/mmap \ + libs/log libs/xc libs/eventchn \ + libs/xb libs/xs + +SUBDIRS_PROGRAMS =3D xenstored + +SUBDIRS =3D $(SUBDIRS_LIBS) $(SUBDIRS_PROGRAMS) + +.PHONY: all +all: build + +.PHONY: build $(SUBDIRS) +build: $(SUBDIRS) + +$(SUBDIRS): + @echo " =3D=3D=3D 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 =3D $(V) + endif +endif +ifndef BUILD_VERBOSE + BUILD_VERBOSE =3D 0 +endif +ifeq ($(BUILD_VERBOSE),1) + E =3D @true + Q =3D +else + E =3D @echo + Q =3D @ +endif + +ALL_OCAML_OBJS ?=3D $(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=3D$(addsuffix .ml, $(ALL_OCAML_OBJS)) + +.ocamldep.make: $(ALL_OCAML_OBJ_SOURCES) Makefile $(TOPLEVEL)/Makefile.r= ules + $(call quiet-command, $(OCAMLDEP) $(ALL_OCAML_OBJ_SOURCES) *.mli $o,MLD= EP,) + +clean: $(CLEAN_HOOKS) + $(Q)rm -f *.o *.so *.a *.cmo *.cmi *.cma *.cmx *.cmxa *.annot $(LIBS) $= (PROGRAMS) $(GENERATED_FILES) .ocamldep.make + +quiet-command =3D $(if $(V),$1,@printf " %-8s %s\n" "$2" "$3" && $1) + +mk-caml-lib-native =3D $(call quiet-command, $(OCAMLOPT) $(OCAMLOPTFLAGS= ) -a -o $1 $2 $3,MLA,$1) +mk-caml-lib-bytecode =3D $(call quiet-command, $(OCAMLC) $(OCAMLCFLAGS) = -a -o $1 $2 $3,MLA,$1) + +mk-caml-stubs =3D $(call quiet-command, $(OCAMLMKLIB) -o `basename $1 .a= ` $2,MKLIB,$1) +mk-caml-lib-stubs =3D \ + $(call quiet-command, $(AR) rcs $1 $2 && $(OCAMLMKLIB) -o `basename $1 = .a | sed -e 's/^lib//'` $2,MKLIB,$1) + +# define a library target .cmxa and .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,$(li= b)))) +$(foreach lib,$(OCAML_NOC_LIBRARY),$(eval $(call OCAML_NOC_LIBRARY_templ= ate,$(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 ?=3D gcc +OCAMLOPT ?=3D ocamlopt +OCAMLC ?=3D ocamlc +OCAMLMKLIB ?=3D ocamlmklib +OCAMLDEP ?=3D ocamldep +OCAMLLEX ?=3D ocamllex +OCAMLYACC ?=3D ocamlyacc + +CFLAGS ?=3D -Wall -fPIC -O2 + +XEN_ROOT ?=3D $(TOPLEVEL)/../xen-unstable.hg +XEN_DIST_ROOT ?=3D $(XEN_ROOT)/dist/install +CFLAGS +=3D -I$(XEN_DIST_ROOT)/usr/include + +OCAMLOPTFLAG_G :=3D $(shell $(OCAMLOPT) -h 2>&1 | sed -n 's/^ *\(-g\) .= */\1/p') +OCAMLOPTFLAGS =3D $(OCAMLOPTFLAG_G) -ccopt "$(LDFLAGS)" -dtypes $(OCAMLI= NCLUDE) -cc $(CC) -w F -warn-error F +OCAMLCFLAGS +=3D -g $(OCAMLINCLUDE) -w F -warn-error F + +#LDFLAGS =3D -cclib -L./ + +DESTDIR ?=3D / +VERSION :=3D echo 0.0 + +OCAMLABI =3D $(shell $(OCAMLC) -version) +OCAMLLIBDIR =3D $(shell $(OCAMLC) -where) +OCAMLDESTDIR ?=3D $(OCAMLLIBDIR) + +o=3D >$@.new && mv -f $@.new $@ --------------1.7.0 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --------------1.7.0--