diff options
author | Richard Jones <rjones@trick.home.annexia.org> | 2009-10-06 15:04:25 +0100 |
---|---|---|
committer | Richard Jones <rjones@trick.home.annexia.org> | 2009-10-06 15:04:25 +0100 |
commit | d0381948857fa48c1c1e24cac01997a57c067403 (patch) | |
tree | 3ff23924ba8a316e24eb754da68b9c59e7899a77 | |
parent | 9f869ebd731800a0307842f3997da084a98ffe86 (diff) | |
download | virt-top-d0381948857fa48c1c1e24cac01997a57c067403.tar.gz virt-top-d0381948857fa48c1c1e24cac01997a57c067403.tar.xz virt-top-d0381948857fa48c1c1e24cac01997a57c067403.zip |
Change over to using ocaml.m4 macros.
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | aclocal.m4 | 170 | ||||
-rw-r--r-- | configure.ac | 33 | ||||
-rw-r--r-- | m4/ocaml.m4 | 217 | ||||
-rwxr-xr-x | virt-top/Makefile.in | 25 |
5 files changed, 248 insertions, 198 deletions
@@ -10,6 +10,7 @@ config.cache Makefile Make.rules */Makefile +aclocal.m4 autom4te.cache core core.* diff --git a/aclocal.m4 b/aclocal.m4 deleted file mode 100644 index 38ad15f..0000000 --- a/aclocal.m4 +++ /dev/null @@ -1,170 +0,0 @@ -dnl autoconf macros for OCaml -dnl by Olivier Andrieu -dnl modified by Richard W.M. Jones -dnl from a configure.in by Jean-Christophe Filliâtre, -dnl from a first script by Georges Mariano -dnl -dnl defines AC_PROG_OCAML that will check the OCaml compiler -dnl and set the following variables : -dnl OCAMLC "ocamlc" if present in the path, or a failure -dnl or "ocamlc.opt" if present with same version number as ocamlc -dnl OCAMLOPT "ocamlopt" (or "ocamlopt.opt" if present), or "no" -dnl OCAMLBEST either "byte" if no native compiler was found, -dnl or "opt" otherwise -dnl OCAMLDEP "ocamldep" -dnl OCAMLLIB the path to the ocaml standard library -dnl OCAMLVERSION the ocaml version number -AC_DEFUN(AC_PROG_OCAML, -[dnl -# checking for ocamlc -AC_CHECK_PROG(OCAMLC,ocamlc,ocamlc,AC_MSG_ERROR(Cannot find ocamlc.)) -OCAMLVERSION=`$OCAMLC -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' ` -AC_MSG_RESULT(OCaml version is $OCAMLVERSION) -OCAMLLIB=`$OCAMLC -where 2>/dev/null || $OCAMLC -v|tail -1|cut -d ' ' -f 4` -AC_MSG_RESULT(OCaml library path is $OCAMLLIB) -# checking for ocamlopt -AC_CHECK_PROG(OCAMLOPT,ocamlopt,ocamlopt) -OCAMLBEST=byte -if test -z "$OCAMLOPT"; then - AC_MSG_WARN(Cannot find ocamlopt; bytecode compilation only.) -else - TMPVERSION=`$OCAMLOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' ` - if test "$TMPVERSION" != "$OCAMLVERSION" ; then - AC_MSG_RESULT(versions differs from ocamlc; ocamlopt discarded.) - unset OCAMLOPT - else - OCAMLBEST=opt - fi -fi -# checking for ocamlc.opt -AC_CHECK_PROG(OCAMLCDOTOPT,ocamlc.opt,ocamlc.opt) -if test -z "$OCAMLCDOTOPT"; then - TMPVERSION=`$OCAMLCDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' ` - if test "$TMPVERSION" != "$OCAMLVERSION" ; then - AC_MSG_RESULT(versions differs from ocamlc; ocamlc.opt discarded.) - else - OCAMLC=$OCAMLCDOTOPT - fi -fi -# checking for ocamlopt.opt -if test "$OCAMLOPT" ; then - AC_CHECK_PROG(OCAMLOPTDOTOPT,ocamlopt.opt,ocamlopt.opt) - if test "$OCAMLOPTDOTOPT"; then - TMPVER=`$OCAMLOPTDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' ` - if test "$TMPVER" != "$OCAMLVERSION" ; then - AC_MSG_RESULT(version differs from ocamlc; ocamlopt.opt discarded.) - else - OCAMLOPT=$OCAMLOPTDOTOPT - fi - fi -fi -# checking for ocamldep -AC_CHECK_PROG(OCAMLDEP,ocamldep,ocamldep,AC_MSG_ERROR(Cannot find ocamldep.)) - -#checking for ocamlmktop -AC_CHECK_PROG(OCAMLMKTOP,ocamlmktop,ocamlmktop, AC_MSG_WARN(Cannot find ocamlmktop.)) -#checking for ocamlmklib -AC_CHECK_PROG(OCAMLMKLIB,ocamlmklib,ocamlmklib, AC_MSG_WARN(Cannot find ocamlmklib.)) -# checking for ocamldoc -AC_CHECK_PROG(OCAMLDOC,ocamldoc,ocamldoc, AC_MSG_WARN(Cannot find ocamldoc.)) - - -AC_SUBST(OCAMLC) -AC_SUBST(OCAMLOPT) -AC_SUBST(OCAMLDEP) -AC_SUBST(OCAMLBEST) -AC_SUBST(OCAMLVERSION) -AC_SUBST(OCAMLLIB) -AC_SUBST(OCAMLMKLIB) -AC_SUBST(OCAMLDOC) -]) - - -dnl macro AC_PROG_OCAML_TOOLS will check OCamllex and OCamlyacc : -dnl OCAMLLEX "ocamllex" or "ocamllex.opt" if present -dnl OCAMLYACC "ocamlyac" -AC_DEFUN(AC_PROG_OCAML_TOOLS, -[dnl -# checking for ocamllex and ocamlyacc -AC_CHECK_PROG(OCAMLLEX,ocamllex,ocamllex) -if test "$OCAMLLEX"; then - AC_CHECK_PROG(OCAMLLEXDOTOPT,ocamllex.opt,ocamllex.opt) - if test "$OCAMLLEXDOTOPT"; then - OCAMLLEX=$OCAMLLEXDOTOPT - fi -else - AC_MSG_ERROR(Cannot find ocamllex.) -fi -AC_CHECK_PROG(OCAMLYACC,ocamlyacc,ocamlyacc,AC_MSG_ERROR(Cannot find ocamlyacc.)) -AC_SUBST(OCAMLLEX) -AC_SUBST(OCAMLYACC) -]) - - -dnl AC_PROG_CAMLP4 checks for Camlp4 -AC_DEFUN(AC_PROG_CAMLP4, -[dnl -AC_REQUIRE([AC_PROG_OCAML]) -# checking for camlp4 -AC_CHECK_PROG(CAMLP4,camlp4,camlp4) -if test "$CAMLP4"; then - TMPVERSION=`$CAMLP4 -v 2>&1| sed -n -e 's|.*version *\(.*\)$|\1|p'` - if test "$TMPVERSION" != "$OCAMLVERSION" ; then - AC_MSG_RESULT(versions differs from ocamlc) - fi -fi -]) - - -dnl macro AC_PROG_FINDLIB will check for the presence of -dnl ocamlfind -AC_DEFUN(AC_PROG_FINDLIB, -[dnl -# checking for ocamlfind -AC_CHECK_PROG(OCAMLFIND,ocamlfind,ocamlfind, - AC_MSG_WARN([ocamlfind not found])) -AC_SUBST(OCAMLFIND) -]) - - -dnl AC_CHECK_OCAML_PKG checks wether a findlib package is present -dnl defines pkg_name to "yes" -AC_DEFUN(AC_CHECK_OCAML_PKG, -[dnl -AC_REQUIRE([AC_PROG_FINDLIB]) -AC_MSG_CHECKING(findlib package $1) -if $OCAMLFIND query $1 >/dev/null 2>/dev/null; then -AC_MSG_RESULT(found) -eval "pkg_`echo $1 | tr - _`=yes" -else -AC_MSG_RESULT(not found) -eval "pkg_`echo $1 | tr - _`=no" -fi -]) - - -dnl AC_CHECK_OCAML_MODULE looks for a module in a given path -dnl 1st arg -> name (just for printing messages) -dnl 2nd arg -> env var name (set to include path, or "no" if not found) -dnl 3rd arg -> module to check -dnl 4th arg -> default include dirs to check -AC_DEFUN([AC_CHECK_OCAML_MODULE], -[dnl -AC_MSG_CHECKING(for module $1) -cat > conftest.ml <<EOF -open $3 -EOF -unset found -for $2 in $$2 $4 ; do - if $OCAMLC -c -I "$$2" conftest.ml >&5 2>&5 ; then - found=yes - break - fi -done -if test "$found" ; then - AC_MSG_RESULT($$2) -else - AC_MSG_RESULT(not found) - $2=no -fi -AC_SUBST($2)]) diff --git a/configure.ac b/configure.ac index 7b698fa..e68dcf3 100644 --- a/configure.ac +++ b/configure.ac @@ -18,6 +18,7 @@ dnl Process this file with autoconf to produce a configure script. AC_INIT(virt-top,1.0.4) +AC_CONFIG_MACRO_DIR([m4]) AC_PROG_INSTALL @@ -33,22 +34,22 @@ dnl Use ocamlfind to find the required packages ... dnl Check for required OCaml packages. AC_CHECK_OCAML_PKG(unix) -if test "x$pkg_unix" != "xyes"; then +if test "x$OCAML_PKG_unix" = "xno"; then AC_MSG_ERROR([Cannot find required OCaml package 'unix']) fi AC_CHECK_OCAML_PKG(extlib) -if test "x$pkg_extlib" != "xyes"; then +if test "x$OCAML_PKG_extlib" = "xno"; then AC_MSG_ERROR([Cannot find required OCaml package 'extlib']) fi AC_CHECK_OCAML_PKG(libvirt) -if test "x$pkg_libvirt" != "xyes"; then +if test "x$OCAML_PKG_libvirt" = "xno"; then AC_MSG_ERROR([Cannot find required OCaml package 'libvirt']) fi AC_CHECK_OCAML_PKG(curses) -if test "x$pkg_curses" != "xyes"; then +if test "x$OCAML_PKG_curses" = "xno"; then AC_MSG_ERROR([Cannot find required OCaml package 'curses']) fi @@ -58,19 +59,19 @@ AC_CHECK_OCAML_PKG(xml-light) AC_CHECK_OCAML_PKG(csv) dnl Need to check which version of calendar is installed. -AC_CHECK_OCAML_MODULE(calendar,pkg_calendar2,CalendarLib.Date,[+calendar]) -if test "x$pkg_calendar2" = "xno"; then - AC_CHECK_OCAML_PKG(calendar) +AC_CHECK_OCAML_PKG(calendar) +if test "x$OCAML_PKG_calendar" != "xno"; then + AC_CHECK_OCAML_MODULE(is_calendar2,calendar,[CalendarLib.Date],[+$OCAML_PKG_calendar]) fi -AC_SUBST(pkg_unix) -AC_SUBST(pkg_extlib) -AC_SUBST(pkg_curses) -AC_SUBST(pkg_gettext) -AC_SUBST(pkg_xml_light) -AC_SUBST(pkg_csv) -AC_SUBST(pkg_calendar) -AC_SUBST(pkg_calendar2) +AC_SUBST(OCAML_PKG_unix) +AC_SUBST(OCAML_PKG_extlib) +AC_SUBST(OCAML_PKG_curses) +AC_SUBST(OCAML_PKG_gettext) +AC_SUBST(OCAML_PKG_xml_light) +AC_SUBST(OCAML_PKG_csv) +AC_SUBST(OCAML_PKG_calendar) +AC_SUBST(is_calendar2) dnl Check for optional perldoc (for building manual pages). AC_CHECK_PROG(HAVE_PERLDOC,perldoc,perldoc) @@ -178,7 +179,7 @@ for d in virt-top; do AC_MSG_NOTICE([creating $d/$f]) rm -f $d/$f echo "(* This file is generated automatically by ./configure. *)" > $d/$f - if test "x$pkg_gettext" != "xno"; then + if test "x$OCAML_PKG_gettext" != "xno"; then # Gettext module is available, so use it. cat <<EOT >>$d/$f module Gettext = Gettext.Program ( diff --git a/m4/ocaml.m4 b/m4/ocaml.m4 new file mode 100644 index 0000000..fa8c4ce --- /dev/null +++ b/m4/ocaml.m4 @@ -0,0 +1,217 @@ +dnl autoconf macros for OCaml +dnl +dnl Copyright © 2009 Richard W.M. Jones +dnl Copyright © 2009 Stefano Zacchiroli +dnl Copyright © 2000-2005 Olivier Andrieu +dnl Copyright © 2000-2005 Jean-Christophe Filliâtre +dnl Copyright © 2000-2005 Georges Mariano +dnl +dnl For documentation, please read the ocaml.m4 man page. + +AC_DEFUN([AC_PROG_OCAML], +[dnl + # checking for ocamlc + AC_CHECK_TOOL([OCAMLC],[ocamlc],[no]) + + if test "$OCAMLC" != "no"; then + OCAMLVERSION=`$OCAMLC -v | sed -n -e 's|.*version* *\(.*\)$|\1|p'` + AC_MSG_RESULT([OCaml version is $OCAMLVERSION]) + OCAMLLIB=`$OCAMLC -where 2>/dev/null || $OCAMLC -v|tail -1|cut -d ' ' -f 4` + AC_MSG_RESULT([OCaml library path is $OCAMLLIB]) + + AC_SUBST([OCAMLVERSION]) + AC_SUBST([OCAMLLIB]) + + # checking for ocamlopt + AC_CHECK_TOOL([OCAMLOPT],[ocamlopt],[no]) + OCAMLBEST=byte + if test "$OCAMLOPT" = "no"; then + AC_MSG_WARN([Cannot find ocamlopt; bytecode compilation only.]) + else + TMPVERSION=`$OCAMLOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' ` + if test "$TMPVERSION" != "$OCAMLVERSION" ; then + AC_MSG_RESULT([versions differs from ocamlc; ocamlopt discarded.]) + OCAMLOPT=no + else + OCAMLBEST=opt + fi + fi + + AC_SUBST([OCAMLBEST]) + + # checking for ocamlc.opt + AC_CHECK_TOOL([OCAMLCDOTOPT],[ocamlc.opt],[no]) + if test "$OCAMLCDOTOPT" != "no"; then + TMPVERSION=`$OCAMLCDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' ` + if test "$TMPVERSION" != "$OCAMLVERSION" ; then + AC_MSG_RESULT([versions differs from ocamlc; ocamlc.opt discarded.]) + else + OCAMLC=$OCAMLCDOTOPT + fi + fi + + # checking for ocamlopt.opt + if test "$OCAMLOPT" != "no" ; then + AC_CHECK_TOOL([OCAMLOPTDOTOPT],[ocamlopt.opt],[no]) + if test "$OCAMLOPTDOTOPT" != "no"; then + TMPVERSION=`$OCAMLOPTDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' ` + if test "$TMPVERSION" != "$OCAMLVERSION" ; then + AC_MSG_RESULT([version differs from ocamlc; ocamlopt.opt discarded.]) + else + OCAMLOPT=$OCAMLOPTDOTOPT + fi + fi + fi + + AC_SUBST([OCAMLOPT]) + fi + + AC_SUBST([OCAMLC]) + + # checking for ocamldep + AC_CHECK_TOOL([OCAMLDEP],[ocamldep],[no]) + + # checking for ocamlmktop + AC_CHECK_TOOL([OCAMLMKTOP],[ocamlmktop],[no]) + + # checking for ocamlmklib + AC_CHECK_TOOL([OCAMLMKLIB],[ocamlmklib],[no]) + + # checking for ocamldoc + AC_CHECK_TOOL([OCAMLDOC],[ocamldoc],[no]) + + # checking for ocamlbuild + AC_CHECK_TOOL([OCAMLBUILD],[ocamlbuild],[no]) +]) + + +AC_DEFUN([AC_PROG_OCAMLLEX], +[dnl + # checking for ocamllex + AC_CHECK_TOOL([OCAMLLEX],[ocamllex],[no]) + if test "$OCAMLLEX" != "no"; then + AC_CHECK_TOOL([OCAMLLEXDOTOPT],[ocamllex.opt],[no]) + if test "$OCAMLLEXDOTOPT" != "no"; then + OCAMLLEX=$OCAMLLEXDOTOPT + fi + fi + AC_SUBST([OCAMLLEX]) +]) + +AC_DEFUN([AC_PROG_OCAMLYACC], +[dnl + AC_CHECK_TOOL([OCAMLYACC],[ocamlyacc],[no]) + AC_SUBST([OCAMLYACC]) +]) + + +AC_DEFUN([AC_PROG_CAMLP4], +[dnl + AC_REQUIRE([AC_PROG_OCAML])dnl + + # checking for camlp4 + AC_CHECK_TOOL([CAMLP4],[camlp4],[no]) + if test "$CAMLP4" != "no"; then + TMPVERSION=`$CAMLP4 -v 2>&1| sed -n -e 's|.*version *\(.*\)$|\1|p'` + if test "$TMPVERSION" != "$OCAMLVERSION" ; then + AC_MSG_RESULT([versions differs from ocamlc]) + CAMLP4=no + fi + fi + AC_SUBST([CAMLP4]) + + # checking for companion tools + AC_CHECK_TOOL([CAMLP4BOOT],[camlp4boot],[no]) + AC_CHECK_TOOL([CAMLP4O],[camlp4o],[no]) + AC_CHECK_TOOL([CAMLP4OF],[camlp4of],[no]) + AC_CHECK_TOOL([CAMLP4OOF],[camlp4oof],[no]) + AC_CHECK_TOOL([CAMLP4ORF],[camlp4orf],[no]) + AC_CHECK_TOOL([CAMLP4PROF],[camlp4prof],[no]) + AC_CHECK_TOOL([CAMLP4R],[camlp4r],[no]) + AC_CHECK_TOOL([CAMLP4RF],[camlp4rf],[no]) + AC_SUBST([CAMLP4BOOT]) + AC_SUBST([CAMLP4O]) + AC_SUBST([CAMLP4OF]) + AC_SUBST([CAMLP4OOF]) + AC_SUBST([CAMLP4ORF]) + AC_SUBST([CAMLP4PROF]) + AC_SUBST([CAMLP4R]) + AC_SUBST([CAMLP4RF]) +]) + + +AC_DEFUN([AC_PROG_FINDLIB], +[dnl + AC_REQUIRE([AC_PROG_OCAML])dnl + + # checking for ocamlfind + AC_CHECK_TOOL([OCAMLFIND],[ocamlfind],[no]) + AC_SUBST([OCAMLFIND]) +]) + + +dnl Thanks to Jim Meyering for working this next bit out for us. +dnl XXX We should define AS_TR_SH if it's not defined already +dnl (eg. for old autoconf). +AC_DEFUN([AC_CHECK_OCAML_PKG], +[dnl + AC_REQUIRE([AC_PROG_FINDLIB])dnl + + AC_MSG_CHECKING([for OCaml findlib package $1]) + + unset found + unset pkg + found=no + for pkg in $1 $2 ; do + if $OCAMLFIND query $pkg >/dev/null 2>/dev/null; then + AC_MSG_RESULT([found]) + AS_TR_SH([OCAML_PKG_$1])=$pkg + found=yes + break + fi + done + if test "$found" = "no" ; then + AC_MSG_RESULT([not found]) + AS_TR_SH([OCAML_PKG_$1])=no + fi + + AC_SUBST(AS_TR_SH([OCAML_PKG_$1])) +]) + + +AC_DEFUN([AC_CHECK_OCAML_MODULE], +[dnl + AC_MSG_CHECKING([for OCaml module $2]) + + cat > conftest.ml <<EOF +open $3 +EOF + unset found + for $1 in $$1 $4 ; do + if $OCAMLC -c -I "$$1" conftest.ml >&5 2>&5 ; then + found=yes + break + fi + done + + if test "$found" ; then + AC_MSG_RESULT([$$1]) + else + AC_MSG_RESULT([not found]) + $1=no + fi + AC_SUBST([$1]) +]) + + +dnl XXX Cross-compiling +AC_DEFUN([AC_CHECK_OCAML_WORD_SIZE], +[dnl + AC_MSG_CHECKING([for OCaml compiler word size]) + cat > conftest.ml <<EOF + print_endline (string_of_int Sys.word_size) + EOF + OCAML_WORD_SIZE=`ocaml conftest.ml` + AC_MSG_RESULT([$OCAML_WORD_SIZE]) + AC_SUBST([OCAML_WORD_SIZE]) +]) diff --git a/virt-top/Makefile.in b/virt-top/Makefile.in index 64c222e..0d0ccdc 100755 --- a/virt-top/Makefile.in +++ b/virt-top/Makefile.in @@ -25,16 +25,16 @@ prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ -pkg_curses = @pkg_curses@ -pkg_xml_light = @pkg_xml_light@ -pkg_csv = @pkg_csv@ -pkg_calendar = @pkg_calendar@ -pkg_calendar2 = @pkg_calendar2@ -pkg_gettext = @pkg_gettext@ +OCAML_PKG_curses = @OCAML_PKG_curses@ +OCAML_PKG_xml_light = @OCAML_PKG_xml_light@ +OCAML_PKG_csv = @OCAML_PKG_csv@ +OCAML_PKG_calendar = @OCAML_PKG_calendar@ +is_calendar2 = @is_calendar2@ +OCAML_PKG_gettext = @OCAML_PKG_gettext@ OCAMLCPACKAGES := -package unix,extlib,curses,str,libvirt -ifeq ($(pkg_gettext),yes) +ifneq ($(OCAML_PKG_gettext),no) OCAMLCPACKAGES += -package gettext-stub endif @@ -43,22 +43,23 @@ OBJS := \ virt_top_gettext.cmo \ virt_top_utils.cmo \ virt_top.cmo -ifeq ($(pkg_xml_light),yes) +ifneq ($(OCAML_PKG_xml_light),no) OBJS += virt_top_xml.cmo OCAMLCPACKAGES += -package xml-light endif -ifeq ($(pkg_csv),yes) +ifneq ($(OCAML_PKG_csv),no) OBJS += virt_top_csv.cmo OCAMLCPACKAGES += -package csv endif -ifeq ($(pkg_calendar),yes) +ifneq ($(OCAML_PKG_calendar),no) +ifeq ($(is_calendar2),no) OBJS += virt_top_calendar1.cmo OCAMLCPACKAGES += -package calendar -endif -ifneq ($(pkg_calendar2),no) +else OBJS += virt_top_calendar2.cmo OCAMLCPACKAGES += -package calendar endif +endif OBJS += virt_top_main.cmo XOBJS := $(OBJS:.cmo=.cmx) |