Omer Dagan
Omer Dagan

Reputation: 15976

How to force final target in autotools

I have an autotools project. In one of its directories, I would like to run a script, after the make process is done. In other words, I'd like to have an option to "phony" target that would be executed last. Alternatively, I could use a dedicated m4 Macro (I only I knew which one...). Any ideas?

Thanks

Upvotes: 2

Views: 341

Answers (1)

user626998
user626998

Reputation:

I'm assuming that by "autotools", you're using Automake as well as Autoconf. I can see two ways of doing this.

You can make a -hook rule in your Makefile.am. However, this can only be done for certain default targets: install-data, install-exec, uninstall, dist and distcheck. So, to make a rule that will be run immediately after install-exec, call it install-exec-hook. Then just run the script in the recipe for that rule.

Based on the wording of your question, though, it seems that you want to run the script after building. If that's the case, you can customize the all target with an all-local target and then run the script in the recipe for this target. Note that, according to the Automake documentation,

With the '-local' targets, there is no particular guarantee of execution order; typically, they are run early, but with parallel make, there is no way to be sure of that.

However, since the all target is phony, it shouldn't run until everything is built. Nevertheless, if you can run the script after installation, I would recommend that way since the execution order is guaranteed.

Upvotes: 3

Related Questions