The following is the <openwrt root directory>/feeds/packages/utils/helloworld/Makefile for my helloworld package:
include $(TOPDIR)/rules.mk
PKG_NAME:=helloworld
PKG_VERSION:=1.0.0
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
include $(INCLUDE_DIR)/package.mk
define Package/$(PKG_NAME)
SECTION:=utils
CATEGORY:=Utilities
TITLE:=$(PKG_NAME)
MAINTAINER:=Mazilo <myEmail.add>
endef
define Package/$(PKG_NAME)/description
This is a hello world package that contains a program to only print "hello world".
endef
CONFIGURE_VARS+= \
CC="$(TOOLCHAIN_DIR)/bin/$(TARGET_CC)"
define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/usr/bin
$(CP) $(PKG_BUILD_DIR)/$(PKG_NAME) $(1)/usr/bin
endef
$(eval $(call BuildPackage,$(PKG_NAME)))
My helloword-1.0.0.tar.xz file contains only two files, namely Makefile and helloworld.c as shown below:
[mazilo@Mi:/opt/openwrt-svn-trunk 460%] ~ tar -Jvtf dl/helloworld-1.0.0.tar.xz
drwxr-xr-x mazilo/users 0 2013-04-26 19:01 helloworld-1.0.0/
-rw-r--r-- mazilo/users 158 2013-04-26 19:01 helloworld-1.0.0/Makefile
-rw-r--r-- mazilo/users 75 2013-04-26 18:37 helloworld-1.0.0/helloworld.c
[mazilo@Mi:/opt/openwrt-svn-trunk 461%] ~
The Makefile from the helloworld-1.0.0.tar.xz file is as follows:
helloworld: helloworld.o
$(CC) $(LDFLAGS) helloworld.o -o helloworld
helloworld.o: helloworld.c
$(CC) $(CFLAGS) -c helloworld.c
clean:
rm *.o helloworld
while the helloworld.c is as follows:
#include <stdio.h>
int main(void)
{
printf("Hello World\n");
return 0;
}
You can create the helloworld-1.0.0.tar.xz package as follows:
Create a directory called helloword-1.0.0
Inside the helloworld-1.0.0 directory, create both the Makefile and helloworld.c files
Use tar utility to package the helloworld-1.0.0 subdirectory, i.e. tar -Jcf helloworld-1.0.0.tar.xz helloworld-1.0.0
Move the helloworld-1.0.0.tar.xz file to your OpenWRT download directory
To compile the helloworld package, do as follows:
Run scripts/feeds install helloworld (suggested below by salutuj)
Run make menuconfig
Go to Utilities sub menu and enable helloworld package
< Exit > and < Exit .> to save the changes.
Now, just run make package/helloworld/compile to compile helloworld package (thanks jow for the correction)
(Last edited by mazilo on 18 Feb 2014, 04:52)