[Patch] make/main.cfg: Allow application source subdirectories
Nick Withers
nick.withers at anu.edu.au
Fri Jul 5 03:37:29 UTC 2013
Hmmm...
On Fri, 2013-07-05 at 11:59 +1000, Nick Withers wrote:
> Hi guys,
>
> The following patch to make/main.cfg in rtems.git (generated with git
> diff) allows me to have an application subdirectory with sources (not a
> Makefile; e.g., I can define "SRCS=boom.c bam/baby.c"):
> ____
>
> diff --git a/make/main.cfg b/make/main.cfg
> index 1a712de..e9219b4 100644
> --- a/make/main.cfg
> +++ b/make/main.cfg
> @@ -40,8 +40,15 @@ ARCH_DEBUG_V = o-debug
> ARCH__V = $(ARCH_OPTIMIZE_V)
> ARCH = $(ARCH_$(VARIANT_V)_V)
>
> +ARCH_DIRS = $(filter-out ./, $(dir $(C_FILES)))
> +
> $(ARCH):
> test -d ${ARCH} || mkdir $(ARCH)
> +
> +ifneq ($(strip ARCH_DIRS),)
> + mkdir -p ${ARCH_DIRS:%=${ARCH}/%}
> +endif
> +
> #
> # Default makefile name
> # May be overridden by command line macro assignment
> ____
>
> Without that, the linking stage fails because "$(ARCH)/bam" doesn't
> exist for GCC to output "baby.o" into
>
> Dunno that it's the most elegant way of doing it though :-P
Perhaps this is nicer (it doesn't rely on $(C_FILES), just $(OBJS),
which I believe needs to be defined anyway)?
____
diff --git a/make/main.cfg b/make/main.cfg
index 1a712de..2ab6e2b 100644
--- a/make/main.cfg
+++ b/make/main.cfg
@@ -40,8 +40,15 @@ ARCH_DEBUG_V = o-debug
ARCH__V = $(ARCH_OPTIMIZE_V)
ARCH = $(ARCH_$(VARIANT_V)_V)
+ARCH_DIRS = $(sort $(dir $(OBJS)))
+
$(ARCH):
test -d ${ARCH} || mkdir $(ARCH)
+
+ifneq ($(strip ARCH_DIRS),)
+ mkdir -p ${ARCH_DIRS}
+endif
+
#
# Default makefile name
# May be overridden by command line macro assignment
____
> Would it be possible to merge this (or similar) in for 4.11?
>
> Ta!
--
Nick Withers
Embedded Systems Programmer
Room 2.26, Building 57
Department of Nuclear Physics
Research School of Physics and Engineering
The Australian National University (CRICOS: 00120C)
eMail: nick.withers at anu.edu.au
Phone: +61 2 6125 2091
Mobile: +61 414 397 446
More information about the devel
mailing list