-# mclu (mini cluster)
-# Copyright (C) 2014 Red Hat Inc.
+# mclu: Mini Cloud
+# Copyright (C) 2014-2015 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
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+CLEANFILES = *~ *.cmi *.cmo *.cmx
+
ACLOCAL_AMFLAGS = -I m4
-# Why doesn't automake include _SCRIPTS and _DATA ...?
-EXTRA_DIST = mclu.spec $(pkgdata_SCRIPTS) $(conf_DATA)
-
-# This rule just ensures that the wrapper binary and Python files get
-# installed when we do 'make install'.
-
-bin_SCRIPTS = mclu
-
-pkgdata_SCRIPTS = \
- config.py \
- lib.py \
- mclu.py \
- mclu_build.py \
- mclu_console.py \
- mclu_info.py \
- mclu_list.py \
- mclu_migrate.py \
- mclu_shutdown.py \
- mclu_start.py \
- mclu_status.py \
- mclu_stop.py \
- mclu_viewer.py \
- mclu_wake.py \
- node.py
+EXTRA_DIST = \
+ $(SOURCES_MLI) \
+ $(SOURCES_ML) \
+ templates/rawhide.sh
-# Configuration file.
+# In alphabetical order.
+SOURCES_MLI = \
+ mclu_boot.mli \
+ mclu_conf.mli \
+ mclu_console.mli \
+ mclu_list.mli \
+ mclu_onoff.mli \
+ mclu_status.mli \
+ parallel.mli \
+ template.mli \
+ utils.mli
+
+# These must appear in dependency order.
+SOURCES_ML = \
+ config.ml \
+ utils.ml \
+ parallel.ml \
+ template.ml \
+ mclu_conf.ml \
+ mclu_list.ml \
+ mclu_status.ml \
+ mclu_onoff.ml \
+ mclu_boot.ml \
+ mclu_console.ml \
+ mclu.ml
+
+OCAMLPACKAGES = -package unix,pcre,libvirt
+OCAMLFLAGS = -g -warn-error CDEFLMPSUVYZX-3
+
+BOBJECTS = $(SOURCES_ML:.ml=.cmo)
+XOBJECTS = $(BOBJECTS:.cmo=.cmx)
+if !HAVE_OCAMLOPT
+OBJECTS = $(BOBJECTS)
+BEST = ocamlc
+else
+OBJECTS = $(XOBJECTS)
+BEST = ocamlopt
+endif
+
+bin_PROGRAMS = mclu
+# Since there are no real C sources (at least, not yet) we have a
+# token C file that is empty, just to keep automake happy. The real
+# sources are *.ml files.
+mclu_SOURCES = empty.c
+mclu_DEPENDENCIES = $(OBJECTS)
+mclu_LINK = \
+ ./link.sh \
+ $(OCAMLFIND) $(BEST) $(OCAMLFLAGS) $(OCAMLPACKAGES) \
+ $(OBJECTS) -o $@
-confdir = $(sysconfdir)/$(PACKAGE_NAME)
-conf_DATA = mclu.conf
+.mli.cmi:
+ $(OCAMLFIND) ocamlc $(OCAMLFLAGS) $(OCAMLPACKAGES) -c $< -o $@
+.ml.cmo:
+ $(OCAMLFIND) ocamlc $(OCAMLFLAGS) $(OCAMLPACKAGES) -c $< -o $@
+if HAVE_OCAMLOPT
+.ml.cmx:
+ $(OCAMLFIND) ocamlopt $(OCAMLFLAGS) $(OCAMLPACKAGES) -c $< -o $@
+endif
+
+# Dependencies.
+depend: .depend
+
+.depend: $(SOURCES_MLI) $(SOURCES_ML)
+ rm -f $@ $@-t
+ $(OCAMLFIND) ocamldep -I $(abs_srcdir) -I . $^ | \
+ $(SED) 's/ *$$//' | \
+ $(SED) -e :a -e '/ *\\$$/N; s/ *\\\n */ /; ta' | \
+ $(SED) -e 's,$(abs_srcdir)/,$(builddir)/,g' | \
+ sort > $@-t
+ mv $@-t $@
+
+-include .depend
+
+DISTCLEANFILES = .depend
+.PHONY: depend
+
+# Configuration file.
+sysconf_DATA = mclu.conf
-install-data-hook:
- mkdir -p $(DESTDIR)/$(sysconfdir)/$(PACKAGE_NAME)/xmls
+# Documentation.
+man_MANS = mclu.1
-CLEANFILES = \
- *~ \
- *.pyc \
- config.py \
- mclu \
- mclu.spec
+mclu.1: mclu.pod
+ $(POD2MAN) \
+ -c "Virtualization Support" \
+ --release "$(PACKAGE)-$(VERSION)" \
+ $< > $@-t
+ mv $@-t $@