Where to put helper-scripts with GNU autoconf/automake?

后端 未结 4 1728
我寻月下人不归
我寻月下人不归 2021-01-14 23:11

I\'m working on a project that will be distributed with GNU autoconf/automake, and I have a set of bash scripts which call awk scripts. I would like the bash scripts to end

相关标签:
4条回答
  • 2021-01-14 23:45

    You can just list the scripts that you want to be installed in Makefile.am:

    bin_SCRIPTS = foo bar
    

    This will cause foo and bar to be installed during make install. To get the path to their final location, you can use @bindir@ in foo.in and let configure build foo for you. For example, in configure.ac:

    AC_CONFIG_FILES([foo bar])
    

    and then in foo.in:

    #!/bin/sh
    
    prefix=@prefix@
    exec_prefix=@exec_prefix@
    bindir=@bindir@
    echo bindir = $bindir
    

    Keep in mind that the person running configure may specify any of --prefix, --exec_prefix, or --bindir, and the installation may be redirected with a DESTDIR. Using the technique described here, DESTDIR will not be taken into account and the script will be installed in a location other than the path that it will echo. This is by design, and is the correct behavior, as usually a DESTDIR installation is used to create a tarball that will eventually be unpacked into the filesystem in such a way that the bindir in the script becomes valid.

    0 讨论(0)
  • 2021-01-14 23:45

    Jonathan, in response to your additional question: if you want to replace the value of prefix at the time of build, you will need to:

    1. rename your script 'myscript' to 'myscript.in'
    2. add a rule to configure.ac to generate it at the bottom
    3. use a macro I made called AS_AC_EXPAND
    4. use it like this:

      AS_AC_EXPAND(BINDIR, $bindir)

    5. in your 'myscript.in', you can now use @BINDIR@ and it will get expanded to the full path where the script will end up being installed.

    Note that you shouldn't use PREFIX directly, any of the installation directories can potentially be changed so you really want to use the value passed to configure for bindir and expand that.

    0 讨论(0)
  • 2021-01-14 23:45

    If the awk scripts won't go into the main bin directory (prefix/bin), then you need to place them in an appropriate sub-directory - probably of lib but possibly libexec or share (since the awk scripts are probably platform neutral).

    Correct: software won't necessarily end up in /usr/local/bin; on my machine, /usr/local/bin is managed by MIS and all the software I install therefore goes under /usr/gnu/. I use: ./configure --prefix=/usr/gnu to get the software installed where I want it.

    You can embed the value of PREFIX in the bash scripts -- effectively, you will 'compile' the scripts to include the install location. Be aware of problems during the build testing - you may need to locate the scripts relative to the current directory first and relative to PREFIX later.

    0 讨论(0)
  • 2021-01-15 00:05

    Add something like this to Makefile.am

    scriptsdir = $(prefix)/bin
    scripts_DATA = awkscript1 awkscript2
    

    In this case it will install awkscript in $(prefix)/bin (you can also use $(bindir)).

    Note: Dont forget that the first should be named name + dir (scripts -> scriptsdir) and the second should be name + _DATA (scripts -> scripts_DATA).

    0 讨论(0)
提交回复
热议问题