Files
libguestfs/mllib/Makefile.am
2014-04-09 14:51:59 +01:00

180 lines
4.2 KiB
Makefile

# libguestfs OCaml tools common code
# Copyright (C) 2011-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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
include $(top_srcdir)/subdir-rules.mk
EXTRA_DIST = \
$(filter-out config.ml,$(SOURCES))
CLEANFILES = *~ *.cmi *.cmo *.cmx *.cmxa *.o
# Alphabetical order.
SOURCES = \
common_gettext.ml \
common_utils.ml \
common_utils_tests.ml \
config.ml \
fsync-c.c \
fsync.mli \
fsync.ml \
mkdtemp.mli \
mkdtemp.ml \
mkdtemp-c.c \
planner.mli \
planner.ml \
progress-c.c \
progress.mli \
progress.ml \
tty-c.c \
tTY.mli \
tTY.ml \
uri-c.c \
uRI.mli \
uRI.ml
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 \
tTY \
fsync \
progress \
uRI \
mkdtemp \
planner
OBJECTS = \
$(top_builddir)/fish/guestfish-progress.o \
$(top_builddir)/fish/guestfish-uri.o \
tty-c.o \
fsync-c.o \
progress-c.o \
uri-c.o \
mkdtemp-c.o
if HAVE_OCAMLOPT
OBJECTS += $(patsubst %,%.cmx,$(ocaml_modules))
else
OBJECTS += $(patsubst %,%.cmo,$(ocaml_modules))
endif
noinst_SCRIPTS = dummy
# -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
if HAVE_OCAML_PKG_GETTEXT
OCAMLPACKAGES += -package gettext-stub
endif
OCAMLCFLAGS = -g -warn-error CDEFLMPSUVYZX $(OCAMLPACKAGES)
OCAMLOPTFLAGS = $(OCAMLCFLAGS)
OCAMLCLIBS = \
$(LIBXML2_LIBS) -lncurses -lcrypt \
-L../src/.libs -lutils \
-L../gnulib/lib/.libs -lgnu
dummy: $(OBJECTS)
if HAVE_OCAMLOPT
$(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) \
mlguestfs.cmxa -linkpkg $^ \
-cclib '$(OCAMLCLIBS)' \
-o $@
else
$(OCAMLFIND) ocamlc $(OCAMLCFLAGS) \
mlguestfs.cma -linkpkg $^ \
-cclib '$(OCAMLCLIBS)' \
-custom \
-o $@
endif
.mli.cmi:
$(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -c $< -o $@
.ml.cmo:
$(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -c $< -o $@
.ml.cmx:
$(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) -c $< -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 $@
# automake will decide we don't need C support in this file. Really
# we do, so we have to provide it ourselves.
DEFAULT_INCLUDES = \
-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
if HAVE_OCAMLOPT
common_utils_tests: common_gettext.cmx common_utils.cmx common_utils_tests.cmx
$(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) \
mlguestfs.cmxa -linkpkg $^ -cclib -lncurses -o $@
else
common_utils_tests: common_gettext.cmo common_utils.cmo common_utils_tests.cmo
$(OCAMLFIND) ocamlc $(OCAMLCFLAGS) \
mlguestfs.cma -linkpkg $^ -cclib -lncurses -custom -o $@
endif
TESTS_ENVIRONMENT = $(top_builddir)/run --test
TESTS = common_utils_tests
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