From 4a8a66739db2ef06565f51d7d6e43c9bc27ca748 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 1 Jan 1970 00:00:00 +0000 Subject: [PATCH] Use autoconf to generate the Makefile. --- Makefile => Makefile.in | 36 +++++++--- aclocal.m4 | 170 ++++++++++++++++++++++++++++++++++++++++++++++++ configure.ac | 57 ++++++++++++++++ 3 files changed, 253 insertions(+), 10 deletions(-) rename Makefile => Makefile.in (89%) create mode 100644 aclocal.m4 create mode 100644 configure.ac diff --git a/Makefile b/Makefile.in similarity index 89% rename from Makefile rename to Makefile.in index f548710..13967ee 100644 --- a/Makefile +++ b/Makefile.in @@ -1,6 +1,7 @@ # Makefile for virt-p2v +# @configure_input@ # -# Copyright (C) 2007 Red Hat Inc. +# Copyright (C) 2007-2008 Red Hat Inc. # Written by Richard W.M. Jones # # This program is free software; you can redistribute it and/or modify @@ -16,14 +17,17 @@ # 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# $Id$ #---------------------------------------------------------------------- # General configuration -PACKAGE := virt-p2v -VERSION := 0.9.2 +PACKAGE := @PACKAGE@ +VERSION := @VERSION@ + +HAVE_PERLDOC := @HAVE_PERLDOC@ +HAVE_QEMU := @HAVE_QEMU@ +HAVE_QEMU_KVM := @HAVE_QEMU_KVM@ +HAVE_LIVECD_CREATOR := @HAVE_LIVECD_CREATOR@ # i386 images also work on x86-64, so best to stick with i386. ARCH := i386 @@ -36,11 +40,6 @@ LANG := en_US.UTF-8 KEYBOARD := us TIMEZONE := US/Eastern -# Select a suitable HTTP proxy. -# The default assumes a local squid proxy. -export http_proxy := http://127.0.0.1:3128/ -export ftp_proxy := http://127.0.0.1:3128/ - LABEL := $(PACKAGE)-$(VERSION) ISO := $(LABEL).iso @@ -57,6 +56,8 @@ all: # Build live CD. +ifeq ($(HAVE_LIVECD_CREATOR),livecd-creator) + build: checkroot checkscript livecd.ks rm -f $(ISO) livecd-creator --config=livecd.ks --fslabel=$(LABEL) @@ -88,9 +89,19 @@ livecd-post.sh: livecd-post.sh.in virt-p2v virt-p2v-update-wrapper iso-attach in -e '/@LVM.CONF@/ d' \ < $< > $@ +endif + # Run live CD under qemu. +ifeq ($(HAVE_QEMU_KVM),qemu-kvm) +QEMU := qemu-kvm +else +ifeq ($(HAVE_QEMU),qemu) QEMU := qemu +endif +endif + +ifneq ($(QEMU),) HDA := HDB := @@ -104,6 +115,7 @@ endif boot: $(QEMU) $(QEMU_ARGS) +endif # Update an existing ISO. @@ -149,6 +161,8 @@ check-manifest: # Manual page. +ifeq ($(HAVE_PERLDOC),perldoc) + MAN_SECTION := Virtualization Support man: virt-p2v.1 virt-p2v.1.txt virt-p2v.1.html @@ -162,6 +176,8 @@ virt-p2v.1.txt: virt-p2v.pod virt-p2v.1.html: virt-p2v.pod pod2html -css virt-p2v.1.css $< > $@ +endif + # Website. WEBSITE_DIR := ../redhat/et-website/virt-p2v diff --git a/aclocal.m4 b/aclocal.m4 new file mode 100644 index 0000000..38ad15f --- /dev/null +++ b/aclocal.m4 @@ -0,0 +1,170 @@ +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 <&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 new file mode 100644 index 0000000..be821a0 --- /dev/null +++ b/configure.ac @@ -0,0 +1,57 @@ +# virt-p2v +# Copyright (C) 2007-2008 Red Hat Inc., Richard W.M. Jones +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2 of the License, or (at your option) any later version. +# +# This library 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 +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +dnl Process this file with autoconf to produce a configure script. +AC_INIT(virt-p2v,0.9.2) + +dnl Check for basic OCaml script interpreter. +AC_PROG_OCAML + +dnl Check for required OCaml modules. +AC_CHECK_OCAML_MODULE(unix,pkg_unix,Unix,[.]) +if test "x$pkg_unix" = "xno"; then + AC_MSG_ERROR([Cannot find required OCaml package 'unix']) +fi + +AC_CHECK_OCAML_MODULE(extlib,pkg_extlib,ExtString,[+extlib]) +if test "x$pkg_extlib" = "xno"; then + AC_MSG_ERROR([Cannot find required OCaml package 'extlib']) +fi + +AC_CHECK_OCAML_MODULE(xml-light,pkg_xml_light,Xml,[+xml-light]) +if test "x$pkg_xml_light" = "xno"; then + AC_MSG_ERROR([Cannot find required OCaml package 'xml-light']) +fi + +dnl Check for recommended livecd-creator (for building ISOs). +AC_CHECK_PROG(HAVE_LIVECD_CREATOR,livecd-creator,livecd-creator) + +dnl Check for optional perldoc (for building manual pages). +AC_CHECK_PROG(HAVE_PERLDOC,perldoc,perldoc) + +dnl Check for optional qemu or qemu-kvm (for test-booting). +AC_CHECK_PROG(HAVE_QEMU,qemu,qemu) +AC_CHECK_PROG(HAVE_QEMU_KVM,qemu-kvm,qemu-kvm) + +dnl Summary. +echo "------------------------------------------------------------" +echo "Thanks for downloading" $PACKAGE_STRING +echo "------------------------------------------------------------" + +dnl Produce output files. +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT -- 1.8.3.1