dtc: add option for a static build
[openwrt/staging/blocktrron.git] / package / utils / dtc / Makefile
1 # SPDX-License-Identifier: GPL-2.0
2 #
3 # Copyright (C) 2016-2019 Yousong Zhou <yszhou4tech@gmail.com>
4
5 include $(TOPDIR)/rules.mk
6
7 PKG_NAME:=dtc
8 PKG_VERSION:=1.7.0
9 PKG_RELEASE:=2
10
11 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
12 PKG_HASH:=29edce3d302a15563d8663198bbc398c5a0554765c83830d0d4c0409d21a16c4
13 PKG_SOURCE_URL:=@KERNEL/software/utils/dtc
14
15 PKG_MAINTAINER:=Yousong Zhou <yszhou4tech@gmail.com>
16 PKG_LICENSE:=GPL-2.0-only
17 PKG_LICENSE_FILES:=GPL
18 PKG_CPE_ID:=cpe:/a:dtc_project:dtc
19
20 PKG_INSTALL:=1
21
22 include $(INCLUDE_DIR)/package.mk
23 include $(INCLUDE_DIR)/meson.mk
24
25 define Package/dtc
26 SECTION:=utils
27 CATEGORY:=Utilities
28 TITLE:=Device Tree Compiler
29 URL:=https://git.kernel.org/pub/scm/utils/dtc/dtc.git
30 endef
31
32 define Package/dtc/description
33 Device Tree Compiler for Flat Device Trees Device Tree Compiler, dtc, takes
34 as input a device-tree in a given format and outputs a device-tree in another
35 format for booting kernels on embedded systems.
36 endef
37
38 define Package/dtc/config
39 config DTC_STATIC_BUILD
40 depends on PACKAGE_dtc
41 bool "Build dtc as static binary"
42 default n
43 help
44 Builds dtc as a static binary.
45 This is usefull in order to export live DTS from a device running
46 various vendor modified OpenWrt versions.
47 endef
48
49 define Package/dtc/install
50 $(INSTALL_DIR) $(1)/usr/bin
51 $(CP) $(PKG_INSTALL_DIR)/usr/bin/dtc $(1)/usr/bin
52 endef
53
54
55 # See Documentation/manual.txt for details about each utility
56 define Package/fdt-utils
57 SECTION:=utils
58 CATEGORY:=Utilities
59 TITLE:=Flat Device Tree Utilities
60 URL:=https://git.kernel.org/pub/scm/utils/dtc/dtc.git
61 DEPENDS:=+libfdt
62 endef
63
64 define Package/fdt-utils/install
65 $(INSTALL_DIR) $(1)/usr/bin
66 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/convert-dtsv0 $(1)/usr/bin
67 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/fdtdump $(1)/usr/bin
68 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/fdtget $(1)/usr/bin
69 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/fdtput $(1)/usr/bin
70 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/fdtoverlay $(1)/usr/bin
71 endef
72
73
74 define Package/libfdt
75 SECTION:=libs
76 CATEGORY:=Libraries
77 TITLE:=a utility library for reading and manipulating dtb files
78 URL:=https://git.kernel.org/pub/scm/utils/dtc/dtc.git
79 endef
80
81 define Package/libfdt/description
82 This is a library containing functions for manipulating Flat Device Trees.
83 endef
84
85 define Package/libfdt/install
86 $(INSTALL_DIR) $(1)/usr/lib
87 $(CP) $(PKG_INSTALL_DIR)/usr/lib/libfdt*.so* $(1)/usr/lib
88 endef
89
90 MESON_ARGS += \
91 -Dtools=true \
92 -Dyaml=disabled \
93 -Dvalgrind=disabled \
94 -Dpython=disabled \
95 -Dstatic-build=$(if $(CONFIG_DTC_STATIC_BUILD),true,false)
96
97 define Build/InstallDev
98 $(INSTALL_DIR) $(1)/usr/lib
99 $(INSTALL_DIR) $(1)/usr/include
100 $(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include
101 $(CP) $(PKG_INSTALL_DIR)/usr/lib/* $(1)/usr/lib
102 endef
103
104 $(eval $(call BuildPackage,dtc))
105 $(eval $(call BuildPackage,fdt-utils))
106 $(eval $(call BuildPackage,libfdt))