Buildroot external 未进入 hello.mk 文件中指定的 HELLO_SITE 指定的项目源目录

问题描述 投票:0回答:1

我正在尝试使用 buildroot 外部项目构建一个非常简单的 hello world 程序。

我的项目结构从顶层看起来像这样。

构建根目录 你好

里面你好我有这棵树

.
├── Config.in
├── external.desc
├── external.mk
├── hello.mk
└── src
    ├── Makefile
    └── hello.c

这些文件的内容如下。

配置.in

config BR2_PACKAGE_HELLO
    bool "hello"
    help
        Hello world package.
        
        http://example.com

外部.desc

name: HELLO

外部.mk

#include $(sort $(wildcard $(BR2_EXTERNAL_HELLO_PATH)/hello/*.mk))
$(info inside $(lastword $(MAKEFILE_LIST)))
include $(sort $(wildcard $(BR2_EXTERNAL_HELLO_PATH)/hello.mk))

你好.mk

################################################################################
#
# hello
#
################################################################################
$(info inside $(lastword $(MAKEFILE_LIST)))

HELLO_VERSION=1.0
#I don't understand why but giving site PKG_SITE below
#  makes no difference on @D variable below
#  it always points at base of project why?????
#  But if you don't define it buildroot puts this out... What gives??
#  *** HELLO_SITE cannot be empty when HELLO_SOURCE is not.  
HELLO_SITE=$(TOPDIR)/../hello/src
HELLO_SITE_METHOD=local

define HELLO_BUILD_CMDS
    $(MAKE) CC="$(TARGET_CC)" LD="$(TARGET_LD)" -C $(@D)/src
endef

define HELLO_INSTALL_TARGET_CMDS
    $(INSTALL) -D -m 0755 $(@D)/src/hello $(TARGET_DIR)/usr/bin
endef

$(eval $(generic-package))

src/Makefile

$(info inside $(lastword $(MAKEFILE_LIST)))

CC = gcc

.PHONY: clean

hello: hello.c
    $(CC) -o '$@' '$<'
clean:
    rm hello

src/hello.c

#include <stdio.h>

int main(void) {
    puts("hello");
}

在 buildroot 目录中,我有一个 local.mk,其中包含这一行

HELLO_OVERRIDE_SRCDIR = ../hello

从我运行的 buildroot 文件夹中

make BR2_EXTERNAL="$(pwd)/../hello" myprj_defconfig
echo 'BR2_PACKAGE_HELLO=y' >> .config
make hello-rebuild all

hello 可执行文件已构建。但是... hello.mk 中的 HELLO_SITE=$(TOPDIR)/../hello/src 未生效。请参阅 hello.mk 中的评论。 @D 变量不会指向 HELLO_SITE 定义的内容。不过,如果我完全删除 HELLO_SITE,buildroot 会在评论中吐出该消息。另外,如果我为 HELLO_SITE 分配一个垃圾名称,它无论如何构建都没关系并且不会尝试进入垃圾路径。它是使用上面的文件构建的,因为我将 /src 附加到 hello.mk 中的@D。在我在网上找到的示例中,这应该是不必要的,因为 HELLO_SITE 应该使 buildroot 进入 src 文件夹来运行 Makefile。对我来说这不起作用。

从我在谷歌搜索和 buildroot 文档中看到的所有内容来看,HELLO_SITE 应该受到尊重,但事实并非如此。

有人看到我做错了什么吗?

我使用的是buildroot 2023.02-1.0。

谢谢你。

buildroot
1个回答
0
投票

包必须位于与包同名的目录中,因此在本例中为

hello
。换句话说,文件应该这样组织:

.
├── Config.in
├── external.desc
├── external.mk
└── hello
    ├── Makefile
    ├── hello.c
    └── hello.mk

(您通常还会将

Config.in
放入
hello
目录中,但这不是严格要求的。)

© www.soinside.com 2019 - 2024. All rights reserved.