bac5018adfbd80ddf3c9e5b98b308570ffb0218e
[freeradius.git] / src / modules / rlm_rest / configure.in
1 AC_PREREQ([2.53])
2 AC_INIT(rlm_rest.c)
3 AC_REVISION($Revision$)
4 AC_DEFUN(modname,[rlm_rest])
5 AC_CONFIG_HEADER(config.h)
6 m4_include([m4/libcurl_check_config.m4])
7
8 if test x$with_[]modname != xno; then
9
10         AC_PROG_CC
11         AC_PROG_CPP
12
13         dnl put configuration checks here.
14         dnl set $fail to what's missing, on fatal errors.
15         dnl use AC_MSG_WARN() on important messages.
16
17         dnl ############################################################
18         dnl # Check for curl
19         dnl ############################################################
20
21         LIBCURL_CHECK_CONFIG([], [7.19.1])
22
23         if test "x$libcurl_cv_lib_curl_usable" != "xyes"; then
24                 fail="$fail libcurl"
25         else    
26                 if test x$libcurl_protocol_HTTP != xyes; then
27                         fail="$fail libcurl_protocol_http"
28                 fi
29         
30                 if test x$libcurl_protocol_HTTPS != xyes || test x$libcurl_feature_SSL != xyes; then
31                         AC_MSG_WARN([silently building without HTTPS support. requires: libcurl_protocol_https.])
32                 fi
33         fi
34
35         dnl ############################################################
36         dnl # Check for json-c
37         dnl ############################################################
38
39         dnl extra argument: --with-jsonc-include-dir=DIR
40         jsonc_include_dir=
41         AC_ARG_WITH(jsonc-include-dir,
42                 [AS_HELP_STRING([--with-jsonc-include-dir=DIR],
43                 [Directory where the json-c includes may be found])],
44                 [case "$withval" in
45                     no)
46                         AC_MSG_ERROR(Need jsonc-include-dir)
47                     ;;
48                         yes)
49                     ;;
50                     *)
51                         jsonc_include_dir="$withval"
52                     ;;
53                 esac])
54
55         dnl extra argument: --with-jsonc-lib-dir=DIR
56         jsonc_lib_dir=
57         AC_ARG_WITH(jsonc-lib-dir,
58         [AS_HELP_STRING([--with-jsonc-lib-dir=DIR],
59                 [Directory where the json-c libraries may be found])],
60                 [case "$withval" in
61                     no)
62                         AC_MSG_ERROR(Need jsonc-lib-dir)
63                         ;;
64                     yes)
65                         ;;
66                     *)
67                         jsonc_lib_dir="$withval"
68                         ;;
69                 esac])
70
71         dnl extra argument: --with-jsonc-dir=DIR
72         AC_ARG_WITH(jsonc-dir,
73         [AS_HELP_STRING([--with-jsonc-dir=DIR],
74                 [Base directory where json-c is installed])],
75                 [case "$withval" in
76                     no)
77                         AC_MSG_ERROR(Need json-c-dir)
78                         ;;
79                     yes)
80                         ;;
81                     *)
82                         jsonc_lib_dir="$withval/lib"
83                         jsonc_include_dir="$withval/include"
84                         ;;
85                 esac])
86
87
88         dnl ############################################################
89         dnl # Check for json-c header files
90         dnl ############################################################
91
92         smart_try_dir="$jsonc_include_dir"
93         FR_SMART_CHECK_INCLUDE([json/json.h])
94         if test "x$ac_cv_header_json_json_h" != "xyes"; then
95                 have_json="no"
96                 AC_MSG_WARN([json-c headers not found. Use --with-jsonc-include-dir=<path>.])
97         fi
98         
99         dnl ############################################################
100         dnl # Check for json-c libraries
101         dnl ############################################################
102
103         have_json="yes"
104         smart_try_dir="$jsonc_lib_dir"
105         FR_SMART_CHECK_LIB([json-c], [json_c_version])
106         if test "x$ac_cv_lib_json_c_json_c_version" != "xyes"
107         then
108                 have_json="no"
109                 AC_MSG_WARN([json-c libraries not found. Use --with-jsonc-lib-dir=<path>.])
110         fi
111         
112         if test "x$have_json" = "xyes"; then
113                 AC_DEFINE([HAVE_JSON],[1],[Build with JSON support from json-c])
114         else
115                 AC_MSG_WARN([silently building without JSON support. requires: json-c])
116         fi
117
118         targetname=modname     # keep this!  Don't change!
119 else
120         targetname=            # keep this!  Don't change!
121         echo \*\*\* module modname is disabled.  # keep this!  Don't change!
122 fi
123
124 dnl  Don't change this section.
125 if test x"$fail" != x""; then
126         if test x"${enable_strict_dependencies}" = x"yes"; then
127                 AC_MSG_ERROR([set --without-]modname[ to disable it explicitly.])
128         else
129                 AC_MSG_WARN([silently not building ]modname[.])
130                 AC_MSG_WARN([FAILURE: ]modname[ requires: $fail.]);
131                 targetname=""
132         fi
133 fi
134
135 rest_ldflags="${LIBCURL} ${SMART_LIBS}"
136 rest_cflags="${SMART_CFLAGS}"
137
138 AC_SUBST(rest_cflags)
139 AC_SUBST(rest_ldflags)
140
141 AC_SUBST(targetname)
142 AC_OUTPUT(Makefile)
143 AC_OUTPUT(all.mk)