summaryrefslogtreecommitdiff
path: root/configure.in
blob: 41fcfc534d00d7db7378b0c084c59bd655eafd4c (plain)
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
dnl Autoconf file for Serf

AC_PREREQ(2.50)
AC_INIT(context.c)

AC_CONFIG_AUX_DIR(build)

sinclude(build/apr_common.m4)
sinclude(build/find_apr.m4)

AC_PREFIX_DEFAULT(/usr/local/serf)

dnl Get the layout here, so we can pass the required variables to apr
APR_ENABLE_LAYOUT(Serf, [])

dnl reparse the configure arguments.
APR_PARSE_ARGUMENTS

APR_SAVE_THE_ENVIRONMENT(CPPFLAGS)
APR_SAVE_THE_ENVIRONMENT(CFLAGS)
APR_SAVE_THE_ENVIRONMENT(CXXFLAGS)
APR_SAVE_THE_ENVIRONMENT(LDFLAGS)
APR_SAVE_THE_ENVIRONMENT(LIBS)
APR_SAVE_THE_ENVIRONMENT(INCLUDES)

APR_CONFIG_NICE(config.nice)

nl='
'
dnl Check that mkdir -p works
APR_MKDIR_P_CHECK($top_srcdir/build/mkdir.sh)
AC_SUBST(mkdir_p)

dnl ## Run configure for packages Apache uses

dnl shared library support for these packages doesn't currently
dnl work on some platforms

AC_CANONICAL_SYSTEM

orig_prefix="$prefix"

echo $ac_n "${nl}Configuring Apache Portable Runtime library...${nl}"

APR_FIND_APR("$srcdir/apr", "./apr", 1, 0 1 2)

if test "$apr_found" = "no"; then
  AC_MSG_ERROR([APR not found.  Please read the documentation.])
fi

if test "$apr_found" = "reconfig"; then
  APR_SUBDIR_CONFIG(apr,
                    [--prefix=$prefix --exec-prefix=$exec_prefix --libdir=$libdir --includedir=$includedir --bindir=$bindir --datadir=$datadir --with-installbuilddir=$installbuilddir],
                    [--enable-layout=*|\'--enable-layout=*])
  dnl We must be the first to build and the last to be cleaned
  SERF_BUILD_SRCLIB_DIRS="apr $SERF_BUILD_SRCLIB_DIRS"
  SERF_CLEAN_SRCLIB_DIRS="$SERF_CLEAN_SRCLIB_DIRS apr"
fi

APR_SETIFNULL(CC, `$apr_config --cc`)
APR_SETIFNULL(CPP, `$apr_config --cpp`)
APR_SETIFNULL(APR_LIBTOOL, `$apr_config --apr-libtool`)
APR_ADDTO(CFLAGS, `$apr_config --cflags`)
APR_ADDTO(CPPFLAGS, `$apr_config --cppflags`)
APR_ADDTO(LDFLAGS, `$apr_config --ldflags`)
SHLIBPATH_VAR=`$apr_config --shlib-path-var`
APR_BINDIR=`$apr_config --bindir`
APR_INCLUDES=`$apr_config --includes`
APR_VERSION=`$apr_config --version`
APR_CONFIG="$apr_config"

APR_SETIFNULL(LTFLAGS, "--silent")
AC_SUBST(LTFLAGS)

AC_SUBST(APR_LIBTOOL)
AC_SUBST(APR_BINDIR)
AC_SUBST(APR_INCLUDES)
AC_SUBST(APR_VERSION)
AC_SUBST(APR_CONFIG)

APR_VERSION_MAJOR="`echo \"$APR_VERSION\" | sed 's,\..*,,'`"
APR_VERSION_NUM="`echo \"$APR_VERSION\" | \
                sed -e 's/[[^0-9\.]].*$//' \
                    -e 's/\.\([[0-9]]\)$/.0\1/' \
                    -e 's/\.\([[0-9]][[0-9]]\)$/.0\1/' \
                    -e 's/\.\([[0-9]]\)\./0\1/; s/\.//g;'`"

if test "$APR_VERSION_NUM" -ge "200000"; then

  APU_BINDIR=""
  APU_INCLUDES=""
  APU_VERSION=""
  APU_CONFIG=""

else
  sinclude(build/find_apu.m4)

  echo $ac_n "${nl}Configuring Apache Portable Runtime Utility library...${nl}"

   ifdef([APR_FIND_APU], [
     APR_FIND_APU("$srcdir/apr-util", "./apr-util", 1, $APR_VERSION_MAJOR)
   ], [AC_MSG_ERROR([APR-util required, but find_apu.m4 not present!])])

  if test "$apu_found" = "no"; then
    AC_MSG_ERROR([APR-util not found.  Please read the documentation.])
  fi

  # Catch some misconfigurations:
  case ${apr_found}.${apu_found} in
    reconfig.yes)
      AC_MSG_ERROR([Cannot use an external APR-util with the bundled APR])
      ;;
    yes.reconfig)
      AC_MSG_ERROR([Cannot use an external APR with the bundled APR-util])
      ;;
  esac  

  if test "$apu_found" = "reconfig"; then
    APR_SUBDIR_CONFIG(apr-util,
                      [--with-apr=../apr --prefix=$prefix --exec-prefix=$exec_prefix --libdir=$libdir --includedir=$includedir --bindir=$bindir],
                      [--enable-layout=*|\'--enable-layout=*])
    dnl We must be the last to build and the first to be cleaned
    SERF_BUILD_SRCLIB_DIRS="$SERF_BUILD_SRCLIB_DIRS apr-util"
    SERF_CLEAN_SRCLIB_DIRS="apr-util $SERF_CLEAN_SRCLIB_DIRS"
  fi

  APR_ADDTO(LDFLAGS, `$apu_config --ldflags`)
  APU_BINDIR=`$apu_config --bindir`
  APU_INCLUDES=`$apu_config --includes`
  APU_VERSION=`$apu_config --version`
  APU_CONFIG="$APU_BINDIR/apu-`echo ${APU_VERSION} | sed 's,\..*,,'`-config"
fi

AC_SUBST(APU_BINDIR)
AC_SUBST(APU_INCLUDES)
AC_SUBST(APU_VERSION)
AC_SUBST(APU_CONFIG)

dnl In case we picked up CC and CPP from APR, get that info into the
dnl config cache so that PCRE uses it.  Otherwise, CC and CPP used for
dnl PCRE and for our config tests will be whatever PCRE determines.
AC_PROG_CC
AC_PROG_CPP
AC_PROG_INSTALL

if test "x${cache_file}" = "x/dev/null"; then
  # Likewise, ensure that CC and CPP are passed through to the pcre
  # configure script iff caching is disabled (the autoconf 2.5x default).
  export CC; export CPP
fi

echo $ac_n "Configuring Serf...${nl}"

dnl Absolute source/build directory
abs_srcdir=`(cd $srcdir && pwd)`
abs_builddir=`pwd`

dnl get our version information
get_version="$abs_srcdir/build/get-version.sh"
version_hdr="$abs_srcdir/serf.h"
SERF_MAJOR_VERSION="`$get_version major $version_hdr SERF`"
SERF_DOTTED_VERSION="`$get_version all $version_hdr SERF`"

AC_SUBST(SERF_MAJOR_VERSION)
AC_SUBST(SERF_DOTTED_VERSION)

AC_SUBST(SERF_BUILD_SRCLIB_DIRS)
AC_SUBST(SERF_CLEAN_SRCLIB_DIRS)

AC_ARG_WITH(openssl,
  APR_HELP_STRING([--with-openssl=PATH],[Path to OpenSSL (eg. /usr/local/ssl)]),
[
  if test "$withval" = "yes"; then
    AC_MSG_ERROR([--with-openssl requires a path])
  else
    openssl_prefix=$withval

    if test "x$openssl_prefix" != "x" -a ! -d "$openssl_prefix"; then
      AC_MSG_ERROR('--with-openssl requires a path to a directory')
    fi

    APR_ADDTO(CPPFLAGS, "-I${openssl_prefix}/include")
    if test -e "${openssl_prefix}/Makefile"; then
      APR_ADDTO(LDFLAGS, "-L${openssl_prefix}")
      APR_ADDTO(LDFLAGS, "-R${openssl_prefix}")
    else
      APR_ADDTO(LDFLAGS, "-L${openssl_prefix}/lib")
      APR_ADDTO(LDFLAGS, "-R${openssl_prefix}/lib")
    fi
  fi
])

dnl Look for OpenSSL
AC_CHECK_HEADER([openssl/opensslv.h], [],
                [AC_MSG_ERROR([We require OpenSSL; try --with-openssl])])

dnl Look for Kerberos 5 for GSSAPI
AC_ARG_WITH(gssapi,
  APR_HELP_STRING([--with-gssapi=PATH],[build with GSSAPI support; needs krb5-config in PATH/bin (eg. /usr/lib/mit)]),
[
  if test "$withval" = "yes"; then
    AC_MSG_ERROR([--with-gssapi requires a path])
  else
    gssapi_prefix=$withval/
  
    if test "x$gssapi_prefix" != "x" -a ! -d "$gssapi_prefix"; then
      AC_MSG_ERROR('--with-gssapi requires a path to a directory')
    fi
    AC_MSG_CHECKING([for krb5-config])
    if test -x "$gssapi_prefix/bin/krb5-config"; then
	krb5conf=$gssapi_prefix/bin/krb5-config
	AC_MSG_RESULT([$krb5conf])
	AC_MSG_CHECKING([for gssapi support in krb5-config])
	if "$krb5conf" | grep gssapi > /dev/null; then
		AC_MSG_RESULT([yes])
		GSSAPI_confopts=gssapi
	else
		AC_MSG_RESULT([no])
		GSSAPI_confopts=
	fi
	GSSAPI_cflags=`"$krb5conf" --cflags $GSSAPI_confopts`
	GSSAPI_libs=`"$krb5conf" --libs $GSSAPI_confopts`
	if test -z "$GSSAPI_confopts"; then
		case "${host_os}" in
			solaris*)		
			  GSSAPI_cflags="$GSSAPI_cflags -I/usr/include/gssapi"
			  GSSAPI_libs="$GSSAPI_libs -lgss"
			  ;;
		esac
	fi
	APR_ADDTO(CFLAGS, "$GSSAPI_cflags")
	APR_ADDTO(CFLAGS, [-DSERF_HAVE_GSSAPI])
	APR_ADDTO(LDFLAGS, "$GSSAPI_libs")
	AC_MSG_CHECKING([if gssapi works])
	AC_LINK_IFELSE([AC_LANG_SOURCE([[
#include <gssapi.h>
int main()
{gss_init_sec_context(NULL, NULL, NULL, NULL, NULL, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL);}]])],
	lib_gssapi="yes", lib_gssapi="no")
	if test "$lib_gssapi" = "yes"; then
		AC_MSG_RESULT([yes])
	else
		AC_MSG_RESULT([no])
		AC_MSG_ERROR([cannot find GSSAPI (Kerberos)])
	fi
    else
     	AC_MSG_RESULT([no])
	AC_MSG_WARN([--with-gssapi specified but krb5-config not found])
    fi

  fi
])


dnl CuTest requires libm on Solaris
AC_SEARCH_LIBS(fabs, m)

libs=""
if test -n "$apu_config"; then
  APR_ADDTO(libs, [`$apu_config --link-libtool --libs`])
fi
APR_ADDTO(libs, [`$apr_config --link-libtool --libs` $LIBS])

APR_ADDTO(SERF_LIBS, [$libs])
AC_SUBST(SERF_LIBS)

APR_RESTORE_THE_ENVIRONMENT(CPPFLAGS, EXTRA_)
APR_RESTORE_THE_ENVIRONMENT(CFLAGS, EXTRA_)
APR_RESTORE_THE_ENVIRONMENT(CXXFLAGS, EXTRA_)
APR_RESTORE_THE_ENVIRONMENT(LDFLAGS, EXTRA_)
APR_RESTORE_THE_ENVIRONMENT(LIBS, EXTRA_)
APR_RESTORE_THE_ENVIRONMENT(INCLUDES, EXTRA_)

AC_CONFIG_FILES([Makefile serf.pc])
AC_CONFIG_COMMANDS([mkdir-vpath],[make mkdir-vpath])

AC_OUTPUT