Thread: GNU Build System and referring to Libraries

  1. #1
    Registered User
    Join Date
    Dec 2007
    Posts
    2

    GNU Build System and referring to Libraries

    I created a simple software project and want to build and distribute it using the GNU Build system. However, I can't for the life of me figure out how to include preexisting installed libraries in the project. The GNU Build System's hello world examples are great but they are too simple, not showing you how to include other object files or installed libraries.

    I know there is the LDADD in Makefile.am but how do you specify the installed library name and where to look for it. I thought one of those auto tools (aclocal, autoconf, automake, etc) would automatically figure out the location of library files so that you could just specify the library name but it doesn't appear to work that way.

    Please help.

    Jim Y.

  2. #2
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Unless you can very clearly justify why you think you need a full automake and configure script, don't use it. I've seen projects on Sourceforge that consist of about 500 lines of code and over 50,000 lines of build framework. Frankly, that's insane.

    Too many projects use ./configure when they could get away with a simple makefile. Why do you feel you need to use automake?

  3. #3
    Registered User
    Join Date
    Dec 2007
    Posts
    2
    I am doing this as a favor to a friend who makes usb digital I/O boards. He wanted a Linux driver for it so I ported it for him.

    It seems like it would be great if he could distribute it using the GNU Build System so that anyone on any flavor of Linux could just:

    ./configure
    make

    You're right about the complexity of the GNU Build system. I know I am lost. The last time I did a Unix project was back in 1990 and it was a simple edit/compile/link. I have spent 10 hours porting the code and 30 hours trying to figure out how to configure the GNU Build System so he could distribute it to all flavors of Linux. It seems like it should be a one or two line thing to specify the installed library I need. I just haven't been able to find any documentation on how to do that.

    Jim

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    It obviously depends quite a lot on the "wideness" you imply by "any linux distribution".

    One way to solve the problem is to just "expect" certain libraries & packages to be installed, and document that in a readme file, and leave it to the user to build the files and install the correct packages.

    Automake is really quite complex and arcane.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by orwb View Post
    I am doing this as a favor to a friend who makes usb digital I/O boards. He wanted a Linux driver for it so I ported it for him.
    Is it really a DRIVER, as in a kernel driver? Automake is not appropriate for that at all. You can still have a ./configure script which sets up any specific things you need, but that can be a simple shell script you write yourself.

    Automake is dedicated (mostly) to configuring user-space software. Most of what it does is completely irrelevant to the kernel.

    It seems like it would be great if he could distribute it using the GNU Build System so that anyone on any flavor of Linux could just:

    ./configure
    make
    And in fact, that's how MOST people expect to be able to build software on Linux. I'm not saying you should not have a configuration script. I just think the time it takes to comprehend automake is going to be 10 times longer than the time it takes to write a basic script that does what you need.

    If you can explain some of the specific things you need to configure, we can probably help with a script that does it. But I can't give help on automake because honestly, I don't understand it either.

    You're right about the complexity of the GNU Build system. I know I am lost. The last time I did a Unix project was back in 1990 and it was a simple edit/compile/link. I have spent 10 hours porting the code and 30 hours trying to figure out how to configure the GNU Build System so he could distribute it to all flavors of Linux. It seems like it should be a one or two line thing to specify the installed library I need. I just haven't been able to find any documentation on how to do that.
    You and me both. I've been writing software for Linux for 12 years and I don't understand automake. I think MOST people don't understand automake. They copy a Makefile.am from some other project and add their own stuff into it.

    The result is lots of tiny projects with configure scripts that take 15 minutes to run, and do all sorts of pointless things like detect whether alloca() works (in a program that doesn't even use alloca()).

  6. #6
    Registered User
    Join Date
    Nov 2006
    Posts
    519
    I also don't understand automake. But if you really need to, try to setup your program with kdevelop. It is able to manage automake for you (also with additional libraries).

    I think the most important thing automake does is to configure the code so it can find the place it's installed in. I don't know any alternative on linux how to do that at run time. All software I saw which doesn't use automake does go to /opt and uses a shell script to switch to the right directory before the app is started. If I'm wrong I'd love to know
    Last edited by pheres; 12-06-2007 at 03:14 AM.

  7. #7
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    I don't know any alternative on linux how to do that at run time.
    True. But autoconf isn't the only way to achieve that. Really, all the configure script does in this case is take what you pass in the --prefix option and make it accessible to the code, i.e.

    ./configure --prefix=/usr/local

    results in a line in config.h like this:
    #define APP_PREFIX "/usr/local"

    Not too hard to emulate without autoconf.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  8. #8
    Registered User
    Join Date
    Nov 2006
    Posts
    519
    Now you are even able to answer questions I haven't spoken out yet.
    Because "how does automake do that internally" would have been my next one
    Thanks!

Popular pages Recent additions subscribe to a feed