openwrt 添加软件包案例
2015-09-10 10:26
441 查看
添加软件包的方法
1.我的openwrt的源码目录(编译后)为/home/zhangxx/owt/backfire (编译后会多出 /bin /build_dir /dl 三个目录。
自己上网查看这三个目录的用途 附上网址:http://bbs.tawei.com/thread-409-1-1.html)
.
├── bin
├── BSDmakefile
├── build_dir
├── Config.in
├── dl
├── docs
├── feeds
├── feeds.conf.default
├── include
├── LICENSE
├── Makefile
├── Makefile~
├── package
├── README
├── rules.mk
├── scripts
├── staging_dir
├── tags
├── target
├── tmp
├── toolchain
└── tools
2.进入源码的package目录,创建hello目录,进入hello目录,在hello目录下创建src目录和Makefile文件
$ cd /home/zhangxx/owt/package
$ mkdir hello
$ cd hello
$ mkdir src
$ touch Makefile
3.进入src目录,创建hello.c文件和Makefile文件
$ cd hello
$ touch hello.c Makefile
4.分别编写src目录下的hello.c Makefil文件
hello.c 文件
#include <stdio.h>
#include <unistd.h>
int main(void)
{
printf("hello!\n");
return 0;
}
Makefile 文件
hello : hello.o
$(CC) $(LDFLAGS) hello.o -o hello
hello.o : hello.c
$(CC) $(CFLAGS) -c hello.c
clean :
rm *.o hello
5.编写hello下的Makefile文件, 这个Makefile 文件可以参考package下的其他文件夹里面的Makefile,参考资料上网http://bbs.tawei.com/thread-409-1-1.html “OpenWrt增加软件包方法”
Makefile
include $(TOPDIR)/rules.mk
PKG_NAME:=hello
PKG_RELEASE:=1
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
include $(INCLUDE_DIR)/package.mk
define Package/hello
SECTION:=utils
CATEGORY:=Utilities
TITLE:=hello -- prints a snarky mwssage
endef
define Package/hello/description
It's my first package demo.
endef
define Build/Prepare
echo "Here is Package/Prepare"
mkdir -p $(PKG_BUILD_DIR)
$(CP) ./src/* $(PKG_BUILD_DIR)/
endef
define Package/hello/install
echo "Here is Package/install"
$(INSTALL_DIR) $(1)/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/hello$(1)/bin/
endef
$(eval$(call BuildPackage,hello))
6.进入openwrt的源码目录 /home/zhangxx/owt/backfire 然后 make menuconfig 在Utilities可以看到hello的选项
$ cd /home/zhangxx/owt/backfire
$ name menuconfig
选择Utilities --->
< > hello................................... hello -- prints a snarky mwssage
1.我的openwrt的源码目录(编译后)为/home/zhangxx/owt/backfire (编译后会多出 /bin /build_dir /dl 三个目录。
自己上网查看这三个目录的用途 附上网址:http://bbs.tawei.com/thread-409-1-1.html)
.
├── bin
├── BSDmakefile
├── build_dir
├── Config.in
├── dl
├── docs
├── feeds
├── feeds.conf.default
├── include
├── LICENSE
├── Makefile
├── Makefile~
├── package
├── README
├── rules.mk
├── scripts
├── staging_dir
├── tags
├── target
├── tmp
├── toolchain
└── tools
2.进入源码的package目录,创建hello目录,进入hello目录,在hello目录下创建src目录和Makefile文件
$ cd /home/zhangxx/owt/package
$ mkdir hello
$ cd hello
$ mkdir src
$ touch Makefile
3.进入src目录,创建hello.c文件和Makefile文件
$ cd hello
$ touch hello.c Makefile
4.分别编写src目录下的hello.c Makefil文件
hello.c 文件
#include <stdio.h>
#include <unistd.h>
int main(void)
{
printf("hello!\n");
return 0;
}
Makefile 文件
hello : hello.o
$(CC) $(LDFLAGS) hello.o -o hello
hello.o : hello.c
$(CC) $(CFLAGS) -c hello.c
clean :
rm *.o hello
5.编写hello下的Makefile文件, 这个Makefile 文件可以参考package下的其他文件夹里面的Makefile,参考资料上网http://bbs.tawei.com/thread-409-1-1.html “OpenWrt增加软件包方法”
Makefile
include $(TOPDIR)/rules.mk
PKG_NAME:=hello
PKG_RELEASE:=1
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
include $(INCLUDE_DIR)/package.mk
define Package/hello
SECTION:=utils
CATEGORY:=Utilities
TITLE:=hello -- prints a snarky mwssage
endef
define Package/hello/description
It's my first package demo.
endef
define Build/Prepare
echo "Here is Package/Prepare"
mkdir -p $(PKG_BUILD_DIR)
$(CP) ./src/* $(PKG_BUILD_DIR)/
endef
define Package/hello/install
echo "Here is Package/install"
$(INSTALL_DIR) $(1)/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/hello$(1)/bin/
endef
$(eval$(call BuildPackage,hello))
6.进入openwrt的源码目录 /home/zhangxx/owt/backfire 然后 make menuconfig 在Utilities可以看到hello的选项
$ cd /home/zhangxx/owt/backfire
$ name menuconfig
选择Utilities --->
< > hello................................... hello -- prints a snarky mwssage
相关文章推荐
- linux 实训1
- 用xampp启动apache和mysql的问题
- .xyz域名总量TOP10:新网等4家中国域名商上榜
- CentOS6.5下kafka+ZooKeeper下载与安装详细教程-单机版
- 交叉编译zlib和openssl for arm
- 9月8日全球域名商(国际域名)解析量排行榜TOP20
- 腾讯QQ企业邮箱POP3/SMTP设置
- win7系统开机遇到reboot and select proper boot device错误解决方法
- win7系统开机遇到reboot and select proper boot device错误解决方法
- Linux查找find命令详解
- Apache Spark 1.5发布:有哪些变化
- Hadoop学习笔记七之 job.setNumReduceTasks
- xen利用URL的centos镜像文件安装(三)
- android4.4.4睡眠唤醒软件架构
- winxp3IIS网站访问需要输入用户名和密码 .
- Hadoop 实例16-----MultipleOutputs实战:结果输出到多个文件夹或者文件中
- bash
- centos 6.6 下ython 的编译安装和python 编写测试工具Ipython 的编译安装
- Unity3D 之 Shell更新svn出现冲突
- zabbix中通过shell脚本进行微信监控告警