解剖Nginx·自动脚本篇(6)编译器名称变量脚本 auto/cc/name

回顾变量 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=yes
ngx_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脚本中被置值的),则:

echo
echo $0: error: C compiler $CC is not found
echo
exit 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"
fi
fi
fi

2.2 owc

else
if [ "$CC" = wcl386 ]; then
    NGX_CC_NAME=owc
    echo " + using Open Watcom C compiler"

2.3 bcc

else
if [ "$CC" = bcc32 ]; then
    NGX_CC_NAME=bcc
    echo " + using Borland C++ compiler"

2.4 gcc

else
if `$CC -v 2>&1 | grep ‘gcc version‘ >/dev/null 2>&1`; then
    NGX_CC_NAME=gcc
    echo " + using GNU C compiler"

2.5 icc

else
if `$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

else
if `$CC -V 2>&1 | grep ‘Sun C‘ >/dev/null 2>&1`; then
    NGX_CC_NAME=sunc
    echo " + using Sun C compiler"

2.7 ccc

else
if `$CC -V 2>&1 | grep ‘^Compaq C‘ >/dev/null 2>&1`; then
    NGX_CC_NAME=ccc
    echo " + using Compaq C compiler"

2.8 acc

else
if `$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
时间: 2024-08-19 11:35:47

解剖Nginx·自动脚本篇(6)编译器名称变量脚本 auto/cc/name的相关文章

解剖Nginx·自动脚本篇(5)编译器相关主脚本

在 Nginx 的自动脚本中,auto/cc目录下的所有脚本都是用于编译器相关配置使用的.Nginx的出色跨平台性(Linux.Darwin.Solaris.Win32 等)就有这些脚本的贡献.该目录下包含如下脚本: 目录 conf:主脚本,配置编译器的基本属性,并根据系统的编译器环境引用不同的脚本. name:与编译器名称相关的处理逻辑在该脚本中. gcc:GNU C 编译器的 Specified 配置. sunc:Sun C 编译器的 Specified 配置. acc:HP ANSI C+

解剖Nginx·自动脚本篇(4)工具型脚本系列

目录 auto/have 向自动配置头文件追加可用宏定义(objs/ngx_auto_config.h) auto/nohave 向自动配置头文件追加不可用宏定义(objs/ngx_auto_config.h) auto/define 向自动配置脚本追加 K-V 宏定义(objs/ngx_auto_config.h),表示“设置了 K,其值为 V” auto/have_headers 向自动头头文件(objs/ngx_auto_header.h) auto/feature auto/types/

解剖Nginx·自动脚本篇(3)源码相关变量脚本 auto/sources

在configure脚本中,运行完auto/options和auto/init脚本后,接下来就运行auto/soures脚本.这个脚本是为编译做准备的. 目录 核心模块 事件模块 OpenSSL 模块相关变量 事件驱动模块 操作系统相关项 HTTP 模块 邮件模块 Google PerfTools 模块 C++ 测试模块 1 核心模块 1.1 核心模块名称 CORE_MODULES CORE_MODULES变量记录 Nginx 的核心模块,默认包括ngx_core_module.ngx_errl

解剖Nginx·自动脚本篇(1)解析配置选项脚本 auto/options

在安装Nginx之前(即运行make脚本之前),首先是进行安装的配置准备,包括环境检查及生成文件.这些工作是由自动脚本完成的.和绝大多数软件一样,Nginx的自动脚本的入口,同样是名为configure的文件. 除了configure,其他的自动脚本都在auto目录下.通过分析configure脚本源码,我们可以看到,configure首先运行了auto目录下的几个自动脚本,如下: . auto/options . auto/init . auto/sources 其中通过运行auto/opti

解剖Nginx·自动脚本篇(2)设置初始变量脚本 auto/init

在configure中运行完auto/options脚本后,接着运行auto/init脚本,其中所做的工作如下. 1 Makefile文件名变量 默认情况下是: objs/Makefile 代码如下: NGX_MAKEFILE=$NGX_OBJS/Makefile 2 源文件名变量 默认情况下是: objs/ngx_modules.c 代码如下: NGX_MODULES_C=$NGX_OBJS/ngx_modules.c 3 头文件名变量 默认情况下是: objs/ngx_auto_header

解剖Nginx·自动脚本篇(7)类型相关脚本系列

1 auto/types/sizeof 该脚本的功能,是通过测试程序获知给定的ngx_type的大小. 1.1 显示提示信息 echo $ngx_n "checking for $ngx_type size ...$ngx_c" cat << END >> $NGX_AUTOCONF_ERR ---------------------------------------- checking for $ngx_type size END 1.2 生成计算ngx_t

解剖Nginx&#183;模块开发篇(4)模块开发中的命名规则和模块加载与运行流程

1 命名规则 1.1 基本变量 基本变量有三个: ngx_module_t 类型的 ngx_http_foo_bar_module: ngx_command_t 类型的数组 ngx_http_foo_bar_commands: ngx_http_module_t 类型的 ngx_http_foo_bar_module_ctx. 假设你开发了一个 Foo Bar 模块,那么模块名称应该叫: ngx_http_foo_bar_module 命令集合的名字的命名规则: ngx_http_foo_bar

解剖Nginx&#183;模块开发篇(1)跑起你的 Hello World 模块!

1 学习 Nginx 模块开发需要有哪些准备? 需要的预备知识不多,有如下几点: 有过一些 C 语言的编程经历: 知道 Nginx 是干嘛的,并有过编写或改写 Nginx 的配置文件的经历. OK,就这两点就够了 :) 好了,那就开始吧~ 2 我们的 HelloWorld 的目标是什么? 我们的目标,就是你在浏览器里输入http://localhost/hello_world时,显示: hello world 当然,为了能够更加自定义一些,我们尝试在hello world后面再显示一个字符串,比

解剖Nginx&#183;模块开发篇(3)ngx_http_hello_world_module 模块的基本函数实现

还记得我们定义过一个结构体如下吗? typedef struct { ngx_str_t output_words; } ngx_http_hello_world_loc_conf_t; 它就是 HelloWorld 的 location 组件配置,其中有一个字符串成员 output_words. 1 create location 用于 ngx_http_hello_world_module_ctx 中的 location 创建函数: static void* ngx_http_hello_w