From: "Richard W.M. Jones" <rjones@redhat.com> By arranging the C part of the bindings into a library, we can get automake to build it instead of using $(CC) directly. --- ocaml/Makefile.am | 28 +++++++++++++++------------- 1 files changed, 15 insertions(+), 13 deletions(-) diff --git a/ocaml/Makefile.am b/ocaml/Makefile.am index 83c0ed4..7649cc5 100644 --- a/ocaml/Makefile.am +++ b/ocaml/Makefile.am @@ -35,10 +35,6 @@ EXTRA_DIST = \ CLEANFILES = *.cmi *.cmo *.cmx *.cma *.cmxa *.o *.a *.so CLEANFILES += t/*.cmi t/*.cmo t/*.cmx t/*.o t/*.a t/*.so -AM_CPPFLAGS = -I$(top_builddir) -I$(OCAMLLIB) -I$(top_srcdir)/ocaml \ - -I$(top_srcdir)/src -I$(top_builddir)/src \ - $(WARN_CFLAGS) $(WERROR_CFLAGS) - if HAVE_OCAML OCAMLCFLAGS = -g -warn-error CDEFLMPSUVYZX @@ -46,20 +42,26 @@ OCAMLOPTFLAGS = $(OCAMLCFLAGS) noinst_DATA = mlguestfs.cma mlguestfs.cmxa META -OBJS = guestfs_c.o guestfs_c_actions.o guestfs.cmo +# Build the C part into a library, so that automake handles the C +# compilation step for us. Note that we don't directly use this +# library; we link with the object files that it generates. +noinst_LIBRARIES = libguestfsocaml.a + +OBJS = libguestfsocaml.a guestfs.cmo XOBJS = $(OBJS:.cmo=.cmx) mlguestfs.cma: $(OBJS) - $(OCAMLMKLIB) -o mlguestfs $^ -L$(top_builddir)/src/.libs -lguestfs + $(OCAMLMKLIB) -o mlguestfs libguestfsocaml_a-guestfs_c_actions.o libguestfsocaml_a-guestfs_c.o guestfs.cmo -L$(top_builddir)/src/.libs -lguestfs mlguestfs.cmxa: $(XOBJS) - $(OCAMLMKLIB) -o mlguestfs $^ -L$(top_builddir)/src/.libs -lguestfs - -guestfs_c.o: guestfs_c.c - $(CC) $(AM_CPPFLAGS) $(CFLAGS) -fPIC -Wall -c $< - -guestfs_c_actions.o: guestfs_c_actions.c - $(CC) $(AM_CPPFLAGS) $(CFLAGS) -fPIC -Wall -c $(srcdir)/$< + $(OCAMLMKLIB) -o mlguestfs libguestfsocaml_a-guestfs_c_actions.o libguestfsocaml_a-guestfs_c.o guestfs.cmx -L$(top_builddir)/src/.libs -lguestfs + +libguestfsocaml_a_CFLAGS = \ + -I$(top_builddir) -I$(OCAMLLIB) -I$(top_srcdir)/ocaml \ + -I$(top_srcdir)/src -I$(top_builddir)/src \ + $(WARN_CFLAGS) $(WERROR_CFLAGS) \ + -fPIC +libguestfsocaml_a_SOURCES = guestfs_c.c guestfs_c_actions.c if HAVE_OCAMLDOC -- 1.7.6