###############################################
#OpenWrt Makefile for easydrcom program
##############################################
include $(TOPDIR)/rules.mk
# Name and release number of this package
PKG_NAME:=easydrcom
PKG_RELEASE:=1
# This specifies the directory where we're going to build the program.
# The root build directory, $(BUILD_DIR), is by default the build_mipsel
# directory in your OpenWrt SDK directory
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
include $(INCLUDE_DIR)/package.mk
# Specify package information for this program.
# The variables defined here should be self explanatory.
# If you are running Kamikaze, delete the DESCRIPTION
# variable below and uncomment the Kamikaze define
# directive for the description below
define Package/$(PKG_NAME)
SECTION:=utils
CATEGORY:=Utilities
DEPENDS:=+libpcap +libpthread +libstdcpp
TITLE:=$(PKG_NAME) -- drcom fro hitwh
endef
# Uncomment portion below for Kamikaze and delete DESCRIPTION variable above
define Package/$(PKG_NAME)/description
free wireless at hitwh.
endef
# Specify what needs to be done to prepare for building the package.
# In our case, we need to copy the source files to the build directory.
# This is NOT the default. The default uses the PKG_SOURCE_URL and the
# PKG_SOURCE which is not defined here to download the source from the web.
# In order to just build a simple program that we have just written, it is
# much easier to do it this way.
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
$(CP) ./src/* $(PKG_BUILD_DIR)/
endef
# We do not need to define Build/Configure or Build/Compile directives
# The defaults are appropriate for compiling a simple program such as this one
# Specify where and how to install the program. Since we only have one file,
# the easydrcom executable, install it by copying it to the /bin directory on
# the router. The $(1) variable represents the root directory on the router running
# OpenWrt. The $(INSTALL_DIR) variable contains a command to prepare the install
# directory if it does not already exist. Likewise $(INSTALL_BIN) contains the
# command to copy the binary file from its current location (in our case the build
# directory) to the install directory.
define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/$(PKG_NAME) $(1)/bin/
endef
# This line executes the necessary commands to compile our program.
# The above define directives specify all the information needed, but this
# line calls BuildPackage which in turn actually uses this information to build a package.
$(eval $(call BuildPackage,$(PKG_NAME)))
“如何在任意刷写了 OpenWrt 的设备上运行 EasyDrcom” 一直是我的一个心病,因为大学期间搞了好多次,搞了好久,时间跨度将近两年也没解决这个问题。不过最近有时间,用了两天时间,终于研究得差不多了。
开发前要搭建 OpenWrt 交叉编译环境,按照网上教程就可以了,就是在 Ubuntu 上安装各种包。然后开始开发:
1.下载对应芯片的 SDK,里面包含了开发一个 OpenWrt 软件包所需要的所有东西。 比如 HG255D 是 rampis 厂家 rt3052 芯片,那么最新版 OpenWrt 对应的 SDK 链接就是 https://archive.openwrt.org/releases/21.02.0/targets/ramips/rt305x/openwrt-sdk-21.02.0-ramips-rt305x_gcc-8.4.0_musl.Linux-x86_64.tar.xz
OpenWrt 前几个版本差异有点大,而且还出了 LEDE 这样一个 fork,所以你路由里用的什么版本的固件,就要使用什么版本的 SDK,不然兼容性可能有问题。比如 21 的 SDK 编译的软件包在 14 的系统下很有可能是跑不了的。
2.解压 SDK,进入文件夹,首先要获取必要的包,运行
./script/feeds update -a
,之后运行./script/feeds install -af
这样就安装了所有的依赖。如果发生问题,要不是时区的问题,要么是梯子的问题,自行解决吧。3.在 package 目录下建立我们自己的包,首先建空文件夹命名为 easydrcom,然后创建一个 Makefile,内容如下:
4.建立src文件夹,将 EasyDrcom 的代码复制进去,链接:https://github.com/coverxit/EasyDrcom/tree/master/EasyDrcom 这里需要修改一下,我们不用 boost,一是太老了,二是编译时候还需要额外引入 boost,没必要这样。
我们使用这个头文件,用一个文件就能解析 init 配置文件:https://github.com/benhoyt/inih
复制 https://github.com/benhoyt/inih/tree/master/cpp 下 INIReader.h 到 src 文件夹里
5.修改 main.cpp 为
6.最后在 src 目录下再建一个 Makefile:
之后就开始编译,首先
make menuconfig
去掉不需要编译的包,然后make package/easydrcom/compile -j8 V=s
八核编译,等一会就好了附件: hg255d.zip