主页 > 路由器 > 交叉编译nginx for arm 版本

交叉编译nginx for arm 版本

2017年11月5日 交叉编译nginx for arm 版本无评论 阅读: 19,345 次

1、下载源码
先新建一个目录ss:
mkdir ss
全路径为/home/yushi/ss/

然后进入ss目录,下载源码
nginx依赖两个库zlib、pcre
wget https://downloads.sourceforge.net/project/libpng/zlib/1.2.11/zlib-1.2.11.tar.gz
tar zxvf zlib-1.2.11.tar.gz

wget http://ftp.cs.stanford.edu/pub/exim/pcre/pcre-8.39.tar.gz
tar zxvf pcre-8.39.tar.gz

wget http://nginx.org/download/nginx-1.6.2.tar.gz
tar xvf nginx-1.6.2.tar.gz
mkdir nginx

2、修改nginx源码
1)auto/cc/conf
case $NGX_CC_NAME in
arm-linux-gcc)
# gcc 2.7.2.3, 2.8.1, 2.95.4, egcs-1.1.2
# 3.0.4, 3.1.1, 3.2.3, 3.3.2, 3.3.3, 3.3.4, 3.4.0, 3.4.2
# 4.0.0, 4.0.1, 4.1.0

2)auto/types/sizeof
checking for $ngx_type size

END

ngx_size=4

。。。

#ngx_test="$CC $CC_TEST_FLAGS $CC_AUX_FLAGS \
ngx_test="gcc $CC_TEST_FLAGS $CC_AUX_FLAGS \

-o $NGX_AUTOTEST $NGX_AUTOTEST.c $NGX_LD_OPT $ngx_feature_libs"

#eval "$ngx_test >> $NGX_AUTOCONF_ERR 2>&1"

#if [ -x $NGX_AUTOTEST ]; then
# ngx_size=`$NGX_AUTOTEST`
# echo " $ngx_size bytes"
#fi

3)auto/feature
# /bin/sh is used to intercept "Killed" or "Abort trap" messages
#if /bin/sh -c $NGX_AUTOTEST >> $NGX_AUTOCONF_ERR 2>&1; then
echo " found"
ngx_found=yes

if test -n "$ngx_feature_name"; then
have=$ngx_have_feature . auto/have
fi

# else
# echo " found but is not working"
# fi

4)configure
if test -z "$NGX_PLATFORM"; then
echo "checking for OS"

#NGX_SYSTEM=`uname -s 2>/dev/null`
#NGX_RELEASE=`uname -r 2>/dev/null`
#NGX_MACHINE=`uname -m 2>/dev/null`

5)src/os/unix/ngx_time.h
#include
#include
#include
6)src/os/unix/ngx_errno.h
#define NGX_ELOOP ELOOP
#define NGX_EBADF EBADF
#define NGX_SYS_NERR 1
7)auto/lib/pcre/make
$PCRE/Makefile: $NGX_MAKEFILE
cd $PCRE \\
&& if [ -f Makefile ]; then \$(MAKE) distclean; fi \\
&& CC="\$(CC)" CFLAGS="$PCRE_OPT" \\
./configure --disable-shared $PCRE_CONF_OPT --host=arm-uclibc-linux

3、配置环境变量
用华硕的工具编译
export PATH=$PATH:/opt/ac1200g/asuswrt/release/src-rt-9.x/src/toolchains/hndtools-arm-linux-2.6.36-uclibc-4.5.3/bin
export STAGING_DIR=/opt/ac1200g/asuswrt/release/src-rt-9.x/src/toolchains/hndtools-arm-linux-2.6.36-uclibc-4.5.3
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/opt/ac1200g/asuswrt/release/src-rt-9.x/src/toolchains/hndtools-arm-linux-2.6.36-uclibc-4.5.3/lib
export CC=arm-uclibc-linux-2.6.36-gcc
export CXX=arm-uclibc-linux-2.6.36-g++
export AR=arm-uclibc-linux-2.6.36-ar
export RANLIB=arm-uclibc-linux-2.6.36-ranlib
export NGX_SYSTEM=linux
export NGX_RELEASE=3.2-XT6
export NGX_MACHINE=arm

4、编译
./configure --with-zlib=/home/yushi/ss/zlib-1.2.11 --with-pcre=/home/yushi/ss/pcre-8.39 --prefix=/home/yushi/ss/nginx
make && make install

发表评论

新用户的评论需审核后才会显示;

电子邮件地址不会被公开;
必填项已用*标注