Search code examples
openwrt

"recipe commences before first target" makefile error with self created open wrt package


I am trying to create my own Open WRT package called 'azure'. So far, I have only created a Makefile in the package/utils/azure directory. When I'm trying to build the package with make in the Open WRT root directory, a dump.txt will be created containing:
Makefile:44: *** recipe commences before first target. Stop.

My Makefile:

include $(TOPDIR)/rules.mk

PKG_NAME:=azure
PKG_VERSION:=1.0
PKG_RELEASE:=1

PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=<URL TO MY GIT REPO>
PKG_SOURCE_VERSION:=<COMMIT HASH>

HOST_BUILD_DEPENDS:=curl/host
PKG_BUILD_DEPENDS:=curl/host
include $(INCLUDE_DIR)/host-build.mk

CONFIGURE_ARGS += --recursive

include $(INCLUDE_DIR)/package.mk

define Package/azure
    SECTION:=utils
    CATEGORY:=Network
    DEPENDS:+=curl
    TITLE:=<MY TITLE>
endef

define Package/azure/description
 <DESCRIPTION>
endef

# Use CMake for building the git repo.
define Build/Compile
    #!/bin/sh
    mkdir $(PKG_BUILD_DIR)/build
    pushd $(PKG_BUILD_DIR)/build
    cmake ..
    make
    popd
endef

define Package/azure/install
    $(INSTALL_DIR) $(1)/usr/bin
    $(INSTALL_BIN) $(PKG_BUILD_DIR)/azure $(1)/usr/bin/azure
endef

$(eval $(call BuildPackage,azure)) # <-- Line 44, the line that generates the error.

I presume that it has to do with this. Since I use Open WRT and not really Make the way it's intended to be used, I don't know how properly rewrite the code. Could someone help me with this? Many thanks in advance :)


Solution

  • Found the solution to my problem!

    A few things went wrong:

    1. There is a difference between curl and libcurl. Should have been using libcurl instead.
    2. PKG_BUILD_DIR is not defined. It is easier to get the source files in advance, instead of using git in the Makefile. When the source files are cloned or copied, it is clear what the PKG_BUILD_DIR will be.

    I completely rewrote the Makefile and added a define Build/Configure section. I assume that the tools for (cross-)compiling and linking should have been defined in this section in order to start a compiling process. For example, a definition for the CXX compiler would be:

    CXX="$(TOOLCHAIN_DIR)/bin/$(TARGET_CROSS)g++"

    Another thing of good practice would be to define directories with absolute paths instead of using relative ones.