Makefile based verification environment has some advantages specially, there are embedded software too which need to be compiled. Incremental compilation works pretty good.
Except, the issues with make are very cryptic. I came across a situation where an strange kind of problem popped up with no clues to look into the real problem. After a lot of debug, I found the reason and it was terrible experience.
The code segment as follows -
OBJ_C_CODE = $(foreach d,$(CODE_DIR1),$(patsubst %.c,%.o,$(subst $(d),$(OBJ_DIR),$(wildcard $(d)/*.c))))
OBJ_S_CODE = $(foreach d,$(ASM_DIR),$(patsubst %.s,%.o,$(subst $(d),$(OBJ_DIR),$(wildcard $(d)/*.s))))
create_obj_dir:
mkdir -p $(OBJ_DIR);
compile :
create_obj_dir $(OBJ_DIR)/libsela_fw.a
@echo "TOP Makefile"
@echo "INCLUDE_PATH : $(INCLUDE_PATH)"
@echo "BOOT_CODES : $(BOOT_CODES)"
@echo "BOOT_OBJS_DIR : $(BOOT_OBJS_DIR)"
$(OBJ_DIR)/%.o :
./code/%.c $(HEADER_FILES)
$(ARM_CC) $(foreach m,$(INCLUDE_PATH),-I$m) $(C_OPT) -o $@ $< ;
$(OBJ_DIR)/%.o:
./asm/%.s $(HEADER_FILES)
$(ARM_ASM) $(foreach m,$(INCLUDE_PATH),-I$m) $(ASM_OPT) -o $@ $< ;
$(OBJ_DIR)/libsela_fw.a :
prova $(OBJ_C_CODE) $(OBJ_S_CODE)
$(ARM_AR) $(AR_OPT) $@ $(OBJ_C_CODE) $(OBJ_S_CODE)
The dependency in this case was working fine but with a change in INCLUDEPATH, the compilation started breaking. The implicit compilation for "$(OBJ_DIR)/%.o :
./code/%.c $(HEADER_FILES)" stopped working without any clue.
The debug with make file as I performed -
$ make
-n
So typically, it shows what all commands are coded against the target. It's very helpful but in this case, it stopped popping up the same error.
$ make
-d
The output for the above command details out all dependencies which are there. It tries out all implicit rules too and a very detail log file is prepared. At times, it's difficult to understand but with patience, we can look at lines to understand the sequence of operations -
.... Trying implicit prerequisite `/prj/hsi_ss/digvijay/PureSuite/VERIFICATION/puresuite_usb3/setup/.././..//Makefile.common.l'.
........
Trying pattern rule with stem `Makefile.common.l'.
Trying implicit prerequisite `/prj/hsi_ss/digvijay/PureSuite/VERIFICATION/puresuite_usb3/setup/.././..//s.Makefile.common.l'.
Trying pattern rule with stem `Makefile.common.l'.
Trying implicit prerequisite `/prj/hsi_ss/digvijay/PureSuite/VERIFICATION/puresuite_usb3/setup/.././..//SCCS/s.Makefile.common.l'.
........
Trying implicit prerequisite `/prj/hsi_ss/digvijay/PureSuite/VERIFICATION/puresuite_usb3/setup/.././..//s.Makefile.common.w'.
Trying pattern rule with stem `Makefile.common.w'.
Trying implicit prerequisite `/prj/hsi_ss/digvijay/PureSuite/VERIFICATION/puresuite_usb3/setup/.././..//SCCS/s.Makefile.common.w'.
Trying pattern rule with stem `Makefile.common'.
In case of the issue, this file also brings to and end without anymore conclusive point.
Then, I found out a very strange issue...the implicit rules if fails, do not generate any error message properly. Digging into possible causes of implicit rules failures, I found that the INCLUDEPATH has pointed to a path which was not accessible. The reason being that the Admin team has been planning to remove some of the tools versions.
I just replaced the INCLUDEPATH with the good version which was available and the make command worked fine.
So the learning -
- - If the implicit rules are not working, Check the possible compilation command which might be running.
- - Checking any path which are involved there...and availability of the hierarchy of directory.
- - Check if the options provided to tools are good one.
- - Then, the make command MUST run and you should not have any problem.
- - Additionally, you can apply the above 2 commands (make -n and make -d) for other debugging.
Have fun !!