-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
274 lines (247 loc) · 5.67 KB
/
configure
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
#!/bin/sh
# Set define options
#
use_zlib=yes
use_debug=yes
# Set the prefix path
#
prefix=/opt/apache
# Set the install paths
#
bindir=${prefix}/bin
mandir=${prefix}/man
# Parse command line arguments
#
ac_prearg=
for ac_option
do
# If the previous option needs an argument, assign it.
#
if [ -n "$ac_prearg" ]; then
eval "$ac_prearg=\$ac_option"
ac_prearg=
continue
fi
ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
case $ac_option in
--prefix)
prefix=$ac_prearg
bindir=${prefix}/bin
mandir=${prefix}/man
;;
--prefix=*)
prefix=$ac_optarg
bindir=${prefix}/bin
mandir=${prefix}/man
;;
--bindir)
bindir=$ac_prearg
;;
--bindir=*)
bindir=$ac_optarg
;;
--mandir)
mandir=$ac_prearg
;;
--mandir=*)
mandir=$ac_optarg
;;
--enable-*)
ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
if [ "$ac_optarg" = "y" -o "$ac_optarg" = "yes" ]; then
ac_optarg=yes
else
ac_optarg=no
fi
eval use_${ac_feature}=$ac_optarg
;;
--disable-*)
ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
eval use_${ac_feature}=no
;;
*)
cat << EOF
Usage: configure [options]
Options: [defaults in brackets after descriptions]
Configuration:
--help print this message
Directory and file names:
--prefix=PREFIX install files in PREFIX [${prefix}]
--bindir=DIR user executables in DIR [PREFIX/bin]
--mandir=DIR man documentation in DIR [PREFIX/man]
Features and packages:
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--enable and --with options recognized:
--enable-zlib include zlib compression support [${use_zlib}]
--enable-debug include detailed error messages [${use_debug}]
EOF
exit 1
;;
esac
done
# Make sure environment is sane
#
rm -f ./dummy* ./defines.h 1>/dev/null 2>&1
# Determine what compiler to use
#
cat << EOF > ./dummy.c
int main(void) {return(0);}
EOF
if [ -n "$CC" ]; then
$CC -c -o ./dummy ./dummy.c 1>/dev/null 2>&1
if [ $? -ne 0 ]; then
$CC=
fi
fi
if [ -z "$CC" ]; then
for c in gcc egcs cc ; do
$c -c -o ./dummy ./dummy.c 1>/dev/null 2>&1
if [ $? -eq 0 ]; then
CC=$c
break
fi
done
rm -f ./dummy*
if [ -z "$CC" ]; then
echo "Checking compiler: not found."
echo
echo "No suitable compiler found. Install one or set $$CC env variable"
echo
exit 1
fi
fi
rm -f ./dummy* 1>/dev/null 2>&1
echo "Checking compiler: $CC found."
# Get the current version number
#
echo "#define VERSION \"`cat VERSION`\"" >> ./defines.h
# Test to see if zlib 1.1.3 is available
#
if [ "$use_zlib" = "yes" ]; then
cat << EOF > ./dummy.c
#include <stdio.h>
#include <zlib.h>
int main(void) {
return(printf("%s", ZLIB_VERSION));
}
EOF
$CC -o ./dummy ./dummy.c -lz 1>/dev/null 2>&1
if [ $? -eq 0 ]; then
if [ `./dummy` = "1.1.3" ]; then
use_zlib=yes
LDFLAGS="$LDFLAGS -lz"
echo "Checking zlib version: `./dummy` found."
echo "#define USE_ZLIB" >> ./defines.h
else
use_zlib=no
echo "Checking zlib version: `./dummy` found."
echo
echo "You must have at least version 1.1.3 installed."
echo "If you have something newer than 1.1.3 and you're getting this"
echo "message, edit defines.h and #define USE_ZLIB to enable it's use."
echo
echo "#undef USE_ZLIB" >> ./defines.h
fi
else
use_zlib=no
echo "Checking zlib version: not found."
echo "#undef USE_ZLIB" >> ./defines.h
fi
rm -f ./dummy* 1>/dev/null 2>&1
else
use_zlib=no
echo "#undef USE_ZLIB" >> ./defines.h
fi
# Test to see if errno functions are available
#
if [ "$use_debug" = "yes" ]; then
cat << EOF > ./dummy.c
#include <stdio.h>
#include <errno.h>
int main(void) {
return(printf("%s", strerror(errno)));
}
EOF
$CC -o ./dummy ./dummy.c 1>/dev/null 2>&1
if [ $? -eq 0 ]; then
use_debug=yes
echo "Checking errno functions: found."
echo "#define USE_DEBUG" >> ./defines.h
else
use_debug=no
echo "Checking errno functions: not found."
echo "#undef USE_DEBUG" >> ./defines.h
fi
rm -f ./dummy* 1>/dev/null 2>&1
else
use_debug=no
echo "#undef USE_DEBUG" >> ./defines.h
fi
# Test to see if hostent functions are avialable
#
cat << EOF > ./dummy.c
#include <stdio.h>
#include <netdb.h>
int main(void) {
struct hostent *hostinfo;
if ((hostinfo = gethostbyname("localhost")) != NULL)
return(0);
return(1);
}
EOF
$CC -o ./dummy ./dummy.c 1>/dev/null 2>&1
if [ $? -ne 0 ]; then
$CC -o ./dummy ./dummy.c -lresolv 1>/dev/null 2>&1
if [ $? -eq 0 ]; then
LDFLAGS="$LDFLAGS -lresolv"
else
$CC -o ./dummy ./dummy.c -lnsl 1>/dev/null 2>&1
if [ $? -eq 0 ]; then
LDFLAGS="$LDFLAGS -lnsl"
else
echo
echo "Unable to locate gethostbyname() function."
echo
echo "This program requires the use of hostname lookup functions, but"
echo "we are not able to find them on your system. Sorry."
echo
exit 1
fi
fi
fi
rm -f ./dummy* 1>/dev/null 2>&1
# Tell the user what they just did
#
cat << EOF
Your configuration settings are as follows:
Use zlib compression: ${use_zlib}
Use detailed errors: ${use_debug}
httplog install dir: ${bindir}
manpage install dir: ${mandir}
You are now ready to run 'make'.
EOF
# Make our Makefile now
#
if [ ! "$CFLAGS" ]; then
CFLAGS="-O2 -Wall"
fi
cat << EOF > ./Makefile
all:
${CC} ${CFLAGS} -o ./httplog ./httplog.c ${LDFLAGS}
@echo
@echo "Good, now you can run 'make install'."
@echo
clean:
rm -f ./dummy* ./httplog
distclean: clean
rm -f ./Makefile ./defines.h
install: install-bin install-man
install-bin:
install -d ${bindir}
install -s -m755 ./httplog ${bindir}/httplog
install-man:
install -d ${mandir}/man8
install -m644 ./httplog.8 ${mandir}/man8/httplog.8
EOF
#End of configure.