I'm a beginner on OpenWrt and Makefiles, I'm following the helloworld example of creating package for OpenWrt. But I really stuck on something. I've tried it with both building from source and pre-compiled SDK. I've made the simple Makefile, when I get to the step of feeding my package with ./scripts/feeds update mypackages
command it threw an error like
Updating feed 'mypackages' from '/home/onur/Desktop/OpenWrt_SDK/mypackages' ...
Create index file './feeds/mypackages.index'
grep: feeds/mypackages/Makefile:$(eval: No such file or directory
grep: $(call: No such file or directory
grep: BuildPackage,helloworld))/Makefile: No such file or directory
/home/onur/Desktop/OpenWrt_SDK/openwrt-sdk-19.07.7-ath79-generic_gcc-7.5.0_musl.Linux-x86_64/feeds/mypackages.tmp/info/.files-packageinfo.mk:1: *** target pattern contains no '%'. Stop.
Collecting target info: done
When I tried to make
my Makefile I noticed it couldn't find any include files, then I exported the TOPDIR variable like that in my Makefile:
export TOPDIR:=/home/onur/Desktop/OpenWrt_SDK/openwrt-sdk-19.07.7-ath79-generic_gcc-7.5.0_musl.Linux-x86_64
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)
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_SDK/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
$(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
# 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))
But that didn't work. I've come across on the Internet that error of .files-packageinfo.mk:1: *** target pattern contains no '%'. Stop.
but I couldn't find any answer.
Also my directory tree is like; root directory
/home/onur/Desktop/OpenWrt_SDK/openwrt-sdk-19.07.7-ath79-generic_gcc-7.5.0_musl.Linux-x86_64
package directory is
/home/onur/Desktop/OpenWrt_SDK/mypackages
and the code directory
/home/onur/Desktop/OpenWrt_SDK/helloworld
Please help me it's important for my work.