#583265 ocaml.m4: cross-compilation still chooses build system tools instead of host tools

#583265#5
Date:
2010-05-26 17:46:16 UTC
From:
To:
Debian has both ocamlc and ocamlc.opt. Configure (built using ocaml.m4 from
ocaml-tools) correctly finds the location of ocamlc, and others, however it
OVERRIDES them with the ocamlc.opt executables.
These are host executables (they lack the cross prefix too), and there is no
.opt variant for the i586-mingw32msvc target.
Configure shouldn't override an ocamlc/ocamlopt it has found for one target
(i586-mingw32msvc) with an ocamlc.opt/ocamlopt.opt it has found for another
target (Debian x86_64-linux-gnu).

To reproduce:
./configure --host=i586-mingw32msvc --target=i586-mingw32msvc --build=x86_64-linux-gnu
checking for i586-mingw32msvc-ocamlc... i586-mingw32msvc-ocamlc
OCaml version is 3.11.2
OCaml library path is /usr/i586-mingw32msvc/lib/ocaml
checking for i586-mingw32msvc-ocamlopt... i586-mingw32msvc-ocamlopt
checking for i586-mingw32msvc-ocamlc.opt... no
checking for ocamlc.opt... ocamlc.opt
configure: WARNING: using cross tools not prefixed with host triplet
checking for i586-mingw32msvc-ocamlopt.opt... no
checking for ocamlopt.opt... ocamlopt.opt
checking for i586-mingw32msvc-ocaml... no
checking for ocaml... ocaml
checking for i586-mingw32msvc-ocamldep... i586-mingw32msvc-ocamldep
checking for i586-mingw32msvc-ocamlmktop... i586-mingw32msvc-ocamlmktop
checking for i586-mingw32msvc-ocamlmklib... i586-mingw32msvc-ocamlmklib
checking for i586-mingw32msvc-ocamldoc... no
checking for ocamldoc... ocamldoc
checking for i586-mingw32msvc-ocamlbuild... no
checking for ocamlbuild... ocamlbuild
checking for i586-mingw32msvc-ocamllex... no
checking for ocamllex... ocamllex
checking for i586-mingw32msvc-ocamllex.opt... no
checking for ocamllex.opt... ocamllex.opt
configure: creating ./config.status
config.status: creating Makefile

Files: configure.ac:
AC_INIT(ocaml-autoconf-example,1.0)

AC_PROG_OCAML
if test "$OCAMLC" = "no"; then
  AC_MSG_ERROR([Please install the OCaml compiler])
fi

if test "$OCAMLBUILD" = "no"; then
  AC_MSG_ERROR([Please install ocamlbuild])
fi

AC_PROG_OCAMLLEX

if test "$OCAMLLEX" = "no"; then
    AC_MSG_ERROR([Please install ocamllex])
fi

AC_SUBST([OCAMLBUILD])
AC_SUBST([OCAMLC])
AC_SUBST([OCAMLOPT])
AC_SUBST([OCAMLDEP])
AC_SUBST([OCAMLLEX])
if test "$OCAMLBEST" = "opt"; then
    AC_SUBST([OCAMLBEST], [native])
else
    AC_SUBST([OCAMLBEST], [byte])
fi

AC_CONFIG_FILES([Makefile])
AC_OUTPUT

Makefile.in:
OCAMLBUILD=@OCAMLBUILD@ -ocamlc @OCAMLC@ -ocamlopt @OCAMLOPT@ -ocamldep @OCAMLDEP@ -ocamllex @OCAMLLEX@
all:
	$(OCAMLBUILD) test.@OCAMLBEST@ $(MAKEFLAGS)
clean:
	$(OCAMLBUILD) -clean

#583265#10
Date:
2010-05-26 18:58:50 UTC
From:
To:
Attached is a patch that fixes this, by using AC_CHECK_TARGET_TOOL
instead of AC_CHECK_TOOL for all the compiler tools except ocamlc itself
(since bytecode should be portable doesn't matter which ocamlc is used).