sngrep: fix error if gnutls and openssl are both enabled
[buildroot-gz.git] / boot / barebox / barebox.mk
blob7a110d214575c2b0d4ae2fc5ab019e22e89477c2
1 ################################################################################
3 # barebox
5 ################################################################################
7 ################################################################################
8 # inner-barebox-package -- generates the KConfig logic and make targets needed
9 # to support a barebox package. All barebox packages are built from the same
10 # source (origin, version and patches). The remainder of the package
11 # configuration is unique to each barebox package.
13 # argument 1 is the uppercase package name (used for variable name-space)
14 ################################################################################
16 define inner-barebox-package
18 $(1)_VERSION = $$(call qstrip,$$(BR2_TARGET_BAREBOX_VERSION))
20 ifeq ($$($(1)_VERSION),custom)
21 # Handle custom Barebox tarballs as specified by the configuration
22 $(1)_TARBALL = $$(call qstrip,$$(BR2_TARGET_BAREBOX_CUSTOM_TARBALL_LOCATION))
23 $(1)_SITE = $$(patsubst %/,%,$$(dir $$($(1)_TARBALL)))
24 $(1)_SOURCE = $$(notdir $$($(1)_TARBALL))
25 BR_NO_CHECK_HASH_FOR += $$($(1)_SOURCE)
26 else ifeq ($$(BR2_TARGET_BAREBOX_CUSTOM_GIT),y)
27 $(1)_SITE = $$(call qstrip,$$(BR2_TARGET_BAREBOX_CUSTOM_GIT_REPO_URL))
28 $(1)_SITE_METHOD = git
29 else
30 # Handle stable official Barebox versions
31 $(1)_SOURCE = barebox-$$($(1)_VERSION).tar.bz2
32 $(1)_SITE = http://www.barebox.org/download
33 ifeq ($$(BR2_TARGET_BAREBOX_CUSTOM_VERSION),y)
34 BR_NO_CHECK_HASH_FOR += $$($(1)_SOURCE)
35 endif
36 endif
38 $(1)_DEPENDENCIES = host-lzop
39 $(1)_LICENSE = GPLv2 with exceptions
40 $(1)_LICENSE_FILES = COPYING
42 $(1)_CUSTOM_EMBEDDED_ENV_PATH = $$(call qstrip,$$(BR2_TARGET_$(1)_CUSTOM_EMBEDDED_ENV_PATH))
44 ifneq ($$(call qstrip,$$(BR2_TARGET_BAREBOX_CUSTOM_PATCH_DIR)),)
45 define $(1)_APPLY_CUSTOM_PATCHES
46 $$(APPLY_PATCHES) $$(@D) \
47 $$(BR2_TARGET_BAREBOX_CUSTOM_PATCH_DIR) \*.patch
48 endef
50 $(1)_POST_PATCH_HOOKS += $(1)_APPLY_CUSTOM_PATCHES
51 endif
53 $(1)_INSTALL_IMAGES = YES
54 ifneq ($$(BR2_TARGET_$(1)_BAREBOXENV),y)
55 $(1)_INSTALL_TARGET = NO
56 endif
58 ifeq ($$(KERNEL_ARCH),i386)
59 $(1)_ARCH = x86
60 else ifeq ($$(KERNEL_ARCH),x86_64)
61 $(1)_ARCH = x86
62 else ifeq ($$(KERNEL_ARCH),powerpc)
63 $(1)_ARCH = ppc
64 else ifeq ($$(KERNEL_ARCH),arm64)
65 $(1)_ARCH = arm
66 else
67 $(1)_ARCH = $$(KERNEL_ARCH)
68 endif
70 $(1)_MAKE_FLAGS = ARCH=$$($(1)_ARCH) CROSS_COMPILE="$$(TARGET_CROSS)"
71 $(1)_MAKE_ENV = $$(TARGET_MAKE_ENV)
73 ifeq ($$(BR2_TARGET_$(1)_USE_DEFCONFIG),y)
74 $(1)_KCONFIG_DEFCONFIG = $$(call qstrip,$$(BR2_TARGET_$(1)_BOARD_DEFCONFIG))_defconfig
75 else ifeq ($$(BR2_TARGET_$(1)_USE_CUSTOM_CONFIG),y)
76 $(1)_KCONFIG_FILE = $$(call qstrip,$$(BR2_TARGET_$(1)_CUSTOM_CONFIG_FILE))
77 endif
79 $(1)_KCONFIG_FRAGMENT_FILES = $$(call qstrip,$$(BR2_TARGET_$(1)_CONFIG_FRAGMENT_FILES))
80 $(1)_KCONFIG_EDITORS = menuconfig xconfig gconfig nconfig
81 $(1)_KCONFIG_OPTS = $$($(1)_MAKE_FLAGS)
83 ifeq ($$(BR2_TARGET_$(1)_BAREBOXENV),y)
84 define $(1)_BUILD_BAREBOXENV_CMDS
85 $$(TARGET_CC) $$(TARGET_CFLAGS) $$(TARGET_LDFLAGS) -o $$(@D)/bareboxenv \
86 $$(@D)/scripts/bareboxenv.c
87 endef
88 endif
90 ifeq ($$(BR2_TARGET_$(1)_CUSTOM_ENV),y)
91 $(1)_ENV_NAME = $$(notdir $$(call qstrip,\
92 $$(BR2_TARGET_$(1)_CUSTOM_ENV_PATH)))
93 define $(1)_BUILD_CUSTOM_ENV
94 $$(@D)/scripts/bareboxenv -s \
95 $$(call qstrip, $$(BR2_TARGET_$(1)_CUSTOM_ENV_PATH)) \
96 $$(@D)/$$($(1)_ENV_NAME)
97 endef
98 define $(1)_INSTALL_CUSTOM_ENV
99 cp $$(@D)/$$($(1)_ENV_NAME) $$(BINARIES_DIR)
100 endef
101 endif
103 ifneq ($$($(1)_CUSTOM_EMBEDDED_ENV_PATH),)
104 define $(1)_KCONFIG_FIXUP_CMDS
105 $$(call KCONFIG_ENABLE_OPT,CONFIG_DEFAULT_ENVIRONMENT,$$(@D)/.config)
106 $$(call KCONFIG_SET_OPT,CONFIG_DEFAULT_ENVIRONMENT_PATH,"$$($(1)_CUSTOM_EMBEDDED_ENV_PATH)",$$(@D)/.config)
107 endef
108 endif
110 define $(1)_BUILD_CMDS
111 $$($(1)_BUILD_BAREBOXENV_CMDS)
112 $$(TARGET_MAKE_ENV) $$(MAKE) $$($(1)_MAKE_FLAGS) -C $$(@D)
113 $$($(1)_BUILD_CUSTOM_ENV)
114 endef
116 $(1)_IMAGE_FILE = $$(call qstrip,$$(BR2_TARGET_$(1)_IMAGE_FILE))
118 define $(1)_INSTALL_IMAGES_CMDS
119 if test -n "$$($(1)_IMAGE_FILE)"; then \
120 cp -L $$(@D)/$$($(1)_IMAGE_FILE) $$(BINARIES_DIR) ; \
121 elif test -h $$(@D)/barebox-flash-image ; then \
122 cp -L $$(@D)/barebox-flash-image $$(BINARIES_DIR)/barebox.bin ; \
123 else \
124 cp $$(@D)/barebox.bin $$(BINARIES_DIR);\
126 $$($(1)_INSTALL_CUSTOM_ENV)
127 endef
129 ifeq ($$(BR2_TARGET_$(1)_BAREBOXENV),y)
130 define $(1)_INSTALL_TARGET_CMDS
131 cp $$(@D)/bareboxenv $$(TARGET_DIR)/usr/bin
132 endef
133 endif
135 # Checks to give errors that the user can understand
136 # Must be before we call to kconfig-package
137 ifeq ($$(BR2_TARGET_$(1))$$(BR_BUILDING),yy)
138 # We must use the user-supplied kconfig value, because
139 # $(1)_KCONFIG_DEFCONFIG will at least contain the
140 # trailing _defconfig
141 ifeq ($$(or $$($(1)_KCONFIG_FILE),$$(call qstrip,$$(BR2_TARGET_$(1)_BOARD_DEFCONFIG))),)
142 $$(error No Barebox config. Check your BR2_TARGET_$(1)_BOARD_DEFCONFIG or BR2_TARGET_$(1)_CUSTOM_CONFIG_FILE settings)
143 endif
144 endif
146 $$(eval $$(kconfig-package))
148 endef
150 ################################################################################
151 # barebox-package -- the target generator macro for barebox packages
152 ################################################################################
154 barebox-package=$(call inner-barebox-package,$(call UPPERCASE,$(pkgname)))
156 include boot/barebox/barebox/barebox.mk
157 include boot/barebox/barebox-aux/barebox-aux.mk