Results 1 to 7 of 7

Thread: autoconf / automake etc

  1. #1

    autoconf / automake etc

    Does anyone know of a simple tutorial on putting together portable software packages?
    I don't want to become an expert user of these tools, I just want something that allows me to provide all the environment pre-checks and standard build options. We are just talking about simple cases of programs that use standard available libraries.
    My current state of knowledge is that I can just about hand code a makefile which will compile everything in the right order. This is ok for other Linux users who don't want to uninstall, or have binaries copied to the right place etc etc

  2. #2
    Moderator
    Advisor
    redhead's Avatar
    Join Date
    Jun 2001
    Location
    Copenhagen, Denmark
    Posts
    811

    Re: autoconf / automake etc

    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:
    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
    And then in my Makefile I have as the first line:
    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..)

  3. #3

    Re: autoconf / automake etc

    Thanks
    To my untrained eye it looks as though it would do the job on a wide range of platforms.
    Just to make sure I understand it :
    I have never seen that "exec <nember> ..." thing before - that's just a way of opening new file streams for use in the script, right? (in this case redirected from stdout)
    When a working compiler is not found, it suggests re-running with "--with-c-compiler". Howeverm the script does not actually check for this parameter. Am I missing something, or is this a bug?
    Oh, one more thing, I trust it's GPL, you won't sue or anyhting?

  4. #4
    Moderator
    Advisor
    redhead's Avatar
    Join Date
    Jun 2001
    Location
    Copenhagen, Denmark
    Posts
    811

    Re: autoconf / automake etc


    Thanks
    To my untrained eye it looks as though it would do the job on a wide range of platforms.
    Just to make sure I understand it :
    I have never seen that "exec <nember> ..." thing before - that's just a way of opening new file streams for use in the script, right? (in this case redirected from stdout)
    Well Its just the file descriptors.. I usualy have this scheme when assigning them I think most configure scripts uses it:
    Code:
    # File descriptor usage:
    # 0 standard input
    # 1 file creation
    # 2 errors and warnings
    # 3 some systems may open it to /dev/tty
    # 4 used on the Kubota Titan
    # 6 checking for... messages and results
    # 5 compiler messages saved in config.log
    When a working compiler is not found, it suggests re-running with "--with-c-compiler". Howeverm the script does not actually check for this parameter. Am I missing something, or is this a bug?
    It was a testing feature in the $1 from the first while loop, where I woudl simply assign the CC to hold what was parsed with the --with-c-compiler=blah.. I just didnt copied it in with the rest of the script..
    Oh, one more thing, I trust it's GPL, you won't sue or anyhting?
    naturaly, it is GPL'ed.. Else I wouldnt have posted it on the board..
    Get the latest Sigit from my homepage, and take the configure file from there, and the scripts/ directory, if you want the whole thing.. tests for install program/pod2man/gcc/make environments/build architecture/pthread/BSD signals/gzip/getopt_long/snprintf/etc..

    Just hack it any way you want.. The parts I've posted here was just a way to give info on how it could be structured, with the:
    cat << EOF > conftest.c
    #include ...
    /* small test program to see for the needed */
    EOF
    if [( $CC conftest.c || exit 1) blah... .

  5. #5

    Re: autoconf / automake etc

    There's a good tutorial on developer.gnome.org - posted the exact link over at LNO yesterday that is specifically on the autoconf/automake stuff.

  6. #6

    Re: autoconf / automake etc

    There's a good tutorial on developer.gnome.org - posted the exact link over at LNO yesterday that is specifically on the autoconf/automake stuff.
    Thanks, I went and found the link (what is this LNO that you speak of? )
    It's aimed specifically at Gnome development, but looks on the surface as though it's mostly generic stuff. I'll give it a read.

  7. #7

    Re: autoconf / automake etc

    LNO == www.linuxnewbie.org - several folks here visit both boards, and I wasn't sure if you were one of them. The material in the "Creating Your Source Tree" section of that is very generic - more GNU than GNOME. I read over it, thought it was good stuff, so I posted a link over there - I'm relatively new on this board.

Similar Threads

  1. Autoconf version
    By Tyr_7BE in forum Linux - General Topics
    Replies: 1
    Last Post: 10-20-2002, 11:13 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •