File: configure

package info (click to toggle)
html2text 1.3.2a-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 736 kB
  • ctags: 1,694
  • sloc: cpp: 9,311; yacc: 828; sh: 209; makefile: 144
file content (316 lines) | stat: -rwxr-xr-x 6,745 bytes parent folder | download | duplicates (7)
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
#! /bin/sh

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License in the file COPYING for more details.

# Changes to version 1.2.2 were made by Martin Bayer <mbayer@zedat.fu-berlin.de>
# Dates and reasons of modifications:
# Son Mar 18 21:55:24 CET 2001
# Fre Jun  8 18:46:58 CEST 2001
# Thu Oct  4 21:54:50 CEST 2001
# Sun Apr  7 12:04:48 CEST 2002
# Tue Nov 11 21:30:26 CET 2003


echo='/bin/echo -e'

rm -rf configure-tmp || exit 1;
mkdir configure-tmp || exit 1;
tmp_file="configure-tmp/xxx";
makedirs=".";

#
# $CXX
#

$echo 'Checking C++ compiler... \c';
cat <<EOF >$tmp_file.C;
#include <iostream>
int main(int, char **) {
  std::cout << "hello" << std::endl;
  return 0;
}
EOF
CXX=unknown;
for i in "CC" "g++" "cc" "$CC"; do
  if $i -c $tmp_file.C 2>/dev/null; then
    CXX="$i";
    break;
  fi;
done;
if test "$CXX" = unknown; then
  $echo "Error: Could not find a working C++ compiler.";
  exit 1;
fi;
$echo "use \"$CXX\"";

#
# $SYS_POLL_MISSING
#

$echo 'Checking <sys/poll.h>... \c';
SYS_POLL_MISSING=unknown;
cat <<EOF >$tmp_file.C;
#ifdef SYS_POLL_MISSING /* { */
struct pollfd { int fd; short events; short revents; };
extern "C" int poll(struct pollfd *ufds, unsigned int nfds, int timeout);
#define POLLIN      0x0001
#define POLLPRI     0x0002
#define POLLOUT     0x0004
#define POLLERR     0x0008
#define POLLHUP     0x0010
#define POLLNVAL    0x0020
#else /* } { */
#include <sys/poll.h>
#endif /* } */
int main() {
  struct pollfd fds[3];
  return poll(fds, 3, 700);
}
EOF
for i in "" -DSYS_POLL_MISSING; do
  if $CXX $tmp_file.C $i -o $tmp_file 2>/dev/null; then
    SYS_POLL_MISSING="$i";
    break;
  fi;
done;
case "$SYS_POLL_MISSING" in
unknown)
  $echo 'Error: Could not get "poll()" to working.';
  exit 1;;
"")
  $echo "OK";;
*)
  $echo "use \"$SYS_POLL_MISSING\"";;
esac;

#
# $SOCKET_LIBRARIES
#

$echo 'Checking for socket libraries... \c';
SOCKET_LIBRARIES=unknown;
cat >$tmp_file.C <<EOF;
extern "C" int socket();
extern "C" void gethostbyname();
int main() {
  socket();
  gethostbyname();
  return 0;
}
EOF
for i in "" "-lbsocket" "-lbsocket -lnsl" "-lsocket" "-lsocket -lnsl"; do
  if $CXX $tmp_file.C $i -o $tmp_file 2>/dev/null; then
    SOCKET_LIBRARIES="$i";
    break;
  fi;
done;
if test "$SOCKET_LIBRARIES" = unknown; then
  $echo "Error: Could not determine the library for the socket API.";
  exit 1;
fi;
if test "$SOCKET_LIBRARIES" = ""; then
  $echo "no extra libraries required";
else
  $echo "use \"$SOCKET_LIBRARIES\"";
fi;

#
# $BOOL_DEFINITION
#

$echo 'Checking "bool"... \c';
BOOL_DEFINITION=unknown;
cat <<EOF >$tmp_file.C;
#ifdef BOOL_DEFINITION
BOOL_DEFINITION
#endif
int main(int argc, char **) {
  bool x = argc == 3;
  x = !x;
  if (x && argc == 7) x = false;
  return 0;
}
EOF
for i in \
  '' \
  '-DBOOL_DEFINITION="typedef unsigned char bool;const bool false=0,true=1;"' \
  '-DBOOL_DEFINITION="enum bool{false,true};"'; \
do
  if eval "$CXX $tmp_file.C $i -o $tmp_file 2>/dev/null"; then
    BOOL_DEFINITION="$i";
    break;
  fi;
done;
case "$BOOL_DEFINITION" in
unknown)
  $echo 'Error: Could not a suitable definition for "bool".';
  exit 1;;
"")
  $echo "built-in";;
*)
  $echo "use '$BOOL_DEFINITION'";;
esac;

#
# $EXPLICIT
#

$echo 'Checking "explicit"... \c';
EXPLICIT=unknown;
cat <<EOF >$tmp_file.C;
struct C {
  explicit C(int) {}
};
int main(int, char **) { C x(7); return 0; }
EOF
for i in \
  '' \
  '-Dexplicit='; \
do
  if eval "$CXX $tmp_file.C $i -o $tmp_file 2>/dev/null"; then
    EXPLICIT="$i";
    break;
  fi;
done;
case "$EXPLICIT" in
unknown)
  $echo 'Error: Could not a suitable definition for "explicit".';
  exit 1;;
"")
  $echo "built-in";;
*)
  $echo "use '$EXPLICIT'";;
esac;

#
# $LIBSTDCXX_INCLUDES, $LIBSTDCXX_LIBS
#

$echo 'Checking Standard C++ library... \c';
cat <<EOF >$tmp_file.C;
#include <string>
#include <list>
#include <memory>
#include <utility>
#include <map>
#include <set>
#include <new>
#include <vector>
using namespace std;
void func() { map<string, string> x; }
EOF
if $CXX -c $tmp_file.C 2>/dev/null; then
  LIBSTDCXX_INCLUDES="";
  LIBSTDCXX_LIBS="";
  $echo 'works; no need to make "./libstd"';
else
  LIBSTDCXX_INCLUDES='-Ilibstd/include';
  LIBSTDCXX_LIBS='libstd/libstd.a';
  echo 'not available or not working; use "./libstd"';
  makedirs="$makedirs ./libstd";
fi;

#
# $AUTO_PTR_BROKEN
#
AUTO_PTR_BROKEN="";
$echo 'Checking "auto_ptr"... \c';
cat <<EOF >$tmp_file.C;
#include <memory>
#include <string>
#include <list>
using namespace std;
int main(int, char**) {
  auto_ptr<string> x(new string("hello"));
  *x = "world";
  (void) x.get();
  (void) x.release();
  x.reset(0);   // egcs-2.91.66 lacks "reset()"!

  // G++ 2.95.1 on AIX 4.2 cannot compile this:
  auto_ptr<int> api;
  list<auto_ptr<int> > lapi;
  lapi.push_back(api);

  return 0;
}  
EOF
if eval "$CXX -c $LIBSTDCXX_INCLUDES $EXPLICIT $BOOL_DEFINITION $tmp_file.C" 2>/dev/null; then
  $echo 'defined in <memory>, good';
else
  $echo 'not defined or not working, use "./libstd/include/auto_ptr.h"';
  AUTO_PTR_BROKEN="-DAUTO_PTR_BROKEN";
fi;

#
# $MAKEDEPEND_INCLUDES
#
MAKEDEPEND_INCLUDES="";
$echo 'Checking "makedepend" includes... \c';
echo "#include <iostream>" >$tmp_file.C;
MAKEDEPEND_INCLUDES=`$CXX -E $tmp_file.C 2>/dev/null |
sed -n \
  -e 's/^#line .*"\(\/.*\)\/.*".*/-I\1/p' \
  -e 's/^# [1-9][0-9]* "\(\/.*\)\/.*".*/-I\1/p' |
sort -u |
tr '\n' ' '`;

if test "$MAKEDEPEND_INCLUDES" = ""; then
  $echo none;
else
  $echo "use \"$MAKEDEPEND_INCLUDES\"";
fi;

#
# Create "Makefile" from "Makefile.in".
#

rm -f Makefile libstd/Makefile;
cmd=sed;
for i in \
  SYS_POLL_MISSING \
  SOCKET_LIBRARIES \
  CXX \
  BOOL_DEFINITION \
  EXPLICIT \
  LIBSTDCXX_INCLUDES \
  LIBSTDCXX_LIBS \
  AUTO_PTR_BROKEN \
  MAKEDEPEND_INCLUDES; \
do cmd="$cmd -e \"s|@$i@|\$$i|g\""; done;
for dir in $makedirs; do
  $echo "Creating \"$dir/Makefile\" from \"$dir/Makefile.in\"... \\c";
  cat <<EOF >$dir/Makefile;

#
# This make file was generated from "Makefile.in" by "./configure" on
# `date` -- all your changes will be lost if you
# run "./configure" again!
#

EOF
  eval "$cmd" <$dir/Makefile.in >>$dir/Makefile;
  $echo 'done';
  if test -f $dir/Dependencies; then true; else >$dir/Dependencies; fi;
done;

#
# Clean up.
#

rm -rf configure-tmp;
rm -f xxx.o;

cat <<EOF;

Preparing completed. You may now run "make" (or "gmake").

EOF