I'm trying to do something similar where I check if board.mk does *not* exist, and then do a touch board.mk to generate an empty one. I read this:
https://www.gnu.org/software/make/manua ... files.html
I think that means if we include the empty board.mk file early on, then generate it, make will automagically reinclude the generated version and then proceed.
PRE_MAKE_ALL_RULE_HOOK to generate board files Topic is solved
Moderators: RoccoMarco, lbednarz, utzig, tfAteba, barthess
Re: PRE_MAKE_ALL_RULE_HOOK to generate board files
For some reason the PRE_MAKE_ALL_RULE_HOOK runs every time when I run make clean. My CLEAN_RULE_HOOK just deletes the board.c/.h/.mk files . I don't see why calling make clean would result in the PRE_MAKE_ALL_RULE_HOOK running.
I tried commenting out PRE_MAKE_ALL_RULE_HOOK : $(BOARD_FILES) , so that only the $(BOARD_FILES) rule exists (but no link to the eventual make all or clean targets) - but that didn't work. When I run a make clean multiple times, it keeps running the $(BOARD_FILES) rule and generates the board files, which clean then deletes right after ...
I tried commenting out PRE_MAKE_ALL_RULE_HOOK : $(BOARD_FILES) , so that only the $(BOARD_FILES) rule exists (but no link to the eventual make all or clean targets) - but that didn't work. When I run a make clean multiple times, it keeps running the $(BOARD_FILES) rule and generates the board files, which clean then deletes right after ...
Re: PRE_MAKE_ALL_RULE_HOOK to generate board files
I'm finding out some more stuff ... Make's order-only-prerequisites don't really enforce an order when running with multiple jobs (i.e. -j4). You need to introduce actual dependencies between them to enforce ordering ..
Re: PRE_MAKE_ALL_RULE_HOOK to generate board files
Going further down the rabbit hole - Ever wanted a GNU Make debugger to step thru and inspect variables? Give remake a try. It works!
https://remake.readthedocs.io/en/latest/
https://remake.readthedocs.io/en/latest/
Re: PRE_MAKE_ALL_RULE_HOOK to generate board files
I think I get it now, if anyone else is interested in learning a little more:
https://github.com/faisal-shah/makefile-experiments
https://github.com/faisal-shah/makefile-experiments
- Giovanni
- Site Admin
- Posts: 14457
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1076 times
- Been thanked: 922 times
- Contact:
Re: PRE_MAKE_ALL_RULE_HOOK to generate board files
Is that a generic example not related to boards right?
Giovanni
Giovanni
Re: PRE_MAKE_ALL_RULE_HOOK to generate board files
Giovanni wrote:Is that a generic example not related to boards right?
Giovanni
Yep. It follows the same concept though .. just a simple makefile to play with.
Code: Select all
.PHONY: clean all
-include module.mk
SRC := foo.c bar.c $(MODULE_SRC)
SRCBUILT := $(foreach f,$(SRC),$(f).built)
$(info restarts = $(MAKE_RESTARTS))
$(info SRC = $(SRC))
all: PRE_MAKE_ALL_HOOK $(SRCBUILT)
$(SRCBUILT): $(SRC)
@echo built $@
@touch $@
MODULE_FILES = module.c module.mk
PRE_MAKE_ALL_HOOK: $(MODULE_FILES)
$(MODULE_FILES) &: module.template
@echo "generating module"
@touch module.c
@echo "MODULE_SRC = module.c" > module.mk
clean:
@echo - module.mk
@echo - module.c
@echo - *.built
@rm -f module.mk 2>/dev/null
@rm -f module.c 2>/dev/null
@rm -f *.built 2>/dev/null
Who is online
Users browsing this forum: No registered users and 45 guests