Makefile: Execute target multiple times - Stack Overflow
This answer is somewhat related but doesn't really answer my question: How do you force a makefile to rebuild a target?
I have the following targets defined in a Makefile:
dist-3:
@echo "calling dist-3"
dist-2: dist-3
@echo "calling dist-2"
dist-1: dist-2 dist-3
@echo "calling dist-1"
The output of 'make dist-1' is:
calling dist-3
calling dist-2
calling dist-1
but I want dist-3 to be executed multiple times. I've tried declaring dist-3 as .PHONY and tried using the FORCE option but neither seem to work.
Is there a way to have dist-3 executed multiple times?
This answer is somewhat related but doesn't really answer my question: How do you force a makefile to rebuild a target?
I have the following targets defined in a Makefile:
dist-3:
@echo "calling dist-3"
dist-2: dist-3
@echo "calling dist-2"
dist-1: dist-2 dist-3
@echo "calling dist-1"
The output of 'make dist-1' is:
calling dist-3
calling dist-2
calling dist-1
but I want dist-3 to be executed multiple times. I've tried declaring dist-3 as .PHONY and tried using the FORCE option but neither seem to work.
Is there a way to have dist-3 executed multiple times?
Share Improve this question asked yesterday thetangothetango 633 bronze badges 1 |1 Answer
Reset to default 3You can achieve this by recursively calling make
using the MAKE
variable within the target recipes. Since these targets aren't referencing files, you should declare them as .PHONY
.
Makefile
.PHONY: dist-3
dist-3:
@echo "calling dist-3"
.PHONY: dist-2
dist-2:
@$(MAKE) --no-print-directory dist-3
@echo "calling dist-2"
.PHONY: dist-1
dist-1:
@$(MAKE) --no-print-directory dist-2 dist-3
@echo "calling dist-1"
$ make dist-1
calling dist-3
calling dist-2
calling dist-3
calling dist-1
- Win10、安卓手机实现打通:拖拽即可互传文件
- 谷歌回应欧盟反垄断指控:安卓利于竞争和消费者
- 谷歌提出新方案 欲解决增加时间引起的计算机故障
- 忘记安卓电脑 ChromeWin双系统PC更有前途
- electron - Windows task scheduler triggers the task but it is not invoking the app which I want to open on system login - Stack
- Integration-testing a Spring Boot @Service without SpringBootApplication - Stack Overflow
- android - Room Database is very slow For query 20 results with limit in 25k records - Stack Overflow
- TypeScript Error (ts2345) when trying to collect property names in array - Stack Overflow
- tomcat9 - guacd WebSocket Tunnel Timeout with "Support for protocol 'vnc' is not installed" Er
- python - Why is my KivyMD Button not changing Color with "md_bg_color"? - Stack Overflow
- graph theory - Algorithm to find a subgraph that includes all vertices, ensures single connection failure tolerance, and minimiz
- How to work with output of tsdisplay (capturemodify plots produced by it) in R - Stack Overflow
- kotlin - Android Studio Code Completion not working in test folder in all projects - Stack Overflow
- javascript - Why Does Putting a Custom HTML Element Inside Another Leaves the Second Hidden? - Stack Overflow
- artificial intelligence - ImportError in Python when using the phi library - Stack Overflow
- java - XSLT 3.0 chained burst-streaming with saxon - memory consumption considerations - Stack Overflow
- VS Code : How to deactivate matching characters in bold? - Stack Overflow
make
will never build the same target more than one time, in a single invocation. It's impossible to make it do so. – MadScientist Commented 21 hours ago