1#! /bin/sh 2 3# This program is free software; you can redistribute it and/or modify 4# it under the terms of the GNU General Public License as published by 5# the Free Software Foundation; either version 2 of the License, or 6# (at your option) any later version. 7# 8# This program is distributed in the hope that it will be useful, 9# but WITHOUT ANY WARRANTY; without even the implied warranty of 10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11# GNU General Public License in the file COPYING for more details. 12 13# Changes to version 1.2.2 were made by Martin Bayer <mbayer@zedat.fu-berlin.de> 14# Dates and reasons of modifications: 15# Son Mar 18 21:55:24 CET 2001 16# Fre Jun 8 18:46:58 CEST 2001 17# Thu Oct 4 21:54:50 CEST 2001 18# Sun Apr 7 12:04:48 CEST 2002 19# Tue Nov 11 21:30:26 CET 2003 20 21 22echo='/bin/echo' 23 24rm -rf configure-tmp || exit 1; 25mkdir configure-tmp || exit 1; 26tmp_file="configure-tmp/xxx"; 27makedirs="."; 28 29# 30# $CXX 31# 32 33$echo 'Checking C++ compiler... \c'; 34cat <<EOF >$tmp_file.C; 35#include <iostream> 36int main(int, char **) { 37 std::cout << "hello" << std::endl; 38 return 0; 39} 40EOF 41for i in "$CXX" "c++"; do 42 if $i -c $tmp_file.C 2>/dev/null; then 43 CXX="$i"; 44 break; 45 fi; 46done; 47if test "$CXX" = unknown; then 48 $echo "Error: Could not find a working C++ compiler."; 49 exit 1; 50fi; 51$echo "use \"$CXX\""; 52 53# 54# $SYS_POLL_MISSING 55# 56 57$echo 'Checking <sys/poll.h>... \c'; 58SYS_POLL_MISSING=unknown; 59cat <<EOF >$tmp_file.C; 60#ifdef SYS_POLL_MISSING /* { */ 61struct pollfd { int fd; short events; short revents; }; 62extern "C" int poll(struct pollfd *ufds, unsigned int nfds, int timeout); 63#define POLLIN 0x0001 64#define POLLPRI 0x0002 65#define POLLOUT 0x0004 66#define POLLERR 0x0008 67#define POLLHUP 0x0010 68#define POLLNVAL 0x0020 69#else /* } { */ 70#include <sys/poll.h> 71#endif /* } */ 72int main() { 73 struct pollfd fds[3]; 74 return poll(fds, 3, 700); 75} 76EOF 77for i in "" -DSYS_POLL_MISSING; do 78 if $CXX $tmp_file.C $i -o $tmp_file 2>/dev/null; then 79 SYS_POLL_MISSING="$i"; 80 break; 81 fi; 82done; 83case "$SYS_POLL_MISSING" in 84unknown) 85 $echo 'Error: Could not get "poll()" to working.'; 86 exit 1;; 87"") 88 $echo "OK";; 89*) 90 $echo "use \"$SYS_POLL_MISSING\"";; 91esac; 92 93# 94# $SOCKET_LIBRARIES 95# 96 97$echo 'Checking for socket libraries... \c'; 98SOCKET_LIBRARIES=unknown; 99cat >$tmp_file.C <<EOF; 100extern "C" int socket(); 101extern "C" void gethostbyname(); 102int main() { 103 socket(); 104 gethostbyname(); 105 return 0; 106} 107EOF 108for i in "" "-lbsocket" "-lbsocket -lnsl" "-lsocket" "-lsocket -lnsl"; do 109 if $CXX $tmp_file.C $i -o $tmp_file 2>/dev/null; then 110 SOCKET_LIBRARIES="$i"; 111 break; 112 fi; 113done; 114if test "$SOCKET_LIBRARIES" = unknown; then 115 $echo "Error: Could not determine the library for the socket API."; 116 exit 1; 117fi; 118if test "$SOCKET_LIBRARIES" = ""; then 119 $echo "no extra libraries required"; 120else 121 $echo "use \"$SOCKET_LIBRARIES\""; 122fi; 123 124# 125# $BOOL_DEFINITION 126# 127 128$echo 'Checking "bool"... \c'; 129BOOL_DEFINITION=unknown; 130cat <<EOF >$tmp_file.C; 131#ifdef BOOL_DEFINITION 132BOOL_DEFINITION 133#endif 134int main(int argc, char **) { 135 bool x = argc == 3; 136 x = !x; 137 if (x && argc == 7) x = false; 138 return 0; 139} 140EOF 141for i in \ 142 '' \ 143 '-DBOOL_DEFINITION="typedef unsigned char bool;const bool false=0,true=1;"' \ 144 '-DBOOL_DEFINITION="enum bool{false,true};"'; \ 145do 146 if eval "$CXX $tmp_file.C $i -o $tmp_file 2>/dev/null"; then 147 BOOL_DEFINITION="$i"; 148 break; 149 fi; 150done; 151case "$BOOL_DEFINITION" in 152unknown) 153 $echo 'Error: Could not a suitable definition for "bool".'; 154 exit 1;; 155"") 156 $echo "built-in";; 157*) 158 $echo "use '$BOOL_DEFINITION'";; 159esac; 160 161# 162# $EXPLICIT 163# 164 165$echo 'Checking "explicit"... \c'; 166EXPLICIT=unknown; 167cat <<EOF >$tmp_file.C; 168struct C { 169 explicit C(int) {} 170}; 171int main(int, char **) { C x(7); return 0; } 172EOF 173for i in \ 174 '' \ 175 '-Dexplicit='; \ 176do 177 if eval "$CXX $tmp_file.C $i -o $tmp_file 2>/dev/null"; then 178 EXPLICIT="$i"; 179 break; 180 fi; 181done; 182case "$EXPLICIT" in 183unknown) 184 $echo 'Error: Could not a suitable definition for "explicit".'; 185 exit 1;; 186"") 187 $echo "built-in";; 188*) 189 $echo "use '$EXPLICIT'";; 190esac; 191 192# 193# $LIBSTDCXX_INCLUDES, $LIBSTDCXX_LIBS 194# 195 196$echo 'Checking Standard C++ library... \c'; 197cat <<EOF >$tmp_file.C; 198#include <string> 199#include <list> 200#include <memory> 201#include <utility> 202#include <map> 203#include <set> 204#include <new> 205#include <vector> 206using namespace std; 207int main(void) { 208 map<string, string> x; 209 return 0; 210} 211EOF 212if $CXX $tmp_file.C 2>/dev/null; then 213 LIBSTDCXX_INCLUDES=""; 214 LIBSTDCXX_LIBS=""; 215 $echo 'works; no need to make "./libstd"'; 216elif $CXX $tmp_file.C -lstdc++ 2>/dev/null; then 217 LIBSTDCXX_INCLUDES=""; 218 LIBSTDCXX_LIBS="-lstdc++"; 219 $echo 'works with libstdc++; no need to make "./libstd"'; 220else 221 LIBSTDCXX_INCLUDES='-Ilibstd/include'; 222 LIBSTDCXX_LIBS='libstd/libstd.a'; 223 echo 'not available or not working; use "./libstd"'; 224 makedirs="$makedirs ./libstd"; 225fi; 226 227# 228# $AUTO_PTR_BROKEN 229# 230AUTO_PTR_BROKEN=""; 231$echo 'Checking "auto_ptr"... \c'; 232cat <<EOF >$tmp_file.C; 233#include <memory> 234#include <string> 235#include <list> 236using namespace std; 237int main(int, char**) { 238 auto_ptr<string> x(new string("hello")); 239 *x = "world"; 240 (void) x.get(); 241 (void) x.release(); 242 x.reset(0); // egcs-2.91.66 lacks "reset()"! 243 244 // G++ 2.95.1 on AIX 4.2 cannot compile this: 245 auto_ptr<int> api; 246 list<auto_ptr<int> > lapi; 247 lapi.push_back(api); 248 249 return 0; 250} 251EOF 252if eval "$CXX -c $LIBSTDCXX_INCLUDES $EXPLICIT $BOOL_DEFINITION $tmp_file.C" 2>/dev/null; then 253 $echo 'defined in <memory>, good'; 254else 255 $echo 'not defined or not working, use "./libstd/include/auto_ptr.h"'; 256 AUTO_PTR_BROKEN="-DAUTO_PTR_BROKEN"; 257fi; 258 259# 260# $MAKEDEPEND_INCLUDES 261# 262MAKEDEPEND_INCLUDES=""; 263$echo 'Checking "makedepend" includes... \c'; 264echo "#include <iostream>" >$tmp_file.C; 265MAKEDEPEND_INCLUDES=`$CXX -E $tmp_file.C 2>/dev/null | 266sed -n \ 267 -e 's/^#line .*"\(\/.*\)\/.*".*/-I\1/p' \ 268 -e 's/^# [1-9][0-9]* "\(\/.*\)\/.*".*/-I\1/p' | 269sort -u | 270tr '\n' ' '`; 271 272if test "$MAKEDEPEND_INCLUDES" = ""; then 273 $echo none; 274else 275 $echo "use \"$MAKEDEPEND_INCLUDES\""; 276fi; 277 278# 279# Create "Makefile" from "Makefile.in". 280# 281 282rm -f Makefile libstd/Makefile; 283cmd=sed; 284for i in \ 285 SYS_POLL_MISSING \ 286 SOCKET_LIBRARIES \ 287 CXX \ 288 BOOL_DEFINITION \ 289 EXPLICIT \ 290 LIBSTDCXX_INCLUDES \ 291 LIBSTDCXX_LIBS \ 292 AUTO_PTR_BROKEN \ 293 MAKEDEPEND_INCLUDES; \ 294do cmd="$cmd -e \"s|@$i@|\$$i|g\""; done; 295for dir in $makedirs; do 296 $echo "Creating \"$dir/Makefile\" from \"$dir/Makefile.in\"... \\c"; 297 cat <<EOF >$dir/Makefile; 298 299# 300# This make file was generated from "Makefile.in" by "./configure" on 301# `date` -- all your changes will be lost if you 302# run "./configure" again! 303# 304 305EOF 306 eval "$cmd" <$dir/Makefile.in >>$dir/Makefile; 307 $echo 'done'; 308 if test -f $dir/Dependencies; then true; else >$dir/Dependencies; fi; 309done; 310 311# 312# Clean up. 313# 314 315rm -rf configure-tmp; 316rm -f xxx.o; 317 318cat <<EOF; 319 320Preparing completed. You may now run "make" (or "gmake"). 321 322EOF 323