Makefile option/rule to handle missing/removed source files -


Some indications on how to handle .o files is to handle deleted source files. I am using GCC / G ++, so while adding the MIp option to generating dependencies works great for me, as long as I do not reach the link stage with my .a file ...

About updating archives / libraries when the input sources go away? It works fine for me, but is it a cleaner way (i.e., G ++ -mpe option direct)?

  #BUILD_DIR my target directory (debug / release and target arch) #SRC_OUTS my .o files LIBATLS_HAS = $ (shell nm $ {BUILD_DIR} /libatls.a | grep $ {BUILD_DIR} | Sed -e 's /.*(//' -e 's ///.*: //') LIBATLS_REMOVE = $ (filter out $ ($ {SRC_OUTS} notdir), $ {LIBATLS_HAS}) $ {BUILD_DIR } /libatls.a: $ {BUILD_DIR} /libatls.a ($ {SRC_OUTS}) ifneq (after the initial feedback $ {LIBATLS_REMOVE}) $ $ in the following ($ $ {LIBATLS_REMOVE}), $ $ ($ AR) - D $$$ {LIBATLS_REMOVE} endiff  

updated :

  LIBATLS_HAS: $ $ (shell $ (AR) T $ {BUILD_DIR} /libatls.a) LIBATLS_REMOVE: $ $ (filter out $ (notdir $ {SRC_OUTS}), $ (filt And% o, $ {LIBATLS_HAS})) .PHONY: clean_archive clean_archive: $ (AR) -d $ (BUILD_DIR) $ /libatls.a (LIBATLS_REMOVE) .PHONY: $ (LIBATLS_REMOVE) $ (LIBATLS_REMOVE): clean_archive $ {} BUILD_DIR /libatls.a:%:% ($ {SRC_OUTS}) $ {LIBATLS_REMOVE}  

>

There are a few different ways to do this. Is a pretty neat that:

  LIBATLS_HAS: = $ (shell $ (AR) T $ (BUILD_DIR) /libatls.a) LIBATLS_REMOVE: = $ (filter out $ (SRC_OUTS), $ (LIBATLS_HAS)) REMOVE_LIST = $ (addprefix Remove _, $ (LIBATLS_REMOVE)) .PHONY: $ (REMOVE_LIST) $ (REMOVE_LIST): remove_% $ (AR) -d $ (BUILD_DIR) /libatls.a $ * $ (BUILD_DIR ) /libatls.a:%:% ($ (SRC_OUTS)) $ (REMOVE_LIST)  

This is slightly disabled because it runs a different $ (AR) Command to remove each member I suspect that this will be a problem, but if you can get it with a fake target:

  # I will run this most often. .PHONY: clean_archive clean_archive: $ (AR) -d $ (BUILD_DIR) /libatls.a $ (LIBATLS_REMOVE) .PHONY: $ (REMOVE_LIST) $ (REMOVE_LIST): clean_archive  
< / Html>

Comments