Printing CFLAGS in GNU make exaclty once if source files have changed -


here snippet makefile:

all: $(target)   $(c_objs): %.o: %.c     @ echo -n "compiling " $*.c;     @ $(cc) -c $(cflags) $*.c -o $*.o     @ echo " ...... done"  $(target): $(c_objs)     @ $(ar) rus $@ $(c_objs);  print_cflags:     @ echo "cflags: " $(cflags) "\n" 

moving forward, want

  1. print cflags once if compilation takes place.
  2. get make: nothing done "all" message if no modifications has been done previous build. printing cflags optional in case.

i feel, can achieved keeping counter inside $(c_objs): %.o: %.cbut there better way achieve this? understand specific question appreciated.

etan gives number of options. here's one, assuming version of gnu make new enough support eval:

print_cflags := $(cflags)  $(c_objs): %.o: %.c         @ $(if $(print_cflags),echo "cflags: $(print_cflags)" $(eval print_cflags:=))         @ echo -n "compiling " $*.c;         @ $(cc) -c $(cflags) $*.c -o $*.o         @ echo " ...... done" 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -