📄 configure
字号:
#!/bin/sh# $Id: configure,v 1.19 1999/12/17 14:05:01 arno Exp $echo=/bin/echorm -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.h>int main(int, char **) { cout << "hello" << endl; return 0;}EOFCXX=unknown;for i in "CC" "g++"; 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);}EOFfor 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" inunknown) $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();int main() { socket(); gethostbyname(); return 0;}EOFfor 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_DEFINITIONBOOL_DEFINITION#endifint main(int argc, char **) { bool x = argc == 3; x = !x; if (x && argc == 7) x = false; return 0;}EOFfor 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" inunknown) $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; }EOFfor 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" inunknown) $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>void func() { map<string, string> x; }EOFif $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>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;} EOFif 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.h>" >$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;cat <<EOF;You can now run "make depend" (if you have the MAKEDEPEND utility) andthen "make".EOF
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -