freebsd平台编译openwrt

来源:互联网 发布:沟通软件 编辑:程序博客网 时间:2024/05/16 15:26

最开始接触的是linux,用一叠软盘装salckware,当时一盒软盘10个,要用十几个软盘。后来用过一段时间sun工作站,还用solaris9维护过一个小型局域网。

现在的ubuntu版本linux感觉隐藏的细节太多了,还是更喜欢简单的方式。相对于systemv的风格,更喜欢bsd风格。

freebsdlinux在系统头文件定义和系统调用方面有些区别,在freebsd平台编译为linux平台准备的openwrt有很多地方需要修改。本文以frebsd10.1 amd64为例,记录编译过程中遇到的问题和解决办法。

1、编译平台freebsd10.1csh

2freebsd默认编译器为llvm,需要安装gcc编译器,选择gcc4.8

3、安装依赖软件,参考http://wiki.openwrt.org/doc/howto/buildroot.exigence,很多软件和gentoolinux名称差不多,gentoo的作者和freebsd渊源很深的缘故,哈哈。另外可以参考macos x,这个系统和freebsd也有很多相似之处。

4、在用户目录下建立bin-gun目录,在该目录下创建一些链接:

awk@-> /usr/local/bin/gawk

c++@-> /usr/local/bin/g++48

cc@-> /usr/local/bin/gcc48

echo@-> /usr/local/bin/gecho

find@-> /usr/local/bin/gfind

g++@-> /usr/local/bin/g++48

gcc@-> /usr/local/bin/gcc48

getopt@-> /usr/local/bin/getopt

gmake@-> /usr/local/bin/gmake

ld@-> /usr/local/bin/ld

make@-> /usr/local/bin/gmake

od@-> /usr/local/bin/god

patch@-> /usr/local/bin/gpatch

sed@-> /usr/local/bin/gsed

stat@-> /usr/local/bin/gnustat

tail@-> /usr/local/bin/gtail

tar@-> /usr/local/bin/gtar

tr@-> /usr/local/bin/gtr

然后修改path,将bin-gnu设置为第一选择路径。

以上为编译平台的准备。下面是编译过程,以及在编译时遇到的问题的解决。

下载openwrt源码:

gitclone git://git.openwrt.org/openwrt.git

下载安装package源码:

cdopenwrt

./scripts/feedsupdate -a

./scripts/feedsinstall -a

配置安装:

makemenuconfig

make


编译中遇到的软件包的问题:

编译pkg-config0.28

Makefile HOST_CONFIGURE_ARGS选项添加--with-libiconv=gnu,否则内部glibc编译时会出错。


编译xz-5.0.5

出现swap3264未定义错误,测试5.0.x版本均有此错误,改为5.1.3alpha版虽可编译测试通过,但依赖其的mtd-utilssquashfs4无法编译。最终改为xz-4.999.9beta


编译cmake3.8.12

参考/usr/ports/devel/cmake/files,增加Source__kwsys__SystemInformation.cxx补丁。

cd/usr/bin

mvld ld.bsd

ln-s /usr/local/bin/ld ld

编译完cmake后改会来,以免影响其他程序。


编译过程中有时会显示找不到/bin/bash而出错退出,需连接:

/bin

ln-s /usr/local/bin/bash bash


编译package/libs/nettle

config.h:206:22:fatal error: alloca.h: No such file or directory

FreeBSD平台没有alloca.halloca定义在stdlib.h中。修改0003-Include-local-macros-in-nettle.m4-to-allow-regenerat.patch,替换之。


编译package/utils/busybox

scripts/basic/fixdep.cdocproc.c

两个文件中

#include<alloca.h>

替换为

#include<stdlib.h>

原因是FreeBSD中相关函数定义在stdlib.h中,

linux定义在alloca.h中。


编译utils/lua

src/Makefilefreebsd编译配置选项多了一个"host/100-no_readline.patch未能正确修改

$(MAKE)all MYCFLAGS="-DLUA_USE_LINUX" $(RFLAG)"MYLIBS="-Wl,-E$(if $(USE_READLINE), -lreadline)"

改为

$(MAKE)all MYCFLAGS="-DLUA_USE_LINUX $(RFLAG)" MYLIBS="-Wl,-E$(if$ (USE_READLINE), -lreadline)"


编译feeds/luci/contrib/package/luci

/usr/local/bin/gtarc -C ../../.. . --exclude=.pc --exclude=.svn --exclude=.git--exclude='*.o' --exclude='*.so' --exclude=dist | tar x -C/usr/home/foo/openwrt_ai-br100_bb/build_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/luci/

/usr/local/bin/gtar:/dev/sa0: Cannot open: Operation not supported

/usr/local/bin/gtar:Error is not recoverable: exiting now

tar:/dev/sa0: Cannot open: No such file or directory

tar:Error is not recoverable: exiting now

需修改两处文件

feeds/luci/contrib/package/luci/Makefile

feeds/luci/contrib/package/luci-addons/Makefile

$(TAR)c -C $(LUCI_TOPDIR) . \

--exclude=.pc--exclude=.svn --exclude=.git \

--exclude='*.o'--exclude='*.so' \

--exclude=dist| \

tarx -C $(PKG_BUILD_DIR)/

改为

$(TAR)-cf - -C $(LUCI_TOPDIR) . \

--exclude=.pc--exclude=.svn --exclude=.git \

--exclude='*.o'--exclude='*.so' \

--exclude=dist| \

tar-xf - -C $(PKG_BUILD_DIR)/


多出用到/usr/bin/perl,需创建/usr/local/bin/perl到此的连接。


编译feeds/oldpackages/libs/mysql

mysql-5.1.73/include/my_global.h:

#include<alloca.h>替换为#include<stdlib.h>

#include<crypt.h>替换为#include<unistd.h>,注意不是rpcsvc/crypt.h

typedefunsigned long ulong;判断条件注释掉,使该定义有效。

mysql-5.1.73/libmysql/Makefile:

lnsl-network services library

OnFreeBSD, unlike Linux, libnsl functionality is included in libc. Soyou need to remove all references in the makefile to -lnsl.

mysql-5.1.73/libmysql/Makefile-lnsl替换为-lc


编译feeds/oldpackages/libs/cyrus-sasl

cyrus-sasl-2.1.23/include/Makefile-lresolv替换为-lc,原理同编译mysql




0 0
原创粉丝点击