#! /bin/sh # $Id: configure,v 1.4 2004/05/29 14:46:09 mjt Exp $ # autoconf-style configuration script # Author: Michael Tokarev # License: GPL name=proxycheck case "$1" in --help | --hel | --he | --h | -help | -hel | -he | -h ) cat <&2; exit 1 ;; esac if [ -f proxycheck.c -a -f event.h -a -f CHANGES -a -f Makefile.in ] ; then : else echo "configure: error: sources not found at `pwd`" >&2 exit 1 fi set -e rm -f conftest* confdef* config.log exec 5>config.log cat <&5 This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. EOF cat >confdef.h <>confdef.h } ac_subst() { subst="$subst $*" } ac_error() { if [ -n "$*" ]; then echo "configure: $*" >&2 fi echo "configure: see config.log and conftest.* for possible explanation" exit 1 } ac_checking() { echo $en "checking $1... $ec" >&2 echo >&5 echo "configure: *** checking for $1 ***" >&5 } read VERSION_DATE VERSION < CHANGES ac_subst VERSION VERSION_DATE echo "Configuring $name $VERSION ($VERSION_DATE)" echo ### check for C compiler. Set $CC ### ac_checking "for C compiler" rm -f conftest*; cat >conftest.c <&5 && ./conftest 2>&5 ; then echo "\$CC ($CC)" >&2 else echo no >&2 ac_error "\$CC ($CC) is not a working compiler" fi else for cc in gcc cc ; do if $cc -o conftest conftest.c 2>&5 && ./conftest 2>&5 ; then echo $cc CC=$cc break fi done if [ -z "$CC" ]; then echo no ac_error "no working C compiler found in \$PATH" fi fi ac_subst CC if [ -z "$CFLAGS" ]; then ac_checking "whenever C compiler ($CC) is GNU CC" rm -f conftest*; cat >conftest.c <&5 | grep yes_it_is_gcc >/dev/null ; then echo yes CFLAGS="-Wall -W -O2" else echo no CFLAGS=-O fi fi cc="$CC $CFLAGS" if [ -z "$LDFLAGS" ]; then LDFLAGS='$(CFLAGS)'; ldflags= else ldflags="$LDFLAGS" fi ccld="$cc $ldflags -o conftest conftest.c" cpp="$cc -E conftest.c" cc="$cc -c conftest.c" ac_subst CFLAGS LDFLAGS ac_run() { ac_checking "$1" rm -f conftest*; cat >conftest.c if $ccld $2 2>&5 && ./conftest 2>&5 ; then echo ${3:-yes} >&2 return 0 else echo ${4:-no} >&2 return 1 fi } ac_link() { ac_checking "$1" rm -f conftest*; cat >conftest.c if $ccld $2 2>&5 ; then echo ${3:-yes} >&2 return 0 else echo ${4:-no} >&2 return 1 fi } ac_cpp() { ac_checking "$1" rm -f conftest*; cat >conftest.c if $cpp $2 2>&5 ; then echo ${3:-yes} >&2 return 0 else echo ${4:-no} >&2 return 1 fi } ac_run "whenever C compiler ($CC) works" </dev/null || exit 1 #include int main(int argc, char **argv) { puts("hello, world!"); return 0; } EOF if ac_link "for socket routines" <" </dev/null && ac_define HAVE_SYS_SELECT_H #include #include #include #include int foo() { return 0; } EOF ac_link "for poll()" < #include int main() { struct pollfd pfd[2]; return poll(pfd, 2, 10); } EOF ac_link "for epoll" < #include #include int main() { struct epoll_event ev; ev.events = EPOLLIN; ev.data.fd = 0; epoll_create(10); epoll_ctl(10, EPOLL_CTL_ADD, 0, &ev); return 0; } EOF ac_link "for kqueue" < #include #include int main() { struct kevent ke; EV_SET(&ke, 1, EVFILT_READ, EV_ADD, 0, 0, 0); kqueue(); kevent(10, &ke, 1, 0, 0, 0); return 0; } EOF ac_link "for devpoll" < #include #include #include #include int main() { struct pollfd pfd; dvpoll_t dp; pfd.fd = 10; pfd.events = POLLIN|POLLREMOVE; dp.dp_timeout = 10; dp.dp_nfds = 1; dp.dp_fds = &pfd; ioctl(10, DP_POLL, &dp); return 0; } EOF echo "Using the following I/O multiplexing methods: $ev_methods" >&2 ac_link "for memmem()" < int main(int argc, char **argv) { memmem(argv[0], 'a', 10); return 0; } EOF echo $en "creating Makefile... $ec" for var in $subst LIBS DEFS ; do eval echo "\"s|@$var@|\$$var|\"" done >>confdef.sed rm -f Makefile.tmp echo "# Automatically generated from Makefile.in by configure" >Makefile.tmp echo "#" >>Makefile.tmp sed -f confdef.sed Makefile.in >>Makefile.tmp chmod +x Makefile.tmp mv -f Makefile.tmp Makefile echo ok echo $en "creating config.h... $ec" mv -f confdef.h config.h echo ok echo "all done." rm -f conftest* confdef* exit 0