help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problem with VPATH builds and SCRIPTS primary


From: Raphaël Halimi
Subject: Problem with VPATH builds and SCRIPTS primary
Date: Thu, 27 Oct 2016 16:41:34 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.4.0

Hi,

I have a problem with parallel build trees (a.k.a. VPATH Builds).

I'm trying to use GNU autotools to distribute a shell script that need
to be installed with some other files (sample configuration, man pages,
data, etc etc).

Nothing in this project needs to be compiled, but the script is passed
through sed to replace some variables (as showed through examples in
section 9.1 of automake documentation, and section 4.8.2 of autoconf
documentation).

The provided examples work with recursive make, but I only want to
manage a single Makefile.am, and thus I want to use non-recursive make;
that's where my problem appears.

I'm trying to have the final script (the file where sed output is
redirected) in the same subdirectory as the script template, but I can't
find a way to do this that would let "make distcheck" work.

According to section 2.2.6 of GNU automake documentation:

"The build tree usually has the same subdirectory layout as the source
tree; its subdirectories are created automatically by the build system."

Unfortunately, it doesn't seem to be true for the SCRIPTS primary (I
assume it's true and works as expected for compiled binaries and
libraries, I can't know, I'm new to autotools and I'm a sysadmin, I
develop only scripts, nothing compiled).

So, at first, I did this :

-----%<-----

#
# Main script
#

pkgsysconfdir = $(sysconfdir)/$(PACKAGE)

bin_SCRIPTS = scripts/my_script

# Command to substitute variables
do_subst = $(SED) \
        -e 's,address@hidden@],$(PACKAGE),g' \
        -e 's,address@hidden@],$(VERSION),g' \
        -e 's,address@hidden@],$(pkgsysconfdir),g' \
        -e 's,address@hidden@],$(pkgdatadir),g'

# Generic recipe to substitute variables in scripts
$(bin_SCRIPTS): Makefile
        $(do_subst) $(srcdir)/address@hidden > $@
        chmod +x $@

# Per-script prerequisites
scripts/my_script: $(srcdir)/scripts/my_script.in

----->%-----

This works for a normal build, but not with "make distcheck"; it fails
with the error message (translated from French):

/bin/bash: scripts/my_script: No such file or directory

I guess make doesn't create the "scripts" subdirectory in "_build/sub"
as it's supposed to (according to the documentation quoted above), so
the shell can't redirect sed's output to this file.

So for now I'm doing this:

-----%<-----

#
# Main script
#

pkgsysconfdir = $(sysconfdir)/$(PACKAGE)

bin_SCRIPTS = my_script

# Command to substitute variables
do_subst = $(SED) \
        -e 's,address@hidden@],$(PACKAGE),g' \
        -e 's,address@hidden@],$(VERSION),g' \
        -e 's,address@hidden@],$(pkgsysconfdir),g' \
        -e 's,address@hidden@],$(pkgdatadir),g'

# Generic recipe to substitute variables in scripts
$(bin_SCRIPTS): Makefile
        $(do_subst) $(srcdir)/scripts/address@hidden > $@
        chmod +x $@

# Per-script prerequisites
my_script: scripts/my_script.in

----->%-----

It works with both a normal build and "make distcheck", but the script
ends up in $(srcdir), instead of the "scripts" subdirectory, which is
not my initial goal.

Is there a way to create the script in the "scripts" subdirectory, *and*
make it work with "make distcheck" ?

Thanks in advance.

Regards,

-- 
Raphaël Halimi

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]