Commit 4a20df395d9b6961a4877852e911cbbadd019d40

Authored by Masahiro Yamada
Committed by Tom Rini
1 parent e183a1745a

examples: Use scripts/Makefile.build

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

Showing 4 changed files with 24 additions and 55 deletions Side-by-side Diff

... ... @@ -558,11 +558,8 @@
558 558 $(LIBS): depend $(SUBDIR_TOOLS)
559 559 $(MAKE) $(build) $(dir $(subst $(obj),,$@))
560 560  
561   -tools: depend
  561 +$(SUBDIRS): depend
562 562 $(MAKE) $(build) $@ all
563   -
564   -$(filter-out tools,$(SUBDIRS)): depend
565   - $(MAKE) -C $@ all
566 563  
567 564 $(SUBDIR_EXAMPLES-y): $(obj)u-boot
568 565  
examples/api/Makefile
... ... @@ -11,10 +11,8 @@
11 11 LOAD_ADDR = 0x1000000
12 12 endif
13 13  
14   -include $(TOPDIR)/config.mk
15   -
16 14 # Resulting ELF and binary exectuables will be named demo and demo.bin
17   -OUTPUT = $(obj)demo
  15 +extra-y = demo
18 16  
19 17 # Source files located in the examples/api directory
20 18 SOBJ_FILES-y += crt0.o
21 19  
22 20  
23 21  
... ... @@ -43,14 +41,14 @@
43 41 OBJS += $(addprefix $(obj),$(notdir $(EXT_COBJ_FILES-y)))
44 42 OBJS += $(addprefix $(obj),$(notdir $(EXT_SOBJ_FILES-y)))
45 43  
46   -all: $(obj).depend $(OUTPUT)
47   -
48 44 #########################################################################
49 45  
50   -$(OUTPUT): $(OBJS)
  46 +$(obj)demo: $(OBJS)
51 47 $(LD) --gc-sections -Ttext $(LOAD_ADDR) -o $@ $^ $(PLATFORM_LIBS)
52   - $(OBJCOPY) -O binary $@ $(OUTPUT).bin 2>/dev/null
53 48  
  49 +$(obj)demo.bin: $(obj)demo
  50 + $(OBJCOPY) -O binary $< $@ 2>/dev/null
  51 +
54 52 # Rule to build generic library C files
55 53 $(obj)%.o: $(SRCTREE)/lib/%.c
56 54 $(CC) -g $(CFLAGS) -c -o $@ $<
... ... @@ -58,13 +56,4 @@
58 56 # Rule to build architecture-specific library assembly files
59 57 $(obj)%.o: $(SRCTREE)/arch/$(ARCH)/lib/%.S
60 58 $(CC) -g $(CFLAGS) -c -o $@ $<
61   -
62   -#########################################################################
63   -
64   -# defines $(obj).depend target
65   -include $(SRCTREE)/rules.mk
66   -
67   -sinclude $(obj).depend
68   -
69   -#########################################################################
examples/standalone/Makefile
... ... @@ -5,28 +5,26 @@
5 5 # SPDX-License-Identifier: GPL-2.0+
6 6 #
7 7  
8   -include $(TOPDIR)/config.mk
  8 +extra-y := hello_world
  9 +extra-$(CONFIG_SMC91111) += smc91111_eeprom
  10 +extra-$(CONFIG_SMC911X) += smc911x_eeprom
  11 +extra-$(CONFIG_SPI_FLASH_ATMEL) += atmel_df_pow2
  12 +extra-$(CONFIG_MPC5xxx) += interrupt
  13 +extra-$(CONFIG_8xx) += test_burst timer
  14 +extra-$(CONFIG_8260) += mem_to_mem_idma2intr
  15 +extra-$(CONFIG_PPC) += sched
9 16  
10   -ELF-y := hello_world
11   -
12   -ELF-$(CONFIG_SMC91111) += smc91111_eeprom
13   -ELF-$(CONFIG_SMC911X) += smc911x_eeprom
14   -ELF-$(CONFIG_SPI_FLASH_ATMEL) += atmel_df_pow2
15   -ELF-$(CONFIG_MPC5xxx) += interrupt
16   -ELF-$(CONFIG_8xx) += test_burst timer
17   -ELF-$(CONFIG_8260) += mem_to_mem_idma2intr
18   -ELF-$(CONFIG_PPC) += sched
19   -
20 17 #
21 18 # Some versions of make do not handle trailing white spaces properly;
22 19 # leading to build failures. The problem was found with GNU Make 3.80.
23 20 # Using 'strip' as a workaround for the problem.
24 21 #
25   -ELF := $(strip $(ELF-y))
  22 +ELF := $(strip $(extra-y))
26 23  
27   -SREC := $(addsuffix .srec,$(ELF))
28   -BIN := $(addsuffix .bin,$(ELF))
  24 +extra-y += $(addsuffix .srec,$(extra-y)) $(addsuffix .bin,$(extra-y))
  25 +clean-files := $(extra-) $(addsuffix .srec,$(extra-)) $(addsuffix .bin,$(extra-))
29 26  
  27 +
30 28 COBJS := $(ELF:=.o)
31 29  
32 30 LIB = $(obj)libstubs.o
... ... @@ -42,8 +40,6 @@
42 40 SRCS := $(COBJS:.o=.c) $(LIBCOBJS:.o=.c) $(LIBAOBJS:.o=.S)
43 41 OBJS := $(addprefix $(obj),$(COBJS))
44 42 ELF := $(addprefix $(obj),$(ELF))
45   -BIN := $(addprefix $(obj),$(BIN))
46   -SREC := $(addprefix $(obj),$(SREC))
47 43  
48 44 gcclibdir := $(shell dirname `$(CC) -print-libgcc-file-name`)
49 45  
50 46  
51 47  
... ... @@ -60,13 +56,10 @@
60 56 # We don't want gcc reordering functions if possible. This ensures that an
61 57 # application's entry point will be the first function in the application's
62 58 # source file.
63   -CFLAGS_NTR := $(call cc-option,-fno-toplevel-reorder)
64   -CFLAGS += $(CFLAGS_NTR)
  59 +CFLAGS += $(call cc-option,-fno-toplevel-reorder)
65 60  
66   -all: $(obj).depend $(OBJS) $(LIB) $(SREC) $(BIN) $(ELF)
67   -
68 61 #########################################################################
69   -$(LIB): $(obj).depend $(LIBOBJS)
  62 +$(LIB): $(LIBOBJS)
70 63 $(call cmd_link_o_target, $(LIBOBJS))
71 64  
72 65 $(ELF):
73 66  
74 67  
... ... @@ -75,20 +68,9 @@
75 68 -o $@ -e $(SYM_PREFIX)$(notdir $(<:.o=)) $< $(LIB) \
76 69 -L$(gcclibdir) -lgcc
77 70  
78   -$(SREC):
79 71 $(obj)%.srec: $(obj)%
80 72 $(OBJCOPY) -O srec $< $@ 2>/dev/null
81 73  
82   -$(BIN):
83 74 $(obj)%.bin: $(obj)%
84 75 $(OBJCOPY) -O binary $< $@ 2>/dev/null
85   -
86   -#########################################################################
87   -
88   -# defines $(obj).depend target
89   -include $(SRCTREE)/rules.mk
90   -
91   -sinclude $(obj).depend
92   -
93   -#########################################################################
scripts/Makefile.build
... ... @@ -4,7 +4,8 @@
4 4  
5 5 include $(TOPDIR)/config.mk
6 6  
7   -LIB := $(obj)built-in.o
  7 +# variable LIB is used in examples/standalone/Makefile
  8 +__LIB := $(obj)built-in.o
8 9 LIBGCC = $(obj)libgcc.o
9 10 SRCS :=
10 11 subdir-y :=
11 12  
... ... @@ -42,9 +43,9 @@
42 43  
43 44 LGOBJS := $(addprefix $(obj),$(sort $(lib-y)))
44 45  
45   -all: $(LIB) $(addprefix $(obj),$(extra-y) $(always)) $(subdir-y)
  46 +all: $(__LIB) $(addprefix $(obj),$(extra-y) $(always)) $(subdir-y)
46 47  
47   -$(LIB): $(obj).depend $(OBJS)
  48 +$(__LIB): $(obj).depend $(OBJS)
48 49 $(call cmd_link_o_target, $(OBJS))
49 50  
50 51 ifneq ($(strip $(lib-y)),)