【问题标题】:Build error: make: Nothing to be done for 'compile'构建错误:make:“编译”无事可做
【发布时间】:2021-05-19 23:17:33
【问题描述】:

我需要将自己的包添加到 openwrt 映像中。在项目的 wiki 上,我发现了这个 article

我尝试按照说明进行操作,但最后我没有设法将自己的包添加到源代码树中(构建忽略了它的存在)。

因此,我试图找到其他方法。结果是this instruction。我按照那里的指示编译了我自己的包。

但是正如你所看到的,该包的源代码不依赖于其他人,也不需要任何其他构建头文件。此外,他的Makefile 完全包含编译说明。

define Build/Compile
    $(TARGET_CC) $(TARGET_CFLAGS) -o $(PKG_BUILD_DIR)/helloworld.o -c $(PKG_BUILD_DIR)/helloworld.c
    $(TARGET_CC) $(TARGET_LDFLAGS) -o $(PKG_BUILD_DIR)/$1 $(PKG_BUILD_DIR)/helloworld.o
endef

但是现在这不适合我,因为我要添加的另一个包已经具有这样的依赖项。 我试图像这样绕过它们(将源代码复制到构建文件夹和位于那里的call the makefile)但没有任何结果:

define Build/Prepare
    echo $PKG_NAME
    mkdir -p $(PKG_BUILD_DIR)
    cp $(SOURCE_DIR)/* $(PKG_BUILD_DIR)
    $(Build/Patch)
endef

define Build/Compile
    $(PKG_BUILD_DIR) $(MAKE)
endef

我得到下一个输出:

    $ make -C package/feeds/mypackages/helloworld compile TOPDIR=$PWD
make: Entering directory '/home/username/mypackages/examples/helloworld'
bash: mkhash: command not found
bash: mkhash: command not found
bash: mkhash: command not found
bash: mkhash: command not found
bash: mkhash: command not found
bash: mkhash: command not found
bash: mkhash: command not found
bash: mkhash: command not found
make: Nothing to be done for 'compile'.
make: Leaving directory '/home/username/mypackages/examples/helloworld'

我的包和二进制的完整 Makefile:

include $(TOPDIR)/rules.mk
PKG_NAME:=helloworld
PKG_VERSION:=1.0
PKG_RELEASE:=1
SOURCE_DIR:=/home/username/helloworld
include $(INCLUDE_DIR)/package.mk
define Package/$(PKG_NAME)
    SECTION:=utils
    DEPENDS:= +libstdcpp
    TITLE:=helloworld
endef
define Package/helloworld/description
    A simple "Hello, world!" -application.
endef
define Build/Prepare
    echo $PKG_NAME
    mkdir -p $(PKG_BUILD_DIR)
    cp $(SOURCE_DIR)/* $(PKG_BUILD_DIR)
    $(Build/Patch)
endef
define Build/Compile
    $(PKG_BUILD_DIR) $(MAKE)
endef
define Package/helloworld/install
    # Install binary
    #$(INSTALL_DIR) $(1)/usr/bin
    #$(INSTALL_BIN) $(PKG_BUILD_DIR)/helloworld $(1)/usr/bin/
endef
$(eval $(call BuildPackage,$(PKG_NAME)))

,

TARGET = heloworld
OBJS = heloworld.o
CFLAGS += -Wall -Wextra 
LDFLAGS += -lxsacpp -lxsac -lubus -lubox 
CXXFLAGS += $(CFLAGS) -std=c++14

%.o : %.cpp
    $(CXX) -c $(CXXFLAGS) $< -o $@

all: $(TARGET)

$(TARGET): $(OBJS)
    $(CXX) $(LDFLAGS) -o $@ $^

clean:
    rm *.o $(TARGET)

实际上我的问题是,需要在Makefile 中设置什么才能正确复制文件并调用本地Makefile 以获取软件包二进制文件?

【问题讨论】:

    标签: c++ makefile openwrt


    【解决方案1】:

    为了复制文件和目录,您可以使用以下步骤:

    # copy all files and directories using **cp -r -f **
    define Build/Prepare
        echo $PKG_NAME
        mkdir -p $(PKG_BUILD_DIR)
        cp -r -f $(SOURCE_DIR)/* $(PKG_BUILD_DIR)
        $(Build/Patch)
    endef
    

    为了执行本地makefile,请使用以下步骤:

    # Execute local makefile by giving path using '-C' option
    define Build/Compile
         `$(MAKE) -C $(PKG_BUILD_DIR)`
    endef
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-01-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多