summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2012-01-18 12:30:36 +0000
committerRichard W.M. Jones <rjones@redhat.com>2012-01-23 18:16:14 +0000
commit6eba9e678d0b8ffdec0924dd56de3cb95e84b4f8 (patch)
tree88497b0cee195b479e539d9f802dd086a5d49691
parentefbae9ac49864c4614e057d9823cd055d23ecfe8 (diff)
downloadlibguestfs-6eba9e678d0b8ffdec0924dd56de3cb95e84b4f8.tar.gz
libguestfs-6eba9e678d0b8ffdec0924dd56de3cb95e84b4f8.tar.xz
libguestfs-6eba9e678d0b8ffdec0924dd56de3cb95e84b4f8.zip
ocaml: Use automake to build the C part of the bindings.
By arranging the C part of the bindings into a library, we can get automake to build it instead of using $(CC) directly. (cherry picked from commit 8b9eaec993e3199ff4ef1056abe2f18cbed1289b)
-rw-r--r--ocaml/Makefile.am39
1 files changed, 21 insertions, 18 deletions
diff --git a/ocaml/Makefile.am b/ocaml/Makefile.am
index 83c0ed4b..35cba466 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,27 @@ OCAMLOPTFLAGS = $(OCAMLCFLAGS)
noinst_DATA = mlguestfs.cma mlguestfs.cmxa META
-OBJS = guestfs_c.o guestfs_c_actions.o guestfs.cmo
-XOBJS = $(OBJS:.cmo=.cmx)
-
-mlguestfs.cma: $(OBJS)
- $(OCAMLMKLIB) -o mlguestfs $^ -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)/$<
+# 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
+
+mlguestfs.cma: libguestfsocaml.a guestfs.cmo
+ $(OCAMLMKLIB) -o mlguestfs \
+ $(am_libguestfsocaml_a_OBJECTS) guestfs.cmo \
+ -L$(top_builddir)/src/.libs -lguestfs
+
+mlguestfs.cmxa: libguestfsocaml.a guestfs.cmx
+ $(OCAMLMKLIB) -o mlguestfs \
+ $(am_libguestfsocaml_a_OBJECTS) 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