[Top][All Lists]

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

Re: export not working...

From: Christopher J Bottaro
Subject: Re: export not working...
Date: Wed, 21 Jan 2004 13:42:57 -0600
User-agent: KMail/1.5

ok, now i'm confused.  i'm looking at some pretty popular linux projects (KDE) 
and in their makefiles (generated by automake/autoconf) the command lines of 
the rules are pretty big shell scripts (complete with for loops to do 
recursive makes).  this seems to be pretty much the standard way to do things 
it seems.  i did a search for "recursive make" and found web articles giving 
examples of using the shell for loop as the "correct" way of doing it.

why is what seems to be the "accepted standard" the wrong way to do it?

again, the makefiles for popular linux projects seem to follow the form of 
each rule having one command line.  and the command line being a pretty 
involved multiline shell script.

example (from a kde package):

        @set fnord $$MAKEFLAGS; amf=$$2; \
        dot_seen=no; \
        target=`echo $@ | sed s/-recursive//`; \
        list='$(SUBDIRS)'; for subdir in $$list; do \
          echo "Making $$target in $$subdir"; \
          if test "$$subdir" = "."; then \
            dot_seen=yes; \
            local_target="$$target-am"; \
          else \
            local_target="$$target"; \
          fi; \
          (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
           || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; 
        done; \
        if test "$$dot_seen" = "no"; then \
          $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
        fi; test -z "$$fail"

which leaves me wondering...why don't they just do something like this 


that way that huge, ugly, multiline command can be tucked away in a shell 
script...where you don't have to use so many ";"s and "\"s.

sorry if my questions are naive, but my only experience with makefiles so far 
is just from school projects where they are entirely handwritten and pretty 


On Wednesday 21 January 2004 01:00 pm, Paul D. Smith wrote:
>   cjb> on another note, how would one do a recursive make clean without
>   cjb> using a shell for loop?  right now i have it like this:
> You don't.  Using a shell for loop is a bad idea; anyway why do that
> when this kind of thing is what make was designed to do?
>   cjb> clean:
>   cjb>        @for d in $(SUBDIRS); do \
>   cjb>                cd $dd && $(MAKE) clean || exit 1; \
>   cjb>        done
>   cjb> but what is the "correct" way to do this?
> Look at the GNU make manual section on "Phony Targets" for an example of
> another way to do this.
> The problem with your attempt above is that it won't obey make options
> like -k, etc.

Christopher J Bottaro
Software Developer
GeoCenter, Inc

reply via email to

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