[Top][All Lists]

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

Re: a for-loop-like function

From: Tristan Van Berkom
Subject: Re: a for-loop-like function
Date: Wed, 10 Sep 2003 15:28:53 -0400
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20030225

Chien-Lung Wu wrote:

        I have a question about writing Makefile. Could any one help me.

        As I do my project using gnu make, I have  sub_directories and I
would like the files/directories under these subdirectories been compiled.

        Therefore I create a makefile as follows:

        SUB_DIRS = src vlan ip lib    # (I have 4 subdirs-- src, vlan, ip,
and lib)

all: for subdir in $(SUBDIRS) ; do \
                        make -C $subdir; \

        So that I can "make -C" to each sub-directory and get them compiled.
        However, Make utility seems can not support this kind of for-loop.

        Are there any way in make utility to get this for-loop done?
If you need to access a shell variable, you'll need to pass a `$' to the shell.
To do so, you'll need to escape it with an additional `$' like so:

   make -C $$subdir;

Furthermore, (as discussed in another mail on this list just today),
you will loose any exit value from the sub-make, if you wish to
trap the errors you should at least do this:

   make -C $$subdir || exit -1;

for something a little more scalable.


reply via email to

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