Improve multi makefiles

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

Improve multi makefiles

Postby piers » Tue Jun 16, 2020 12:05 pm

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/$@.make all
   @echo ====================================================================
   @echo

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

#
##############################################################################

steved
Posts: 725
Joined: Fri Nov 09, 2012 2:22 pm
Has thanked: 10 times
Been thanked: 103 times

Re: Improve multi makefiles

Postby steved » Tue Jun 16, 2020 12:42 pm

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: 12963
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 735 times
Been thanked: 610 times
Contact:

Re: Improve multi makefiles

Postby Giovanni » Tue Jun 16, 2020 1:24 pm

Hi,

Interesting idea.

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

Giovanni

User avatar
piers
Posts: 34
Joined: Fri Apr 06, 2012 1:02 am
Location: Netherlands
Been thanked: 11 times
Contact:

Re: Improve multi makefiles

Postby piers » Tue Jun 16, 2020 3:36 pm

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: 12963
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 735 times
Been thanked: 610 times
Contact:

Re: Improve multi makefiles

Postby Giovanni » Tue Jun 16, 2020 5:48 pm

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

Giovanni

mikeprotts
Posts: 141
Joined: Wed Jan 09, 2019 12:37 pm
Has thanked: 16 times
Been thanked: 21 times

Re: Improve multi makefiles

Postby mikeprotts » Tue Jun 16, 2020 6:05 pm

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: 12963
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 735 times
Been thanked: 610 times
Contact:

Re: Improve multi makefiles

Postby Giovanni » Tue Jun 16, 2020 6:31 pm

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

Giovanni

mikeprotts
Posts: 141
Joined: Wed Jan 09, 2019 12:37 pm
Has thanked: 16 times
Been thanked: 21 times

Re: Improve multi makefiles

Postby mikeprotts » Tue Jun 16, 2020 7:24 pm

That'll do for me.

Mike

User avatar
piers
Posts: 34
Joined: Fri Apr 06, 2012 1:02 am
Location: Netherlands
Been thanked: 11 times
Contact:

Re: Improve multi makefiles

Postby piers » Fri Jun 19, 2020 8:21 am

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.


Return to “Small Change Requests”

Who is online

Users browsing this forum: No registered users and 1 guest