~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to m4/search_for_lib.m4

  • Committer: Monty Taylor
  • Date: 2009-01-09 10:35:18 UTC
  • mto: (779.1.2 devel)
  • mto: This revision was merged to the branch mainline in revision 784.
  • Revision ID: mordred@inaugust.com-20090109103518-f35ifnnuvnjbck9r
Removed search_for_lib. Now totally using AC_LIB_HAVE_LINKFLAGS.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
dnl
2
 
dnl Copyright (C) 2008 Sun Microsystems
3
 
dnl 
4
 
dnl This program is free software; you can redistribute it and/or modify
5
 
dnl it under the terms of the GNU General Public License as published by
6
 
dnl the Free Software Foundation; version 2 of the License.
7
 
dnl 
8
 
dnl This program is distributed in the hope that it will be useful,
9
 
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 
dnl GNU General Public License for more details.
12
 
dnl 
13
 
dnl You should have received a copy of the GNU General Public License
14
 
dnl along with this program; if not, write to the Free Software
15
 
dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
16
 
dnl
17
 
dnl SEARCH_FOR_LIB(LIB, FUNCTIONS, FUNCTION,
18
 
dnl                [ACTION-IF-NOT-FOUND],
19
 
dnl                [LIBS_TO_ADD])
20
 
 
21
 
AC_DEFUN([SEARCH_FOR_LIB],
22
 
[
23
 
  AS_VAR_PUSHDEF([with_lib], [with_$1])
24
 
  AS_VAR_PUSHDEF([ac_header], [ac_cv_header_$3])
25
 
  AS_VAR_PUSHDEF([have_lib], [ac_cv_have_$1])
26
 
  AS_VAR_PUSHDEF([libs_var], AS_TR_CPP([$1_LIBS]))
27
 
  AS_VAR_PUSHDEF([cflags_var], AS_TR_CPP([$1_CFLAGS]))
28
 
  AS_VAR_PUSHDEF([path_var], AS_TR_CPP([$1_PATH]))
29
 
  AS_VAR_PUSHDEF([header_var], AS_TR_CPP([HAVE_$3]))
30
 
  AS_LITERAL_IF([$1],
31
 
                [AS_VAR_PUSHDEF([ac_lib], [ac_cv_lib_$1_$2])],
32
 
                [AS_VAR_PUSHDEF([ac_lib], [ac_cv_lib_$1''_$2])])
33
 
 
34
 
  AS_IF([test "x$prefix" = "xNONE"],
35
 
    [AS_VAR_SET([path_var],["$ac_default_prefix"])],
36
 
    [AS_VAR_SET([path_var],["$prefix"])])
37
 
 
38
 
 
39
 
  AC_ARG_WITH([$1],
40
 
    [AS_HELP_STRING([--with-$1@<:@=DIR@:>@],
41
 
       [Use lib$1 in DIR])],
42
 
    [ AS_VAR_SET([with_lib], [$withval]) ],
43
 
    [ AS_VAR_SET([with_lib], [yes]) ])
44
 
 
45
 
  AS_IF([test AS_VAR_GET([with_lib]) = yes],[
46
 
    AC_CHECK_HEADER([$3])
47
 
 
48
 
    my_save_LIBS="$LIBS"
49
 
    LIBS="$5"
50
 
    AC_CHECK_LIB($1, $2)
51
 
    AS_VAR_SET([libs_var],[${LIBS}])
52
 
    LIBS="${my_save_LIBS}"
53
 
    AS_VAR_SET([cflags_var],[""])
54
 
    AS_IF([test AS_VAR_GET([ac_header]) = yes -a AS_VAR_GET([ac_lib]) = yes],
55
 
      [AS_VAR_SET([have_lib],[yes])
56
 
       AS_VAR_SET([path_var],[$PATH])
57
 
      ],
58
 
      [AS_VAR_SET([have_lib],[no])
59
 
       AS_VAR_SET([with_lib],["AS_VAR_GET([path_var]) /usr/local /opt/csw /opt/local"])
60
 
      ])
61
 
  ])
62
 
  AS_IF([test "AS_VAR_GET([with_lib])" != yes],[
63
 
   for libloc in AS_VAR_GET([with_lib])
64
 
   do
65
 
    AC_MSG_CHECKING(for $1 in $libloc)
66
 
    if test -f $libloc/$3 -a -f $libloc/lib$1.a
67
 
    then
68
 
      owd=`pwd`
69
 
      if cd $libloc; then libloc=`pwd`; cd $owd; fi
70
 
      AS_VAR_SET([cflags_var],[-I$libloc])
71
 
      AS_VAR_SET([libs_var],["-L$libloc -l$1"])
72
 
      AS_VAR_SET([path_var],["$libloc:$PATH"])
73
 
      AS_VAR_SET([have_lib],[yes])
74
 
      AS_VAR_SET([ac_header],[yes])
75
 
      AC_MSG_RESULT([yes])
76
 
      break
77
 
    elif test -f $libloc/include/$3 -a -f $libloc/lib/lib$1.a; then
78
 
      owd=`pwd`
79
 
      if cd $libloc; then libloc=`pwd`; cd $owd; fi
80
 
      AS_VAR_SET([cflags_var],[-I$libloc/include])
81
 
      AS_VAR_SET([libs_var],["-L$libloc/lib -l$1"])
82
 
      AS_VAR_SET([path_var],["$libloc/bin:$PATH"])
83
 
      AS_VAR_SET([have_lib],[yes])
84
 
      AS_VAR_SET([ac_header],[yes])
85
 
      AC_MSG_RESULT([yes])
86
 
      break
87
 
    else
88
 
      AC_MSG_RESULT([no])
89
 
      AS_VAR_SET([have_lib],[no])
90
 
    fi
91
 
   done
92
 
  ])
93
 
  AS_IF([test AS_VAR_GET([have_lib]) = no],[
94
 
    AC_MSG_WARN([$3 or lib$1.a not found. Try installing $1 developement packages])
95
 
    $4
96
 
  ])
97
 
  AS_IF([test AS_VAR_GET([ac_header]) = "yes"],
98
 
    AC_DEFINE(header_var,[1],
99
 
              [Define to 1 if you have the <$3> header file.]))
100
 
 
101
 
  AC_SUBST(libs_var)
102
 
  AC_SUBST(cflags_var)
103
 
  AC_SUBST(path_var)
104
 
  AS_VAR_POPDEF([with_lib])
105
 
  AS_VAR_POPDEF([ac_header])
106
 
  AS_VAR_POPDEF([libs_var])
107
 
  AS_VAR_POPDEF([cflags_var])
108
 
  AS_VAR_POPDEF([path_var])
109
 
  AS_VAR_POPDEF([have_lib])
110
 
  AS_VAR_POPDEF([ac_lib])
111
 
  AS_VAR_POPDEF([header_var])
112
 
])