I have a somewhat complicated Makefile which runs perl scripts and other tools and generates some 1000 files. I would like to edit/modify some of those generated files after all files are generated. So I thought I can simply add a new rule to do so like this:
(phony new rule): $LIST_OF_FILES_TO_EDIT
file_modifier ...
however, the point here is some of those generated files which I’d like to edit ($LIST_OF_FILES_TO_EDIT) are used in the same make process to generate a long list of files. So I have to wait to make sure those files are no longer needed in the make process before I can go ahead and edit them. But I don’t know how to do that. Not to mention that it is really hard to find out what files are generated by the help of $LIST_OF_FILES_TO_EDIT.
If it was possible to mention in the Makefile that this rule should be only run as the last rule, then my problem would be solved. but as far as I know this is not possible. So anyone has an idea?
Some points:
-
List of files to edit ($LIST_OF_FILES_TO_EDIT) is determined dynamically (not known before make process)
-
I am not sure I have picked a good title for this question. 🙂
1) If you’re going to modify the files like that, it might behoove you to give the targets different names, like
foo_unmodifiedandfoo_modified, so that the Make’s dependency handling will take care of this.2) If your phony new rule is the one you invoke on the command line (“make phonyNewRule”), then Make will build whatever else it’s going to build before executing the
file_modifiercommand. If you want to build targets not on that list, you could do it this way:3) If your dependencies are set up correctly, you can find out which targets depend on $(LIST_OF_FILES_TO_EDIT), but it’s not very tidy. You could just
touchone of the files, runmake, see which targets it built, repeat for all files. You could save a little time by using Make arguments: “make -n -W foo1 -W foo2 -W foo3 … -W foo99 all”. This will print the commands Make would run– I don’t know of any way to get it to tell you which targets it would rebuild.