EmbDev.net

Forum: ARM programming with GCC/GNU tools Makefile problems


Author: Craig Stracey (craigstracey)
Posted on:

Rate this post
0 useful
not useful
Hi all,

I am trying to build a number of related projects for the LPC2366 & 
LPC2478. They share a common core of code and I want to generate all the 
hex files when this changes. My thought was to have each individual 
project in its own sub-directory of a main project with a master 
makefile which recursively built the sub-projects. The problem is that 
the make target is being ignored. Sorry if this is off topic, but it is 
driving me mad!

My main makefile is:
SUBDIRS = subdirs/*

all clean:
  target="$(patsubst %,%,$@)"; \
  list='$(SUBDIRS)'; for subdir in $$list; do \
    echo "Making $$target in $$subdir"; \
    (cd $$subdir && $(MAKE) $$target) \
  done; \


# Listing of phony targets.
.PHONY : all clean

The problem is when the command $(MAKE) $$target is run the target is 
ignored and the default target is executed.
To test and show the problem I am using 3 subdirs dir1, dir2 & dir3 with 
the following makefile:

all clean:
  make_target="$(patsubst %,%,$@)"; \
  echo "Making $$target";

When I run make clean I get:

target="clean"; \
list='subdirs/*'; for subdir in $list; do \
  echo "Making $target in $subdir"; \
  (cd $subdir && make  $target) \
done; \

Making clean in subdirs/dir1
C:\WinARM\utils\bin\make.exe[1]: Entering directory `c:/Documents and 
Settings/Craig/workspace/Test/subdirs/dir1'
make_target="all"; \
echo "Making $target";
Making
C:\WinARM\utils\bin\make.exe[1]: Leaving directory `c:/Documents and 
Settings/Craig/workspace/Test/subdirs/dir1'
Making clean in subdirs/dir2
C:\WinARM\utils\bin\make.exe[1]: Entering directory `c:/Documents and 
Settings/Craig/workspace/Test/subdirs/dir2'
make_target="all"; \
echo "Making $target";
Making
C:\WinARM\utils\bin\make.exe[1]: Leaving directory `c:/Documents and 
Settings/Craig/workspace/Test/subdirs/dir2'
Making clean in subdirs/dir3
C:\WinARM\utils\bin\make.exe[1]: Entering directory `c:/Documents and 
Settings/Craig/workspace/Test/subdirs/dir3'
make_target="all"; \
echo "Making $target";
Making
C:\WinARM\utils\bin\make.exe[1]: Leaving directory `c:/Documents and 
Settings/Craig/workspace/Test/subdirs/dir3'

Any help would be greatly appreciated.

Author: Clifford Slocombe (clifford)
Posted on:

Rate this post
0 useful
not useful
Craig Stracey wrote:
> Entering directory `c:/Documents and Settings/Craig/
> workspace/Test/subdirs/dir1'


GNU make does not always play well with paths containing spaces.

Author: Wolfgang Mües (Guest)
Posted on:

Rate this post
0 useful
not useful
$(MAKECMDGOALS):
  list='$(SUBDIRS)'; for subdir in $$list; do \
    echo "Making $(MAKECMDGOALS) in $$subdir"; \
    $(MAKE) -C $$subdir $(MAKECMDGOALS) \
  done; \

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.