bfin-xxx-gcc中multilib.h的生成

快乐虾

http://blog.csdn.net/lights_joy/

[email protected]

   

 

本文适用于

gcc- 4.3.1

Blackfin系列DSP

Visual Studio 2005

   

欢迎转载,但请保留作者信息

 

 

1.1.1.1             Makefile的生成方式

Makefile.in中有这样一段:

# Use the genmultilib shell script to generate the information the gcc

# driver program needs to select the library directory based on the

# switches.

multilib.h: s-mlib; @true

s-mlib: $(srcdir)/genmultilib Makefile

     if test @enable_multilib@ = yes /

        || test -n "$(MULTILIB_OSDIRNAMES)"; then /

       $(SHELL) $(srcdir)/genmultilib /

         "$(MULTILIB_OPTIONS)" /

         "$(MULTILIB_DIRNAMES)" /

         "$(MULTILIB_MATCHES)" /

         "$(MULTILIB_EXCEPTIONS)" /

         "$(MULTILIB_EXTRA_OPTS)" /

         "$(MULTILIB_EXCLUSIONS)" /

         "$(MULTILIB_OSDIRNAMES)" /

         "@enable_multilib@" /

         > tmp-mlib.h; /

     else /

       $(SHELL) $(srcdir)/genmultilib '' '' '' '' '' '' '' no /

         > tmp-mlib.h; /

     fi

     $(SHELL) $(srcdir)/../move-if-change tmp-mlib.h multilib.h

     $(STAMP) s-mlib

也就是说,这个文件是由genmultilib这个脚本文件生成的。

1.1.1.2             变量来源

Makefile.in中涉及到几个变量:

第一个是@enable_multilib@,这个变量将由config.status进行替换。查下替换的内容:

s,@enable_multilib@,$enable_multilib,;t t

即它将用$enable_multilib这个在configure脚本中出现的变量进行替换。而在configure中还有这样一段:

# Determine whether or not multilibs are enabled.

# Check whether --enable-multilib or --disable-multilib was given.

if test "${enable_multilib+set}" = set; then

  enableval="$enable_multilib"

 

else

  enable_multilib=yes

fi;

因而在默认配置下这个变量的取值将为yes

接下来是$ MULTILIB_OPTIONS这几个变量,找一下,可以发现在config/bfin/t-bfin-uclinux这个文件中有它们的定义。

MULTILIB_OPTIONS=mcpu=bf532-none/mcpu=bf532-0.3

MULTILIB_OPTIONS+=mid-shared-library/msep-data mleaf-id-shared-library

MULTILIB_DIRNAMES=bf532-none bf532-0.3 mid-shared-library msep-data mleaf-id-shared-library

MULTILIB_MATCHES=mcpu?bf532-none=mcpu?bf561

MULTILIB_MATCHES+=mcpu?bf532-none=mcpu?bf531-none mcpu?bf532-none=mcpu?bf533-none mcpu?bf532-none=mcpu?bf534-none mcpu?bf532-none=mcpu?bf536-none mcpu?bf532-none=mcpu?bf537-none mcpu?bf532-none=mcpu?bf561-none mcpu?bf532-none=mcpu?bf561-0.5

MULTILIB_MATCHES+=mcpu?bf532-0.3=mcpu?bf531-0.4 mcpu?bf532-0.3=mcpu?bf531-0.3 mcpu?bf532-0.3=mcpu?bf532-0.4 mcpu?bf532-0.3=mcpu?bf533-0.4 mcpu?bf532-0.3=mcpu?bf533-0.3 mcpu?bf532-0.3=mcpu?bf534-0.2 mcpu?bf532-0.3=mcpu?bf534-0.1 mcpu?bf532-0.3=mcpu?bf536-0.2 mcpu?bf532-0.3=mcpu?bf536-0.1 mcpu?bf532-0.3=mcpu?bf537-0.2 mcpu?bf532-0.3=mcpu?bf537-0.1 mcpu?bf532-0.3=mcpu?bf561-0.3 mcpu?bf532-0.3=mcpu?bf561-0.2 mcpu?bf532-0.3=mcpu?bf531-any mcpu?bf532-0.3=mcpu?bf532-any mcpu?bf532-0.3=mcpu?bf533-any mcpu?bf532-0.3=mcpu?bf534-any mcpu?bf532-0.3=mcpu?bf536-any mcpu?bf532-0.3=mcpu?bf537-any mcpu?bf532-0.3=mcpu?bf561-any

MULTILIB_EXCEPTIONS=mleaf-id-shared-library*

MULTILIB_EXCEPTIONS+=mcpu=bf532-0.3/mleaf-id-shared-library*

MULTILIB_EXCEPTIONS+=mcpu=bf532-none/mleaf-id-shared-library*

MULTILIB_EXCEPTIONS+=*msep-data/mleaf-id-shared-library*

那么,t-bfin-uclinux这个文件又用在什么地方呢?在config.gcc中有这样的用法:

bfin*-uclinux*)

     tm_file="${tm_file} dbxelf.h elfos.h bfin/elf.h linux.h bfin/uclinux.h"

     tmake_file=bfin/t-bfin-uclinux

     tm_defines="${tm_defines} UCLIBC_DEFAULT=1"

     extra_options="${extra_options} linux.opt"

     use_collect2=no

     ;;

而我们知道config.gcc这个脚本是在configure脚本中调用的,用于与target相关的一些配置。再查找tmake_file,在configure脚本中有这样的语句:

tmake_file_=

for f in ${tmake_file}

do

     if test -f ${srcdir}/config/$f

     then

         tmake_file_="${tmake_file_} /$(srcdir)/config/$f"

     fi

done

tmake_file="${tmake_file_}"

…………..

s,@tmake_file@,$tmake_file,;t t

即它将Makefile.in中的@tmake_file@变量替换为bfin/t-bfin-uclinux

Makefile.in中就有这样的一行:

tmake_file=@tmake_file@

# target overrides

ifneq ($(tmake_file),)

include $(tmake_file)

endif

原来如此。

config.gcc还可以知道,如果我们的目标是生成bfin-elf-gcc,那么它包含的将是config/bfin/t-bfin-elf这个文件。

1.1.1.3             genmultilib脚本

下面再看看genmultilib这个脚本的输出,以bfin-uclinux-gcc的目标为例:

第一个参数是$MULTILIB_OPTIONS,它的值为:

mcpu=bf532-none/mcpu=bf532-0.3 mid-shared-library/msep-data mleaf-id-shared-library

第二个参数$ MULTILIB_DIRNAMES的值为:

bf532-none bf532-0.3 mid-shared-library msep-data mleaf-id-shared-library

第三个参数$ MULTILIB_MATCHES的值为:

mcpu?bf532-none=mcpu?bf561 mcpu?bf532-none=mcpu?bf531-none mcpu?bf532-none=mcpu?bf533-none mcpu?bf532-none=mcpu?bf534-none mcpu?bf532-none=mcpu?bf536-none mcpu?bf532-none=mcpu?bf537-none mcpu?bf532-none=mcpu?bf561-none mcpu?bf532-none=mcpu?bf561-0.5 mcpu?bf532-0.3=mcpu?bf531-0.4 mcpu?bf532-0.3=mcpu?bf531-0.3 mcpu?bf532-0.3=mcpu?bf532-0.4 mcpu?bf532-0.3=mcpu?bf533-0.4 mcpu?bf532-0.3=mcpu?bf533-0.3 mcpu?bf532-0.3=mcpu?bf534-0.2 mcpu?bf532-0.3=mcpu?bf534-0.1 mcpu?bf532-0.3=mcpu?bf536-0.2 mcpu?bf532-0.3=mcpu?bf536-0.1 mcpu?bf532-0.3=mcpu?bf537-0.2 mcpu?bf532-0.3=mcpu?bf537-0.1 mcpu?bf532-0.3=mcpu?bf561-0.3 mcpu?bf532-0.3=mcpu?bf561-0.2 mcpu?bf532-0.3=mcpu?bf531-any mcpu?bf532-0.3=mcpu?bf532-any mcpu?bf532-0.3=mcpu?bf533-any mcpu?bf532-0.3=mcpu?bf534-any mcpu?bf532-0.3=mcpu?bf536-any mcpu?bf532-0.3=mcpu?bf537-any mcpu?bf532-0.3=mcpu?bf561-any

第四个参数$ MULTILIB_EXCEPTIONS的值为:

mleaf-id-shared-library* mcpu=bf532-0.3/mleaf-id-shared-library* mcpu=bf532-none/mleaf-id-shared-library* *msep-data/mleaf-id-shared-library*

第五个参数$MULTILIB_EXTRA_OPTS为空字符串。

第六个参数$ MULTILIB_EXCLUSIONS为空字符串。

第七个参数$ MULTILIB_OSDIRNAMES为空字符串。

第八个参数@enable_multilib@”yes”

最后生成的multilib.h如下:

static const char *const multilib_raw[] = {

". !mcpu=bf532-none !mcpu=bf532-0.3 !mid-shared-library !msep-data !mleaf-id-shared-library;",

"bf532-none mcpu=bf532-none !mcpu=bf532-0.3 !mid-shared-library !msep-data !mleaf-id-shared-library;",

"bf532-0.3 !mcpu=bf532-none mcpu=bf532-0.3 !mid-shared-library !msep-data !mleaf-id-shared-library;",

"mid-shared-library !mcpu=bf532-none !mcpu=bf532-0.3 mid-shared-library !msep-data !mleaf-id-shared-library;",

"msep-data !mcpu=bf532-none !mcpu=bf532-0.3 !mid-shared-library msep-data !mleaf-id-shared-library;",

"mid-shared-library/mleaf-id-shared-library !mcpu=bf532-none !mcpu=bf532-0.3 mid-shared-library !msep-data mleaf-id-shared-library;",

"bf532-none/mid-shared-library mcpu=bf532-none !mcpu=bf532-0.3 mid-shared-library !msep-data !mleaf-id-shared-library;",

"bf532-none/msep-data mcpu=bf532-none !mcpu=bf532-0.3 !mid-shared-library msep-data !mleaf-id-shared-library;",

"bf532-none/mid-shared-library/mleaf-id-shared-library mcpu=bf532-none !mcpu=bf532-0.3 mid-shared-library !msep-data mleaf-id-shared-library;",

"bf532-0.3/mid-shared-library !mcpu=bf532-none mcpu=bf532-0.3 mid-shared-library !msep-data !mleaf-id-shared-library;",

"bf532-0.3/msep-data !mcpu=bf532-none mcpu=bf532-0.3 !mid-shared-library msep-data !mleaf-id-shared-library;",

"bf532-0.3/mid-shared-library/mleaf-id-shared-library !mcpu=bf532-none mcpu=bf532-0.3 mid-shared-library !msep-data mleaf-id-shared-library;",

NULL

};

 

static const char *const multilib_matches_raw[] = {

"mcpu=bf561 mcpu=bf532-none;",

"mcpu=bf531-none mcpu=bf532-none;",

"mcpu=bf533-none mcpu=bf532-none;",

"mcpu=bf534-none mcpu=bf532-none;",

"mcpu=bf536-none mcpu=bf532-none;",

"mcpu=bf537-none mcpu=bf532-none;",

"mcpu=bf561-none mcpu=bf532-none;",

"mcpu=bf561-0.5 mcpu=bf532-none;",

"mcpu=bf531-0.4 mcpu=bf532-0.3;",

"mcpu=bf531-0.3 mcpu=bf532-0.3;",

"mcpu=bf532-0.4 mcpu=bf532-0.3;",

"mcpu=bf533-0.4 mcpu=bf532-0.3;",

"mcpu=bf533-0.3 mcpu=bf532-0.3;",

"mcpu=bf534-0.2 mcpu=bf532-0.3;",

"mcpu=bf534-0.1 mcpu=bf532-0.3;",

"mcpu=bf536-0.2 mcpu=bf532-0.3;",

"mcpu=bf536-0.1 mcpu=bf532-0.3;",

"mcpu=bf537-0.2 mcpu=bf532-0.3;",

"mcpu=bf537-0.1 mcpu=bf532-0.3;",

"mcpu=bf561-0.3 mcpu=bf532-0.3;",

"mcpu=bf561-0.2 mcpu=bf532-0.3;",

"mcpu=bf531-any mcpu=bf532-0.3;",

"mcpu=bf532-any mcpu=bf532-0.3;",

"mcpu=bf533-any mcpu=bf532-0.3;",

"mcpu=bf534-any mcpu=bf532-0.3;",

"mcpu=bf536-any mcpu=bf532-0.3;",

"mcpu=bf537-any mcpu=bf532-0.3;",

"mcpu=bf561-any mcpu=bf532-0.3;",

"mcpu=bf532-none mcpu=bf532-none;",

"mcpu=bf532-0.3 mcpu=bf532-0.3;",

"mid-shared-library mid-shared-library;",

"msep-data msep-data;",

"mleaf-id-shared-library mleaf-id-shared-library;",

NULL

};

 

static const char *multilib_extra = "";

 

static const char *const multilib_exclusions_raw[] = {

NULL

};

 

static const char *multilib_options = "mcpu=bf532-none/mcpu=bf532-0.3 mid-shared-library/msep-data mleaf-id-shared-library";

 

 

参考资料

无心插柳-在vs2005中编译GCC4( 2008-1-13 )

gcc交叉编译的实现( 2008-1-25 )

vs2005下编译gcc:工程文件( 2008-1-30 )

asm_out_filegcc编代码的生成( 2008-1-30 )

gcc4.1中的machine_mode( 2008-2-1 )

gcc 4.3 configure脚本学习(1):前言( 2008-4-23 )

gcc 4.3 configure脚本学习(2):Be Bourne compatible( 2008-4-24 )

gcc 4.3 configure脚本学习(3):NLS nuisances( 2008-4-24 )

bfin-gcc-4.3.1config.h的生成( 2008-8-5 )

bfin-xxx-gcc-4.3.1config.status的生成及运行(1):输出注释( 2008-8-5 )

bfin-xxx-gcc-4.3.1config.status的生成及运行(2):Shell检测( 2008-8-5 )

bfin-xxx-gcc-4.3.1config.status的生成及运行(3):文件配置( 2008-8-6 )

bfin-xxx-gcc-4.3.1config.status的生成及运行(4):帮助信息输出( 2008-8-6 )

bfin-xxx-gcc-4.3.1config.status的生成及运行(5):参数判断( 2008-8-6 )

bfin-xxx-gcc-4.3.1config.status的生成及运行(6):子目录获取( 2008-8-6 )

bfin-xxx-gcc-4.3.1config.status的生成及运行(7):创建临时目录( 2008-8-6 )

bfin-xxx-gcc-4.3.1config.status的生成及运行(8):配置文件生成( 2008-8-6 )

bfin-xxx-gcc-4.3.1config.status的生成及运行(9):头文件生成( 2008-8-6 )

 

 

 

 

 

 

 

你可能感兴趣的:(shell,脚本,File,gcc,null,makefile)