標籤: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