Statistics
| Branch: | Tag: | Revision:

root / autotools / ac_ghc_pkg.m4 @ cefd4a4a

History | View | Annotate | Download (2.1 kB)

1 21a5e56c Iustin Pop
#####
2 21a5e56c Iustin Pop
3 21a5e56c Iustin Pop
# Copyright (C) 2012 Google Inc.
4 21a5e56c Iustin Pop
#
5 21a5e56c Iustin Pop
# This program is free software; you can redistribute it and/or modify
6 21a5e56c Iustin Pop
# it under the terms of the GNU General Public License as published by
7 21a5e56c Iustin Pop
# the Free Software Foundation; either version 2 of the License, or
8 21a5e56c Iustin Pop
# (at your option) any later version.
9 21a5e56c Iustin Pop
#
10 21a5e56c Iustin Pop
# This program is distributed in the hope that it will be useful, but
11 21a5e56c Iustin Pop
# WITHOUT ANY WARRANTY; without even the implied warranty of
12 21a5e56c Iustin Pop
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 21a5e56c Iustin Pop
# General Public License for more details.
14 21a5e56c Iustin Pop
#
15 21a5e56c Iustin Pop
# You should have received a copy of the GNU General Public License
16 21a5e56c Iustin Pop
# along with this program; if not, write to the Free Software
17 21a5e56c Iustin Pop
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 21a5e56c Iustin Pop
# 02110-1301, USA.
19 21a5e56c Iustin Pop
20 21a5e56c Iustin Pop
#####
21 21a5e56c Iustin Pop
#
22 21a5e56c Iustin Pop
# SYNOPSIS
23 21a5e56c Iustin Pop
#
24 21a5e56c Iustin Pop
#   AC_GHC_PKG_CHECK(modname, action_found, action_not_found, extended)
25 21a5e56c Iustin Pop
#
26 21a5e56c Iustin Pop
# DESCRIPTION
27 21a5e56c Iustin Pop
#
28 21a5e56c Iustin Pop
#   Checks for a Haskell (GHC) module. If found, execute the second
29 21a5e56c Iustin Pop
#   argument, if not found, the third one.
30 21a5e56c Iustin Pop
#
31 21a5e56c Iustin Pop
#   If the fourth argument is non-empty, then the check will be some
32 21a5e56c Iustin Pop
#   via 'ghc-pkg list' (which supports patterns), otherwise it will
33 21a5e56c Iustin Pop
#   use just 'ghc-pkg latest'.
34 21a5e56c Iustin Pop
#
35 21a5e56c Iustin Pop
#
36 21a5e56c Iustin Pop
#####
37 21a5e56c Iustin Pop
38 21a5e56c Iustin Pop
AC_DEFUN([AC_GHC_PKG_CHECK],[
39 21a5e56c Iustin Pop
    if test -z $GHC_PKG; then
40 21a5e56c Iustin Pop
        AC_MSG_ERROR([GHC_PKG not defined])
41 21a5e56c Iustin Pop
    fi
42 21a5e56c Iustin Pop
    AC_MSG_CHECKING([haskell library $1])
43 21a5e56c Iustin Pop
    if test -n "$4"; then
44 21a5e56c Iustin Pop
      GHC_PKG_RESULT=$($GHC_PKG --simple-output list '$1'|tail -n1)
45 21a5e56c Iustin Pop
    else
46 21a5e56c Iustin Pop
      GHC_PKG_RESULT=$($GHC_PKG latest '$1' 2>/dev/null)
47 21a5e56c Iustin Pop
    fi
48 21a5e56c Iustin Pop
    if test -n "$GHC_PKG_RESULT"; then
49 21a5e56c Iustin Pop
      AC_MSG_RESULT($GHC_PKG_RESULT)
50 21a5e56c Iustin Pop
      $2
51 21a5e56c Iustin Pop
    else
52 21a5e56c Iustin Pop
      AC_MSG_RESULT([no])
53 21a5e56c Iustin Pop
      $3
54 21a5e56c Iustin Pop
    fi
55 21a5e56c Iustin Pop
])
56 21a5e56c Iustin Pop
57 21a5e56c Iustin Pop
#####
58 21a5e56c Iustin Pop
#
59 21a5e56c Iustin Pop
# SYNOPSIS
60 21a5e56c Iustin Pop
#
61 21a5e56c Iustin Pop
#   AC_GHC_PKG_REQUIRE(modname, extended)
62 21a5e56c Iustin Pop
#
63 21a5e56c Iustin Pop
# DESCRIPTION
64 21a5e56c Iustin Pop
#
65 21a5e56c Iustin Pop
#   Checks for a Haskell (GHC) module, and abort if not found. If the
66 21a5e56c Iustin Pop
#   second argument is non-empty, then the check will be some via
67 21a5e56c Iustin Pop
#   'ghc-pkg list' (which supports patterns), otherwise it will use
68 21a5e56c Iustin Pop
#   just 'ghc-pkg latest'.
69 21a5e56c Iustin Pop
#
70 21a5e56c Iustin Pop
#
71 21a5e56c Iustin Pop
#####
72 21a5e56c Iustin Pop
73 21a5e56c Iustin Pop
AC_DEFUN([AC_GHC_PKG_REQUIRE],[
74 21a5e56c Iustin Pop
    AC_GHC_PKG_CHECK($1, [],
75 21a5e56c Iustin Pop
                     [AC_MSG_FAILURE([Required Haskell module $1 not found])],
76 21a5e56c Iustin Pop
                     $2)
77 21a5e56c Iustin Pop
])