I usualy go with a small shell script that checks to see, if the things I need can be compiled on the system.. I havnt had the time or the need to get full control of autoconf/make.
The usual structure in the script is somethign like this:
And then in my Makefile I have as the first line:Code:#!/bin/sh DFLAGS="" CC="$CC" ## setup echo on different systems case `echo -n` in *-n) * echo_front='' * * *echo_end='\c' * *;; * * *# SysV echo **) * *echo_front=-n * * *echo_end='' * * *;; * * *# BSD echo esac ## some testing with the --arguments while [ x$1 != x ]; do case $1 in * * * *--help) * * * *cat <<EOF Usage: configure [options] * *--help * * * * * * * *Show this message * *--quiet * * * * * * * Sshh.. Be vewy vewy quiet, I'm hunting wabbits EOF * * * *exit 0;; * * * *--quiet) * * * * * *QUIET="yes" * * * * * *LOG="yes" * * * * * *;; * * * **) echo "Unrecognized option: $1"; exit 1;; esac shift done ## Setup the loging feature if [ "$QUIET" = "yes" ]; then * * * *exec 6>/dev/null else * *exec 6>&1 fi if [ "$LOG" = "yes" ]; then * *exec 5>./config.log * *echo "Logfile for debugging: ./config.log" 1>&6 fi ## some testing to find the c/C compiler cat << EOF > __conftest.c * *int main() { int class=0; return class; } EOF if [ x"$CC" = x ]; then * *echo $echo_front "Looking for a C compiler... $echo_end" 1>&6 * *if [ "$LOG" = "yes" ]; then * * * *echo $echo_front "Looking for a C compiler... $echo_end" 1>&5 * *fi * *for TRY in gcc egcs g++ CC c++ cc; do * * * ( * * * * * $TRY __conftest.c -o __conftest || exit 1; * * * * * ./__conftest || exit 1; * * * ) >/dev/null 2>&1 || continue; * * * CC=$TRY * * * break; * *done * *if [ x"'$CC'" = x ]; then * * * *echo "failed" 1>&6 * * * *echo "Cannot find a C compiler. Run configure with --with-c-compiler." 1 >&6 * * * *if [ "$LOG" = "yes" ]; then * * * * * *echo "failed" 1>&5 * * * * * *echo "Cannot find a C compiler. Run configure with --with-c-compiler ." 1>&5 * * * *fi * * * *rm -f __conftest* * * * *exit * *fi * *echo "$CC" 1>&6 * *if [ "$LOG" = "yes" ]; then * * * *echo "$CC" 1>&5 * *fi fi ## See if compiler works.. echo $echo_front "Checking if $CC compiler works... $echo_end" 1>&6 if [ "$LOG" = "yes" ]; then * *echo $echo_front "Checking if $CC compiler works... $echo_end" 1>&5 fi if ( * * * *$CC __conftest.c -o __conftest || exit 1 * * * *./__conftest || exit 1 * *) >/dev/null 2>&1; then * *echo "yes" 1>&6 * *if [ "$LOG" = "yes" ]; then * * * *echo "yes" 1>&5 * *fi else * *echo "no" 1>&6 * *echo "Compiler \"$CC\" does not exist or cannot compile C; try another." 1>& 6 * *if [ "$LOG" = "yes" ]; then * * * *echo "no" 1>&5 * * * *echo "Compiler \"$CC\" does not exist or cannot compile C; try another." 1>&5 * *fi * *rm -f __conftest* * *exit fi ## Test for what ever I need.. echo $echo_front "Checking for BSD signal semantics... $echo_end" 1>&6 if [ "$LOG" = "yes" ]; then * *echo $echo_front "Checking for BSD signal semantics... $echo_end" 1>&5 fi cat <<EOF >__conftest.c #include <sys/types.h> #include <unistd.h> #include <signal.h> int count=0; void handle(int foo) { count++; } int main() { * *int pid=getpid(); * *signal(SIGINT, handle); * *kill(pid,SIGINT); * *if (count == 0) return 1; * *return 0; } EOF if ( * * *$CC __conftest.c *-o __conftest || exit 1 * * *./__conftest || exit 1 * ) >/dev/null 2>&1; then * *echo "yes" 1>&6 * *if [ "$LOG" = "yes" ]; then * * * *echo "yes" 1>&5 * *fi else * *if ( * * * * *$CC -D__USE_BSD_SIGNAL __conftest.c *-o __conftest || exit 1 * * * * *./__conftest || exit 1 * * * ) >/dev/null 2>&1; then * * * *echo "-D__USE_BSD_SIGNAL" 1>&6 * * * *if [ "$LOG" = "yes" ]; then * * * * * *echo "-D__USE_BSD_SIGNAL" 1>&5 * * * *fi * * * *DFLAGS="$DFLAGS -D__USE_BSD_SIGNAL" * *else * * * *echo "no" 1>&6 * * * *echo "This package needs BSD signal semantics to run." 1>&6 * * * *if [ "$LOG" = "yes" ]; then * * * * * *echo "no" 1>&5 * * * * * *echo "This package needs BSD signal semantics to run." 1>&5 * * * *fi * * * *rm -f __conftest* * * * *exit * *fi fi rm -f __conftest* ## Lets say this was all that was needed... echo $echo_front "Generating Makefile.guess... $echo_end" 1>&6 ( * *echo "# Generated by configure " * *echo "#" * *echo * *echo "CC=$CC" * *echo "DFLAGS=$DFLAGS" | sed 's/= */=/' ) > Makefile.guess echo "done" 1>&6
include Makefile.guess *
Then if you havnt run your lovely small configure script, then it will return with "couldnt find file in include ... Makefile line.."
And else you'll just reffere to $CC and your $DFLAGS in your rules settigns when doing the %.o:%.c etc.
(I hope this want too much text for yabb to handle..)



Reply With Quote

Bookmarks