~drizzle-trunk/drizzle/development

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
dnl SEARCH_FOR_LIB(LIB, FUNCTIONS, FUNCTION,
dnl                [ACTION-IF-NOT-FOUND],
dnl                [LIBS_TO_ADD])

AC_DEFUN([SEARCH_FOR_LIB],
[
  AS_VAR_PUSHDEF([with_lib], [with_$1])
  AS_VAR_PUSHDEF([ac_header], [ac_cv_header_$3])
  AS_VAR_PUSHDEF([have_lib], [ac_cv_have_$1])
  AS_VAR_PUSHDEF([libs_var], AS_TR_CPP([$1_LIBS]))
  AS_VAR_PUSHDEF([cflags_var], AS_TR_CPP([$1_CFLAGS]))
  AS_VAR_PUSHDEF([path_var], AS_TR_CPP([$1_PATH]))
  AS_LITERAL_IF([$1],
                [AS_VAR_PUSHDEF([ac_lib], [ac_cv_lib_$1_$2])],
                [AS_VAR_PUSHDEF([ac_lib], [ac_cv_lib_$1''_$2])])

  AS_IF([test "x$prefix" = "xNONE"],
    [AS_VAR_SET([path_var],["$ac_default_prefix"])],
    [AS_VAR_SET([path_var],["$prefix"])])


  AC_ARG_WITH([$1],
    [AS_HELP_STRING([--with-$1@<:@=DIR@:>@],
       [Use lib$1 in DIR])],
    [ AS_VAR_SET([with_lib], [$withval]) ],
    [ AS_VAR_SET([with_lib], [yes]) ])

  AS_IF([test AS_VAR_GET([with_lib]) = yes],[
    AC_CHECK_HEADERS([$3])

    my_save_LIBS="$LIBS"
    LIBS="$5"
    AC_CHECK_LIB($1, $2)
    AS_VAR_SET([libs_var],[${LIBS}])
    LIBS="${my_save_LIBS}"
    AS_VAR_SET([cflags_var],[""])
    AS_IF([test AS_VAR_GET([ac_header]) = "$3" -a AS_VAR_GET([ac_lib]) = yes],
      [AS_VAR_SET([have_lib],[yes])
       AS_VAR_SET([path_var],[$PATH])
      ],
      [AS_VAR_SET([have_lib],[no])
       AS_VAR_SET([with_lib],["AS_VAR_GET([path_var]) /usr/local /opt/csw"])
      ])
  ])
  AS_IF([test "AS_VAR_GET([with_lib])" != yes],[
   for libloc in AS_VAR_GET([with_lib])
   do
    AC_MSG_CHECKING(for $1 in $libloc)
    if test -f $libloc/$3 -a -f $libloc/lib$1.a
    then
      owd=`pwd`
      if cd $libloc; then libloc=`pwd`; cd $owd; fi
      AS_VAR_SET([cflags_var],[-I$libloc])
      AS_VAR_SET([libs_var],["-L$libloc -l$1"])
      AS_VAR_SET([path_var],["$libloc:$PATH"])
      AS_VAR_SET([have_lib],[yes])
      AC_MSG_RESULT([yes])
      break
    elif test -f $libloc/include/$3 -a -f $libloc/lib/lib$1.a; then
      owd=`pwd`
      if cd $libloc; then libloc=`pwd`; cd $owd; fi
      AS_VAR_SET([cflags_var],[-I$libloc/include])
      AS_VAR_SET([libs_var],["-L$libloc/lib -l$1"])
      AS_VAR_SET([path_var],["$libloc/bin:$PATH"])
      AS_VAR_SET([have_lib],[yes])
      AC_MSG_RESULT([yes])
      break
    else
      AC_MSG_RESULT([no])
      AS_VAR_SET([have_lib],[no])
    fi
   done
  ])
  AS_IF([test AS_VAR_GET([have_lib]) = no],[
    AC_MSG_WARN([$3 or lib$1.a not found. Try installing $1 developement packages])
    $4
  ])
  AC_SUBST(libs_var)
  AC_SUBST(cflags_var)
  AC_SUBST(path_var)
  AS_VAR_POPDEF([with_lib])
  AS_VAR_POPDEF([ac_header])
  AS_VAR_POPDEF([libs_var])
  AS_VAR_POPDEF([cflags_var])
  AS_VAR_POPDEF([path_var])
  AS_VAR_POPDEF([have_lib])
  AS_VAR_POPDEF([ac_lib])
])