Commit cc4f427bbd7192b602310ee27ee34e3bfe81608b

Authored by Stephen Warren
Committed by Tom Rini
1 parent 6697d55862

dts/Makefile: simplify dtc invocation

The invocation of dtc is significantly more complex that it could be,
in order to work around an issue on old versions of dtc, which print
a message to stdout every time they run.

Remove this workaround, on the assumption that people have or will
upgrade to a newer version of dtc. This simplifies the build rule
significantly.

Related, split the invocation of cpp and dtc into separate commands
rather than a pipeline, so that if either fail, it is detected. This has
the nice benefit of saving off the result of the pre-processing step,
allowing it to be easily inspected.

Assuming a new enough dtc (which an earlier patch enforces), dtc will
parse #line directives in its input file, and generate correct file and
line numbers in error messages, even though cpp is unconditionally
applied to its input file.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Acked-by: Simon Glass <sjg@chromium.org>

Showing 2 changed files with 3 additions and 7 deletions Inline Diff

1 # 1 #
2 # NOTE! Don't add files that are generated in specific 2 # NOTE! Don't add files that are generated in specific
3 # subdirectories here. Add them in the ".gitignore" file 3 # subdirectories here. Add them in the ".gitignore" file
4 # in that subdirectory instead. 4 # in that subdirectory instead.
5 # 5 #
6 # Normal rules 6 # Normal rules
7 # 7 #
8 8
9 *.rej 9 *.rej
10 *.orig 10 *.orig
11 *.a 11 *.a
12 *.o 12 *.o
13 *.su 13 *.su
14 *~ 14 *~
15 *.swp 15 *.swp
16 *.patch 16 *.patch
17 *.bin 17 *.bin
18 *.cfgtmp 18 *.cfgtmp
19 *.dts.tmp
19 20
20 # Build tree 21 # Build tree
21 /build-* 22 /build-*
22 23
23 # 24 #
24 # Top-level generic files 25 # Top-level generic files
25 # 26 #
26 27
27 /MLO 28 /MLO
28 /SPL 29 /SPL
29 /System.map 30 /System.map
30 /u-boot 31 /u-boot
31 /u-boot.hex 32 /u-boot.hex
32 /u-boot.imx 33 /u-boot.imx
33 /u-boot-with-spl.imx 34 /u-boot-with-spl.imx
34 /u-boot-with-nand-spl.imx 35 /u-boot-with-nand-spl.imx
35 /u-boot.map 36 /u-boot.map
36 /u-boot.srec 37 /u-boot.srec
37 /u-boot.ldr 38 /u-boot.ldr
38 /u-boot.ldr.hex 39 /u-boot.ldr.hex
39 /u-boot.ldr.srec 40 /u-boot.ldr.srec
40 /u-boot.img 41 /u-boot.img
41 /u-boot.kwb 42 /u-boot.kwb
42 /u-boot.sha1 43 /u-boot.sha1
43 /u-boot.dis 44 /u-boot.dis
44 /u-boot.lds 45 /u-boot.lds
45 /u-boot.ubl 46 /u-boot.ubl
46 /u-boot.ais 47 /u-boot.ais
47 /u-boot.dtb 48 /u-boot.dtb
48 /u-boot.sb 49 /u-boot.sb
49 /u-boot.bd 50 /u-boot.bd
50 /u-boot.geany 51 /u-boot.geany
51 52
52 # 53 #
53 # Generated files 54 # Generated files
54 # 55 #
55 56
56 *.depend* 57 *.depend*
57 /LOG 58 /LOG
58 /errlog 59 /errlog
59 /reloc_off 60 /reloc_off
60 61
61 /include/generated/ 62 /include/generated/
62 asm-offsets.s 63 asm-offsets.s
63 64
64 # stgit generated dirs 65 # stgit generated dirs
65 patches-* 66 patches-*
66 .stgit-edit.txt 67 .stgit-edit.txt
67 68
68 # quilt's files 69 # quilt's files
69 patches 70 patches
70 series 71 series
71 72
72 # gdb files 73 # gdb files
73 .gdb_history 74 .gdb_history
74 75
75 # cscope files 76 # cscope files
76 cscope.* 77 cscope.*
77 78
78 # tags files 79 # tags files
79 /tags 80 /tags
80 /ctags 81 /ctags
81 /etags 82 /etags
82 83
83 # gnu global files 84 # gnu global files
84 GPATH 85 GPATH
85 GRTAGS 86 GRTAGS
86 GSYMS 87 GSYMS
87 GTAGS 88 GTAGS
88 89
89 # spl ais files 90 # spl ais files
90 /spl/*.ais 91 /spl/*.ais
91 92
1 # 1 #
2 # Copyright (c) 2011 The Chromium OS Authors. 2 # Copyright (c) 2011 The Chromium OS Authors.
3 # 3 #
4 # SPDX-License-Identifier: GPL-2.0+ 4 # SPDX-License-Identifier: GPL-2.0+
5 # 5 #
6 6
7 # This Makefile builds the internal U-Boot fdt if CONFIG_OF_CONTROL is 7 # This Makefile builds the internal U-Boot fdt if CONFIG_OF_CONTROL is
8 # enabled. See doc/README.fdt-control for more details. 8 # enabled. See doc/README.fdt-control for more details.
9 9
10 include $(TOPDIR)/config.mk 10 include $(TOPDIR)/config.mk
11 11
12 LIB = $(obj)libdts.o 12 LIB = $(obj)libdts.o
13 13
14 ifeq ($(DEVICE_TREE),) 14 ifeq ($(DEVICE_TREE),)
15 $(if $(CONFIG_DEFAULT_DEVICE_TREE),,\ 15 $(if $(CONFIG_DEFAULT_DEVICE_TREE),,\
16 $(error Please define CONFIG_DEFAULT_DEVICE_TREE in your board header file)) 16 $(error Please define CONFIG_DEFAULT_DEVICE_TREE in your board header file))
17 DEVICE_TREE = $(subst ",,$(CONFIG_DEFAULT_DEVICE_TREE)) 17 DEVICE_TREE = $(subst ",,$(CONFIG_DEFAULT_DEVICE_TREE))
18 endif 18 endif
19 19
20 $(if $(CONFIG_ARCH_DEVICE_TREE),,\ 20 $(if $(CONFIG_ARCH_DEVICE_TREE),,\
21 $(error Your architecture does not have device tree support enabled. \ 21 $(error Your architecture does not have device tree support enabled. \
22 Please define CONFIG_ARCH_DEVICE_TREE)) 22 Please define CONFIG_ARCH_DEVICE_TREE))
23 23
24 # We preprocess the device tree file provide a useful define 24 # We preprocess the device tree file provide a useful define
25 DTS_CPPFLAGS := -x assembler-with-cpp \ 25 DTS_CPPFLAGS := -x assembler-with-cpp \
26 -DARCH_CPU_DTS=\"$(SRCTREE)/arch/$(ARCH)/dts/$(CONFIG_ARCH_DEVICE_TREE).dtsi\" \ 26 -DARCH_CPU_DTS=\"$(SRCTREE)/arch/$(ARCH)/dts/$(CONFIG_ARCH_DEVICE_TREE).dtsi\" \
27 -DBOARD_DTS=\"$(SRCTREE)/board/$(VENDOR)/$(BOARD)/dts/$(DEVICE_TREE).dts\" \ 27 -DBOARD_DTS=\"$(SRCTREE)/board/$(VENDOR)/$(BOARD)/dts/$(DEVICE_TREE).dts\" \
28 -I$(SRCTREE)/board/$(VENDOR)/dts -I$(SRCTREE)/arch/$(ARCH)/dts 28 -I$(SRCTREE)/board/$(VENDOR)/dts -I$(SRCTREE)/arch/$(ARCH)/dts
29 29
30 all: $(obj).depend $(LIB) 30 all: $(obj).depend $(LIB)
31 31
32 # Use a constant name for this so we can access it from C code. 32 # Use a constant name for this so we can access it from C code.
33 # objcopy doesn't seem to allow us to set the symbol name independently of 33 # objcopy doesn't seem to allow us to set the symbol name independently of
34 # the filename. 34 # the filename.
35 DT_BIN := $(obj)dt.dtb 35 DT_BIN := $(obj)dt.dtb
36 36
37 $(DT_BIN): $(TOPDIR)/board/$(VENDOR)/dts/$(DEVICE_TREE).dts 37 $(DT_BIN): $(TOPDIR)/board/$(VENDOR)/dts/$(DEVICE_TREE).dts
38 rc=$$( \ 38 $(CPP) -P $(DTS_CPPFLAGS) $< -o $(DT_BIN).dts.tmp
39 cat $< | $(CPP) -P $(DTS_CPPFLAGS) - | \ 39 $(DTC) -R 4 -p 0x1000 -O dtb -o ${DT_BIN} $(DT_BIN).dts.tmp
40 { { $(DTC) -R 4 -p 0x1000 -O dtb -o ${DT_BIN} - 2>&1 ; \
41 echo $$? >&3 ; } | \
42 grep -v '^DTC: dts->dtb on file' ; \
43 } 3>&1 1>&2 ) ; \
44 exit $$rc
45 40
46 process_lds = \ 41 process_lds = \
47 $(1) | sed -r -n 's/^OUTPUT_$(2)[ ("]*([^")]*).*/\1/p' 42 $(1) | sed -r -n 's/^OUTPUT_$(2)[ ("]*([^")]*).*/\1/p'
48 43
49 # Run the compiler and get the link script from the linker 44 # Run the compiler and get the link script from the linker
50 GET_LDS = $(CC) $(CFLAGS) $(LDFLAGS) -Wl,--verbose 2>&1 45 GET_LDS = $(CC) $(CFLAGS) $(LDFLAGS) -Wl,--verbose 2>&1
51 46
52 $(obj)dt.o: $(DT_BIN) 47 $(obj)dt.o: $(DT_BIN)
53 # We want the output format and arch. 48 # We want the output format and arch.
54 # We also hope to win a prize for ugliest Makefile / shell interaction 49 # We also hope to win a prize for ugliest Makefile / shell interaction
55 # We look in the LDSCRIPT first. 50 # We look in the LDSCRIPT first.
56 # Then try the linker which should give us the answer. 51 # Then try the linker which should give us the answer.
57 # Then check it worked. 52 # Then check it worked.
58 [ -n "$(LDSCRIPT)" ] && \ 53 [ -n "$(LDSCRIPT)" ] && \
59 oformat=`$(call process_lds,cat $(LDSCRIPT),FORMAT)` && \ 54 oformat=`$(call process_lds,cat $(LDSCRIPT),FORMAT)` && \
60 oarch=`$(call process_lds,cat $(LDSCRIPT),ARCH)` ;\ 55 oarch=`$(call process_lds,cat $(LDSCRIPT),ARCH)` ;\
61 \ 56 \
62 [ -z $${oformat} ] && \ 57 [ -z $${oformat} ] && \
63 oformat=`$(call process_lds,$(GET_LDS),FORMAT)` ;\ 58 oformat=`$(call process_lds,$(GET_LDS),FORMAT)` ;\
64 [ -z $${oarch} ] && \ 59 [ -z $${oarch} ] && \
65 oarch=`$(call process_lds,$(GET_LDS),ARCH)` ;\ 60 oarch=`$(call process_lds,$(GET_LDS),ARCH)` ;\
66 \ 61 \
67 [ -z $${oformat} ] && \ 62 [ -z $${oformat} ] && \
68 echo "Cannot read OUTPUT_FORMAT from lds file $(LDSCRIPT)" && \ 63 echo "Cannot read OUTPUT_FORMAT from lds file $(LDSCRIPT)" && \
69 exit 1 || true ;\ 64 exit 1 || true ;\
70 [ -z $${oarch} ] && \ 65 [ -z $${oarch} ] && \
71 echo "Cannot read OUTPUT_ARCH from lds file $(LDSCRIPT)" && \ 66 echo "Cannot read OUTPUT_ARCH from lds file $(LDSCRIPT)" && \
72 exit 1 || true ;\ 67 exit 1 || true ;\
73 \ 68 \
74 cd $(dir ${DT_BIN}) && \ 69 cd $(dir ${DT_BIN}) && \
75 $(OBJCOPY) -I binary -O $${oformat} -B $${oarch} \ 70 $(OBJCOPY) -I binary -O $${oformat} -B $${oarch} \
76 $(notdir ${DT_BIN}) $@ 71 $(notdir ${DT_BIN}) $@
77 rm $(DT_BIN) 72 rm $(DT_BIN)
78 73
79 OBJS-$(CONFIG_OF_EMBED) := dt.o 74 OBJS-$(CONFIG_OF_EMBED) := dt.o
80 75
81 COBJS := $(OBJS-y) 76 COBJS := $(OBJS-y)
82 77
83 OBJS := $(addprefix $(obj),$(COBJS)) 78 OBJS := $(addprefix $(obj),$(COBJS))
84 79
85 binary: $(DT_BIN) 80 binary: $(DT_BIN)
86 81
87 $(LIB): $(OBJS) $(DTB) 82 $(LIB): $(OBJS) $(DTB)
88 $(call cmd_link_o_target, $(OBJS)) 83 $(call cmd_link_o_target, $(OBJS))
89 84
90 ######################################################################### 85 #########################################################################
91 86
92 # defines $(obj).depend target 87 # defines $(obj).depend target
93 include $(SRCTREE)/rules.mk 88 include $(SRCTREE)/rules.mk
94 89
95 sinclude $(obj).depend 90 sinclude $(obj).depend
96 91
97 ######################################################################### 92 #########################################################################
98 93