#!/bin/sh # $Id$ # TODO: Make 1.0 VERSION="0.0" if [ "x$CONFIG" = "xGET" ]; then return fi if [ "x$PREFIX" = "x" ]; then PREFIX="/usr/local" fi PLATFORM=`uname -s | tr '[:upper:]' '[:lower:]'`-`uname -r | cut -d'.' -f1` WERROR="" if [ -f "Config/$PLATFORM" ]; then . Config/$PLATFORM fi stty -echo for i in $@; do case "$i" in --prefix=*) PREFIX=`echo $i | sed 's/--prefix=//g'` ;; --help) echo "This is a configuration utility for NewsDist." echo "" echo "Usage: $0 [options] [variables] [config]" echo "" echo "Options:" echo " --prefix=[prefix] Specifies the prefix" echo "" echo "Variables:" echo " CC C compiler" echo " AR Archiver" echo " RANLIB Ranlib" echo " CFLAGS Flags to be used at compile-time" echo " LDFLAGS Flags to be used at link-time" echo " LIBS Libraries to be linked" echo " SOCKLIBS Libraries to be linked for sockets" echo " SSLLIBS Libraries to be linked for SSL" echo " YACC Yacc" echo " LEX Lex" echo "" echo "Recognized configs:" echo " `ls -d Config/* | tr '\n' ' '`" exit 0 ;; --*) echo "Unknown flag: $i" exit 1 ;; *) echo $i | grep "=" >/dev/null 2>&1 if [ "$?" = "0" ]; then eval $i else . $i fi ;; esac done for i in $EXPORTS; do export $i done PRINTF="printf" OLDIFS="$IFS" IFS=":" for i in $PATH; do if [ -f $i/printf ]; then PRINTF=$i/printf break fi done IFS="$OLDIFS" input="" COLOR=1 $PRINTF "\x1b[m" 2>/dev/null if [ ! "$?" = "0" ]; then COLOR=0 fi error_raw () { if [ "$COLOR" = "1" ]; then $PRINTF "\x1b[1m\x1b[31m!!!\x1b[m $1" else $PRINTF "!!! $1" fi } warn_raw () { if [ "$COLOR" = "1" ]; then $PRINTF "\x1b[1m\x1b[33m!!!\x1b[m $1" else $PRINTF "!!! $1" fi } info_raw () { if [ "$COLOR" = "1" ]; then $PRINTF "\x1b[1m\x1b[37m???\x1b[m $1" else $PRINTF "??? $1" fi } log_raw () { if [ "$COLOR" = "1" ]; then $PRINTF "\x1b[1m\x1b[37m \x1b[m $1" else $PRINTF " $1" fi } error () { error_raw "$1\n" } warn () { warn_raw "$1\n" } info () { info_raw "$1\n" } log () { log_raw "$1\n" } quit () { log "" error 'Configuration aborted.' rm -f config.h rm -f config.mk stty echo exit 1 } getinput () { default="$2" while true; do if [ "x$2" = "x" ]; then if [ "$COLOR" = "1" ]; then $PRINTF "\x1b[1m\x1b[34m???\x1b[m $1? " else $PRINTF "??? $1? " fi else if [ "$COLOR" = "1" ]; then $PRINTF "\x1b[1m\x1b[34m???\x1b[m $1 [$default]? " else $PRINTF "??? $1 [$default]? " fi fi stty echo read input || quit stty -echo if [ "x$input" = "x" -a "x$default" = "x" ]; then error "There is no default value" elif [ "x$input" = "x" -a ! "x$default" = "x" ]; then input="$default" break elif [ ! "x$input" = "x" ]; then break fi done } test_c () { result=0 rm -f /tmp/$$.c $PRINTF "$1\n" > /tmp/$$.c if [ "x$2" = "x" ]; then $CC $CFLAGS $WERROR -c -o /tmp/$$.o /tmp/$$.c >/dev/null 2>&1 if [ "$?" = "0" ]; then echo "yes" else echo "no" result=1 fi rm -f /tmp/$$.c /tmp/$$.o $$.c $$.o else $CC $CFLAGS $LDFLAGS $WERROR -o /tmp/$$ /tmp/$$.c $2 >/tmp/log$$ 2>&1 if [ "$?" = "0" ]; then grep "No such file" /tmp/log$$ >/dev/null 2>&1 if [ "$?" = "0" ]; then echo "no" result=1 else echo "yes" fi else echo "no" result=1 fi rm -f /tmp/log$$ /tmp/$$.c /tmp/$$.o /tmp/$$ $$ $$.c $$.o fi return $result } DEFINES="" define () { if [ "x$DEFINES" = "x" ]; then DEFINES="\"+$1\"" else DEFINES="$DEFINES,\"+$1\"" fi echo "#define $1" >> config.h } undef () { if [ "x$DEFINES" = "x" ]; then DEFINES="\"-$1\"" else DEFINES="$DEFINES,\"-$1\"" fi echo "/* #define $1 */" >> config.h } trap quit 2 log "" log "Welcome to NewsDist build environment configuration utility." log "NewsDist is a small (enough) NNTP server." log "" if [ "x$CC" = "x" ]; then log_raw "Probing C compiler: " for c in gcc clang cc; do OLDIFS="$IFS" IFS=":" for i in $PATH; do if [ -f "$i/$c" ]; then CC=$i/$c echo $CC break fi done IFS="$OLDIFS" if [ ! "x$CC" = "x" ]; then break; fi done if [ "x$CC" = "x" ]; then echo "not found" fi fi if [ "x$CPP" = "x" ]; then log_raw "Probing C preprocessor: " for c in gcpp cpp; do OLDIFS="$IFS" IFS=":" for i in $PATH; do if [ -f "$i/$c" ]; then CPP=$i/$c echo $CPP break fi done IFS="$OLDIFS" if [ ! "x$CPP" = "x" ]; then break; fi done if [ "x$CPP" = "x" ]; then echo "not found" fi fi if [ "x$AR" = "x" ]; then log_raw "Probing archiver: " for c in gar ar; do OLDIFS="$IFS" IFS=":" for i in $PATH; do if [ -f "$i/$c" ]; then AR=$i/$c echo $AR break fi done IFS="$OLDIFS" if [ ! "x$AR" = "x" ]; then break; fi done if [ "x$AR" = "x" ]; then echo "not found" fi fi if [ "x$RANLIB" = "x" ]; then log_raw "Probing ranlib: " for c in granlib ranlib; do OLDIFS="$IFS" IFS=":" for i in $PATH; do if [ -f "$i/$c" ]; then RANLIB=$i/$c echo $RANLIB break fi done IFS="$OLDIFS" if [ ! "x$RANLIB" = "x" ]; then break; fi done if [ "x$RANLIB" = "x" ]; then echo "not found" fi fi if [ "x$CC" = "x" ]; then info "GCC/Clang should work." getinput "What is your C compiler" "cc" CC="$input" fi if [ "x$CPP" = "x" ]; then info "SCO OUDK cc can be used too" getinput "What is your C preprocessor" "cpp" CPP="$input" fi if [ "x$AR" = "x" ]; then getinput "What is your archiver" "ar" AR="$input" fi if [ "x$RANLIB" = "x" ]; then info "If you are using SCO OUDK ar, pass true" getinput "What is your ranlib" "ranlib" RANLIB="$input" fi info "===== Flag check =====" log_raw "Does -P work: " echo >/tmp/$$.c $CPP -P /tmp/$$.c >/dev/null 2>&1 if [ "$?" = "0" ]; then CPP="$CPP -P" echo "yes" else echo "no" fi rm -f /tmp/$$.c log_raw "Does -Werror work: " echo >/tmp/$$.c $CC -Werror -c -o /tmp/$$.o /tmp/$$.c >/dev/null 2>&1 if [ "$?" = "0" ]; then WERROR="-Werror" echo "yes" else echo "no" fi rm -f /tmp/$$.c /tmp/$$.o log_raw "Does -O2 work: " echo >/tmp/$$.c $CC -O2 -c -o /tmp/$$.o /tmp/$$.c >/dev/null 2>&1 if [ "$?" = "0" ]; then CFLAGS="$CFLAGS -O2" echo "yes" else echo "no" fi rm -f /tmp/$$.c /tmp/$$.o log_raw "Does -ansi work: " echo >/tmp/$$.c $CC -std=c89 -c -o /tmp/$$.o /tmp/$$.c >/dev/null 2>&1 if [ "$?" = "0" ]; then CFLAGS="$CFLAGS -ansi" echo "yes" else echo "no" log_raw "Does -std=c89 work: " echo >/tmp/$$.c $CC -std=c89 -c -o /tmp/$$.o /tmp/$$.c >/dev/null 2>&1 if [ "$?" = "0" ]; then CFLAGS="$CFLAGS -std=c89" echo "yes" else echo "no" fi fi rm -f /tmp/$$.c /tmp/$$.o echo "/* This file is auto-generated */" > config.h echo "#ifndef __NEWSDIST_CONFIG_H__" >> config.h echo "#define __NEWSDIST_CONFIG_H__" >> config.h SELECT_H="sys/select.h" POLL_H="sys/poll.h" SOCKET_H="sys/socket.h" TCP_H="netinet/tcp.h" IN_H="netinet/in.h" INET_H="arpa/inet.h" TCPUSTD_H="unistd.h" info "===== Check platform =====" log_raw "Is this NetWare build: " if test_c "#ifndef __NETWARE__\n#error no\n#endif"; then define "IS_NETWARE" SELECT_H="sys/socket.h" POLL_H="sys/socket.h" SOCKET_H="sys/socket.h" TCP_H="sys/socket.h" IN_H="sys/socket.h" INET_H="sys/socket.h" else undef "IS_NETWARE" fi log_raw "Is this OS/2 build: " if test_c "#ifndef __OS2__\n#error no\n#endif"; then define "IS_OS2" TCPUSTD_H="tcpustd.h" else undef "IS_OS2" fi log_raw "Is this Watcom: " if test_c "#ifndef __WATCOMC__\n#error no\n#endif"; then WATCOM=1 else WATCOM=0 fi info "===== Socket =====" log_raw "Checking if sys/types.h exists: " if test_c "#include "; then TYPES="$TYPES\n#include " define "HAS_SYS_TYPES_H" else undef "HAS_SYS_TYPES_H" fi log_raw "Checking if types.h exists: " if test_c "#include "; then TYPES="$TYPES\n#include " define "HAS_TYPES_H" else undef "HAS_TYPES_H" fi log_raw "Checking if netdb.h exists: " if test_c "#include "; then TYPES="$TYPES\n#include " define "HAS_NETDB_H" else undef "HAS_NETDB_H" fi log_raw "Checking if Winsock 2 exists: " if test_c "#include \nint main(int argc, char** argv){return 0;}"; then define "HAS_WINSOCK" SELECT_H="winsock2.h" POLL_H="winsock2.h" SOCKET_H="winsock2.h" TCP_H="winsock2.h" IN_H="winsock2.h" INET_H="winsock2.h" TCPUSTD_H="winsock2.h" TYPES="$TYPES\n#include " else undef "HAS_WINSOCK" fi CFLAGS="$CFLAGS -D_DEFAULT_SOURCE -D_BSD_SOURCE" log_raw "Checking if IPV6_V6ONLY exists: " if test_c "$TYPES\n#include <$IN_H>\nint main(int argc, char** argv){(void)IPV6_V6ONLY;return 0;}"; then define "HAS_IPV6_V6ONLY" else undef "HAS_IPV6_V6ONLY" fi log_raw "Checking if TCP_NODELAY exists: " if test_c "$TYPES\n#include <$TCP_H>\nint main(int argc, char** argv){(void)TCP_NODELAY;return 0;}"; then define "HAS_TCP_NODELAY" else undef "HAS_TCP_NODELAY" fi log_raw "Checking if SO_REUSEADDR exists: " if test_c "$TYPES\n#include <$SOCKET_H>\nint main(int argc, char** argv){(void)SO_REUSEADDR;return 0;}"; then define "HAS_SO_REUSEADDR" else undef "HAS_SO_REUSEADDR" fi log_raw "Checking if socklen_t exists: " if test_c "$TYPES\n#include <$SOCKET_H>\nint main(int argc, char** argv){socklen_t i = 0;return 0;}"; then define "HAS_SOCKLEN_T" else undef "HAS_SOCKLEN_T" fi log_raw "Checking if select exists: " if test_c "$TYPES\n#include <$SELECT_H>\nint main(int argc, char** argv){void* s = select;return 0;}"; then define "HAS_SELECT" else undef "HAS_SELECT" fi log_raw "Checking if poll exists: " if test_c "$TYPES\n#include <$POLL_H>\nint main(int argc, char** argv){void* s = poll;return 0;}"; then define "HAS_POLL" else undef "HAS_POLL" fi log_raw "Checking if gethostname exists: " if test_c "$TYPES\n#include <$TCPUSTD_H>\nint main(int argc, char** argv){void* s = gethostname;return 0;}"; then define "HAS_GETHOSTNAME" else undef "HAS_GETHOSTNAME" fi log_raw "Checking if IPPROTO_TCP exists: " if test_c "$TYPES\n#include <$IN_H>\nint main(int argc, char** argv){(void)IPPROTO_TCP;return 0;}"; then define "HAS_IPPROTO_TCP" else undef "HAS_IPPROTO_TCP" fi log_raw "Checking if INADDR_ANY exists: " if test_c "$TYPES\n#include <$IN_H>\nint main(int argc, char** argv){(void)INADDR_ANY;return 0;}"; then define "HAS_INADDR_ANY" else undef "HAS_INADDR_ANY" fi log_raw "Checking if in_addr exists: " if test_c "$TYPES\n#include <$IN_H>\nint main(int argc, char** argv){struct in_addr s;return 0;}"; then define "HAS_IN_ADDR" else undef "HAS_IN_ADDR" fi log_raw "Checking if AF_INET and sockaddr_in exist: " if test_c "#ifndef __NETWARE__\n$TYPES\n#include <$IN_H>\n#include <$SOCKET_H>\nint main(int argc, char** argv){struct sockaddr_in s;return 0;}\n#endif"; then define "HAS_IPV4" else undef "HAS_IPV4" fi log_raw "Checking if AF_INET6 and sockaddr_in6 exist: " if test_c "$TYPES\n#include <$IN_H>\n#include <$SOCKET_H>\nint main(int argc, char** argv){struct sockaddr_in6 s;return 0;}"; then define "HAS_IPV6" else undef "HAS_IPV6" fi log_raw "Checking if htons exists as function: " if test_c "$TYPES\n#include <$INET_H>\nint main(int argc, char** argv){void* s = htons;return 0;}"; then define "HAS_HTONS" else log_raw "Checking if htons exists as macro: " if test_c "$TYPES\n#include <$INET_H>\n#ifndef htons\n#error no\n#endif"; then define "HAS_HTONS" else undef "HAS_HTONS" fi fi log_raw "Checking if closesocket exists: " if test_c "$TYPES\n#include <$SOCKET_H>\n#include \nint main(int argc, char** argv){void* s = closesocket;return 0;}"; then echo "#define CLOSE_SOCKET closesocket" >> config.h else log_raw "Checking if soclose exists: " if test_c "$TYPES\n#include <$SOCKET_H>\n#include \nint main(int argc, char** argv){void* s = soclose;return 0;}"; then echo "#define CLOSE_SOCKET soclose" >> config.h else log_raw "Checking if close exists: " if test_c "$TYPES\n#include <$SOCKET_H>\n#include \nint main(int argc, char** argv){void* s = close;return 0;}"; then echo "#define CLOSE_SOCKET close" >> config.h else echo "#define CLOSE_SOCKET close" >> config.h fi fi fi log_raw "Checking if SIGPIPE exists: " if test_c "#include \nint main(int argc, char** argv){(void)SIGPIPE;return 0;}"; then define "HAS_SIGPIPE" else undef "HAS_SIGPIPE" fi lib () { if [ "$WATCOM" = "1" ]; then echo "$1.lib" else echo "-l$1" fi } log_raw "Checking if libsocket exists: " if test_c "int main(int argc, char** argv){return 0;}" "`lib socket`"; then SOCKLIBS="$SOCKLIBS `lib socket`" fi log_raw "Checking if libnetwork exists: " if test_c "int main(int argc, char** argv){return 0;}" "`lib network`"; then SOCKLIBS="$SOCKLIBS `lib network`" fi log_raw "Checking if libws2_32 exists: " if test_c "int main(int argc, char** argv){return 0;}" "`lib ws2_32`"; then SOCKLIBS="$SOCKLIBS `lib ws2_32`" fi info "===== Utils =====" log_raw "Checking if strdup exists: " if test_c "#include \nint main(int argc, char** argv){void* s = strdup;return 0;}"; then define "HAS_STRDUP" else undef "HAS_STRDUP" fi log_raw "Checking if CreateProcess exists: " if test_c "#include \nint main(int argc, char** argv){void* s = CreateProcess;return 0;}"; then define "HAS_CREATEPROCESS" else undef "HAS_CREATEPROCESS" log_raw "Checking if execle exists: " if test_c "#include \nint main(int argc, char** argv){void* s = execle;return 0;}"; then define "HAS_EXECLE" else undef "HAS_EXECLE" fi fi log_raw "Checking if signal.h exists: " if test_c "#include "; then define "HAS_SIGNAL_H" else undef "HAS_SIGNAL_H" fi info "===== SSL =====" log_raw "Checking if OpenSSL works: " if test_c "#include \nint main(int argc, char** argv){void* s = SSL_CTX_new;return 0;}" "-lcrypto -lssl"; then define "HAS_OPENSSL" SSLLIBS="$SSLLIBS -lcrypto -lssl" SSL="openssl" log_raw "Checking if TLS_server_method exists: " if test_c "#include \nint main(int argc, char** argv){void* s = TLS_server_method;return 0;}"; then define "HAS_TLS_SERVER_METHOD" else undef "HAS_TLS_SERVER_METHOD" fi log_raw "Checking if SSLv23_server_method exists: " if test_c "#include \nint main(int argc, char** argv){void* s = SSLv23_server_method;return 0;}"; then define "HAS_SSLV23_SERVER_METHOD" else undef "HAS_SSLV23_SERVER_METHOD" fi log_raw "Checking if TLSv1_2_server_method exists: " if test_c "#include \nint main(int argc, char** argv){void* s = TLSv1_2_server_method;return 0;}"; then define "HAS_TLSV1_2_SERVER_METHOD" else undef "HAS_TLSV1_2_SERVER_METHOD" fi log_raw "Checking if TLSv1_1_server_method exists: " if test_c "#include \nint main(int argc, char** argv){void* s = TLSv1_1_server_method;return 0;}"; then define "HAS_TLSV1_1_SERVER_METHOD" else undef "HAS_TLSV1_1_SERVER_METHOD" fi log_raw "Checking if TLSv1_server_method exists: " if test_c "#include \nint main(int argc, char** argv){void* s = TLSv1_server_method;return 0;}"; then define "HAS_TLSV1_SERVER_METHOD" else undef "HAS_TLSV1_SERVER_METHOD" fi log_raw "Checking if SSLv3_server_method exists: " if test_c "#include \nint main(int argc, char** argv){void* s = SSLv3_server_method;return 0;}"; then define "HAS_SSLV3_SERVER_METHOD" else undef "HAS_SSLV3_SERVER_METHOD" fi log_raw "Checking if SSLv2_server_method exists: " if test_c "#include \nint main(int argc, char** argv){void* s = SSLv2_server_method;return 0;}"; then define "HAS_SSLV2_SERVER_METHOD" else undef "HAS_SSLV2_SERVER_METHOD" fi else undef "HAS_OPENSSL" fi if [ ! "x$SSL" = "x" ]; then define "HAS_SSL" else undef "HAS_SSL" fi info "===== Log =====" log_raw "Checking if openlog exists: " if test_c "#include \nint main(int argc, char** argv){void* s = openlog;return 0;}"; then define "HAS_SYSLOG" log_raw "Checking if LOG_PID exists: " if test_c "#include \nint main(int argc, char** argv){(void)LOG_PID;return 0;}"; then define "HAS_LOG_PID" else undef "HAS_LOG_PID" fi log_raw "Checking if LOG_NEWS exists: " if test_c "#include \nint main(int argc, char** argv){(void)LOG_NEWS;return 0;}"; then define "HAS_LOG_NEWS" else undef "HAS_LOG_NEWS" fi log_raw "Checking if LOG_USER exists: " if test_c "#include \nint main(int argc, char** argv){(void)LOG_USER;return 0;}"; then define "HAS_LOG_USER" else undef "HAS_LOG_USER" fi log_raw "Checking if LOG_INFO exists: " if test_c "#include \nint main(int argc, char** argv){(void)LOG_INFO;return 0;}"; then define "HAS_LOG_INFO" else undef "HAS_LOG_INFO" fi log_raw "Checking if LOG_NOTICE exists: " if test_c "#include \nint main(int argc, char** argv){(void)LOG_NOTICE;return 0;}"; then define "HAS_LOG_NOTICE" else undef "HAS_LOG_NOTICE" fi log_raw "Checking if LOG_WARNING exists: " if test_c "#include \nint main(int argc, char** argv){(void)LOG_WARNING;return 0;}"; then define "HAS_LOG_WARNING" else undef "HAS_LOG_WARNING" fi else undef "HAS_SYSLOG" undef "HAS_LOG_PID" undef "HAS_LOG_NEWS" undef "HAS_LOG_USER" undef "HAS_LOG_INFO" undef "HAS_LOG_NOTICE" undef "HAS_LOG_WARNING" fi info "===== Multi-socket =====" log_raw "Checking if fork exists: " if test_c "#include \nint main(int argc, char** argv){void* s = fork;return 0;}"; then define "HAS_FORK" log_raw "Checking if SIGCHLD exists: " if test_c "#include \nint main(int argc, char** argv){(void)SIGCHLD;return 0;}"; then define "HAS_SIGCHLD" else undef "HAS_SIGCHLD" fi else undef "HAS_FORK" undef "HAS_SIGCHLD" fi log_raw "Checking if _beginthread exists: " if test_c "#include \nint main(int argc, char** argv){void* s = _beginthread;return 0;}"; then define "HAS_BEGINTHREAD" else undef "HAS_BEGINTHREAD" fi log_raw "Checking if _endthread exists: " if test_c "#include \nint main(int argc, char** argv){void* s = _endthread;return 0;}"; then define "HAS_ENDTHREAD" else undef "HAS_ENDTHREAD" fi log_raw "Checking if BeginThread exists: " if test_c "#include \nint main(int argc, char** argv){void* s = BeginThread;return 0;}"; then define "HAS_NW_BEGINTHREAD" else undef "HAS_NW_BEGINTHREAD" fi info "===== Type =====" check_number () { log_raw "Checking if unsigned char is $1 bits: " if test_c "#include \n#if UCHAR_MAX != $2\n#error no\n#endif"; then echo "typedef char int$1_t;" >> config.h echo "typedef unsigned char uint$1_t;" >> config.h else log_raw "Checking if unsigned short is $1 bits: " if test_c "#include \n#if USHRT_MAX != $2\n#error no\n#endif"; then echo "typedef short int$1_t;" >> config.h echo "typedef unsigned short uint$1_t;" >> config.h else log_raw "Checking if unsigned int is $1 bits: " if test_c "#include \n#if UINT_MAX != $2\n#error no\n#endif"; then echo "typedef int int$1_t;" >> config.h echo "typedef unsigned int uint$1_t;" >> config.h else log_raw "Checking if unsigned long is $1 bits: " if test_c "#include \n#if ULONG_MAX != $2\n#error no\n#endif"; then echo "typedef long int$1_t;" >> config.h echo "typedef unsigned long uint$1_t;" >> config.h fi fi fi fi } log_raw "Checking if stdbool.h exists: " if test_c "#include "; then define "HAS_STDBOOL_H" else undef "HAS_STDBOOL_H" fi log_raw "Checking if stdint.h exists: " if test_c "#include "; then define "HAS_STDINT_H" echo "#include " >> config.h else undef "HAS_STDINT_H" log_raw "Checking if limits.h exists: " if test_c "#include "; then define "HAS_LIMITS_H" check_number "8" "255" check_number "16" "65535" check_number "32" "4294967295" else undef "HAS_LIMITS_H" fi fi info "===== Platform =====" log_raw "Checking if uname exists: " if test_c "#include \nint main(int argc, char** argv){void* s = uname;return 0;}"; then define "HAS_UNAME" else undef "HAS_UNAME" fi log_raw "Checking if errno exists: " if test_c "#include \nint main(int argc, char** argv){(void)errno;return 0;}"; then define "HAS_ERRNO" else undef "HAS_ERRNO" fi echo "#define DEFINES {$DEFINES}" >> config.h echo "#endif" >> config.h log_raw "Finding Yacc: " if [ "x$YACC" = "x" ]; then for i in byacc bison yacc; do OLDIFS="$IFS" IFS=":" for j in $PATH; do if [ -f $j/$i ]; then YACC=$j/$i break fi done IFS="$OLDIFS" if [ ! "x$YACC" = "x" ]; then break fi done fi if [ "x$YACC" = "x" ]; then echo "not found" quit fi echo "$YACC" log_raw "Should I force -y to Yacc: " echo "%%" > /tmp/test.y echo "a: 'a'" >> /tmp/test.y echo "%%" >> /tmp/test.y $YACC -y /tmp/test.y >/dev/null 2>&1 if [ "$?" = "0" ]; then echo "yes" YACC="$YACC -y" else echo "no" fi rm -f y.tab.c /tmp/test.y log_raw "Finding Lex: " if [ "x$LEX" = "x" ]; then for i in flex lex; do OLDIFS="$IFS" IFS=":" for j in $PATH; do if [ -f $j/$i ]; then LEX=$j/$i break fi done IFS="$OLDIFS" if [ ! "x$LEX" = "x" ]; then break fi done fi if [ "x$LEX" = "x" ]; then echo "not found" quit fi echo "$LEX" DEFINES="-DNEWSDIST_VERSION_TEXT='\"NewsDist $VERSION\"' -DNEWSDIST_VERSION='\"$VERSION\"' -DPREFIX='\"$PREFIX\"'" echo "# This file is auto-generated" > config.mk echo "CC = $CC" >> config.mk echo "AR = $AR" >> config.mk echo "RANLIB = $RANLIB" >> config.mk echo "CPP = $CPP $DEFINES -DPREFIX_RAW=$PREFIX" >> config.mk echo "CFLAGS = $CFLAGS $DEFINES" >> config.mk echo "LDFLAGS = $LDFLAGS" >> config.mk echo "LIBS = $LIBS" >> config.mk echo "SOCKLIBS = $SOCKLIBS" >> config.mk echo "SSLLIBS = $SSLLIBS" >> config.mk echo "TOPDIR = `pwd`" >> config.mk echo "EXEC = $EXEC" >> config.mk echo "YACC = $YACC" >> config.mk echo "LEX = $LEX" >> config.mk echo "PREFIX = $PREFIX" >> config.mk FLAGS="" for i in $EXPORTS; do FLAGS="$FLAGS $i=`eval echo \\\$$i`" done sed "s%@EXPORTS@%$FLAGS%g" Makefile.in > Makefile log "" log "Configuration successful, now run \`make'" log "" stty echo