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
- print
cflagsonce if compilation takes place. - get
make: nothing done "all"message if no modifications has been done previous build. printingcflagsoptional 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
Post a Comment