-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathconfigure
executable file
·335 lines (276 loc) · 6.14 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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
#!/bin/sh
#
# configure script
# $Id: configure,v 1.14 1999/10/04 04:44:22 kaz Exp $
#
#
# Check for cc
#
echo Checking for gcc
#
# typhoon uses a mixture of POSIX, BSD and System V interfaces
#
OS=$(uname -s)
case $OS in
'Darwin')
STANDARDS="-D_BSD_SOURCE -D_SVID_SOURCE"
;;
*)
STANDARDS="-D_POSIX_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE"
;;
esac
if type gcc >/dev/null 2>/dev/null ; then
CC=gcc
CARGS="-pedantic $STANDARDS"
CFLAGS="-g -Wall -pedantic -Wstrict-prototypes -Wmissing-prototypes $STANDARDS \$(DEFINES)"
else
CC=cc
CARGS="$STANDARDS"
CFLAGS="-g $STANDARDS \$(DEFINES)"
fi
compile='$CC $CARGS -o conftest conftest.c >/dev/null 2>&1'
compiled_ok='test -s conftest && (./conftest) >/dev/null 2>/dev/null;'
DEFS='' # additional -D compiler defines go here
ENVIRON_H=./include/environ.h
ANSI_H=./include/ansi.h
# ------------------------------------------------------------
# This section generates ./include/environ.h
# ------------------------------------------------------------
echo Generating $ENVIRON_H
echo "/*
* environ.h
*
* Generated by configure
*
*/
#ifndef TYPHOON_ENVIRON_H
#define TYPHOON_ENVIRON_H
#include <sys/types.h>
#include <stddef.h>
#define CONFIG_CREATMASK 0666
#define CONFIG_O_BINARY 0
#define CONFIG_DIR_SWITCH '/'
#ifndef offsetof
#define offsetof(s,m) ((int)&(((s *)0))->m)
#endif
#if defined(sparc) || defined(mips) || defined(HPUX) || defined(__alpha)
#define CONFIG_RISC 1
#endif
#define CONFIG_UNIX 1" > $ENVIRON_H
#
# Check endianess
#
echo Checking endianess
echo "main()
{
short u=0;
*(char *)&u = 1;
return u;
}
" > conftest.c
eval $compile
if test -s conftest && (./conftest) >/dev/null 2>/dev/null ; then ENDIAN="BIG";
else ENDIAN="LITTLE"
fi
echo "#define CONFIG_${ENDIAN}_ENDIAN 1" >> $ENVIRON_H
#
# Check for prototypes
#
echo Checking for prototypes
rm -f conftest*
echo "int foo(int);
int foo(int a) { return ++a; }
int main(void) { (void)foo(2); return 0; } " > conftest.c
eval $compile
if ! test -s conftest || ! (./conftest) >/dev/null 2>/dev/null ; then
echo "#define PRM(x) ();
#define CONFIG_ELLIPSIS /**/" >> $ENVIRON_H ;
else echo "#define CONFIG_PROTOTYPES 1
#define PRM(x) x
#define CONFIG_ELLIPSIS ,..." >> $ENVIRON_H
fi
#
# Check for ANSI C const keyword
#
echo Checking for const keyword
rm -f conftest*
cat << END > conftest.c
int main()
{
const int x = 24;
return 0;
}
END
eval $compile
if test -s conftest && (./conftest) >/dev/null 2>/dev/null ; then
echo "#define CONFIG_CONST const" >> $ENVIRON_H
else
echo "#define CONFIG_CONST /**/" >> $ENVIRON_H
fi
#
# Check for size_t type
#
echo Checking for size_t type
rm -f conftest*
cat << END > conftest.c
#include <stddef.h>
int main()
{
size_t x = 42;
return 0;
}
END
eval $compile
if ! test -s conftest || ! (./conftest) >/dev/null 2>/dev/null ; then
echo "typedef unsigned int size_t;" >> $ENVIRON_H
fi
#
# Check for off_t type
#
echo Checking for off_t type
rm -f conftest*
cat << END > conftest.c
#include <sys/types.h>
#include <unistd.h>
int main()
{
off_t x = 42;
return 0;
}
END
eval $compile
if ! test -s conftest || ! (./conftest) >/dev/null 2>/dev/null ; then
echo "typedef unsigned long off_t;" >> $ENVIRON_H
fi
#
# Check for mode_t type
#
echo Checking for mode_t type
rm -f conftest*
cat << END > conftest.c
#include <sys/types.h>
#include <sys/stat.h>
int main()
{
mode_t x = 42;
return 0;
}
END
eval $compile
if ! test -s conftest || ! (./conftest) >/dev/null 2>/dev/null ; then
echo "typedef unsigned mode_t;" >> $ENVIRON_H
fi
#
# Check for uchar, ushort and ulong
#
for type in char short long
do
echo Checking for u$type
rm -f conftest*
echo "#include <sys/types.h>
int main() { u$type a; return 0; } " > conftest.c
eval $compile
if test -s conftest && (./conftest) >/dev/null 2>/dev/null ; then :
else echo "typedef unsigned $type u$type;" >> $ENVIRON_H
fi
done
#
# Check for locking via fcntl().
#
echo Checking for POSIX 'fcntl()' with F_SETLK and F_GETLK
rm -f conftest*
cat << END > conftest.c
#include <unistd.h>
#include <fcntl.h>
int main()
{
struct flock flk;
int fd = creat("conftest.data", O_RDWR);
char testdata[] = "aaaaaaaaaaaaaaaa";
if (fd == -1)
return 1;
if (write(fd, testdata, sizeof testdata) != sizeof testdata)
return 1;
flk.l_type = F_WRLCK;
flk.l_whence = SEEK_SET;
flk.l_start = 0;
flk.l_len = 16;
if (fcntl(fd, F_SETLK, &flk) == -1)
return 1;
return 0;
}
END
eval $compile
if test -s conftest || ! (./conftest) >/dev/null 2>/dev/null ; then
echo "#define CONFIG_USE_FLOCK 1" >> $ENVIRON_H
fi
rm -f conftest*
echo "#endif
/* end-of-file */" >> $ENVIRON_H
# ------------------------------------------------------------
# This section generates ./include/ansi.h
# ------------------------------------------------------------
echo Generating $ANSI_H
echo "/*
* ansi.h
*
* Generated by configure
*
*/
#ifndef TYPHOON_ANSI_H
#define TYPHOON_ANSI_H
" > $ANSI_H
#
# Check ansi C functions
#
for func in strstr memmove
do
echo Checking for $func
rm -f conftest*
echo "#include <sys/types.h>
int main() {} foo() { $func(); return 0; } " > conftest.c
eval $compile
if test -s conftest && (./conftest) >/dev/null 2>/dev/null ; then :
echo "#define `echo CONFIG_${func}|tr '[a-z]' '[A-Z]'`_MISSING" >> $ANSI_H
fi
done
rm -f conftest*
echo "
#endif
/* end-of-file */" >> $ANSI_H
# ------------------------------------------------------------
# This section generates Makefile
# ------------------------------------------------------------
#
# Check for ranlib
#
echo Checking for ranlib
if test -z "$RANLIB" && type ranlib >/dev/null 2>/dev/null ; then
RANLIB=ranlib
else
RANLIB=true
fi
#
# Check for bison/yacc, giving preference to bison
#
echo Checking for bison/yacc
if test -z "$YACC" && type bison >/dev/null 2>/dev/null ; then
YACC="bison --yacc"
else
YACC=yacc
fi
#
# Now generate Makefile from Makefile.in by substituting the @xxx@ names.
#
for dir in src util examples
do
echo Generating $dir/Makefile
echo "# Makefile generated by configure" > $dir/Makefile
cat $dir/Makefile.in | sed -e "
s/@defs@/$DEFS/
s/@ranlib@/$RANLIB/
s/@yacc@/$YACC/
s/@cc@/$CC/
s/@cflags@/$CFLAGS/
" >> $dir/Makefile ;
done