Executing a Make target inside a target
Published on 2023-03-15 • Modified on 2023-03-15
This snippet shows how to execute a given Make target inside a target. When you want to run a target before another, you can put a target in the requirements. For example, here, hello1 will run before hello2. But, if you want to run it after, the syntax is different: you have to use the particular MAKE
variable, which contains the current path of the Make executable for the current context. Then you can specify the target you want to run as you would do with the command line. In the example, hello3 will run after hello2. The final output for make hello2
will be:
hello 1
hello 2
hello 3
hello1:
@echo "hello 1"
hello2: hello1
@echo "hello 2"
$(MAKE) hello3
hello3:
@echo "hello 3"
More on Stackoverflow Read the doc Random snippet
Call to action
Did you like this post? You can help me back in several ways: (use the "reply" link on the right to comment or to contact me )
- Report any error/typo.
- Report something that could be improved.
- Like and repost!
- Follow me on Bluesky 🦋
- Subscribe to the RSS feed.
- Click on the More on Stackoverflow buttons to make me win "Announcer" badges 🏅.
Thank you for reading! And see you soon on Strangebuzz! 😉
