makefile - Getting a list of all dependencies in make -


i'm trying write etags target in make based on dependency information generated gcc. there way of getting @ dependencies in 1 go? or, failing that, how write rule executed when "tags" target made , passes source , header files etags? want index files compiled (including headers). i'm aware can sed around in .d files myself i'm trying find more elegant , less brittle solution.

i have following (excerpt)

depfiles = $(objfiles:.o=.d)  %.o : %.c     @echo "compiling $<"     $(no_echo) $(cc) $(cflags) -mmd -mf $(@:.o=.d) -o $@ -c $<  %.o : %.s     @echo "compiling $<"     $(no_echo) $(cc) $(asflags) -mmd -mf $(@:.o=.d) -o $@ -c $<  $(target) : $(objfiles)     @echo "linking $@"     $(no_echo) $(ld) $(ldflags) -o $@ $(objfiles) $(libs:%=-l%)  .phony: clean  # order-only dependency make dep/obj-directories if not # present $(objfiles) : | $(allpaths)  $(allpaths):     $(no_echo) mkdir -p $(allpaths)  # depend on makefiles $(objfiles) : $(src_path)/makefile $(makecfg) $(buildcfg)  # include dependency files  sinclude $(depfiles) 

edit : following seems work i'd find more elegant solution (the double sort/uniq performance).

tags : $(target)     cat $(depfiles) | sort | uniq | sed 's/.*:.*$$//' | tr -d '\\' | tr "\n" " " | xargs -n 1 readlink -f | sort | uniq | xargs etags -a  

you need create mini tag file each .d file , use update etags file. note appends stuff file, rather removing , replacing, might need remote tags file (ctags has --update option)

tagfiles = $(objfiles:.o=.t)  # prune .d files bit list of files etags scan %.t: %.d     cat $< | sed stuff > $@     cat $@ | etags -a $@  .phony: tags tags: $(tagfiles) 

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -