-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfigure.ac
273 lines (227 loc) · 8.2 KB
/
configure.ac
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
dnl +----------------------------------------------------------------------+
dnl | Init |
dnl +----------------------------------------------------------------------+
AC_INIT([mod_authnz_ibmdb2], [2.2.7-dev], [https://github.com/tessus/mod_authnz_ibmdb2/issues])
AC_MSG_NOTICE([Configuring $PACKAGE_NAME $PACKAGE_VERSION])
dnl +----------------------------------------------------------------------+
dnl | Configure Options |
dnl +----------------------------------------------------------------------+
AC_ARG_WITH(apxs,
AS_HELP_STRING([--with-apxs=FILE],
[FILE is the pathname of the Apache tool [apxs]]),
[APXS="$with_apxs"])
AC_ARG_WITH(IBM_DB2,
AS_HELP_STRING([--with-IBM_DB2=DIR],
[DIR is the IBM DB2 instance or home directory where the
DB2 application development headers and libraries are located]),
[IBM_DB2="$with_IBM_DB2"])
AC_ARG_ENABLE([man-pages],
AS_HELP_STRING([--disable-man-pages],
[do not install man pages @<:@default: no@:>@]),
[man_pages=${enableval}], [man_pages=yes])
AC_ARG_ENABLE([activation],
AS_HELP_STRING([--enable-activation],
[activate module in Apache config @<:@default: no@:>@]),
[activation=${enableval}], [activation=no])
if test "x${activation}" != "xno" && test "x${activation}" != "xyes"; then
AC_MSG_ERROR([--enable-activation can be either yes or no.])
fi
if test "x${man_pages}" != "xno" && test "x${man_pages}" != "xyes"; then
AC_MSG_ERROR([--enable-man_pages can be either yes or no.])
fi
dnl +----------------------------------------------------------------------+
dnl | config.nice macro |
dnl +----------------------------------------------------------------------+
AC_DEFUN([AC_CONFIG_NICE],
[
test -f $1 && mv $1 $1.old
rm -f $1.old
cat >$1<<EOF
#! /bin/sh
#
# Created by configure
EOF
for var in CFLAGS CXXFLAGS CPPFLAGS LDFLAGS LIBS CC CXX; do
eval val=\$$var
if test -n "$val"; then
echo "$var='$val' \\" >> $1
fi
done
for arg in [$]0 "[$]@"; do
echo "'[$]arg' \\" >> $1
done
echo '"[$]@"' >> $1
chmod +x $1
])
AC_CONFIG_NICE(config.nice)
dnl +----------------------------------------------------------------------+
dnl | Additional Init Macros |
dnl +----------------------------------------------------------------------+
AC_CONFIG_AUX_DIR([build])
AM_INIT_AUTOMAKE
AC_PROG_CC
AC_CANONICAL_HOST
dnl +----------------------------------------------------------------------+
dnl | Process Arguments |
dnl +----------------------------------------------------------------------+
if test -n "${APXS}"; then
AC_CHECK_FILE([$APXS], [], [APXS=no])
fi
if test -z "${APXS}"; then
AC_PATH_PROGS(APXS, apxs2 apxs, no, [/usr/local/apache/bin:/usr/sbin:/usr/local/apache2/bin:$PATH])
fi
if test "$APXS" = no; then
AC_MSG_ERROR([apxs not found. set apxs with --with-apxs.])
fi
AC_SUBST(APXS)
if test -n "$IBM_DB_HOME"; then
DB2DIR=$IBM_DB_HOME
fi
# option --with-apxs overrides the ENV var
if test -n "$IBM_DB2"; then
DB2DIR=$IBM_DB2
fi
if test -n "$CFLAGS"; then
MOD_CFLAGS="-Wc,\"$CFLAGS\""
fi
if test -n "$LDFLAGS"; then
MOD_LDFLAGS="-Wc,\"$LDFLAGS\""
fi
MOD_CFLAGS="-I${DB2DIR}/include $MOD_CFLAGS"
MOD_LDFLAGS="-L${DB2DIR}/lib $MOD_LDFLAGS"
AC_SUBST(MOD_CFLAGS)
AC_SUBST(MOD_LDFLAGS)
CFLAGS="$CFLAGS -I${DB2DIR}/include"
CPPFLAGS="$CPPFLAGS -I${DB2DIR}/include"
LDFLAGS="$LDFLAGS -L${DB2DIR}/lib"
AC_CHECK_HEADERS([sqlcli1.h])
AC_SEARCH_LIBS([SQLConnect], [db2],
,
AC_MSG_ERROR([DB2 CLI libraries not found. set DB2 HOME with --with-IBM_DB2.]))
AC_SUBST(DB2DIR)
dnl +----------------------------------------------------------------------+
dnl | Check Apache Version |
dnl +----------------------------------------------------------------------+
# my own super test to check fo the right Apache release
AC_DEFUN([AX_CHECK_APACHE_22_OR_GT],
[
AC_MSG_CHECKING([if Apache release is 2.2 or above])
cat > conftest2.c << EOF
#include "ap_release.h"
int main(){
if (AP_SERVER_MAJORVERSION_NUMBER == 2 && AP_SERVER_MINORVERSION_NUMBER >= 2)
return 0;
else
return -1;
}
EOF
AINC_DIR=`${APXS} -q exp_includedir`
if (($CC $CFLAGS -I $AINC_DIR -o conftest2 conftest2.c >&5) && (./conftest2))
then
#AC_MSG_RESULT([Apache release verified. All good.])
AC_MSG_RESULT([yes])
[$2]
else
#AC_MSG_RESULT([Apache release not 2.2 or above. Panic.])
AC_MSG_RESULT([no])
[$3]
fi
])dnl
AX_CHECK_APACHE_22_OR_GT(,,AC_MSG_ERROR([This module only works with Apache 2.2 and above.]))
dnl +----------------------------------------------------------------------+
dnl | OS specific flags and settings |
dnl +----------------------------------------------------------------------+
AC_MSG_CHECKING(for architecture)
case "$host_os" in
linux*)
ARCH="linux"
;;
aix*)
ARCH="aix"
;;
darwin*|rhapsody*)
ARCH="osx"
;;
*solaris*)
ARCH="solaris"
;;
hpux*)
ARCH="hpux"
;;
freebsd*)
ARCH="freebsd"
;;
netbsd*)
ARCH="netbsd"
;;
osf*)
ARCH="osf"
;;
openbsd*)
ARCH="openbsd"
;;
*)
ARCH="unknown"
;;
esac
AC_MSG_RESULT([$ARCH ($host_os)])
if test "x$ARCH" = "xaix"; then
DB2_LDFLAGS="-Wl,-G,-blibpath:$DB2DIR/lib"
else
DB2_LDFLAGS="-Wl,-rpath,$DB2DIR/lib"
fi
AC_SUBST(DB2_LDFLAGS)
if test "x$ARCH" = "xosx"; then
EXTRA_LDFLAGS="-Wc,\"-arch x86_64\" -Wl,\"-arch x86_64\""
AC_SUBST(EXTRA_LDFLAGS)
fi
dnl +----------------------------------------------------------------------+
dnl | Process Options |
dnl +----------------------------------------------------------------------+
AC_MSG_CHECKING(whether we want to activate the module in Apache config)
if test "x${activation}" = "xno"; then
AC_MSG_RESULT([no])
ACTIVATE=-A
else
AC_MSG_RESULT([yes])
ACTIVATE=-a
fi
AC_SUBST(ACTIVATE)
AC_MSG_CHECKING(whether we want to install the man pages)
if test "x${man_pages}" = "xyes"; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
fi
AM_CONDITIONAL([NO_MAN_PAGES], [test x$man_pages = xno])
dnl +----------------------------------------------------------------------+
dnl | Create config.h |
dnl +----------------------------------------------------------------------+
echo "#define MODULE \"$PACKAGE_NAME\"" >src/config.h
echo "#define RELEASE \"$PACKAGE_VERSION\"" >>src/config.h
dnl +----------------------------------------------------------------------+
dnl | Output |
dnl +----------------------------------------------------------------------+
MOD_LOC=`${APXS} -q exp_libexecdir`
CONF_LOC=`${APXS} -q exp_sysconfdir`
AC_CONFIG_FILES([Makefile src/Makefile man/Makefile])
AC_OUTPUT
echo "
+----------------------------------------------------------------------+
| Configuration Summary |
+----------------------------------------------------------------------+
mod_authnz_ibmdb2: ${PACKAGE_VERSION}
Detected OS: ${host_os}
Compilation arch: ${ARCH}
apxs: ${APXS}
DB2 home: ${DB2DIR}
Activate module: ${activation}
Install man pages: ${man_pages}
Module location: ${MOD_LOC}
+----------------------------------------------------------------------+
| Now run: make install |
| (as root or with sudo) |
| |
| http://tessus.github.io/mod_authnz_ibmdb2 |
+----------------------------------------------------------------------+
"