From 922af4e1eefd77ebc8834771e4e02774aa8b5bf5 Mon Sep 17 00:00:00 2001 From: Virgile Prevosto <virgile.prevosto@m4x.org> Date: Tue, 24 Jul 2018 19:20:04 +0200 Subject: [PATCH] [Makefile] Let configure generate appropriate macros for testing OCaml features --- configure.in | 27 +++++++++++++++++++++++++++ share/Makefile.common | 15 --------------- share/Makefile.config.in | 9 +++++++++ 3 files changed, 36 insertions(+), 15 deletions(-) diff --git a/configure.in b/configure.in index 34ccef60b48..7dc81018123 100644 --- a/configure.in +++ b/configure.in @@ -131,6 +131,33 @@ case $OCAMLVERSION in ;; esac +AC_SUBST(OCAMLMAJORNB) +AC_SUBST(OCAMLMINORNB) +AC_SUBST(OCAMLPATCHNB) + +AC_SUBST(HAS_OCAML403) +AC_SUBST(HAS_OCAML407) + +OCAMLMAJORNB=$(echo $OCAMLVERSION | cut -f 1 -d .) +OCAMLMINORNB=$(echo $OCAMLVERSION | cut -f 2 -d .) +OCAMLPATCHNB=$(echo $OCAMLVERSION | cut -f 3 -d .) + +if test $OCAMLMAJORNB -gt 4; then + HAS_OCAML403=yes; + HAS_OCAML407=yes; +else if test $OCAMLMINORNB -lt 3; then + HAS_OCAML403=no; + HAS_OCAML407=no; +else + HAS_OCAML403=yes; + if test $OCAMLMINORNB -lt 7; then + HAS_OCAML407=no; + else + HAS_OCAML407=yes; + fi; +fi; +fi; + # Ocaml library path AC_MSG_CHECKING(OCaml library path) OCAMLLIB=`$OCAMLC -where | tr -d '\\r'` diff --git a/share/Makefile.common b/share/Makefile.common index 88a4ce4b2fa..d5061d699d1 100644 --- a/share/Makefile.common +++ b/share/Makefile.common @@ -52,21 +52,6 @@ FRAMAC_SRC_DIRS= plugins/pdg_types plugins/value_types \ plugins/gui FRAMAC_SRC_DIRS:= $(addprefix src/, $(FRAMAC_SRC_DIRS)) -################# -# OCaml version # -################# - -# Cumulative semantics: HAS_OCAMLnnn should be set if OCaml version is mmm -# with mmm >= nnn - -# findstring returns an empty string if it does not match, and the value it -# searches if it matches. Hence we compare with the empty string -HAS_OCAML403=no -ifeq ($(findstring 4.02,$(OCAMLVERSION)),) - HAS_OCAML403 = yes -endif - - ################## # Flags # ################## diff --git a/share/Makefile.config.in b/share/Makefile.config.in index 0756a1bfe86..ad081789b77 100644 --- a/share/Makefile.config.in +++ b/share/Makefile.config.in @@ -76,7 +76,16 @@ OCAML_ANNOT_OPTION ?=@OCAML_ANNOT_OPTION@ OCAMLLIB ?=@OCAMLLIB@ # either opt or byte OCAMLBEST ?=@OCAMLBEST@ + OCAMLVERSION ?=@OCAMLVERSION@ + +OCAMLMAJORNB ?=@OCAMLMAJORNB@ +OCAMLMINORNB ?=@OCAMLMINORNB@ +OCAMLPATCHNB ?=@OCAMLPATCHNB@ + +HAS_OCAML403 ?=@HAS_OCAML403@ +HAS_OCAML407 ?=@HAS_OCAML407@ + NATIVE_THREADS ?=@HAS_NATIVE_THREADS@ OCAMLWIN32 ?=@OCAMLWIN32@ PTESTSBEST ?=@PTESTSBEST@ -- GitLab