[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug #62441] Recursive make & PHONY = targets being rebuilt [feature
From: |
Henrik Carlqvist |
Subject: |
Re: [bug #62441] Recursive make & PHONY = targets being rebuilt [feature reques] |
Date: |
Wed, 11 May 2022 19:03:52 +0200 |
> I have two makefiles:
>
> *Makefile*
>
> .PHONY: other_file
> other_file:
> $(MAKE) -f Makefile2 other_file
>
> my_file: other_file
> touch $@
>
>
> *Makefile2*
>
> other_file:
> touch $@
>
>
>
> When I first run the command, it builds my_file and other_file as expected.
>
> > make my_file --trace --no-print-directory
> Makefile:6: target 'other_file' does not exist
> make -f Makefile2 other_file
> Makefile2:3: target 'other_file' does not exist
> touch other_file
> Makefile:9: update target 'my_file' due to: other_file
> touch my_file
>
>
> However, the next time I run the same command, it doesn't rebuild
> other_file, but it does rebuild my_file.
>
> make my_file --trace --no-print-directory
> Makefile:6: target 'other_file' does not exist
> make -f Makefile2 other_file
> make[1]: 'other_file' is up to date.
> Makefile:9: update target 'my_file' due to: other_file
> touch my_file
>
>
> This is obviously because other_file is marked as PHONY.
>
> What I would like is this functionality for recursive make support: When it
> is time to consider such a target, make will run its recipe unconditionally.
> After the recipe is run, make will use the target's timestamp to determine
> if other targets are out of date.
>
> It would look something like:
> *Makefile*
>
> .RECURSIVE_MAKE: other_file
> other_file:
> $(MAKE) -f Makefile2 other_file
>
> my_file: other_file
> touch $@
>
>
> *Makefile2*
>
> other_file:
> touch $@
>
>
>
> > make my_file --trace --no-print-directory
> Makefile:6: target 'other_file' does not exist
> make -f Makefile2 other_file
> Makefile2:3: target 'other_file' does not exist
> touch other_file
> Makefile:9: update target 'my_file' due to: other_file
> touch my_file
>
> > make my_file --trace --no-print-directory
> Makefile:6: target 'other_file' requires recursive make.
> make -f Makefile2 other_file
> make[1]: 'other_file' is up to date.
> make: 'my_file' is up to date.
Wouldn't the easy solution be to not make other_file a phony target and
instead force it to be rebuilt?
-8<-----------------------------
other_file: FORCE
$(MAKE) -f Makefile2 other_file
my_file: other_file
touch $@
FORCE:
-8<-----------------------------
regards Henrik