Well I  screwed up on this. The makefile actually runs before including Board.mk which contains the real targets so the default target becomes the one in the src/Makefile.

Fundamentally this Makefile should not contain any targets.

On 12/31/2023 6:46 PM, Bill Rees wrote:

    Out of curiosity I followed your example and added a clean:: to a src/Makefile. The target fired.

:: git diff
diff --git a/boards/arm/efm32/efm32-g8xx-stk/src/Makefile b/boards/arm/efm32/efm32-g8xx-stk/src/Makefile
index dc8bbbb938..79998ed009 100644
--- a/boards/arm/efm32/efm32-g8xx-stk/src/Makefile
+++ b/boards/arm/efm32/efm32-g8xx-stk/src/Makefile
@@ -28,4 +28,7 @@ else
 CSRCS += efm32_userleds.c
 endif

+clean::
+       @echo "=====" >&2
+
 include $(TOPDIR)/boards/Board.mk

How does your setup differ from this? I had already built nuttx once.

On 12/31/2023 12:33 PM, Bill Rees wrote:

    The command to your rule, clean:: does not need a shell process wrapper.

    You don't need the $() to execute shell commands in the recipe since make does that for you.

    Change the echo to simply: echo "board level clean" >&2

    The '>&2' directs the output of echo to the stderr file descriptor for your process and should outwit most attempts to capture output any recipe uses before hand. Running make can produce so much output that many times its run silent which means your output maybe suppressed.

    What board are you working on?

On 12/30/2023 8:03 PM, yfliu2008 wrote:
Bill,


Thank you.


It seems that there is a "clean::" in "boards/Board.mk" which is included by my board level Makefile. The double-colon target thing sounds nice, so I added one to my board level Makefile like below:


clean::
      $(echo "board level clean")


Then when I tried "make clean" under $(TOPDIR), there is no more errors but the rule I added didn't fire.






I guess something else is still missing. The top level makefile doesn't trigger my board level double-colon target.



Regards,
yf




                        Original

From:"Bill Rees"< redskyo...@icloud.com.INVALID &gt;;

Date:2023/12/31 9:51

To:"dev"< dev@nuttx.apache.org &gt;;

Subject:Re: Makefile vs Make.defs



You're welcome.

The error message is pointing out that you have two targets for clean.
One is clean: and the other is clean::

You may be getting a clean target from an included makefile such as a
Make.def which may be in a directory up the path. Try issuing a grep for
clean: to see what files contain it. Something like "grep -r clean.*:"
You may have to move a dir or two up the path.

You may wish to try changing the syntax of your target to use the colon
syntax of the other. E.g. :: -- : or vice versa. Make allows multiple
instances of a target in some circumstances.

Another way to get around this is to add the target as another name and
perform what you need to do. E.g. instead of clean use myclean:

Please get back with your results.

Bill

On 12/30/2023 4:25 PM, yfliu2008 wrote:
&gt; Bill,
&gt;
&gt;
&gt; Thanks for the information.
&gt;
&gt;
&gt; So far I have been using make command at the $(TOPDIR) and the contents in the board source&nbsp; folder (i.e. "boards/&gt;
&gt;
&gt; For example, I tried to add a "clean:" target in the Makefile at board source folder, but got errors like:
&gt;
&gt;
&gt; yf@r7:uttx/nuttx$ make cleanMakefile:35: *** target file 'clean' has both : and :: entries. &nbsp;Stop.
&gt; make[1]: *** [Makefile:230: clean] Error 2
&gt; make: *** [tools/Unix.mk:757: arch/risc-v/src_clean] Error 2
&gt;
&gt;
&gt;
&gt;
&gt;
&gt;
&gt;
&gt;
&gt;
&gt; I still lack understanding for the overall Makefile design, so pointers to it are highly welcomed.
&gt;
&gt;
&gt; Regards,
&gt; yf
&gt;
&gt;
&gt;
&gt;
&gt; Original
&gt;
&gt;
&gt;
&gt; From:"Bill Rees"< redskyo...@icloud.com.INVALID &gt;;
&gt;
&gt; Date:2023/12/17 16:32
&gt;
&gt; To:"dev"< dev@nuttx.apache.org &gt;;
&gt;
&gt; Subject:Re: Makefile vs Make.defs
&gt;
&gt;
&gt;
&gt; Running make where Makefile exists runs that Makefile.
&gt;
&gt; Running make where you have a Make.defs won't do anything.
&gt;
&gt;
&gt; On 12/16/2023 8:55 PM, yfliu2008 wrote:
&gt; &gt; Hi,
&gt; &gt;
&gt; &gt;
&gt; &gt;
&gt; &gt;
&gt; &gt; It seems that some board source folder uses Makefile and some uses Make.defs:
&gt; &gt;
&gt; &gt;
&gt; &gt;
&gt; &gt; boards/risc-v/hpm6750/hpm6750evk2/src/Makefile
&gt; &gt;
&gt; &gt;
&gt; &gt; boards/risc-v/qemu-rv/rv-virt/src/Makefile
&gt; &gt; boards/risc-v/mpfs/icicle/src/Make.defs
&gt; &gt;
&gt; &gt; boards/risc-v/esp32c6/esp32c6-devkit/src/Make.defs
&gt; &gt;
&gt; &gt; I am wondering what are the differences?
&gt; &gt;
&gt; &gt;
&gt; &gt;
&gt; &gt; Regards,
&gt; &gt; yf



Reply via email to