Find the answer to your Linux question:
Results 1 to 4 of 4
Hello, I`m quite new to autotools, and I find them very hard to learn. I spent a few days reading documentation (autobook by Gary V. Vaughan, man pages, many crash ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Aug 2005
    Location
    Nis, Serbia and Montenegro
    Posts
    2

    autotools - newbie question


    Hello,

    I`m quite new to autotools, and I find them very hard to learn. I spent a few days reading documentation (autobook by Gary V. Vaughan, man pages, many crash courses and tutorials), and I`m still on the very beginner level. Although I have an idea about how these things work, and I know how to do basic things, I`m missing the following:

    If my Makefile.am for config files is:

    confdir = $(sysconfdir)/$(PACKAGE)
    conf_DATA = foo.conf

    and Makefile.am for executables:

    bin_SCRIPTS = foobin.sh
    pkgdata_SCRIPTS = fooextra.sh

    how can I make these files know of the locations of each other?

    For example, if I run ./configure with no parameters, my files end up in:

    /etc/foo/foo.conf
    /usr/bin/foobin.sh
    /usr/share/foo/fooextra.sh

    and if I run ./configure --prefix=/usr/local --sysconfdir=/usr/local/etc, my files end up in

    /usr/local/etc/foo/foo.conf
    /usr/bin/foobin.sh
    /usr/local/share/foo/fooextra.sh

    and I need both scripts to know where is config file, and I also need foobin.sh to know where is fooextra.sh (obviously, hardcoding is not a solution).

    I`m sure that there is a very simple solution to the problem, but I just can`t figure it out.

    Any help would be appreciated.

    --
    Darko

  2. #2
    Linux Guru lakerdonald's Avatar
    Join Date
    Jun 2004
    Location
    St. Petersburg, FL
    Posts
    5,035
    Excuse me for being na´ve, but:
    Code:
    $(confdir)/$(conf_DATA)
    should point to it.

  3. #3
    Just Joined!
    Join Date
    Aug 2005
    Location
    Nis, Serbia and Montenegro
    Posts
    2
    Quote Originally Posted by lakerdonald
    Excuse me for being na´ve, but:
    Code:
    $(confdir)/$(conf_DATA)
    should point to it.
    Yeah, $(confdir)/$(conf_DATA) poits to conf dir, so it makes my Makefile to know where conf files are going to be placed, but how can I make my scripts know that?

    My script foobin.sh has a variable $CONFDIR; Is there a way to replace it`s value with value of $(confdir)/$(conf_DATA) during the make process? Something like when you define a constant in a C file, and preprocessor replace it with real value?

    Of course, I can echo $(confdir)/$(conf_DATA) to a files foolocations in pkgdatadir and bindir, and to make my foobin.sh and fooextra.sh include ./foolocations, but it`s not very elegant, is it?

    --
    Darko

  4. #4
    Linux User
    Join Date
    Aug 2005
    Location
    Italy
    Posts
    401

    The most correct solution...

    I've got the same problem weeks ago...

    If you program in C/C++ and you use autotools, all paths and variables can the wrote out in the file config.h, but this is not the case for you (because you use bash scripting)...

    The trick is: do you see files like config.h.in, Makefile.in, *.in? These files are normally autogenerated by programs (like automake, wich generates all Makefile.in from you own written Makefile.am). You have to write a list of these files the configure.in using AC_OUTPUT macro, right?

    When you generate the configure script using autoreconf (or aclocal; automake; autoconf...) and launch it, the configure script keep the *.in files and transform them without the extension .in... That's the way to create Makefile files from Makefile.in: automake read Makefile.am to generate Makefile.in, and the configure read Makefile.in to generate Makefile.

    But how it generate the relative files? The configure script substitute particoular patterns with the value of some variable. The rest will be copied "paro-paro"...
    I've used this for generate a SysV init.d script:

    Code:
    #foo.in
    
    BIN_PATH=@prefix@/bin/foo.sh
    
    echo $BIN_PATH
    This file, if included in AC_OUTPUT, is the model of the script... when you run configure script "./configure --prefix /damn/if/it/works", it generates "foo" file like this:

    Code:
    #foo.in
    
    BIN_PATH=/damn/if/it/works/bin/foo.sh
    
    echo $BIN_PATH
    I don't remember the variables list... but I think there are somewhere in the documentation... Maybe these variables are customizable...
    When using Windows, have you ever told "Ehi... do your business?"
    Linux user #396597 (http://counter.li.org)

Posting Permissions

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