pl help me to Optimize the given code

Pl help to me to write the below code in a simple way ...
i suupose to use this code 3 to 4 places in my makefile(gnu) ..
****************************************

@for i in $(LIST_A); do \
  for j in  $(LIST_B); do\
  if [ "$$i" = "$$j" ] ;then\
   echo "Need to sign"\
  echo "List A = $$i , List B =$$j"\
  else\
  echo "No need to sign "\
    fi; \
  done\
 done;

**********************************************

---------- Post updated at 09:37 AM ---------- Previous update was at 01:08 AM ----------

what is the difference for loop and foreach loopin Gnu makefile

Seems simple enough already, however ....

You could look into using grep instead of the second for loop. I probably would be more efficient then a shell for loop, and it would help eliminate a few lines.

Also, instead of

if [ cond ]; then
   stmtiftrue
else
   stmtiffalse
fi

you could substitute:

  [ cond ] && stmtiftrue ||  stmtiffalse

HTH.
-RN.

1 Like

The best way to optimize this would be to only run it once, and just use the result as many times as you want... but makefiles make this difficult with their recursive variables that re-re-re-evaluate every single time no matter what. Supposedly "simple variables" don't, but I haven't had any luck convincing a simple variable to be a simple variable and not re-re-re-evaluate n times.