Improve multi makefiles Topic is solved

Use this forum for requesting small changes in ChibiOS. Large changes should be discussed in the development forum. This forum is NOT for support.
Post Reply
User avatar
piers
Posts: 42
Joined: Fri Apr 06, 2012 1:02 am
Been thanked: 15 times

Improve multi makefiles

Post by piers »

Hi Giovanni,
I really like the idea of multi target projects.

I'd like to propose an improved Makefile for these projects. (I also saw you fixed the multi makefiles a few days ago)

Here's an example of what I would propose. It is very general, only the 'targets' line needs to be updated.
Furthermore it allows to compile single targets easily.

This one is for the multi ADC project:

Code: Select all

##############################################################################
# Multi-project makefile rules
#

targets = stm32h743zi_nucleo144 stm32g071rb_nucleo64 stm32g474re_nucleo64 \
   stm32l053r8_nucleo64 stm32l476_discovery stm32l4r5zi_nucleo144

all: $(targets)

clean_targets = $(addprefix clean_,$(targets))

clean: $(clean_targets)

.PHONY: all clean $(targets) $(clean_targets)

$(targets):
   @echo === Building for $@ ===============================
   -@$(MAKE) --no-print-directory -f ./make/[email protected] all
   @echo ====================================================================
   @echo

$(clean_targets): clean_%:
   -@$(MAKE) --no-print-directory -f ./make/$*.make clean
   @echo

#
##############################################################################
steved
Posts: 834
Joined: Fri Nov 09, 2012 2:22 pm
Has thanked: 12 times
Been thanked: 138 times

Re: Improve multi makefiles

Post by steved »

piers wrote:Furthermore it allows to compile single targets easily.

This would make the feature much more useful - when debugging the ability to compile a single target can speed things up significantly.
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Improve multi makefiles

Post by Giovanni »

Hi,

Interesting idea.

Shouldn't the -@ be a +@? I changed all of those that way yesterday.

Giovanni
User avatar
piers
Posts: 42
Joined: Fri Apr 06, 2012 1:02 am
Been thanked: 15 times

Re: Improve multi makefiles

Post by piers »

The - is for continuing on failure. Not really sure about if that is wanted behaviour. They shouldn't really fail, but the stm32g071rb_nucleo64 build fails for me, so I added it. Now that it is easy to compile targets separately I would actually remove the '-'.

The + is for marking it as recursive, lines with $(MAKE) are automatically marked recursive so that isn't necessary. Another reason to use $(MAKE) instead of make. https://www.gnu.org/software/make/manua ... E-Variable

(so - and + are completely different things, and can also be combined)
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Improve multi makefiles

Post by Giovanni »

So it is definitely not "-", a failed make should stop all the following ones.

Giovanni
mikeprotts
Posts: 166
Joined: Wed Jan 09, 2019 12:37 pm
Has thanked: 19 times
Been thanked: 31 times

Re: Improve multi makefiles

Post by mikeprotts »

I'm keen to have the single target option available, usually I've got a few boards to work with but often just using one at a time.

Mike
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Improve multi makefiles

Post by Giovanni »

You can already do single target: make -f make/makefile.make

Giovanni
mikeprotts
Posts: 166
Joined: Wed Jan 09, 2019 12:37 pm
Has thanked: 19 times
Been thanked: 31 times

Re: Improve multi makefiles

Post by mikeprotts »

That'll do for me.

Mike
User avatar
piers
Posts: 42
Joined: Fri Apr 06, 2012 1:02 am
Been thanked: 15 times

Re: Improve multi makefiles

Post by piers »

I agree on the failing part, those '-' shouldn't be there.

make -f works fine too indeed, I can get used to that. Somehow didn't think of leaving '--no-print-directory' and 'all' out, that makes it a lot shorter.
Post Reply