Add libroken as its own library
[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], [found_foundlib=true])
32   AC_CHECK_HEADER([roken], [roken_foundheader=true])
33   CPPFLAGS=$save_CPPFLAGS
34   LDFLAGS=$save_LDFLAGS
35
36   AS_IF([test x"$roken_foundlib" = xtrue && test x"roken_foundheader" = xtrue],
37         [AS_IF([test x"$roken_path" != x],
38                [CPPFLAGS_roken = "-I$roken_path/include"
39                 LDFLAGS_roken="-I$roken_path/lib"
40                 LIB_roken="-lroken"])
41          $2],
42         [$3])
43 ])
44
45 AC_DEFUN([OPENAFS_ROKEN], [
46   roken_root=
47   AC_SUBST(LIB_roken)
48   AC_SUBST(CPPFLAGS_roken)
49   AC_SUBST(LDFLAGS_roken)
50   AC_SUBST(DIR_roken)
51
52   AC_ARG_WITH([roken],
53     [AS_HELP_STRING([--with-roken=DIR],
54         [Location of the roken library, or 'internal'])],
55     [AS_IF([test x"$withval" = xno],
56            [AC_ERROR("OpenAFS requires roken to build")],
57            [AS_IF([test x"$withval" != xyes],
58                   [roken_root="$withval"])
59            ])
60     ])
61
62   AS_IF([test x"$roken_root" = xinteral],
63         [_OPENAFS_ROKEN_INTERNAL()],
64         [AS_IF([test x"$roken_root" = x],
65             [_OPENAFS_ROKEN_CHECK([], [], [_OPENAFS_ROKEN_INTERNAL()])],
66             [_OPENAFS_ROKEN_CHECK($roken_root,
67                 [AC_MSG_ERROR([Cannot find roken at that location])])
68             ])
69         ])
70 ])