ee1f0959eb2863eb6efa85c98aef5326f2b00f1d
[openafs.git] / src / cf / roken.m4
1
2 AC_DEFUN([_OPENAFS_ROKEN_INTERNAL], [
3   DIR_roken=roken
4   CPPFLAGS_roken=
5   LDFLAGS_roken="-L\$(TOP_LIBDIR)"
6   LIB_roken=-lrokenafs
7 ])
8
9 dnl _OPENAFS_ROKEN_CHECK($path,
10 dnl                      $action-if-found,
11 dnl                      $action-if-not-found)
12 dnl Find a roken library at $path.
13 dnl
14 dnl If $path is not specified,
15 dnl try to find one in the standard locations on the system.
16 dnl
17 dnl If we fail, and $path was given, then error out. Otherwise,
18 dnl fall back to the internal roken implementation
19 AC_DEFUN([_OPENAFS_ROKEN_CHECK], [
20   roken_path=$1
21
22   save_CPPFLAGS=$CPPFLAGS
23   save_LDFLAGS=$LDFLAGS
24   save_LIBS=$LIBS
25   AS_IF([test x"$roken_path" != x],
26         [CPPFLAGS="-I$roken_path/include $CPPFLAGS"
27          LDFLAGS="-L$roken_path/lib $LDFLAGS"])
28
29   dnl Need to be careful what we check for here, as libroken contains
30   dnl different symbols on different platforms.
31   AC_CHECK_LIB([roken], [ct_memcmp], [roken_foundlib=true])
32   AC_CHECK_HEADER([roken.h], [roken_foundheader=true])
33   CPPFLAGS=$save_CPPFLAGS
34   LDFLAGS=$save_LDFLAGS
35   LIBS=$save_LIBS
36
37   AS_IF([test x"$roken_foundlib" = xtrue && test x"$roken_foundheader" = xtrue],
38          [AS_IF([test x"$roken_path" != x],
39                [CPPFLAGS_roken="-I$roken_path/include"
40                 LDFLAGS_roken="-L$roken_path/lib"])
41          LIB_roken="-lroken"
42          $2],
43         [$3])
44 ])
45
46 AC_DEFUN([OPENAFS_ROKEN], [
47   roken_root=
48   AC_SUBST(LIB_roken)
49   AC_SUBST(CPPFLAGS_roken)
50   AC_SUBST(LDFLAGS_roken)
51   AC_SUBST(DIR_roken)
52
53   AC_ARG_WITH([roken],
54     [AS_HELP_STRING([--with-roken=DIR],
55         [Location of the roken library, or 'internal'])],
56     [AS_IF([test x"$withval" = xno],
57            [AC_ERROR("OpenAFS requires roken to build")],
58            [AS_IF([test x"$withval" != xyes],
59                   [roken_root="$withval"])
60            ])
61     ])
62
63   AS_IF([test x"$roken_root" = xinteral],
64         [_OPENAFS_ROKEN_INTERNAL()],
65         [AS_IF([test x"$roken_root" = x],
66             [_OPENAFS_ROKEN_CHECK([], [], [_OPENAFS_ROKEN_INTERNAL()])],
67             [_OPENAFS_ROKEN_CHECK($roken_root,
68                 [],
69                 [AC_MSG_ERROR([Cannot find roken at that location])])
70             ])
71         ])
72 ])