Subject: m4: Fix ./configure --disable-ocaml From: Richard W.M. Jones rjones@redhat.com Wed Jul 20 09:23:37 2022 +0100 Date: Wed Jul 20 10:53:08 2022 +0100: Git: f162e47ecfee711f2c3bcc761de17e502fe7ab5e OCaml is required to compile libguestfs, however we should still be able to disable the OCaml bindings. This didn't work because using --disable-ocaml caused various configure tests to be skipped which are required to compile the daemon. In particular the check for caml_alloc_initialized_string, resulting in this error: pcre-c.c:47:1: error: static declaration of ‘caml_alloc_initialized_string’ follows non-static declaration caml_alloc_initialized_string (mlsize_t len, const char *p) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Also OCaml gettext is not required by libguestfs. There are no *.ml files used by libguestfs which require translation. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=2108425 Fixes: https://bugs.gentoo.org/820053 Fixes: commit 733d2182b64df7abc5c5cd7d78177baa6079628c (cherry picked from commit adfaf25a12b97b18f8a22d96803cd0920bfd25f7) diff --git a/Makefile.am b/Makefile.am index aac0d68fe..474f7a8da 100644 --- a/Makefile.am +++ b/Makefile.am @@ -37,7 +37,6 @@ SUBDIRS += include lib docs examples SUBDIRS += common/mlutils SUBDIRS += bundled/ocaml-augeas SUBDIRS += common/mlpcre -SUBDIRS += common/mlgettext if ENABLE_DAEMON SUBDIRS += daemon endif @@ -208,9 +207,8 @@ maintainer-upload-website: # docs/C_SOURCE_FILES # - source files scanned for internal documentation # po/POTFILES - files with ordinary extensions, but not OCaml files -# po/POTFILES-ml - OCaml files, which need a special tool to translate -dist-hook: docs/C_SOURCE_FILES po/POTFILES po/POTFILES-ml +dist-hook: docs/C_SOURCE_FILES po/POTFILES # This has to be in the top-level Makefile.am so that we have access # to DIST_SUBDIRS. @@ -446,6 +444,7 @@ maintainer-check-extra-dist: cd common; git ls-files | sed 's,^,common/,' ) | \ grep -v '^common$$' | \ grep -v '^common/mlcustomize/' | \ + grep -v '^common/mlgettext/' | \ grep -v '^common/mlprogress/' | \ grep -v '^common/mltools/' | \ grep -v '^common/mlv2v/' | \ diff --git a/configure.ac b/configure.ac index 60380c7f7..fed17dbb9 100644 --- a/configure.ac +++ b/configure.ac @@ -211,7 +211,6 @@ AC_CONFIG_FILES([Makefile bundled/ocaml-augeas/Makefile common/errnostring/Makefile common/edit/Makefile - common/mlgettext/Makefile common/mlpcre/Makefile common/mlstdutils/Makefile common/mlstdutils/guestfs_config.ml diff --git a/docs/guestfs-building.pod b/docs/guestfs-building.pod index b93a611a6..296a288e3 100644 --- a/docs/guestfs-building.pod +++ b/docs/guestfs-building.pod @@ -560,8 +560,7 @@ Note that disabling OCaml (bindings) or Perl will have the knock-on effect of disabling parts of the test suite and some tools. OCaml is required to build libguestfs and this requirement cannot be -removed. Using I<--disable-ocaml> only disables the bindings and -OCaml tools. +removed. Using I<--disable-ocaml> only disables the bindings. =item B<--disable-fuse> diff --git a/m4/guestfs-ocaml-gettext.m4 b/m4/guestfs-ocaml-gettext.m4 deleted file mode 100644 index ad1ca0d52..000000000 --- a/m4/guestfs-ocaml-gettext.m4 +++ /dev/null @@ -1,64 +0,0 @@ -# libguestfs -# Copyright (C) 2009-2020 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. - -dnl Write a common gettext module used by each OCaml tool. -dnl If OCaml gettext is not available then we write dummy functions. - -AC_DEFUN([GUESTFS_CREATE_COMMON_GETTEXT_ML],[ - dnl Check for ocaml-gettext package to translate OCaml tools. - AC_CHECK_OCAML_PKG(gettext) - - AC_MSG_NOTICE([creating $1]) - rm -f $1 - - cat < $1 -(* This file is generated automatically by ./configure. *) - -EOF - - if test "x$OCAML_PKG_gettext" != "xno"; then - # ocaml-gettext available: real module. - cat <>$1 -module Gettext = Gettext.Program ( - struct - let textdomain = "$PACKAGE_NAME" - let codeset = None - let dir = None - let dependencies = [[]] - end -) (GettextStub.Native) -EOF - else - # No gettext: module containing dummy gettext functions. - cat <>$1 -module Gettext = struct - external s_ : string -> string = "%identity" - external f_ : ('a, 'b, 'c, 'd, 'e, 'f) format6 - -> ('a, 'b, 'c, 'd, 'e, 'f) format6 - = "%identity" - let sn_ : string -> string -> int -> string - = fun s p n -> if n = 1 then s else p - let fn_ : ('a, 'b, 'c, 'd, 'e, 'f) format6 - -> ('a, 'b, 'c, 'd, 'e, 'f) format6 - -> int -> ('a, 'b, 'c, 'd, 'e, 'f) format6 - = fun s p n -> if n = 1 then s else p -end -EOF - fi - - chmod -w $1 -]) diff --git a/m4/guestfs-ocaml.m4 b/m4/guestfs-ocaml.m4 index 1023baebc..55508d6b9 100644 --- a/m4/guestfs-ocaml.m4 +++ b/m4/guestfs-ocaml.m4 @@ -15,7 +15,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -dnl Check for OCaml (required, for OCaml bindings and OCaml tools). +dnl Check for OCaml (required) dnl OCAMLC and OCAMLFIND have to be unset first, otherwise dnl AC_CHECK_TOOL (inside AC_PROG_OCAML) will not look. @@ -32,9 +32,9 @@ AS_IF([test "x$OCAMLFIND" = "xno"],[ AC_MSG_ERROR([OCaml findlib is required]) ]) -dnl --disable-ocaml only disables OCaml bindings and OCaml virt tools. +dnl --disable-ocaml only disables OCaml bindings. AC_ARG_ENABLE([ocaml], - AS_HELP_STRING([--disable-ocaml], [disable OCaml language bindings and tools]), + AS_HELP_STRING([--disable-ocaml], [disable OCaml language bindings]), [], [enable_ocaml=yes]) @@ -132,51 +132,29 @@ AS_IF([test "x$have_Hivex_OPEN_UNSAFE" = "xno"],[ ]) AC_SUBST([HIVEX_OPEN_UNSAFE_FLAG]) -OCAML_PKG_gettext=no -OCAML_PKG_ounit2=no -ounit_is_v2=no -AS_IF([test "x$OCAMLC" != "xno"],[ - # Create common/mlgettext/common_gettext.ml gettext functions or stubs. - - # If we're building in a different directory, then common/mlgettext - # might not exist yet, so create it: - mkdir -p common/mlgettext - - GUESTFS_CREATE_COMMON_GETTEXT_ML([common/mlgettext/common_gettext.ml]) - - AC_CHECK_OCAML_PKG(ounit2) - - # oUnit >= 2 is required, so check that it has OUnit2. - if test "x$OCAML_PKG_ounit2" != "xno"; then - AC_CHECK_OCAML_MODULE(ounit_is_v2,[OUnit.OUnit2],OUnit2,[+ounit2]) - fi -]) -AM_CONDITIONAL([HAVE_OCAML_PKG_GETTEXT], - [test "x$OCAML_PKG_gettext" != "xno"]) +# oUnit is optional, used by some tests in common/mlstdutils (that we +# should replace with regular tests one day). If used, oUnit >= 2 is +# required. +if test "x$OCAML_PKG_ounit2" != "xno"; then + AC_CHECK_OCAML_MODULE(ounit_is_v2,[OUnit.OUnit2],OUnit2,[+ounit2]) +fi AM_CONDITIONAL([HAVE_OCAML_PKG_OUNIT], [test "x$OCAML_PKG_ounit2" != "xno" && test "x$ounit_is_v2" != "xno"]) -AC_CHECK_PROG([OCAML_GETTEXT],[ocaml-gettext],[ocaml-gettext],[no]) -AM_CONDITIONAL([HAVE_OCAML_GETTEXT], - [test "x$OCAML_PKG_gettext" != "xno" && test "x$OCAML_GETTEXT" != "xno"]) - dnl Check if OCaml has caml_alloc_initialized_string (added 2017). -AS_IF([test "x$OCAMLC" != "xno" && test "x$OCAMLFIND" != "xno" && \ - test "x$enable_ocaml" = "xyes"],[ - AC_MSG_CHECKING([for caml_alloc_initialized_string]) - cat >conftest.c <<'EOF' +AC_MSG_CHECKING([for caml_alloc_initialized_string]) +cat >conftest.c <<'EOF' #include int main () { char *p = (void *) caml_alloc_initialized_string; return 0; } EOF - AS_IF([$OCAMLC conftest.c >&AS_MESSAGE_LOG_FD 2>&1],[ - AC_MSG_RESULT([yes]) - AC_DEFINE([HAVE_CAML_ALLOC_INITIALIZED_STRING],[1], - [caml_alloc_initialized_string found at compile time.]) - ],[ - AC_MSG_RESULT([no]) - ]) - rm -f conftest.c conftest.o +AS_IF([$OCAMLC conftest.c >&AS_MESSAGE_LOG_FD 2>&1],[ + AC_MSG_RESULT([yes]) + AC_DEFINE([HAVE_CAML_ALLOC_INITIALIZED_STRING],[1], + [caml_alloc_initialized_string found at compile time.]) +],[ + AC_MSG_RESULT([no]) ]) +rm -f conftest.c conftest.o dnl Flags we want to pass to every OCaml compiler call. OCAML_WARN_ERROR="-warn-error +C+D+E+F+L+M+P+S+U+V+Y+Z+X+52-3-6 -w -6" diff --git a/po/Makefile.am b/po/Makefile.am index f1509d60f..8b9c03720 100644 --- a/po/Makefile.am +++ b/po/Makefile.am @@ -26,13 +26,12 @@ MSGID_BUGS_ADDRESS = https://bugzilla.redhat.com/enter_bug.cgi?component=libgues linguas := $(shell cat $(srcdir)/LINGUAS) POTFILES := $(shell $(SED) 's,^,$(top_srcdir)/,' $(srcdir)/POTFILES) -POTFILES_ML := $(shell $(SED) 's,^,$(top_srcdir)/,' $(srcdir)/POTFILES-ml) POFILES := $(linguas:%=%.po) GMOFILES := $(linguas:%=%.gmo) EXTRA_DIST = \ LINGUAS \ - POTFILES POTFILES-ml \ + POTFILES \ $(DOMAIN).pot \ $(POFILES) \ $(GMOFILES) @@ -60,14 +59,9 @@ XGETTEXT_ARGS = \ FIX_CHARSET = \ $(SED) -i 's|text/plain; charset=CHARSET|text/plain; charset=utf-8|g' -$(DOMAIN).pot: Makefile POTFILES $(POTFILES) POTFILES-ml $(POTFILES_ML) +$(DOMAIN).pot: Makefile POTFILES $(POTFILES) rm -f $@-t touch $@-t -if HAVE_OCAML_GETTEXT - cd $(top_srcdir) && $(OCAML_GETTEXT) --action extract --extract-pot $(abs_srcdir)/$@-t $(shell cat $(abs_srcdir)/POTFILES-ml) - \ - $(FIX_CHARSET) $@-t -endif $(XGETTEXT) -j -o $@-t $(XGETTEXT_ARGS) \ --files-from=$(abs_srcdir)/POTFILES $(FIX_CHARSET) $@-t diff --git a/po/POTFILES-ml b/po/POTFILES-ml deleted file mode 100644 index 36932d142..000000000 --- a/po/POTFILES-ml +++ /dev/null @@ -1,6 +0,0 @@ -common/mlgettext/common_gettext.ml -common/mlpcre/PCRE.ml -common/mlstdutils/guestfs_config.ml -common/mlstdutils/std_utils.ml -common/mlstdutils/stringMap.ml -common/mlstdutils/stringSet.ml