解剖Nginx·自動指令碼篇(6)編譯器名稱變數指令碼 auto/cc/name

來源:互聯網
上載者:User

標籤:style   color   io   os   ar   for   sp   on   amp   

回顧變數 CC

最初是在auto/options指令碼中初始化的:

CC=${CC:-gcc}
1 C Compiler 的 feature

Windows 平台的編譯器叫做MSVC,其他平台的都統稱為C Compiler

1.1 擷取編譯器參數

該指令碼並不複雜,首先通過NGX_PLATFORM變數來判斷是否是win32(該變數是在auto/options中初始化的),如果是,則:

ngx_feature="C compiler"ngx_feature_name=ngx_feature_run=yesngx_feature_incs=ngx_feature_path=ngx_feature_libs=ngx_feature_test=. auto/feature

其中,ngx_feature變數為C compiler,然後初始化其他一些與 feature 相關的變數,再引用auto/feature指令碼。

1.2 無法找到編譯器則退出

ngx_found表示編譯器是否存在,判斷ngx_found變數如果是no(該變數是在auto/feature指令碼中被置值的),則:

echoecho $0: error: C compiler $CC is not foundechoexit 1

即如果編譯器不存在,就退出自動指令碼運行。

2 根據不同編譯器設定名稱2.1 msvc
if `$NGX_WINE $CC -v 2>&1     | grep ‘^Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16‘     >/dev/null 2>&1`; then    NGX_CC_NAME=msvc10    echo " + using Microsoft Visual C++ 10 compiler"else if `$NGX_WINE $CC -v 2>&1     | grep ‘^Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14‘     >/dev/null 2>&1`; then    NGX_CC_NAME=msvc8    echo " + using Microsoft Visual C++ 8 compiler"else if `$NGX_WINE $CC -v 2>&1     | grep ‘^Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13‘     >/dev/null 2>&1`; then    NGX_CC_NAME=msvc7    echo " + using Microsoft Visual C++ 7 compiler"else    NGX_CC_NAME=msvc    echo " + using Microsoft Visual C++ compiler"fififi
2.2 owc
elseif [ "$CC" = wcl386 ]; then    NGX_CC_NAME=owc    echo " + using Open Watcom C compiler"
2.3 bcc
elseif [ "$CC" = bcc32 ]; then    NGX_CC_NAME=bcc    echo " + using Borland C++ compiler"
2.4 gcc
elseif `$CC -v 2>&1 | grep ‘gcc version‘ >/dev/null 2>&1`; then    NGX_CC_NAME=gcc    echo " + using GNU C compiler"
2.5 icc
elseif `$CC -V 2>&1 | grep ‘^Intel(R) C‘ >/dev/null 2>&1`; then    NGX_CC_NAME=icc    echo " + using Intel C++ compiler"
2.6 sunc
elseif `$CC -V 2>&1 | grep ‘Sun C‘ >/dev/null 2>&1`; then    NGX_CC_NAME=sunc    echo " + using Sun C compiler"
2.7 ccc
elseif `$CC -V 2>&1 | grep ‘^Compaq C‘ >/dev/null 2>&1`; then    NGX_CC_NAME=ccc    echo " + using Compaq C compiler"
2.8 acc
elseif `$CC -V 2>&1 | grep ‘^aCC: ‘ >/dev/null 2>&1`; then    NGX_CC_NAME=acc    echo " + using HP aC++ compiler"
2.9 Unknown
else    NGX_CC_NAME=unknown

解剖Nginx·自動指令碼篇(6)編譯器名稱變數指令碼 auto/cc/name

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.