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
- 谷歌加入硬件战场:正面对抗亚马逊和苹果
- 苹果兜售没用软件脸不红心不跳
- 恶意软件侵害苹果用户!4G更易受攻击
- pycharm - Why would the python code throw an exception (invalid instance in App.root), if "@property" is remov
- What is the correct TypeScript type for the `children` property in Svelte 5? - Stack Overflow
- python - How to Get a Single Solution from a Physics-Informed Neural Network (PINN) for a PDE with Initial and Boundary Conditio
- dataframe - Dataset uploaded and verified, but cannot use read.csv - Stack Overflow
- c++ - Changing STL container (std::string) values in debugger - Stack Overflow
- c# - Loading data to dataGridView freezes the window during loading, why threading does not work here? - Stack Overflow
- c++ - Access violation on ending the main function scope but only with Visual Studio 2019 and gcc - Stack Overflow
- Receiver incorrectly registered? Android, Kotlin - Stack Overflow
- javascript - The side menu bar(sticky) is overflowing unless I scroll - Stack Overflow
- spring boot - Hibernate search backend elastic search with multiple data bases - Stack Overflow
- php - How to return blob in Joomla 5 API - Stack Overflow
- node.js - node-gyp fails with parsing vs version: undefined - Stack Overflow
- next.js - Update Server Component via a Client Component - Stack Overflow
- Is there showhide functionality for boiler plate content in google docs? - 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