title: why a command in makefile is always executed even of all Prerequisites is nothing change?
body: <p>I have a C project ,  the struct is as the last part of this questions,<br />
  there is a main makefile in root and 3 makefile in  AppCode\Comp2 AppCode\Comp3 AppCode\headlamp</p>
  <p>I want to :</p>
  <ol>
  <li><p>compile all c file in  AppCode\Comp2  to object files , then archinve these object file  to a library file (a file)</p>
  </li>
  <li><p>do the same step as 1 for every subdirectory in AppCode ,in this case are AppCode\Comp3 AppCode\headlamp</p>
  </li>
  <li><p>search all object files (*.o) in all directories expect AppCode in $(OBJ_FILES)</p>
  </li>
  <li><p>link all a files in AppCode $(ALL_a_in_AppCode) and o files $(OBJ_FILES) to a elf file</p>
  </li>
  <li><p>create hex file based on elf file</p>
  </li>
  </ol>
  <p>the main makefile will  call the sub-dir's makefile ,</p>
  <p>there is my main makefile in root :</p>
  <pre><code>include rules.mk
  
  rwildcard=$(wildcard $1$2)$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2))
  ALL_C_in_AppCode := $(call rwildcard,./AppCode,*.c)
  ALL_O_in_AppCode := $(call rwildcard,./AppCode,*.o)
  ALL_a_in_AppCode := $(call rwildcard,./AppCode,*.a)
  
  AppCodeSubDirs := $(wildcard AppCode/**)
  OBJPATH_IN_AppCode :=$(addsuffix /obj,$(AppCodeSubDirs))
  APATH_IN_AppCode :=$(addsuffix /lib,$(AppCodeSubDirs))
  
  APPCode_DIR = .\APPCode
  CDD_dir =.\CDD
  DemoAppCode_dir = .\DemoAppCode
  Intergration_dir =.\Intergration
  MCAL_dir=.\MCAL
  
  VOS_BSW_dir=.\VOS\BSW
  VOS_BSW_Config_dir=.\VOS\BSW_config
  VOS_erika_dir=.\VOS\erika
  VOS_LIB_dir=.\VOS\Lib
  
  
  
  OBJ_FILES = $(wildcard $(CDD_dir)/*.o)
  OBJ_FILES += $(wildcard $(DemoAppCode_dir)/*.o)
  OBJ_FILES += $(wildcard $(Intergration_dir)/*.o)
  OBJ_FILES += $(wildcard $(MCAL_dir)/*.o)
  OBJ_FILES += $(wildcard $(VOS_BSW_dir)/*.o)
  OBJ_FILES += $(wildcard $(VOS_BSW_Config_dir)/*.o)
  OBJ_FILES += $(wildcard $(VOS_erika_dir)/*.o)
  OBJ_FILES += $(wildcard $(VOS_LIB_dir)/*.o) 
  
  
  LDFLAGS = -mtc162 -T 
  
  all:erika3app.elf
      $(OBJCOPY) --set-start 0x0000 -R .ram -R .sbRam -R .sb_fix_ram -I elf32-tricore -O ihex erika3app.elf erika3app.hex
  
  erika3app.elf:$(OBJ_FILES)  AppCodeLib
      $(LD) $(LDFLAGS) .\Intergration\out\ee_tc_gcc_flash.ld -nostartfiles -Wl,--gc-sections -Wl,-Map=erika3app.map   -L . -L .\Intergration\out\ -L .\Intergration\erika\mk   $(OBJ_FILES) -o &quot;erika3app.elf&quot; -L .\Intergration\erika\lib -Wl,--start-group  -lee -Wl,--end-group
  
  AppCodeLib: $(AppCodeSubDirs)
  
  $(AppCodeSubDirs):
      make -C $@
  
  
  clean:
      -rm -rf $(OBJPATH_IN_AppCode)   $(APATH_IN_AppCode) erika3app.hex erika3app.elf erika3app.map
  
  
  print-%: ; @echo $* = $($*) 
  
  .PHONY:$(AppCodeSubDirs)
  </code></pre>
  <p>if i execute make , it seems that  the command for erika3app.elf and all is always executed ,
  as follow (i omit some meamless o files):
  anyone can tell me why these two commands are always execute and how to fix it ?<br />
  Thanks!</p>
  <pre><code>PS D:\TEST\project&gt; .\build.bat
  make -C AppCode/headlamp
  make[1]: Entering directory 'D:/TEST/project/AppCode/headlamp'
  C:\VOS_tools_repo\hightec_ifx\v4.9.2.0\bin\tricore-ar.exe csr  lib/libheadlamp.a   obj/app1.o obj/app21.o obj/app2.o
  make[1]: Leaving directory 'D:/TEST/project/AppCode/headlamp'
  make -C AppCode/Comp3
  make[1]: Entering directory 'D:/TEST/project/AppCode/Comp3'
  C:\VOS_tools_repo\hightec_ifx\v4.9.2.0\bin\tricore-ar.exe csr  lib/libComp3.a   obj/33.o
  make[1]: Leaving directory 'D:/TEST/project/AppCode/Comp3'
  make -C AppCode/Comp2
  make[1]: Entering directory 'D:/TEST/project/AppCode/Comp2'
  C:\VOS_tools_repo\hightec_ifx\v4.9.2.0\bin\tricore-ar.exe csr  lib/libComp2.a   obj/22.o
  make[1]: Leaving directory 'D:/TEST/project/AppCode/Comp2'
  C:\VOS_tools_repo\hightec_ifx\v4.9.2.0\bin\tricore-gcc.exe -mtc162 -T  .\Intergration\out\ee_tc_gcc_flash.ld -nostartfiles -Wl,--gc-sections -Wl,-Map=erika3app.map   -L . -L .\Intergration\out\ -L .\Intergration\erika\mk    .\DemoAppCode/Rte_Chas_SA_FDD_IBCInfo.c.o .\VOS\Lib/qn_strcpy.c.o  -o &quot;erika3app.elf&quot; -L .\Intergration\erika\lib -Wl,--start-group  -lee -Wl,--end-group
  C:\VOS_tools_repo\hightec_ifx\v4.9.2.0\bin\tricore-objcopy.exe --set-start 0x0000 -R .ram -R .sbRam -R .sb_fix_ram -I elf32-tricore -O ihex erika3app.elf erika3app.hex
  PS D:\TEST\project&gt;
  PS D:\TEST\project&gt;
  PS D:\TEST\project&gt;
  PS D:\TEST\project&gt; .\build.bat
  make -C AppCode/headlamp
  make[1]: Entering directory 'D:/TEST/project/AppCode/headlamp'
  C:\VOS_tools_repo\hightec_ifx\v4.9.2.0\bin\tricore-ar.exe csr  lib/libheadlamp.a   obj/app1.o obj/app21.o obj/app2.o
  make[1]: Leaving directory 'D:/TEST/project/AppCode/headlamp'
  make -C AppCode/Comp3
  make[1]: Entering directory 'D:/TEST/project/AppCode/Comp3'
  C:\VOS_tools_repo\hightec_ifx\v4.9.2.0\bin\tricore-ar.exe csr  lib/libComp3.a   obj/33.o
  make[1]: Leaving directory 'D:/TEST/project/AppCode/Comp3'
  make -C AppCode/Comp2
  make[1]: Entering directory 'D:/TEST/project/AppCode/Comp2'
  C:\VOS_tools_repo\hightec_ifx\v4.9.2.0\bin\tricore-ar.exe csr  lib/libComp2.a   obj/22.o
  make[1]: Leaving directory 'D:/TEST/project/AppCode/Comp2'
  C:\VOS_tools_repo\hightec_ifx\v4.9.2.0\bin\tricore-gcc.exe -mtc162 -T  .\Intergration\out\ee_tc_gcc_flash.ld -nostartfiles -Wl,--gc-sections -Wl,-Map=erika3app.map   -L . -L .\Intergration\out\ -L .\Intergration\erika\mk    .\DemoAppCode/Rte_Chas_SA_FDD_IBCInfo.c.o .\DemoAppCode/Rte_EN_SA_FDD_WaterTemp1Info.c.o ..\VOS\Lib/qn_strnlen.c.o .\VOS\Lib/qn_memset.c.o .\VOS\Lib/qn_strncpy.c.o .\VOS\Lib/qn_strlen.c.o .\VOS\Lib/qn_strcpy.c.o  -o &quot;erika3app.elf&quot; -L .\Intergration\erika\lib -Wl,--start-group  -lee -Wl,--end-group
  C:\VOS_tools_repo\hightec_ifx\v4.9.2.0\bin\tricore-objcopy.exe --set-start 0x0000 -R .ram -R .sbRam -R .sb_fix_ram -I elf32-tricore -O ihex erika3app.elf erika3app.hex
  PS D:\TEST\project&gt;
  </code></pre>
  <p>here is my  project struct:</p>
  <pre><code>D:.
  |   build.bat
  |   clean.bat
  |   makefile
  |   rules.mk
  |
  +---AppCode
  |   +---Comp2
  |   |   |   22.c
  |   |   |   makefile
  |   |   |
  |   |
  |   +---Comp3
  |   |   |   33.c
  |   |   |   makefile
  |   |   |
  |   |
  |   \---headlamp
  |       |   makefile
  |       |
  |       +---left
  |       |       app1.c
  |       |       app1.h
  |       |
  |       \---right
  |           |   app2.c
  |           |   app2.h
  |           |
  |           \---rightright
  |                   app21.c
  |
  +---CDD
  |   \---include
  +---DemoAppCode
  |       Rte_Chas_SA_FDD_IBCInfo.c.o
  |
  +---Intergration
  |   |   applSignature.oil
  |   |   Dcm_CallOut.c.o
  |   |
  |   +---erika
  |   |   +---lib
  |   |   |       libee.a
  |   |   |
  |   |   \---mk
  |   |           ee.mk
  |   |           ee_arch_cfg.mk
  |   |
  |   \---out
  |           ee_applcfg.h
  |
  +---MCAL
  |       Can_17_McmCan.c.o
  |       Wdg_17_Scu_PBcfg.c.o
  |
  +---other
  \---VOS
      +---BSW
      |       api_standalone.c.o
      |
      +---BSW_Config
      |       BswMBswMConfig_0_CommonPBcfg.c.o
      |       WdgM_PBcfg.c.o
      |
      +---erika
      |       ee_bss_data_init.c.o
      |       ee_oscfg.c.o
      |       osSignature.oil
      |
      \---LIB
              libee.a
              qn_memcpy.c.o
  </code></pre>