Alejandro Colomar (Friday, July 22, 2022 14:05) > I'd like to suggest a new feature: post-requisites. > > As the word suggests, as pre-requisites are satisfied before a given > target, post-requisites would be satisfied _after_ a given target.
and just as a prerequisite can be built at any time before, but must be built before, the post-requisite can be run at any time after, but must be built after. So if several targets that are being built require some given post-requisite, it waits until all of them have been built. > Why would someone ever need that in a Makefile: > > In an install target for a library, you may want to run ldconfig(8) > after any install targets have executed. > > In an install target for the linux man-pages, you may want to run > mandb(8) after any pages have been installed in the system. I think the traditional solution to this would be to make the install depend on rules that get individual files installed and have its command run the post-install steps, or have the install rule depend on a set of post-install rules (each of which does one post-install task), that in turn depend on all the files whose updates would trigger them. However, the problem with that is that if I want to just update the one man page, the mandb(8) run that's needed following it won't be run unless I build the mandb-run rule, that depends on *all* my man pages. So I can't do fine-grained targeted "build this one thing" parts of my build process. Post-requisites would take care of that; if I build and install an update to any man page, then mandb gets run, regardless of what else I am also building, aside from mandb's run happening after any of those that need it to be done later. > The proposed syntax would be similar to that of order only > prerequisites, but using '>' instead of '|': > > [ > [...] > > $(DESTDIR)$(man3dir)/foo.3: man3/foo.3 | $(DESTDIR)$(man3dir) > update-mandb > $(info INSTALL $@) > @$(INSTALL_DATA) -T $< $@ > > $(DESTDIR)$(man3dir)/bar.3: man3/bar.3 | $(DESTDIR)$(man3dir) > update-mandb > $(info INSTALL $@) > @$(INSTALL_DATA) -T $< $@ > > .PHONY: update-mandb > update-mandb: > $(info MANDB) > @mandb > > .PHONY: install > install: $(DESTDIR)$(man3dir)/foo.3 $(DESTDIR)$(man3dir)/bar.3 > ] > > So that `make install` would install foo.3 and bar.3, and after all of > the pages have been installed, mandb(8) would be run. > And `make /usr/local/share/man/man3/foo.3` would install foo.3, and > after it, it would run mandb(8). > > Does that make sense to you? and if my package (e.g. perl) has a whole library of man pages, I'd be able to do updates to just one (or a few) of them at a time and get mandb run after that update, regardless of which subset of pages I update, rather than only being able to get that run when I install the whole library. I guess it would also be useful for tidying away scratch directories and the like, used by rules for their transient or intermediate files. It sounds like a neat idea. I wonder how practical it would be to implement ... Eddy.