Sync toplevel files with GCC tree
[platform/upstream/binutils.git] / config / isl.m4
1 # This file is part of GCC.
2 #
3 # GCC is free software; you can redistribute it and/or modify it under
4 # the terms of the GNU General Public License as published by the Free
5 # Software Foundation; either version 3, or (at your option) any later
6 # version.
7 #
8 # GCC is distributed in the hope that it will be useful, but WITHOUT
9 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
11 # for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with GCC; see the file COPYING3.  If not see
15 # <http://www.gnu.org/licenses/>.
16 #
17 # Contributed by Richard Guenther <rguenther@suse.de>
18 # Based on cloog.m4
19
20 # ISL_INIT_FLAGS ()
21 # -------------------------
22 # Provide configure switches for ISL support.
23 # Initialize isllibs/islinc according to the user input.
24 AC_DEFUN([ISL_INIT_FLAGS],
25 [
26   AC_ARG_WITH(isl,
27     [AS_HELP_STRING(
28       [--with-isl=PATH],
29       [Specify prefix directory for the installed ISL package.
30        Equivalent to --with-isl-include=PATH/include
31        plus --with-isl-lib=PATH/lib])])
32   AC_ARG_WITH([isl-include],
33     [AS_HELP_STRING(
34       [--with-isl-include=PATH],
35       [Specify directory for installed ISL include files])])
36   AC_ARG_WITH([isl-lib],
37     [AS_HELP_STRING(
38       [--with-isl-lib=PATH],
39       [Specify the directory for the installed ISL library])])
40
41   AC_ARG_ENABLE(isl-version-check,
42     [AS_HELP_STRING(
43       [--disable-isl-version-check],
44       [disable check for ISL version])],
45     ENABLE_ISL_CHECK=$enableval,
46     ENABLE_ISL_CHECK=yes)
47   
48   # Initialize isllibs and islinc.
49   case $with_isl in
50     no)
51       isllibs=
52       islinc=
53       ;;
54     "" | yes)
55       ;;
56     *)
57       isllibs="-L$with_isl/lib"
58       islinc="-I$with_isl/include"
59       ;;
60   esac
61   if test "x${with_isl_include}" != x ; then
62     islinc="-I$with_isl_include"
63   fi
64   if test "x${with_isl_lib}" != x; then
65     isllibs="-L$with_isl_lib"
66   fi
67   dnl If no --with-isl flag was specified and there is in-tree ISL
68   dnl source, set up flags to use that and skip any version tests
69   dnl as we cannot run them before building ISL.
70   if test "x${islinc}" = x && test "x${isllibs}" = x \
71      && test -d ${srcdir}/isl; then
72     isllibs='-L$$r/$(HOST_SUBDIR)/isl/'"$lt_cv_objdir"' '
73     islinc='-I$$r/$(HOST_SUBDIR)/isl/include -I$$s/isl/include'
74     ENABLE_ISL_CHECK=no
75   fi
76
77   isllibs="${isllibs} -lisl"
78
79   dnl Flags needed for ISL
80   AC_SUBST(isllibs)
81   AC_SUBST(islinc)
82 ]
83 )
84
85 # ISL_REQUESTED (ACTION-IF-REQUESTED, ACTION-IF-NOT)
86 # ----------------------------------------------------
87 # Provide actions for failed ISL detection.
88 AC_DEFUN([ISL_REQUESTED],
89 [
90   AC_REQUIRE([ISL_INIT_FLAGS])
91
92   if test "x${with_isl}" = xno; then
93     $2
94   elif test "x${with_isl}" != x \
95     || test "x${with_isl_include}" != x \
96     || test "x${with_isl_lib}" != x ; then
97     $1
98   else
99     $2
100   fi
101 ]
102 )
103
104 # _ISL_CHECK_CT_PROG(MAJOR, MINOR)
105 # --------------------------------------------
106 # Helper for verifying ISL compile time version.
107 m4_define([_ISL_CHECK_CT_PROG],[AC_LANG_PROGRAM(
108   [#include <isl/version.h>
109    #include <string.h>],
110   [if (strncmp (isl_version (), "isl-$1.$2", strlen ("isl-$1.$2")) != 0)
111      return 1;
112    ])])
113
114 # ISL_CHECK_VERSION ISL_CHECK_VERSION (MAJOR, MINOR)
115 # ----------------------------------------------------------------
116 # Test the found ISL to be exact of version MAJOR.MINOR and at least
117 # REVISION.
118 AC_DEFUN([ISL_CHECK_VERSION],
119 [
120   if test "${ENABLE_ISL_CHECK}" = yes ; then
121     _isl_saved_CFLAGS=$CFLAGS
122     _isl_saved_LDFLAGS=$LDFLAGS
123     _isl_saved_LIBS=$LIBS
124
125     CFLAGS="${_isl_saved_CFLAGS} ${islinc} ${gmpinc}"
126     LDFLAGS="${_isl_saved_LDFLAGS} ${isllibs}"
127     LIBS="${_isl_saved_LIBS} -lisl"
128     echo $CFLAGS
129
130     AC_CACHE_CHECK([for version $1.$2 of ISL],
131       [gcc_cv_isl],
132       [AC_RUN_IFELSE([_ISL_CHECK_CT_PROG($1,$2)],
133         [gcc_cv_isl=yes],
134         [gcc_cv_isl=no],
135         [gcc_cv_isl=yes])])
136
137     CFLAGS=$_isl_saved_CFLAGS
138     LDFLAGS=$_isl_saved_LDFLAGS
139     LIBS=$_isl_saved_LIBS
140   fi
141 ]
142 )
143
144 # ISL_IF_FAILED (ACTION-IF-FAILED)
145 # ----------------------------------
146 # Executes ACTION-IF-FAILED, if GRAPHITE was requested and
147 # the checks failed.
148 AC_DEFUN([ISL_IF_FAILED],
149 [
150   ISL_REQUESTED([graphite_requested=yes], [graphite_requested=no])
151   
152   if test "${gcc_cv_isl}" = no ; then
153     isllibs=
154     islinc=
155   fi
156
157   if test "${graphite_requested}" = yes \
158     && test "x${isllibs}" = x \
159     && test "x${islinc}" = x ; then
160     $1
161   fi
162 ]
163 )