On Thu, Jun 30, 2005 at 08:20:17PM +0300, Angel Tsankov wrote:
> But how do you get a list of all files that match a pattern, e.g. all .cpp 
> files? Could you give an example?
> 

Replying to the list in case there are others who might be interested.
Please note how involved this gets with even a trival example.  If you
can follow Paul's advice, your life will be much simpler.

You may find 4 files attached which constitute a working example of how
to deal with source files which have spaces.  Note that only the source
files have spaces, as soon as I generate the object files, I no longer
have to deal with the whitespace.  This causes the resultant object
files to have somewhat unseemly names.

  Ken
sources := \
$(shell \
  for each in *.c; \
  do \
      echo $$each | sed -e 's, ,__whitespace__,g'; \
  done \
 )

objects := $(sources:.c=.o)

main: $(objects)
        gcc -o $@ $(^)

.PHONY: clean
clean: 
        rm -f $(objects) main

empty := 
space := $(empty) $(empty)
reconstitute = $(subst __whitespace__,\ ,$(1))
shell-escape = $(subst $(space),\ ,$(1))

$(foreach source,$(sources), \
  $(eval \
    $(source:.c=.o) : \
    $$(call reconstitute,$(source)) ; \
    gcc -c -o $$@ $$(call shell-escape,$$<) \
   ) \
 )
int wacky() {}
int hello() {}
int main() {}
_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make

Reply via email to