【问题标题】:OpenWrt Makefile include package.mk errorOpenWrt Makefile 包含 package.mk 错误
【发布时间】:2021-07-13 12:29:50
【问题描述】:

我是 OpenWrt 和 Makefiles 的初学者,试图演示创建包的“Helloworld”示例,但在包提要更新步骤,来自命令 ./scripts/feeds update mypackages 我收到此错误

Updating feed 'mypackages' from '/home/onur/Desktop/OpenWRT/openwrt/mypackages' ...
Create index file './feeds/mypackages.index' 
/home/onur/Desktop/OpenWRT/openwrt/feeds/mypackages.tmp/info/.files-packageinfo.mk:1: *** target pattern contains no '%'.  Stop.

我的 feeds.conf 中有 src-link mypackages /home/onur/Desktop/OpenWRT/openwrt/mypackages,在 /openwrt/helloworld 目录下编译的“helloworld”C 程序,下面是我的 Makefile:

include $(TOPDIR)/rules.mk
    
# Name, version and release number
# The name and version of your package are used to define the variable to point to the build directory of your package: $(PKG_BUILD_DIR)
PKG_NAME:=helloworld
PKG_VERSION:=1.0
PKG_RELEASE:=1

# Source settings (i.e. where to find the source codes)
# This is a custom variable, used below
SOURCE_DIR:=/home/onur/Desktop/OpenWRT/openwrt/helloworld

include $(INCLUDE_DIR)/package.mk

# Package definition; instructs on how and where our package will appear in the overall configuration menu ('make menuconfig')
define Package/helloworld
    SECTION:=examples
    CATEGORY:=Examples
    TITLE:=Hello, World!
endef

# Package description; a more verbose description on what our package does
define Package/helloworld/description
    A simple "Hello, world!" -application.
endef

# Package preparation instructions; create the build directory and copy the source code. 
# The last command is necessary to ensure our preparation instructions remain compatible with the patching system.
define Build/Prepare
    mkdir -p $(PKG_BUILD_DIR)
    cp $(SOURCE_DIR)/* $(PKG_BUILD_DIR)
    $(Build/Patch)
endef

# Package build instructions; invoke the target-specific compiler to first compile the source file, and then to link the file into the final executable
define Build/Compile
    $(MAKE) -C $(PKG_BUILD_DIR) \
    CXX="$(TARGET_CROSS)g++"
endef

# Package install instructions; create a directory inside the package to hold our executable, and then copy the executable we built previously into the folder
define Package/helloworld/install
    $(INSTALL_DIR) $(1)/usr/bin
    $(INSTALL_BIN) $(PKG_BUILD_DIR)/helloworld $(1)/usr/bin
endef

# This command is always the last, it uses the definitions and variables we give above in order to get the job done
$(eval $(call BuildPackage,helloworld))

我知道我在交叉编译部分可能有错误,但我认为这不是我现在遇到的问题。

当我尝试制作这个 Makefile 时,我得到了那个错误。

Makefile:13: /package.mk: No such file or directory
make: *** No rule to make target '/package.mk'.  Stop.

我在任何地方都找不到这样的问题。为什么它甚至找不到“package.mk”文件。 我的目录结构是这样的,顶层目录是Desktop/OpenWrt/openwrt,这个 Makefile 在Desktop/OpenWrt/openwrt/mypackage 文件夹中。我在 Ubuntu 20.04

【问题讨论】:

  • 那么TOPDIR需要设置为你有这个文件的目录的名字。
  • @tripleee 我该如何设置?
  • 直接的解决方案是make TOPDIR= mypackage 而不仅仅是make,但我猜你正在运行的脚本有一些方法可以传入或配置它以使用这些信息。
  • @tripleee 不幸的是,这也没有用。 “$(INCLUDE_DIR)”在rules.mk中定义为“$(TOPDIR)/include”
  • 如果写得正确,你也可以覆盖它。

标签: c makefile packaging openwrt


【解决方案1】:

我在 OpenWrt 论坛上找到了我的问题的解决方案。 Here is the link of thread

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-12
    相关资源
    最近更新 更多