This is a bit tricky...
I want my Makefile to display progression percentage of my compilation. This is easy as long as I use tput or escaped sequences to move my cursor to modify my percentage.
But if a warning appears, the next warning will be on the previous one and so on...
How can I do something like that ?
I've already found some ideas like storing cursor position inside a variable, but I failed. I've thought about redirect gcc's (or clang's idc) output to a variable but it failed too.
I can output the cursor position with : echo -en "\033[6n" ; read -sdR CURPOS ; CURPOS=$${CURPOS#*[} ; echo "$${CURPOS}"
but I cannot use $(shell ..)
because it just infinit loop (I guess) so $(eval VAR = $(shell echo ..))
is impossible.
Maybe I'm looking the problem at the wrong side ?
I'm really stuck tbh so thank for your help
EDIT:
224 all : $(TARGET)
225 if [[ ! '$(FILE_TODO)' == '0' ]]; then echo -e $(RPOS)$(ENDRASE)Done\n$(DEBUG_COLOR)[Linkage]$(NORMAL) - Done'; fi
226 $(ECHO) '$(DEBUG_MODE_MSG) : $(if $(ISXX),$(CXXFLAGS),$(CFLAGS))'
227
228 $(TARGET) : $(OBJFILES)
230 $(CC) $(OUTPUT_OPTION) $(LDFLAGS) $(LDLIBS) $(LINKAGE) $(if $(UNITARY),--coverage,) $^
231
232 display :
233 $(eval OBJ_NBR := $(shell if [[ -d '$(OBJDIR)' ]]; then find $(OBJDIR) -type f -name \*$(OBJEXT); fi))
234 $(eval OBJ_NBR := $(shell echo -n "$$(($(words $(OBJ_NBR))))"))
235 $(eval FILE_TODO := $(shell echo "$$(($(SRC_NBR)-$(OBJ_NBR)))"))
236 if [[ ! '$(FILE_TODO)' == '0' ]]; then echo -en '$(DEBUG_COLOR)[Compilation]$(NORMAL) - $(SPOS)'; fi
237
238 $(OBJDIR)/%$(OBJEXT) : %$(SRCEXT) | display
239 $(eval I := $(shell echo -n "$$(($(I)+1))"))
240 $(eval PERCENT := $(shell echo "$$((100*$(I)/$(FILE_TODO)))"))
241 $(ECHO) '$(RPOS)$(ENDRASE)$(PERCENT)% ($<)'
242 $(MKDIR) $(@D) $(patsubst $(OBJDIR)%,$(DEPDIR)%,$(@D))
243 $(CC) -c $(OUTPUT_OPTION) $(DEPFLAGS) $(if $(ISXX),$(CXXFLAGS),$(CFLAGS)) $(CPPFLAGS) $(WARNING) $(WNO) $(COMPILATION) $<