关闭

MAC OSX 10.10 Yosemite 下编译 OP_TEE

1838人阅读 评论(2) 收藏 举报
分类:

0. 安装一些必备文件


brew install libelf gnu-sed binutils(解决readelf)

将sed、find、readlink、xargs、readelf分别链接到g开头的同名文件


1. 下载源码


repo init -u https://github.com/OP-TEE/manifest.git -m default.xml -b master

repo sync


2. 修改toolchains


gcc-linaro-arm-linux-gnueabihf-2014.05_mac.pkg会将toolchain安装到

/usr/local/linaro/arm-linux-gnueabihf


因此,需要:

sudo ln -s /usr/local/linaro/arm-linux-gnueabihf ~/works/optee/toolchains/aarch32


3. 修改build/toolchain.mk


ROOT                            ?= ${HOME}/works/optee


4. 解决一系列错误

4.1 'elf.h' 等一系列文件找不到

参照http://stackoverflow.com/questions/10018764/building-linux-kernel-on-mac-os-x


First you'll need the following files to cross-compile a kernel on an OS X box (copy them from your known-working Linux VM to your local /usr/include):

/usr/include/elf.h

/usr/include/features.h

/usr/include/stdc-predef.h

/usr/include/bits/*.h

/usr/include/gnu/*.h

/usr/include/byteswap.h

/usr/include/error.h


Next you'll need malloc.h to be in the expected location for a Linux system, so do:

sudo ln -s /usr/include/malloc/malloc.h /usr/include/malloc.h


4.2 

/usr/include/i386/_types.h:46:20: error: typedef redefinition with different types ('long long' vs 'long')

typedef long long               __int64_t;

                                ^

/usr/include/bits/types.h:43:25: note: previous definition is here

typedef signed long int __int64_t;

解决:

sudo rm /usr/include/bits/types.h

sudo ln -s /usr/include/i386/_types.h /usr/include/bits/types.h


4.3 

Undefined symbols for architecture x86_64:

  "_error", referenced from:

      _main in vdsomunge-a7211f.o

  "_error_message_count", referenced from:

      _cleanup in vdsomunge-a7211f.o

ld: symbol(s) not found for architecture x86_64


参照:https://www.assembla.com/spaces/phylogenetic-likelihood-library/messages/2592013


… had to "remove that #include <error.h> and also remove the error (...) call in …

… quick look on google suggests that this is what people do on MacOSX for error.h …


我的处理,将原来从ubuntu拷贝过来的error.h中的内容修改:

#define error(__status, __errnum, __format, ...)

//     __attribute__ ((__format__ (__printf__, 3, 4)));


#define error_at_line(__status, __errnum, __fname, \

  __lineno, __format, ...)

//     __attribute__ ((__format__ (__printf__, 5, 6)));


/* If NULL, error will flush stdout, then print on stderr the program

   name, a colon and a space.  Otherwise, error will call this

   function without parameters instead.  */

#define error_print_progname


/* This variable is incremented each time `error' is called.  */

int error_message_count = 0;


/* Sometimes we want to have at most one error per line.  This

   variable controls whether this mode is selected or not.  */

int error_one_per_line = 0;


4.4 解决 MAP_ANON 错误

util/oslib-posix.c:132:22: error: use of undeclared identifier 'MAP_ANON'

                     MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);

                     ^

/Users/manfeel/works/optee/qemu/include/qemu-common.h:61:23: note: expanded from macro 'MAP_ANONYMOUS'

#define MAP_ANONYMOUS MAP_ANON


实际上MAP_ANON是定义在/usr/include/sys/mman.h中的

#define MAP_ANON        0x1000  /* allocated from memory, swap space */

不知为何出错!

只好修改qemu-common.h中为:

#define MAP_ANONYMOUS 0x1000


4.5 util/qemu-openpty.c:39:11: fatal error: 'pty.h' file not found

# include <pty.h>


这个问题由如下包含关系导致:

  CC    util/qemu-openpty.o

In file included from util/qemu-openpty.c:36:

In file included from /Users/manfeel/works/optee/qemu/include/qemu-common.h:120:

In file included from /Users/manfeel/works/optee/qemu/include/qemu/bswap.h:17:

In file included from /usr/include/byteswap.h:21:

/usr/include/features.h:388:10: fatal error: 'gnu/stubs.h' file not found

#include <gnu/stubs.h>


因为gnu目录是从linux拷贝,可能和mac系统冲突了


看来4.4的问题也应该和此有关。


原来问题在configure中(生成config-host.mak),如果存在/usr/include/features.h

则会在config-host.mak中添加 CONFIG_BYTESWAP_H=y

实际上,OSX(DARWIN)是不需要这个配置的。

找到3513行,修改为:

# Search for bswap_32 function

byteswap_h=no

# add by Manfeel for DARWIN

if test "$darwin" != "yes"; then

cat > $TMPC << EOF

#include <byteswap.h>

int main(void) { return bswap_32(0); }

EOF

if compile_prog "" "" ; then

  byteswap_h=yes

fi

fi



5. 最后,进入build目录

make all

你就可以在mac下愉快的和optee玩耍了,最后还有一个关于gnome-terminal的小问题,留给聪明的读者朋友去解决吧。

###


1
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:339880次
    • 积分:4036
    • 等级:
    • 排名:第8468名
    • 原创:58篇
    • 转载:19篇
    • 译文:0篇
    • 评论:146条
    联系方式
    本博客所有标头为"原"的内容均为博主原创. 版权所有,严禁抄袭! 转载请保留出处,或联系QQ:179813134
    文章分类
    最新评论