Commit 8a7e7d5697a8b14ec02731d003bed89b1c54dfb7

Authored by Masahiro Yamada
Committed by Tom Rini
1 parent fdb87049d8

Makefile: descend into subdirectories only when CONFIG_API is defined

All objects under api/ and examples/api/ directories are selected
by CONFIG_API.
So we can move CONFIG_API switch to the top Makefile.

In order to use CONFIG_API, the definition of SUBDIR_EXAMPLES-y
must be moved after "sinlude $(obj)include/autoconf.mk".

Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>

Showing 3 changed files with 21 additions and 22 deletions Side-by-side Diff

... ... @@ -136,7 +136,6 @@
136 136 # The "examples" conditionally depend on U-Boot (say, when USE_PRIVATE_LIBGCC
137 137 # is "yes"), so compile examples after U-Boot is compiled.
138 138 SUBDIR_TOOLS = tools
139   -SUBDIR_EXAMPLES = examples/standalone examples/api
140 139 SUBDIRS = $(SUBDIR_TOOLS)
141 140  
142 141 .PHONY : $(SUBDIRS) $(VERSION_FILE) $(TIMESTAMP_FILE)
143 142  
... ... @@ -150,8 +149,10 @@
150 149 sinclude $(obj)include/autoconf.mk.dep
151 150 sinclude $(obj)include/autoconf.mk
152 151  
  152 +SUBDIR_EXAMPLES-y := examples/standalone
  153 +SUBDIR_EXAMPLES-$(CONFIG_API) += examples/api
153 154 ifndef CONFIG_SANDBOX
154   -SUBDIRS += $(SUBDIR_EXAMPLES)
  155 +SUBDIRS += $(SUBDIR_EXAMPLES-y)
155 156 endif
156 157  
157 158 # load ARCH, BOARD, and CPU configuration
... ... @@ -277,7 +278,7 @@
277 278 LIBS-y += drivers/usb/ulpi/
278 279 LIBS-y += common/
279 280 LIBS-y += lib/libfdt/
280   -LIBS-y += api/
  281 +LIBS-$(CONFIG_API) += api/
281 282 LIBS-y += post/
282 283 LIBS-y += test/
283 284  
... ... @@ -362,7 +363,7 @@
362 363  
363 364 build := -f $(TOPDIR)/scripts/Makefile.build -C
364 365  
365   -all: $(ALL-y) $(SUBDIR_EXAMPLES)
  366 +all: $(ALL-y) $(SUBDIR_EXAMPLES-y)
366 367  
367 368 $(obj)u-boot.dtb: checkdtc $(obj)u-boot
368 369 $(MAKE) $(build) dts binary
... ... @@ -550,7 +551,7 @@
550 551 $(SUBDIRS): depend
551 552 $(MAKE) -C $@ all
552 553  
553   -$(SUBDIR_EXAMPLES): $(obj)u-boot
  554 +$(SUBDIR_EXAMPLES-y): $(obj)u-boot
554 555  
555 556 $(LDSCRIPT): depend
556 557 $(MAKE) -C $(dir $@) $(notdir $@)
... ... @@ -4,6 +4,7 @@
4 4 # SPDX-License-Identifier: GPL-2.0+
5 5 #
6 6  
7   -obj-$(CONFIG_API) += api.o api_display.o api_net.o api_storage.o \
8   - api_platform-$(ARCH).o
  7 +obj-y += api.o api_display.o api_net.o api_storage.o
  8 +obj-$(CONFIG_ARM) += api_platform-arm.o
  9 +obj-$(CONFIG_PPC) += api_platform-powerpc.c
examples/api/Makefile
... ... @@ -14,25 +14,22 @@
14 14 include $(TOPDIR)/config.mk
15 15  
16 16 # Resulting ELF and binary exectuables will be named demo and demo.bin
17   -OUTPUT-$(CONFIG_API) = $(obj)demo
18   -OUTPUT = $(OUTPUT-y)
  17 +OUTPUT = $(obj)demo
19 18  
20 19 # Source files located in the examples/api directory
21   -SOBJ_FILES-$(CONFIG_API) += crt0.o
22   -COBJ_FILES-$(CONFIG_API) += demo.o
23   -COBJ_FILES-$(CONFIG_API) += glue.o
24   -COBJ_FILES-$(CONFIG_API) += libgenwrap.o
  20 +SOBJ_FILES-y += crt0.o
  21 +COBJ_FILES-y += demo.o
  22 +COBJ_FILES-y += glue.o
  23 +COBJ_FILES-y += libgenwrap.o
25 24  
26 25 # Source files which exist outside the examples/api directory
27   -EXT_COBJ_FILES-$(CONFIG_API) += lib/crc32.o
28   -EXT_COBJ_FILES-$(CONFIG_API) += lib/ctype.o
29   -EXT_COBJ_FILES-$(CONFIG_API) += lib/div64.o
30   -EXT_COBJ_FILES-$(CONFIG_API) += lib/string.o
31   -EXT_COBJ_FILES-$(CONFIG_API) += lib/time.o
32   -EXT_COBJ_FILES-$(CONFIG_API) += lib/vsprintf.o
33   -ifeq ($(ARCH),powerpc)
34   -EXT_SOBJ_FILES-$(CONFIG_API) += arch/powerpc/lib/ppcstring.o
35   -endif
  26 +EXT_COBJ_FILES-y += lib/crc32.o
  27 +EXT_COBJ_FILES-y += lib/ctype.o
  28 +EXT_COBJ_FILES-y += lib/div64.o
  29 +EXT_COBJ_FILES-y += lib/string.o
  30 +EXT_COBJ_FILES-y += lib/time.o
  31 +EXT_COBJ_FILES-y += lib/vsprintf.o
  32 +EXT_SOBJ_FILES-$(CONFIG_PPC) += arch/powerpc/lib/ppcstring.o
36 33  
37 34 # Create a list of source files so their dependencies can be auto-generated
38 35 SRCS += $(addprefix $(SRCTREE)/,$(EXT_COBJ_FILES-y:.o=.c))