Chinaunix首页 | 论坛 | 博客
  • 博客访问: 442385
  • 博文数量: 185
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 681
  • 用 户 组: 普通用户
  • 注册时间: 2011-08-06 21:45
个人简介

为梦而战

文章分类

全部博文(185)

文章存档

2016年(3)

2015年(103)

2014年(79)

我的朋友

分类: LINUX

2014-05-30 22:24:10

configure文件的解析

 

1.

Sh代码  收藏代码
  1. #!  /bin/sh  

   

    解析: 符号#!用来告诉系统执行该脚本的程序

 

2.#设置分隔符:变量(PATH_SEPARATOR)值

 

Sh代码  收藏代码
  1. if test "X${PATH_SEPARATOR+set}" != Xset; then  
  2.     UNAME=${UNAME-`uname 2>/dev/null`}  
  3.     case X$UNAME in  
  4.         *-DOS) lt_cv_sys_path_separator=';' ;;  
  5.         *)     lt_cv_sys_path_separator=':' ;;  
  6.     esac  
  7.     echo $UNAME  
  8. fi  
 

    解析:

    1) X${PATH_SEPARATOR+set} 意思是如果设置了PATH_SEPARATOR,则用set置换变量,否则不进行置换.

         语法 :变量=${参数+word}:如果设置了参数,则用word置换变量,否则不进行置换.

            代码样例:

Sh代码  收藏代码
  1. t1="ok"  
  2. echo "X${t1+set}"                 # output Xset  
  3. echo "X${t2+set}"                 # output X  
  4. exit 0;  

 

     2) ${UNAME-`uname 2>/dev/null`}         

       

         语法:

         (1) ${UNAME-`uname 2>/dev/null`} 如果设置了UNAME值则用UNAME值置换变量的值,否则用`uname 2>/dev/null`置换.

                 变量=${参数-word} 如果设置了参数的值,则用参数值进行置换,否则用word置换.

         样例:

Sh代码  收藏代码
  1. #!  /bin/sh  
  2. t1="t1value"  
  3. echo ${t1-word}  
  4. echo ${t2-word}  
  5. exit 0;  

         结果:

 

         (2) > /dev/null   就是将标准输出和标准出错的信息屏蔽不显示

              2>/dev/null :表示将命令的错误输出重定向到   /dev/null

              1>/dev/nul l:表示将命令的标准输出重定向到   /dev/null

 

 

3.用于打印帮助信息

 

Sh代码  收藏代码
  1. ac_help=  
  2.   
  3. ac_help="$ac_help  
  4.    440   --with-libdir=NAME      Look for libraries in .../NAME rather than .../lib"  
  5. .  
  6. .  
  7. .  

 

4.指定安装目录

 

Sh代码  收藏代码
  1. ac_default_prefix=/usr/local  

 

5.运行在正确的SHELL终端下

 

Sh代码  收藏代码
  1. SHELL=${CONFIG_SHELL-/bin/sh}  

 

    解析: 如果设置了CONFIG_SHELL则用CONFIG_SHELL,否则用/bin/sh置换变量SHELL.

 

6.定义ECHO

 

Sh代码  收藏代码
  1. case X$ECHO in  
  2. X*--fallback-echo)  
  3.   # Remove one level of quotation (which was required for Make).  
  4.   ECHO=`echo "$ECHO" | sed 's,\\\\\$\\$0,'$0','`  
  5.   ;;  
  6. esac  

 

    解析:

     1) sed 's,\\\\\$\\$0,'$0',' :

     2) $0:表示当前执行的进程名,script 本身的名字,或者在正则表达式中表示整行输出

 

7.输出变量控制

 

Sh代码  收藏代码
  1. echo=${ECHO-echo}  
 

8.shift就是用掉一个位置参数,那么原来的$2就变成现在的$1了

 

9. 指定echo

 

Sh代码  收藏代码
  1. for dir in $PATH /usr/ucb; do  
  2.    IFS="$lt_save_ifs"  
  3.    if (test -f $dir/echo || test -f $dir/echo$ac_exeext) &&  
  4.       test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' &&  
  5.       echo_testing_string=`($dir/echo "$echo_test_string"2>/dev/null` &&  
  6.       test "X$echo_testing_string" = "X$echo_test_string"; then  
  7.      echo="$dir/echo"  
  8.      break  
  9.    fi  
  10.  done  

 

    解析:

    (1) for dir in $PATH /usr/ucb; do :dir的值为$PATH和/usr/ucb

 

 

10.数字具体表示(整个shell中也使用)

 

Sh代码  收藏代码
  1. # File descriptor usage:  
  2. 0 standard input  
  3. 1 file creation  
  4. 2 errors and warnings  
  5. 3 some systems may open it to /dev/tty  
  6. 4 used on the Kubota Titan  
  7. 6 checking for... messages and results  
  8. 5 compiler messages saved in config.log  
  9. if test "$silent" = yes; then  
  10.   exec 6>/dev/null  
  11. else  
  12.   exec 6>&1  
  13. fi  
  14. exec 5>./config.log  
 

 

11.生成文件conftest.$ac_ext —— 用"cat >"方式生成

 

Sh代码  收藏代码
  1. cat > conftest.$ac_ext <
  2. #line 1932 "configure"  
  3. #include "confdefs.h"  
  4.   
  5. int main() {  
  6. return __MINGW32__;  
  7. ; return 0; }  
  8. EOF  
   
阅读(4227) | 评论(0) | 转发(0) |
0

上一篇:shell 参数列表

下一篇:configure生成的文件

给主人留下些什么吧!~~