mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
mllib: Use automake to build the library.
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -309,6 +309,7 @@ Makefile.in
|
||||
/mllib/config.ml
|
||||
/mllib/dummy
|
||||
/mllib/libdir.ml
|
||||
/mllib/link.sh
|
||||
/ocaml/bindtests.bc
|
||||
/ocaml/bindtests.opt
|
||||
/ocaml/bindtests.ml
|
||||
|
||||
@@ -1671,6 +1671,8 @@ AC_CONFIG_FILES([customize/link.sh],
|
||||
[chmod +x,-w customize/link.sh])
|
||||
AC_CONFIG_FILES([inspector/test-xmllint.sh],
|
||||
[chmod +x,-w inspector/test-xmllint.sh])
|
||||
AC_CONFIG_FILES([mllib/link.sh],
|
||||
[chmod +x,-w mllib/link.sh])
|
||||
AC_CONFIG_FILES([p2v/virt-p2v-make-disk],
|
||||
[chmod +x,-w p2v/virt-p2v-make-disk])
|
||||
AC_CONFIG_FILES([p2v/virt-p2v-make-kickstart],
|
||||
|
||||
@@ -18,107 +18,103 @@
|
||||
include $(top_srcdir)/subdir-rules.mk
|
||||
|
||||
EXTRA_DIST = \
|
||||
$(filter-out config.ml,$(SOURCES))
|
||||
$(SOURCES_MLI) \
|
||||
$(filter-out config.ml libdir.ml,$(SOURCES_ML)) \
|
||||
$(SOURCES_C) \
|
||||
common_utils_tests.ml
|
||||
|
||||
CLEANFILES = *~ *.annot *.cmi *.cmo *.cmx *.cmxa *.o
|
||||
|
||||
# Alphabetical order.
|
||||
SOURCES = \
|
||||
SOURCES_MLI = \
|
||||
common_utils.mli \
|
||||
fsync.mli \
|
||||
JSON.mli \
|
||||
mkdtemp.mli \
|
||||
planner.mli \
|
||||
progress.mli \
|
||||
regedit.mli \
|
||||
uRI.mli
|
||||
|
||||
SOURCES_ML = \
|
||||
config.ml \
|
||||
libdir.ml \
|
||||
common_gettext.ml \
|
||||
common_utils.ml \
|
||||
common_utils.mli \
|
||||
common_utils_tests.ml \
|
||||
config.ml \
|
||||
fsync-c.c \
|
||||
fsync.mli \
|
||||
fsync.ml \
|
||||
JSON.mli \
|
||||
JSON.ml \
|
||||
mkdtemp.mli \
|
||||
mkdtemp.ml \
|
||||
mkdtemp-c.c \
|
||||
planner.mli \
|
||||
planner.ml \
|
||||
progress-c.c \
|
||||
progress.mli \
|
||||
progress.ml \
|
||||
regedit.mli \
|
||||
uRI.ml \
|
||||
mkdtemp.ml \
|
||||
planner.ml \
|
||||
regedit.ml \
|
||||
uri-c.c \
|
||||
uRI.mli \
|
||||
uRI.ml
|
||||
JSON.ml
|
||||
|
||||
SOURCES_C = \
|
||||
$(top_srcdir)/fish/progress.c \
|
||||
$(top_srcdir)/fish/uri.c \
|
||||
fsync-c.c \
|
||||
mkdtemp-c.c \
|
||||
progress-c.c \
|
||||
uri-c.c
|
||||
|
||||
if HAVE_OCAML
|
||||
|
||||
# Notes:
|
||||
# - We're not actually building a functioning program here, we're just
|
||||
# linking everything together to check all the modules build OK.
|
||||
# - This list must be in dependency order.
|
||||
ocaml_modules = config \
|
||||
libdir \
|
||||
common_gettext \
|
||||
common_utils \
|
||||
fsync \
|
||||
progress \
|
||||
uRI \
|
||||
mkdtemp \
|
||||
planner \
|
||||
regedit \
|
||||
JSON
|
||||
# Note - we're not actually building a functioning program here, we're
|
||||
# just linking everything together to check all the modules build OK.
|
||||
|
||||
OBJECTS = \
|
||||
$(top_builddir)/fish/guestfish-progress.o \
|
||||
$(top_builddir)/fish/guestfish-uri.o \
|
||||
fsync-c.o \
|
||||
progress-c.o \
|
||||
uri-c.o \
|
||||
mkdtemp-c.o
|
||||
noinst_PROGRAMS = dummy
|
||||
|
||||
if HAVE_OCAMLOPT
|
||||
OBJECTS += $(patsubst %,%.cmx,$(ocaml_modules))
|
||||
else
|
||||
OBJECTS += $(patsubst %,%.cmo,$(ocaml_modules))
|
||||
endif
|
||||
dummy_SOURCES = $(SOURCES_C)
|
||||
dummy_CPPFLAGS = \
|
||||
-I. \
|
||||
-I$(top_builddir) \
|
||||
-I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \
|
||||
-I$(shell $(OCAMLC) -where) \
|
||||
-I$(top_srcdir)/src \
|
||||
-I$(top_srcdir)/fish
|
||||
dummy_CFLAGS = \
|
||||
$(WARN_CFLAGS) $(WERROR_CFLAGS) \
|
||||
$(LIBVIRT_CFLAGS) $(LIBXML2_CFLAGS)
|
||||
|
||||
noinst_SCRIPTS = dummy
|
||||
BOBJECTS = $(SOURCES_ML:.ml=.cmo)
|
||||
XOBJECTS = $(BOBJECTS:.cmo=.cmx)
|
||||
|
||||
# -I $(top_builddir)/src/.libs is a hack which forces corresponding -L
|
||||
# option to be passed to gcc, so we don't try linking against an
|
||||
# installed copy of libguestfs.
|
||||
OCAMLPACKAGES = -package str,unix -I $(top_builddir)/src/.libs -I ../ocaml
|
||||
OCAMLPACKAGES = \
|
||||
-package str,unix \
|
||||
-I $(top_builddir)/src/.libs \
|
||||
-I $(top_builddir)/gnulib/lib/.libs \
|
||||
-I $(top_builddir)/ocaml
|
||||
if HAVE_OCAML_PKG_GETTEXT
|
||||
OCAMLPACKAGES += -package gettext-stub
|
||||
endif
|
||||
|
||||
OCAMLCFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR) $(OCAMLPACKAGES)
|
||||
OCAMLOPTFLAGS = $(OCAMLCFLAGS)
|
||||
OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR)
|
||||
|
||||
OCAMLCLIBS = \
|
||||
$(LIBXML2_LIBS) $(LIBINTL) $(LIBTINFO_LIBS) -lcrypt \
|
||||
-L../src/.libs -lutils \
|
||||
-L../gnulib/lib/.libs -lgnu
|
||||
|
||||
dummy: $(OBJECTS)
|
||||
if HAVE_OCAMLOPT
|
||||
$(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) \
|
||||
mlguestfs.cmxa -linkpkg $^ \
|
||||
-cclib '$(OCAMLCLIBS)' \
|
||||
-o $@
|
||||
if !HAVE_OCAMLOPT
|
||||
OBJECTS = $(BOBJECTS)
|
||||
BEST = c
|
||||
OCAMLLINKFLAGS = mlguestfs.cma -custom
|
||||
else
|
||||
$(OCAMLFIND) ocamlc $(OCAMLCFLAGS) \
|
||||
mlguestfs.cma -linkpkg $^ \
|
||||
-cclib '$(OCAMLCLIBS)' \
|
||||
-custom \
|
||||
-o $@
|
||||
OBJECTS = $(XOBJECTS)
|
||||
BEST = opt
|
||||
OCAMLLINKFLAGS = mlguestfs.cmxa
|
||||
endif
|
||||
|
||||
dummy_DEPENDENCIES = $(OBJECTS)
|
||||
dummy_LINK = \
|
||||
./link.sh \
|
||||
$(OCAMLFIND) $(BEST) $(OCAMLFLAGS) $(OCAMLPACKAGES) $(OCAMLLINKFLAGS) \
|
||||
$(OBJECTS) -o $@
|
||||
|
||||
.mli.cmi:
|
||||
$(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -c $< -o $@
|
||||
$(OCAMLFIND) ocamlc $(OCAMLFLAGS) $(OCAMLPACKAGES) -c $< -o $@
|
||||
.ml.cmo:
|
||||
$(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -c $< -o $@
|
||||
$(OCAMLFIND) ocamlc $(OCAMLFLAGS) $(OCAMLPACKAGES) -c $< -o $@
|
||||
if HAVE_OCAMLOPT
|
||||
.ml.cmx:
|
||||
$(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) -c $< -o $@
|
||||
$(OCAMLFIND) ocamlopt $(OCAMLFLAGS) $(OCAMLPACKAGES) -c $< -o $@
|
||||
endif
|
||||
|
||||
# This OCaml module has to be generated by make (configure will put
|
||||
@@ -128,31 +124,18 @@ libdir.ml: Makefile
|
||||
echo 'let libdir = "$(libdir)"' > $@-t
|
||||
mv $@-t $@
|
||||
|
||||
# automake will decide we don't need C support in this file. Really
|
||||
# we do, so we have to provide it ourselves.
|
||||
|
||||
DEFAULT_INCLUDES = \
|
||||
$(LIBVIRT_CFLAGS) \
|
||||
-I. \
|
||||
-I$(top_builddir) \
|
||||
-I$(shell $(OCAMLC) -where) \
|
||||
-I$(top_srcdir)/src \
|
||||
-I$(top_srcdir)/fish
|
||||
|
||||
.c.o:
|
||||
$(CC) $(CFLAGS) $(PROF_CFLAGS) $(DEFAULT_INCLUDES) -c $< -o $@
|
||||
|
||||
# Tests.
|
||||
|
||||
check_SCRIPTS = common_utils_tests
|
||||
check_SCRIPTS = \
|
||||
common_utils_tests
|
||||
|
||||
if HAVE_OCAMLOPT
|
||||
common_utils_tests: common_gettext.cmx common_utils.cmx common_utils_tests.cmx
|
||||
$(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) \
|
||||
$(OCAMLFIND) ocamlopt $(OCAMLFLAGS) $(OCAMLPACKAGES) \
|
||||
mlguestfs.cmxa -linkpkg $^ -cclib '$(LIBTINFO_LIBS)' -o $@
|
||||
else
|
||||
common_utils_tests: common_gettext.cmo common_utils.cmo common_utils_tests.cmo
|
||||
$(OCAMLFIND) ocamlc $(OCAMLCFLAGS) \
|
||||
$(OCAMLFIND) ocamlc $(OCAMLFLAGS) $(OCAMLPACKAGES) \
|
||||
mlguestfs.cma -linkpkg $^ -cclib '$(LIBTINFO_LIBS)' -custom -o $@
|
||||
endif
|
||||
|
||||
|
||||
22
mllib/link.sh.in
Normal file
22
mllib/link.sh.in
Normal file
@@ -0,0 +1,22 @@
|
||||
# libguestfs Makefile.am
|
||||
# @configure_input@
|
||||
# (C) Copyright 2014 Red Hat Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
# Hack automake to link binary properly. There is no other way to add
|
||||
# the -cclib parameter to the end of the command line.
|
||||
|
||||
exec "$@" -linkpkg -cclib '-lutils @LIBTINFO_LIBS@ -lcrypt @LIBVIRT_LIBS@ @LIBXML2_LIBS@ @LIBINTL@ -lgnu'
|
||||
Reference in New Issue
Block a user