automake
[Top][All Lists]
Advanced

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

Using shell code within Makefile.am


From: David Bruce
Subject: Using shell code within Makefile.am
Date: Wed, 6 Apr 2011 02:39:50 +0000

Hello,

I maintain a GPL Linux application that has a Windows version that is
cross-compiled under Linux.  For the crossbuild, we have a custom
target (install-nsi-local) that does a "make install" into a temporary
location, then copies the needed files into a duplicate of the final
Windows directory structure prior to packaging.

One problem has been that the documentation text files (README,
INSTALL etc.) haven't been converted into the DOS/Windows format,
although our users probably wouldn't look at them anyway.  There is
also a heirarchical directory of text "lesson" files that in principle
are human editable after installation, but they aren't really usable
in Notepad by nontechnical folks because of the Unix/DOS linebreak
differences. So, I want to incorporate such conversion into the custom
target used for the crossbuild.

I wrote a small script that appears to have the desired behavior when
called from the top directory containing the text files to be
converted:

winfriendly.sh: --------------------------------------

#!/bin/bash
FILES=`find . -type f`
for file in $FILES; do
        echo "Processing "$file
        todos -p $file
        mv $file $file".txt"
done

However, I can't get the same shell code to work when incorporated
into the install-nsi-local rule.  I tried putting it in verbatim
(except for a tab before each line), and also tried putting the whole
thing on a "single line" with semicolons between commands and line
continuation characters:

Snippet from install-nsi-local target in Makefile.am:
-----------------------------------------

## Convert text files from Unix format DOS/Windows format and rename
## them with ".txt" extension:
        (cd $(top_builddir)/$(NSI_INSTALL_DIR)/doc; \
        FILES=`find . -type f`; \       
        for file in $(FILES); do \
            echo "Processing "$(file); \
            todos -p $(file); \
            mv $(file) $(file)".txt"; \
        done)

But it doesn't work - I think because the 'FILES' and 'file' variables
aren't available when the subshells are spawned to run the commands.

>From output generated by "make install-nsi-local"

(cd ./mingw32/doc; \
        FILES=`find . -type f`; \
        for file in ; do \
            echo "Processing "; \
            todos -p ; \
            mv  ".txt"; \
        done)

If I just run my script from the Makefile.am, however, it works.  So I
could just package the script with the program, but I'd like to
understand how to get things like this working with shell code placed
directly into the Makefile.am.

Thanks for any help, or suggestions on a better way to do this.

David Bruce



reply via email to

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