Statistics
| Branch: | Tag: | Revision:

root / autotools / ac_ghc_pkg.m4 @ 21a5e56c

History | View | Annotate | Download (2.1 kB)

1
#####
2

    
3
# Copyright (C) 2012 Google Inc.
4
#
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version.
9
#
10
# This program is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
# General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18
# 02110-1301, USA.
19

    
20
#####
21
#
22
# SYNOPSIS
23
#
24
#   AC_GHC_PKG_CHECK(modname, action_found, action_not_found, extended)
25
#
26
# DESCRIPTION
27
#
28
#   Checks for a Haskell (GHC) module. If found, execute the second
29
#   argument, if not found, the third one.
30
#
31
#   If the fourth argument is non-empty, then the check will be some
32
#   via 'ghc-pkg list' (which supports patterns), otherwise it will
33
#   use just 'ghc-pkg latest'.
34
#
35
#
36
#####
37

    
38
AC_DEFUN([AC_GHC_PKG_CHECK],[
39
    if test -z $GHC_PKG; then
40
        AC_MSG_ERROR([GHC_PKG not defined])
41
    fi
42
    AC_MSG_CHECKING([haskell library $1])
43
    if test -n "$4"; then
44
      GHC_PKG_RESULT=$($GHC_PKG --simple-output list '$1'|tail -n1)
45
    else
46
      GHC_PKG_RESULT=$($GHC_PKG latest '$1' 2>/dev/null)
47
    fi
48
    if test -n "$GHC_PKG_RESULT"; then
49
      AC_MSG_RESULT($GHC_PKG_RESULT)
50
      $2
51
    else
52
      AC_MSG_RESULT([no])
53
      $3
54
    fi
55
])
56

    
57
#####
58
#
59
# SYNOPSIS
60
#
61
#   AC_GHC_PKG_REQUIRE(modname, extended)
62
#
63
# DESCRIPTION
64
#
65
#   Checks for a Haskell (GHC) module, and abort if not found. If the
66
#   second argument is non-empty, then the check will be some via
67
#   'ghc-pkg list' (which supports patterns), otherwise it will use
68
#   just 'ghc-pkg latest'.
69
#
70
#
71
#####
72

    
73
AC_DEFUN([AC_GHC_PKG_REQUIRE],[
74
    AC_GHC_PKG_CHECK($1, [],
75
                     [AC_MSG_FAILURE([Required Haskell module $1 not found])],
76
                     $2)
77
])