help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Change a target within Makefile?


From: Masahiro Yamada
Subject: Re: Change a target within Makefile?
Date: Fri, 9 Aug 2024 21:00:42 +0900

On Fri, Jul 26, 2024 at 9:35 AM Dmitry Goncharov
<dgoncharov@users.sf.net> wrote:
>
> On Wed, Jul 24, 2024 at 11:18 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
> > You could do "make .foo.dtb.check" to compile foo.dtb, followed by
> > the schema checking.
> >
> > I do not want to expose the presence of the timestamp file,
> > as it is an internal implementation detail
>
> If the only requirement is that the timestamp file is not exposed, then
> why don't we introduce a phony target (similar to all, clean, install, etc)?
> For example we can call the target 'schema'.
> In our case we need a piece of code to let the user type
> $ make schema-hello
> to build hello.dtb and run a schema check.
>
>
> We can do this with something along the lines of
>
> # Prevent make from removing *.checked and *.dtb files.
> .NOTINTERMEDIATE: .%.dtb.checked %.dtb
>
> schema-%: .%.dtb.checked;
> .%.dtb.checked: %.dtb
>     $(info checking the schema of $*)
>     @touch $@
>
> %.dtb: %.dts
>     cp $< $@
>
> regards, Dmitry



Thanks the feedbacks, all guys.

The Linux kernel build system is complex and caters to
various demands.


 $ make dtbs
         --> build all *.dtb
 $ make dtbs_check
         --> build all *.dtb with schema checks
 $ make foo.dtb bar.dtb
         --> build specified *.dtb
 $ make foo.dtb bar.dtb CHECK_DTBS=y
         --> build and check specified *.dtb

I was searching for a way to improve the code without
inserting ugly code in multiple places.


Paul's idea works by modifying a single Makefile, but
a drawback is $@ does not point to the real target.



If I can do whatever, perhaps I can change the top Makefile

https://github.com/torvalds/linux/blob/v6.11-rc2/Makefile#L1389

%.dtb: dtbs_prepare
        $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$(if
$(CHECK_DTBS),$(@:%.dtb=.%.dtb.checked),$@)


(Using the phony target schema-% is the same)

But, the code already lacks a taste.


So, I believe I should keep the current code as-is.





-- 
Best Regards
Masahiro Yamada



reply via email to

[Prev in Thread] Current Thread [Next in Thread]