mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-22 07:03:38 +00:00
219 lines
5.4 KiB
Makefile
219 lines
5.4 KiB
Makefile
# libguestfs OCaml tools common code
|
|
# Copyright (C) 2011-2016 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) \
|
|
$(filter-out guestfs_config.ml libdir.ml,$(SOURCES_ML)) \
|
|
$(SOURCES_C) \
|
|
common_utils_tests.ml \
|
|
JSON_tests.ml
|
|
|
|
CLEANFILES = *~ *.annot *.cmi *.cmo *.cmx *.cmxa *.o
|
|
|
|
SOURCES_MLI = \
|
|
common_utils.mli \
|
|
dev_t.mli \
|
|
fsync.mli \
|
|
JSON.mli \
|
|
mkdtemp.mli \
|
|
planner.mli \
|
|
progress.mli \
|
|
regedit.mli \
|
|
URI.mli
|
|
|
|
SOURCES_ML = \
|
|
guestfs_config.ml \
|
|
libdir.ml \
|
|
common_gettext.ml \
|
|
dev_t.ml \
|
|
common_utils.ml \
|
|
fsync.ml \
|
|
progress.ml \
|
|
URI.ml \
|
|
mkdtemp.ml \
|
|
planner.ml \
|
|
regedit.ml \
|
|
JSON.ml
|
|
|
|
SOURCES_C = \
|
|
../fish/progress.c \
|
|
../fish/uri.c \
|
|
dev_t-c.c \
|
|
fsync-c.c \
|
|
mkdtemp-c.c \
|
|
progress-c.c \
|
|
uri-c.c
|
|
|
|
if HAVE_OCAML
|
|
|
|
# Note - we're not actually building a functioning program here, we're
|
|
# just linking everything together to check all the modules build OK.
|
|
|
|
noinst_PROGRAMS = dummy
|
|
|
|
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)
|
|
|
|
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 $(top_builddir)/gnulib/lib/.libs \
|
|
-I $(top_builddir)/ocaml
|
|
OCAMLPACKAGES_TESTS =
|
|
if HAVE_OCAML_PKG_GETTEXT
|
|
OCAMLPACKAGES += -package gettext-stub
|
|
endif
|
|
if HAVE_OCAML_PKG_OUNIT
|
|
OCAMLPACKAGES_TESTS += -package oUnit
|
|
endif
|
|
|
|
OCAMLCLIBS = \
|
|
-lutils \
|
|
$(LIBTINFO_LIBS) \
|
|
$(LIBCRYPT_LIBS) \
|
|
$(LIBVIRT_LIBS) \
|
|
$(LIBXML2_LIBS) \
|
|
$(LIBINTL) \
|
|
-lgnu
|
|
|
|
OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR)
|
|
|
|
if !HAVE_OCAMLOPT
|
|
OBJECTS = $(BOBJECTS)
|
|
BEST = c
|
|
OCAMLLINKFLAGS = mlguestfs.cma -custom
|
|
else
|
|
OBJECTS = $(XOBJECTS)
|
|
BEST = opt
|
|
OCAMLLINKFLAGS = mlguestfs.cmxa
|
|
endif
|
|
|
|
dummy_DEPENDENCIES = $(OBJECTS) $(top_srcdir)/ocaml-link.sh
|
|
dummy_LINK = \
|
|
$(top_srcdir)/ocaml-link.sh -cclib '$(OCAMLCLIBS)' -- \
|
|
$(OCAMLFIND) $(BEST) $(OCAMLFLAGS) $(OCAMLPACKAGES) $(OCAMLLINKFLAGS) \
|
|
$(OBJECTS) -o $@
|
|
|
|
# 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.
|
|
|
|
common_utils_tests_SOURCES = \
|
|
dev_t-c.c \
|
|
dummy.c
|
|
common_utils_tests_CPPFLAGS = \
|
|
-I. \
|
|
-I$(top_builddir) \
|
|
-I$(shell $(OCAMLC) -where)
|
|
common_utils_tests_BOBJECTS = \
|
|
guestfs_config.cmo \
|
|
common_gettext.cmo \
|
|
dev_t.cmo \
|
|
common_utils.cmo \
|
|
common_utils_tests.cmo
|
|
common_utils_tests_XOBJECTS = $(common_utils_tests_BOBJECTS:.cmo=.cmx)
|
|
|
|
JSON_tests_SOURCES = dummy.c
|
|
JSON_tests_BOBJECTS = \
|
|
JSON.cmo \
|
|
JSON_tests.cmo
|
|
JSON_tests_XOBJECTS = $(JSON_tests_BOBJECTS:.cmo=.cmx)
|
|
|
|
# Can't call the following as <test>_OBJECTS because automake gets confused.
|
|
if HAVE_OCAMLOPT
|
|
common_utils_tests_THEOBJECTS = $(common_utils_tests_XOBJECTS)
|
|
common_utils_tests.cmx: OCAMLPACKAGES += $(OCAMLPACKAGES_TESTS)
|
|
|
|
JSON_tests_THEOBJECTS = $(JSON_tests_XOBJECTS)
|
|
JSON_tests.cmx: OCAMLPACKAGES += $(OCAMLPACKAGES_TESTS)
|
|
else
|
|
common_utils_tests_THEOBJECTS = $(common_utils_tests_BOBJECTS)
|
|
common_utils_tests.cmo: OCAMLPACKAGES += $(OCAMLPACKAGES_TESTS)
|
|
|
|
JSON_tests_THEOBJECTS = $(JSON_tests_BOBJECTS)
|
|
JSON_tests.cmo: OCAMLPACKAGES += $(OCAMLPACKAGES_TESTS)
|
|
endif
|
|
|
|
common_utils_tests_DEPENDENCIES = $(common_utils_tests_THEOBJECTS) $(top_srcdir)/ocaml-link.sh
|
|
common_utils_tests_LINK = \
|
|
$(top_srcdir)/ocaml-link.sh -- \
|
|
$(OCAMLFIND) $(BEST) $(OCAMLFLAGS) $(OCAMLPACKAGES) $(OCAMLPACKAGES_TESTS) $(OCAMLLINKFLAGS) \
|
|
$(common_utils_tests_THEOBJECTS) -o $@
|
|
|
|
JSON_tests_DEPENDENCIES = $(JSON_tests_THEOBJECTS) $(top_srcdir)/ocaml-link.sh
|
|
JSON_tests_LINK = \
|
|
$(top_srcdir)/ocaml-link.sh -- \
|
|
$(OCAMLFIND) $(BEST) $(OCAMLFLAGS) $(OCAMLPACKAGES) $(OCAMLPACKAGES_TESTS) $(OCAMLLINKFLAGS) \
|
|
$(JSON_tests_THEOBJECTS) -o $@
|
|
|
|
TESTS_ENVIRONMENT = $(top_builddir)/run --test
|
|
|
|
TESTS =
|
|
check_PROGRAMS =
|
|
|
|
if HAVE_OCAML_PKG_OUNIT
|
|
check_PROGRAMS += common_utils_tests JSON_tests
|
|
TESTS += common_utils_tests JSON_tests
|
|
endif
|
|
|
|
CLEANFILES += oUnit-*
|
|
|
|
check-valgrind:
|
|
$(MAKE) VG="$(top_builddir)/run @VG@" check
|
|
|
|
# Dependencies.
|
|
depend: .depend
|
|
|
|
.depend: $(wildcard $(abs_srcdir)/*.mli) $(wildcard $(abs_srcdir)/*.ml)
|
|
rm -f $@ $@-t
|
|
$(OCAMLFIND) ocamldep -I ../ocaml -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
|
|
|
|
endif
|
|
|
|
DISTCLEANFILES = .depend
|
|
|
|
.PHONY: depend docs
|