mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-22 07:03:38 +00:00
Previously the OCaml compiler was only required if building from git but was at least theoretically optional if building from tarballs (although this was never tested). Since we want to write parts of the daemon in OCaml, this makes OCaml required for all builds. Note that the ‘--disable-ocaml’ option remains, but it now only disables OCaml bindings and OCaml virt tools. Using this option does not disable the OCaml compiler requirement. Also note that ‘HAVE_OCAML’ changes meaning slightly, so it now means "build OCaml bindings and tools" (analogous to ‘HAVE_PERL’ and others). The generator, daemon [in a future commit], and some utility libraries needed by the generator or daemon do not test for this macro because we can assume OCaml compiler availability.
148 lines
3.7 KiB
Makefile
148 lines
3.7 KiB
Makefile
# libguestfs OCaml tools common code
|
|
# Copyright (C) 2011-2017 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
include $(top_srcdir)/subdir-rules.mk
|
|
|
|
EXTRA_DIST = \
|
|
$(SOURCES_MLI) \
|
|
$(SOURCES_ML) \
|
|
std_utils_tests.ml
|
|
|
|
SOURCES_MLI = \
|
|
std_utils.mli \
|
|
stringMap.mli
|
|
|
|
SOURCES_ML = \
|
|
guestfs_config.ml \
|
|
$(OCAML_BYTES_COMPAT_ML) \
|
|
libdir.ml \
|
|
stringMap.ml \
|
|
std_utils.ml
|
|
|
|
# We pretend that we're building a C library. automake handles the
|
|
# compilation of the C sources for us. At the end we take the C
|
|
# objects and OCaml objects and link them into the OCaml library.
|
|
# This C library is never used.
|
|
|
|
noinst_LIBRARIES = libmlstdutils.a
|
|
|
|
if !HAVE_OCAMLOPT
|
|
MLSTDUTILS_CMA = mlstdutils.cma
|
|
else
|
|
MLSTDUTILS_CMA = mlstdutils.cmxa
|
|
endif
|
|
|
|
noinst_DATA = $(MLSTDUTILS_CMA)
|
|
|
|
libmlstdutils_a_SOURCES = dummy.c
|
|
libmlstdutils_a_CPPFLAGS = \
|
|
-I. \
|
|
-I$(top_builddir)
|
|
libmlstdutils_a_CFLAGS = \
|
|
$(WARN_CFLAGS) $(WERROR_CFLAGS) \
|
|
-fPIC
|
|
|
|
BOBJECTS = $(SOURCES_ML:.ml=.cmo)
|
|
XOBJECTS = $(BOBJECTS:.cmo=.cmx)
|
|
|
|
OCAMLPACKAGES = \
|
|
-package str,unix \
|
|
-I $(builddir)
|
|
OCAMLPACKAGES_TESTS = $(MLSTDUTILS_CMA)
|
|
if HAVE_OCAML_PKG_OUNIT
|
|
OCAMLPACKAGES_TESTS += -package oUnit
|
|
endif
|
|
|
|
OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR)
|
|
|
|
if !HAVE_OCAMLOPT
|
|
OBJECTS = $(BOBJECTS)
|
|
else
|
|
OBJECTS = $(XOBJECTS)
|
|
endif
|
|
|
|
libmlstdutils_a_DEPENDENCIES = $(OBJECTS)
|
|
|
|
$(MLSTDUTILS_CMA): $(OBJECTS)
|
|
$(OCAMLFIND) mklib $(OCAMLPACKAGES) $(OBJECTS) -o mlstdutils
|
|
|
|
# This OCaml module has to be generated by make (configure will put
|
|
# unexpanded prefix macro in).
|
|
|
|
libdir.ml: Makefile
|
|
echo 'let libdir = "$(libdir)"' > $@-t
|
|
mv $@-t $@
|
|
|
|
# Tests.
|
|
|
|
std_utils_tests_SOURCES = dummy.c
|
|
std_utils_tests_CPPFLAGS = \
|
|
-I. \
|
|
-I$(top_builddir)
|
|
std_utils_tests_BOBJECTS = std_utils_tests.cmo
|
|
std_utils_tests_XOBJECTS = $(std_utils_tests_BOBJECTS:.cmo=.cmx)
|
|
|
|
# Can't call the following as <test>_OBJECTS because automake gets confused.
|
|
if !HAVE_OCAMLOPT
|
|
std_utils_tests_THEOBJECTS = $(std_utils_tests_BOBJECTS)
|
|
std_utils_tests.cmo: OCAMLPACKAGES += $(OCAMLPACKAGES_TESTS)
|
|
else
|
|
std_utils_tests_THEOBJECTS = $(std_utils_tests_XOBJECTS)
|
|
std_utils_tests.cmx: OCAMLPACKAGES += $(OCAMLPACKAGES_TESTS)
|
|
endif
|
|
|
|
OCAMLLINKFLAGS = $(LINK_CUSTOM_OCAMLC_ONLY)
|
|
|
|
std_utils_tests_DEPENDENCIES = \
|
|
$(std_utils_tests_THEOBJECTS) \
|
|
$(MLSTDUTILS_CMA) \
|
|
$(top_srcdir)/ocaml-link.sh
|
|
std_utils_tests_LINK = \
|
|
$(top_srcdir)/ocaml-link.sh -- \
|
|
$(OCAMLFIND) $(BEST) $(OCAMLFLAGS) $(OCAMLLINKFLAGS) \
|
|
$(OCAMLPACKAGES) $(OCAMLPACKAGES_TESTS) \
|
|
$(std_utils_tests_THEOBJECTS) -o $@
|
|
|
|
TESTS_ENVIRONMENT = $(top_builddir)/run --test
|
|
|
|
TESTS =
|
|
check_PROGRAMS =
|
|
|
|
if HAVE_OCAML_PKG_OUNIT
|
|
check_PROGRAMS += std_utils_tests
|
|
TESTS += std_utils_tests
|
|
endif
|
|
|
|
check-valgrind:
|
|
$(MAKE) VG="@VG@" check
|
|
|
|
# Dependencies.
|
|
depend: .depend
|
|
|
|
.depend: $(wildcard $(abs_srcdir)/*.mli) $(wildcard $(abs_srcdir)/*.ml)
|
|
rm -f $@ $@-t
|
|
$(OCAMLFIND) ocamldep -I $(abs_srcdir) $^ | \
|
|
$(SED) 's/ *$$//' | \
|
|
$(SED) -e :a -e '/ *\\$$/N; s/ *\\\n */ /; ta' | \
|
|
$(SED) -e 's,$(abs_srcdir)/,$(builddir)/,g' | \
|
|
sort > $@-t
|
|
mv $@-t $@
|
|
|
|
-include .depend
|
|
|
|
.PHONY: depend docs
|