title: Why does make execute a command I never write in makefile and how to debug it?
body: <p>Here is the makefile from a unity tutorial with a little change:</p>
  <pre><code>CLEANUP = del /F /Q
  TARGET_EXTENSION=exe
  
  .PHONY: test
  
  PATHU = unity/src
  PATHS = src
  PATHT = test
  PATHB = build
  PATHD = build/depends
  PATHO = build/objs
  PATHR = build/results
  
  BUILD_PATHS = $(PATHB) $(PATHD) $(PATHO) $(PATHR)
  
  SRCT = $(wildcard $(PATHT)/*.c)
  
  COMPILE=gcc -c
  LINK=gcc
  DEPEND=gcc -MM -MG -MF
  CFLAGS=-I. -I$(PATHU) -I$(PATHS) -DTEST
  
  RESULTS = $(patsubst $(PATHT)/Test%.c,$(PATHR)/Test%.txt,$(SRCT) )
  
  PASSED = `grep -s PASS $(PATHR)*.txt`
  FAIL = `grep -s FAIL $(PATHR)*.txt`
  IGNORE = `grep -s IGNORE $(PATHR)*.txt`
  
  test: $(BUILD_PATHS) $(RESULTS)
      @echo &quot;-----------------------\nIGNORES:\n-----------------------&quot;
      @echo &quot;$(IGNORE)&quot;
      @echo &quot;-----------------------\nFAILURES:\n-----------------------&quot;
      @echo &quot;$(FAIL)&quot;
      @echo &quot;-----------------------\nPASSED:\n-----------------------&quot;
      @echo &quot;$(PASSED)&quot;
      @echo &quot;\nDONE&quot;
  
  $(PATHR)/%.txt: $(PATHB)/%.$(TARGET_EXTENSION)
      #echo gen result
      -./$&lt; &gt; $@ 2&gt;&amp;1
  
  $(PATHB)/Test%.$(TARGET_EXTENSION): $(PATHO)/Test%.o $(PATHO)/%.o $(PATHU)/unity.o #$(PATHD)/Test%.d
      #echo link
      $(LINK) -o $@ $^
  
  $(PATHO)/%.o:: $(PATHT)/%.c
      #echo compile test
      $(COMPILE) $(CFLAGS) $&lt; -o $@
  
  $(PATHO)/%.o:: $(PATHS)/%.c
      #echo compile src
      $(COMPILE) $(CFLAGS) $&lt; -o $@
  
  $(PATHO)/%.o:: $(PATHU)/%.c $(PATHU)/%.h
      #echo compile unity
      $(COMPILE) $(CFLAGS) $&lt; -o $@
  
  $(PATHD)/%.d:: $(PATHT)/%.c
      #echo gen depend
      $(DEPEND) $@ $&lt;
  </code></pre>
  <p>Use mingw32-make to make, it throws this error:</p>
  <pre><code>D:\test\make\sampleproj&gt;mingw32-make
  cc -I. -Iunity/src -Isrc -DTEST   -c -o unity/src/unity.o unity/src/unity.c
  process_begin: CreateProcess(NULL, cc -I. -Iunity/src -Isrc -DTEST -c -o unity/src/unity.o unity/src/unity.c, ...) failed.
  make (e=2):
  &lt;builtin&gt;: recipe for target 'unity/src/unity.o' failed
  mingw32-make: *** [unity/src/unity.o] Error 2
  </code></pre>
  <p><code>mingw32-make --debug=b</code> gives this:</p>
  <pre><code>Reading makefiles...
  Updating goal targets....
   File 'test' does not exist.
     File 'build/results/Testproduct.txt' does not exist.
      File 'build/Testproduct.exe' does not exist.
       File 'unity/src/unity.o' does not exist.
      Must remake target 'unity/src/unity.o'.
  cc -I. -Iunity/src -Isrc -DTEST   -c -o unity/src/unity.o unity/src/unity.c
  
  (A same error message)
  </code></pre>
  <p>I can't find where the &quot;cc&quot; command comes from. Adding an echo before each command makes no difference. What's wrong with the makefile? Or how to preprocess the makefile so that it can expand all the variables and wildcards?</p>