基于openwrt添加自己的应用程序
接着上一篇,搭建好了环境以后:第一步下载源码后编译(源码存放的路径不能包含中文):openwrt_widore源码结构ubuntu@ubuntu:~/Desktop/openwrt_widora$ makemake[1] worldmake[2] target/compilemake[3] -C target/linux compilemake[2]...
接着上一篇,搭建好了环境以后:
第一步下载源码后编译(源码存放的路径不能包含中文):
ubuntu@ubuntu:~/Desktop/openwrt_widora$ make
make[1] world
make[2] target/compile
make[3] -C target/linux compile
make[2] package/cleanup
make[2] package/compile
make[3] -C package/libs/toolchain compile
make[3] -C package/LetThink compile
make[3] -C package/libs/libnl-tiny compile
make[3] -C package/libs/libjson-c compile
make[3] -C package/utils/lua compile
make[3] -C package/libs/libubox compile
make[3] -C package/system/ubus compile
make[3] -C package/system/uci compile
make[3] -C package/network/config/netifd compile
make[3] -C package/system/opkg host-compile
make[3] -C package/system/ubox compile
make[3] -C package/libs/lzo compile
make[3] -C package/libs/zlib compile
make[3] -C package/libs/ncurses host-compile
make[3] -C package/libs/ncurses compile
make[3] -C package/utils/util-linux compile
make[3] -C package/utils/ubi-utils compile
make[3] -C package/system/procd compile
make[3] -C package/system/usign host-compile
make[3] -C package/utils/jsonfilter compile
make[3] -C package/system/usign compile
make[3] -C package/base-files compile
make[3] -C package/system/fstools compile
make[3] -C package/boot/uboot-envtools compile
make[3] -C package/kernel/gpio-button-hotplug compile
make[3] -C package/firmware/linux-firmware compile
make[3] -C package/kernel/linux compile
make[3] -C package/libs/polarssl compile
make[3] -C package/network/utils/iptables compile
make[3] -C package/network/config/firewall compile
make[3] -C package/network/config/swconfig compile
make[3] -C package/network/ipv6/odhcp6c compile
make[3] -C package/network/services/dnsmasq compile
make[3] -C package/network/services/dropbear compile
make[3] -C package/libs/ocf-crypto-headers compile
make[3] -C package/libs/openssl compile
make[3] -C package/network/services/hostapd compile
make[3] -C package/network/services/odhcpd compile
make[3] -C package/libs/libpcap compile
make[3] -C package/network/utils/linux-atm compile
make[3] -C package/network/utils/resolveip compile
make[3] -C package/network/services/ppp compile
make[3] -C package/network/utils/curl compile
make[3] -C package/network/utils/iwinfo compile
make[3] -C package/system/mtd compile
make[3] -C package/system/opkg compile
make[3] -C package/utils/busybox compile
make[2] package/install
make[3] package/preconfig
make[2] target/install
make[3] -C target/linux install
make[2] package/index
ubuntu@ubuntu:~/Desktop/openwrt_widora$
编译通过,证明自己搭建的开发环境Ok.
第二步:在/openwrt_widora/package/ 目录中添加加自己的应用程序代码:首先建立自己的项目工程文件夹:LetThink,在其中再添加自己的源文件目录src以及在/home/ubuntu/Desktop/openwrt_widora/package/LetThink/Makefile中编写烧入到openwrt中的规则:
src目录:
Makefile编写规则:
include $(TOPDIR)/rules.mk
PKG_NAME:=LetThink
PKG_RELEASE:=1
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
include $(INCLUDE_DIR)/package.mk
define Package/LetThink
SECTION:=utils
CATEGORY:=Utilities
TITLE:=LetThink -- prints a snarky message
endef
define Package/LetThink/description
It's my first package demo.
endef
define Build/Prepare
echo "Here is Package/Prepare"
mkdir -p $(PKG_BUILD_DIR)
$(CP) -rf ./src/* $(PKG_BUILD_DIR)/
endef
define Build/Compile
$(TARGET_CC) $(TARGET_CFLAGS) -fprofile-generate -o $(PKG_BUILD_DIR)/LetThink $(PKG_BUILD_DIR)/source/*.c -I$(PKG_BUILD_DIR)/include/
endef
define Package/LetThink/install
echo "Here is Package/install"
$(INSTALL_DIR) $(1)/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/LetThink $(1)/bin/
endef
$(eval $(call BuildPackage,LetThink))
添加自己的应用程序包,并编译 make V=s:
编译成功后,在/home/ubuntu/Desktop/openwrt_widora/bin/ramips/packages/base/ 发现生成的LetThink_1_ramips_24kec.ipk,以及/home/ubuntu/Desktop/openwrt_widora/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/生成的LetThink目录。
将生成的ipk包以及LetThink可执行用WinScp上传到OpenWrt路由器中:执行验证 opkg install LetThink_1_ramips_24kec.ipk或者直接运行可执行 ./ LetThink.
验证通过!!!
更多推荐
所有评论(0)