avr-libc-dev
[Top][All Lists]
Advanced

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

Re: [avr-libc-dev] Fwd: Library per device


From: Bob Paddock
Subject: Re: [avr-libc-dev] Fwd: Library per device
Date: Thu, 25 Aug 2011 12:24:29 -0400

2011/8/25 Frédéric Nadeau <address@hidden>:

Looks like you are making a library per peripheral of all of the devices?

> I was looking for a
> way to have recipe for all device so it could take advantage of parallel
> build.

"Secondary Expansion" that was added in GNU Make 3.81 might help, at
least in dealing with multiple targets:

http://www.gnu.org/s/hello/manual/make/Secondary-Expansion.html

I use it to build different projects from the same set of source files.
Relevant to building each device's output directory etc.

# See 
http://www.cmcrossroads.com/ask-mr-make/6936-making-directories-in-gnu-make
#From Mr. Make at the above URL.

...
ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)

# In GNU Make 3.81 there's an exciting new feature called 'second
# expansion' (which is enabled by specifying the .SECONDEXPANSION
# target in the Makefile).  With second expansion the prerequisite
# list of any rule under goes a second expansion (the first expansion
# happens when the Makefile is read) just before the rule is used.  By
# escaping any $ signs with a second $ it's possible to use GNU Make
# automatic variables in the prerequisite list.
# We use this to build the empty directory structure if it does not exist.
[Relevant to building each device's output directory etc.]
# See the @D rules later in this file.

.SECONDEXPANSION:

# Default target.
all: begin gccversion sizebefore build sizeafter end Makefile.mak
[different models.mak go here] compiler.mak MakefileOptions.inc

...
# Compile: create object files from C source files.
$(OBJDIR)/%.o : %.c $$(@D)/.keep
        @echo
        @echo $(MSG_COMPILING) $<
        $(CC) -c $(ALL_CFLAGS) $< -o $@

[Others get the $$(@D)/.keep as well.]

%/.keep:
        mkdir -p $(dir $@)
        touch $@

.PRECIOUS: %/.keep

# The pattern rule used to make .o files has a special prerequisite
# $$(@D)/.keep which uses the second expansion feature to obtain the
# directory in which the target (from $@ using the D modifier) is to
# be built.

# That directory will be built by the %/.keep pattern rule that knows how
# to build a .keep file (and the containing directory).  Notice that the
# .keep files are marked as precious so that GNU Make will not delete
# them.  Without this line the .keep files are considered to be useless
# intermediate files and would be cleaned up by GNU Make on exit.
# See 
http://www.cmcrossroads.com/ask-mr-make/6936-making-directories-in-gnu-make



reply via email to

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