编译Linux源码树中的dtc(设备树编译器)
程序员文章站
2024-01-23 16:14:28
...
从Linux源码树中提取dtc源码
# 将linux/scripts/dtc源码拷贝出来
cp /home/share/linux/scripts/dtc /home/share/learn/dts/linux_dtc/ -rf
稍微修改
# 这个三个文件要编译进来
mv dtc-parser.tab.c_shipped dtc-parser.tab.c
mv dtc-parser.tab.h_shipped dtc-parser.tab.h
mv dtc-lexer.lex.c_shipped dtc-lexer.lex.c
构造编译dtc的Makefile
src := $(shell pwd)
fdt_src := $(src)/libfdt
target_bin := dtc
dtc-objs := dtc.o flattree.o fstree.o data.o livetree.o treesource.o \
srcpos.o checks.o util.o
dtc-objs += dtc-lexer.lex.o dtc-parser.tab.o
dtc-objs += $(fdt_src)/fdt.o $(fdt_src)/fdt_ro.o $(fdt_src)/fdt_wip.o \
$(fdt_src)/fdt_sw.o $(fdt_src)/fdt_rw.o $(fdt_src)/fdt_strerror.o \
$(fdt_src)/fdt_empty_tree.o
#$(fdt_src)/fdt_addresses.o $(fdt_src)/fdt_overlay.o
# Source files need to get at the userspace version of libfdt_env.h to compile
CFLAGS := -I$(src) -I$(src)/libfdt
all: $(dtc-objs)
gcc $(CFLAGS) -o $(target_bin) $(dtc-objs)
@echo "Yes!"
%.o : %.c
gcc $(CFLAGS) -c -o [email protected] $^
clean:
rm -rf $(dtc-objs) $(target_bin)
编译dtc
make all
enjoy it
./dtc -h
Usage: dtc [options] <input file>
Options: -[qI:O:o:V:d:R:S:p:a:fb:i:H:sW:E:@Ahv]
。。。。。。。。。。。。。。。。。。。