zoukankan      html  css  js  c++  java
  • 解剖Nginx·自动脚本篇(3)源码相关变量脚本 auto/sources

    configure脚本中,运行完auto/optionsauto/init脚本后,接下来就运行auto/soures脚本。这个脚本是为编译做准备的。

    目录

    1. 核心模块
    2. 事件模块
    3. OpenSSL 模块相关变量
    4. 事件驱动模块
    5. 操作系统相关项
    6. HTTP 模块
    7. 邮件模块
    8. Google PerfTools 模块
    9. C++ 测试模块

    1 核心模块

    1.1 核心模块名称 CORE_MODULES

    CORE_MODULES变量记录 Nginx 的核心模块,默认包括ngx_core_modulengx_errlog_modulengx_conf_module,相应初始化代码如下:

    CORE_MODULES="ngx_core_module ngx_errlog_module ngx_conf_module"
    

    1.2 核心模块头文件所在目录 CORE_INCS

    INCS 的含义是 includes。

    CORE_INCS="src/core"
    

    1.3 核心模块头文件 CORE_DEPS

    DEPS 的含义是 depandencies,包含src/core目录下的 30 个源文件,唯独没有src/core/regex.h文件。

    CORE_DEPS="src/core/nginx.h 
               src/core/ngx_config.h 
               ...
               src/core/ngx_open_file_cache.h 
               src/core/ngx_crypt.h"
    

    1.4 核心模块源文件 CORE_SRCS

    SRCS 的含义是 sources,包含src/core目录下的 29 个源文件,仅仅没有src/core/regex.c文件。

    CORE_SRCS="src/core/nginx.c 
               src/core/ngx_log.c 
               ...
               src/core/ngx_open_file_cache.c 
               src/core/ngx_crypt.c"
    

    正则表达式的内容也是核心模块的一部分,分别是src/core/regex.hsrc/core/regex.c

    REGEX_DEPS=src/core/ngx_regex.h
    REGEX_SRCS=src/core/ngx_regex.c
    

    2 事件模块

    2.1 事件模块名称 EVENT_MODULES

    该模块包括ngx_events_modulengx_event_core_module

    EVENT_MODULES="ngx_events_module ngx_event_core_module"
    

    2.2 事件模块头文件所在目录 EVENT_INCS

    相应的头文件所在目录也包含两部分。

    EVENT_INCS="src/event src/event/modules"
    

    2.3 事件模块头文件 EVENT_DEPS

    包括六个头文件,都位于src/event目录下,唯独不包含该目录下的src/event/ngx_event_openssl.h文件,该文件属于 OpenSSL 模块的头文件。

    EVENT_DEPS="src/event/ngx_event.h 
                src/event/ngx_event_timer.h 
                src/event/ngx_event_posted.h 
                src/event/ngx_event_busy_lock.h 
                src/event/ngx_event_connect.h 
                src/event/ngx_event_pipe.h"
    

    2.4 事件模块源文件 EVENT_SRCS

    包含七个头文件,都位于src/event目录下,该目录下的另外两个文件ngx_event_opensslngx_event_mutex

    EVENT_SRCS="src/event/ngx_event.c 
                src/event/ngx_event_timer.c 
                src/event/ngx_event_posted.c 
                src/event/ngx_event_busy_lock.c 
                src/event/ngx_event_accept.c 
                src/event/ngx_event_connect.c 
                src/event/ngx_event_pipe.c"
    

    3 OpenSSL 模块相关变量

    3.1 OpenSSL 模块名称 OPENSSL_MODULE

    OPENSSL_MODULE:是 OpenSSL 变量的名称,为ngx_openssl_module

    3.2 OpenSSl 模块源文件与头文件 OPENSSL_DEPS 和 OPENSSL_SRCS

    OPENSSL_DEPSOPENSSL_SRCS:是 OpenSSL 的源文件和头文件。

    OPENSSL_MODULE=ngx_openssl_module
    OPENSSL_DEPS=src/event/ngx_event_openssl.h
    OPENSSL_SRCS=src/event/ngx_event_openssl.c
    

    4 事件驱动模型

    模型包括 select、poll、kqueue、devpoll、eventport、epoll、rtsig、iocp、aio。后面我会专门写一篇关于事件驱动方面的博文,来详细介绍这些事件驱动模型的原理和异同。这里先不赘述。

    4.1 select 模型

    SELECT_MODULE=ngx_select_module
    SELECT_SRCS=src/event/modules/ngx_select_module.c
    WIN32_SELECT_SRCS=src/event/modules/ngx_win32_select_module.c
    

    4.2 poll 模型

    POLL_MODULE=ngx_poll_module
    POLL_SRCS=src/event/modules/ngx_poll_module.c
    

    4.3 kqueue 模型

    KQUEUE_MODULE=ngx_kqueue_module
    KQUEUE_SRCS=src/event/modules/ngx_kqueue_module.c
    

    4.4 devpoll 模型

    DEVPOLL_MODULE=ngx_devpoll_module
    DEVPOLL_SRCS=src/event/modules/ngx_devpoll_module.c
    

    4.5 eventport 模型

    EVENTPORT_MODULE=ngx_eventport_module
    EVENTPORT_SRCS=src/event/modules/ngx_eventport_module.c
    

    4.5 epoll 模型

    EPOLL_MODULE=ngx_epoll_module
    EPOLL_SRCS=src/event/modules/ngx_epoll_module.c
    

    4.6 rtsig 模型

    RTSIG_MODULE=ngx_rtsig_module
    RTSIG_SRCS=src/event/modules/ngx_rtsig_module.c
    

    4.7 iocp 模型

    IOCP_MODULE=ngx_iocp_module
    IOCP_SRCS=src/event/modules/ngx_iocp_module.c
    

    4.8 aio 模型

    AIO_MODULE=ngx_aio_module
    AIO_SRCS="src/event/modules/ngx_aio_module.c 
              src/os/unix/ngx_aio_read.c 
              src/os/unix/ngx_aio_write.c 
              src/os/unix/ngx_aio_read_chain.c 
              src/os/unix/ngx_aio_write_chain.c"
    
    FILE_AIO_SRCS="src/os/unix/ngx_file_aio_read.c"
    LINUX_AIO_SRCS="src/os/unix/ngx_linux_aio_read.c"
    

    5 操作系统相关项

    5.1 UNIX

    相关的头文件所在的目录为:

    UNIX_INCS="$CORE_INCS $EVENT_INCS src/os/unix"
    

    所有相关的头文件为:

    UNIX_DEPS="$CORE_DEPS $EVENT_DEPS 
                src/os/unix/ngx_time.h 
                src/os/unix/ngx_errno.h 
                ...
                src/os/unix/ngx_process_cycle.h"
    

    所有相关的源文件为:

    UNIX_SRCS="$CORE_SRCS $EVENT_SRCS 
            src/os/unix/ngx_time.c 
            src/os/unix/ngx_errno.c 
            ...
            src/os/unix/ngx_process_cycle.c"
    

    5.2 POSIX

    POSIX_DEPS=src/os/unix/ngx_posix_config.h
    

    5.3 FreeBSD

    相关的头文件:

    FREEBSD_DEPS="src/os/unix/ngx_freebsd_config.h src/os/unix/ngx_freebsd.h"
    

    相关的源文件:

    FREEBSD_SRCS=src/os/unix/ngx_freebsd_init.c
    

    有关 Sendfile 机制的源文件:

    FREEBSD_SENDFILE_SRCS=src/os/unix/ngx_freebsd_sendfile_chain.c
    

    Rfork相关的文件:

    FREEBSD_RFORK_DEPS="src/os/unix/ngx_freebsd_rfork_thread.h"
    FREEBSD_RFORK_SRCS="src/os/unix/ngx_freebsd_rfork_thread.c"
    FREEBSD_RFORK_THREAD_SRCS="src/os/unix/rfork_thread.S"
    

    5.4 pthread

    PTHREAD_SRCS="src/os/unix/ngx_pthread_thread.c"
    

    5.5 Linux

    相关的头文件:

    LINUX_DEPS="src/os/unix/ngx_linux_config.h src/os/unix/ngx_linux.h"
    

    相关的源文件:

    LINUX_SRCS=src/os/unix/ngx_linux_init.c
    

    有关 Sendfile 机制的源文件:

    LINUX_SENDFILE_SRCS=src/os/unix/ngx_linux_sendfile_chain.c
    

    5.6 Solaris

    相关的头文件:

    SOLARIS_DEPS="src/os/unix/ngx_solaris_config.h src/os/unix/ngx_solaris.h"
    

    相关的源文件:

    SOLARIS_SRCS=src/os/unix/ngx_solaris_init.c
    

    有关 Sendfile 机制的源文件:

    SOLARIS_SENDFILEV_SRCS=src/os/unix/ngx_solaris_sendfilev_chain.c
    

    5.7 Darwin

    相关的头文件:

    DARWIN_DEPS="src/os/unix/ngx_darwin_config.h src/os/unix/ngx_darwin.h"
    

    现骨干的源文件:

    DARWIN_SRCS=src/os/unix/ngx_darwin_init.c
    

    有关 Sendfile 机制的源文件:

    DARWIN_SENDFILE_SRCS=src/os/unix/ngx_darwin_sendfile_chain.c
    

    5.8 Win32

    相关文件所在的目录:

    WIN32_INCS="$CORE_INCS $EVENT_INCS src/os/win32"
    

    相关的头文件:

    WIN32_DEPS="$CORE_DEPS $EVENT_DEPS 
                src/os/win32/ngx_win32_config.h 
                src/os/win32/ngx_time.h 
                ...
                src/os/win32/ngx_process_cycle.h"
    

    相关的用于配置头文件:

    WIN32_CONFIG=src/os/win32/ngx_win32_config.h
    

    相关的源文件:

    WIN32_SRCS="$CORE_SRCS $EVENT_SRCS 
                src/os/win32/ngx_errno.c 
                src/os/win32/ngx_alloc.c 
                ...
                src/event/ngx_event_acceptex.c"
    

    Nginx 在 Windows 平台的图标:

    NGX_WIN32_ICONS="src/os/win32/nginx.ico"
    

    Run Commands:

    NGX_WIN32_RC="src/os/win32/nginx.rc"
    

    6 HTTP 模块

    6.1 HTTP 一些基本模块

    注意这里的模块分类,与 Wiki 上给出的不一样,这四个并不是 Wiki 中的标准模块。模块名:

    HTTP_MODULES="ngx_http_module 
                  ngx_http_core_module 
                  ngx_http_log_module 
                  ngx_http_upstream_module"
    
    HTTP_WRITE_FILTER_MODULE="ngx_http_write_filter_module"
    HTTP_HEADER_FILTER_MODULE="ngx_http_header_filter_module"
    
    HTTP_POSTPONE_FILTER_MODULE=ngx_http_postpone_filter_module
    HTTP_COPY_FILTER_MODULE=ngx_http_copy_filter_module
    
    HTTP_CHUNKED_FILTER_MODULE=ngx_http_chunked_filter_module
    HTTP_HEADERS_FILTER_MODULE=ngx_http_headers_filter_module
    
    HTTP_RANGE_HEADER_FILTER_MODULE=ngx_http_range_header_filter_module
    HTTP_RANGE_BODY_FILTER_MODULE=ngx_http_range_body_filter_module
    
    HTTP_NOT_MODIFIED_FILTER_MODULE=ngx_http_not_modified_filter_module
    
    HTTP_STATIC_MODULE=ngx_http_static_module
    HTTP_INDEX_MODULE=ngx_http_index_module
    

    相关的头文件所在的目录为:

    HTTP_INCS="src/http src/http/modules"
    

    所有相关的头文件为:

    HTTP_DEPS="src/http/ngx_http.h 
               src/http/ngx_http_request.h 
               src/http/ngx_http_config.h 
               src/http/ngx_http_core_module.h 
               src/http/ngx_http_cache.h 
               src/http/ngx_http_variables.h 
               src/http/ngx_http_script.h 
               src/http/ngx_http_upstream.h 
               src/http/ngx_http_upstream_round_robin.h 
               src/http/ngx_http_busy_lock.h"
    

    所有相关的源文件为:

    HTTP_SRCS="src/http/ngx_http.c 
               src/http/ngx_http_core_module.c 
               …
               src/http/modules/ngx_http_not_modified_filter_module.c"
    
    HTTP_SRCS="$HTTP_SRCS src/http/ngx_http_busy_lock.c"
    

    6.2 其他 HTTP 模块

    下面这些变量是关于一些 HTTP 模块的:

    HTTP_POSTPONE_FILTER_SRCS=src/http/ngx_http_postpone_filter_module.c
    
    HTTP_FILE_CACHE_SRCS=src/http/ngx_http_file_cache.c
    
    HTTP_SSI_FILTER_MODULE=ngx_http_ssi_filter_module
    HTTP_SSI_DEPS=src/http/modules/ngx_http_ssi_filter_module.h
    HTTP_SSI_SRCS=src/http/modules/ngx_http_ssi_filter_module.c
    
    HTTP_SSL_MODULE=ngx_http_ssl_module
    HTTP_SSL_DEPS=src/http/modules/ngx_http_ssl_module.h
    HTTP_SSL_SRCS=src/http/modules/ngx_http_ssl_module.c
    
    HTTP_PERL_MODULE=ngx_http_perl_module
    HTTP_PERL_INCS=src/http/modules/perl
    HTTP_PERL_DEPS=src/http/modules/perl/ngx_http_perl_module.h
    HTTP_PERL_SRCS=src/http/modules/perl/ngx_http_perl_module.c
    

    其 他一些模块,只设置了形如 HTTP_XXX_MODULE 和 HTTP_XXX_SRCS 的变量,包括 charset-filter,gzip-filter,xslt-filter,image-filter,sub-filter,userid- filter,realip,addiction-filter,dav,access,auth- basic,autoindex,random,status,geo,geoip,map,split- clients,referer,rewrite,proxy,fastcgi,uwsgi,scgi,memcached,limit- zone,limite-req,empty-gif,browser,secure- link,degradation,flv,mp4,gzip,upstream-ip-hash,例如:

    HTTP_CHARSET_FILTER_MODULE=ngx_http_charset_filter_module
    HTTP_CHARSET_SRCS=src/http/modules/ngx_http_charset_filter_module.c
    
    HTTP_GZIP_FILTER_MODULE=ngx_http_gzip_filter_module
    HTTP_GZIP_SRCS=src/http/modules/ngx_http_gzip_filter_module.c
    

    7 邮件模块

    头文件所在的目录:

    MAIL_INCS="src/mail"
    

    头文件:

    MAIL_DEPS="src/mail/ngx_mail.h"
    

    模块名称:

    MAIL_MODULES="ngx_mail_module ngx_mail_core_module"
    

    源文件:

    MAIL_SRCS="src/mail/ngx_mail.c 
               src/mail/ngx_mail_core_module.c 
               src/mail/ngx_mail_handler.c 
               src/mail/ngx_mail_parse.c"
    

    一些模块的相关变量,包括 POP3、IMAP、SMTP、SSL、AUTH-HTTP、PROXY 模块:

    MAIL_POP3_MODULE="ngx_mail_pop3_module"
    MAIL_POP3_DEPS="src/mail/ngx_mail_pop3_module.h"
    MAIL_POP3_SRCS="src/mail/ngx_mail_pop3_module.c 
                    src/mail/ngx_mail_pop3_handler.c"
    
    MAIL_IMAP_MODULE="ngx_mail_imap_module"
    MAIL_IMAP_DEPS="src/mail/ngx_mail_imap_module.h"
    MAIL_IMAP_SRCS="src/mail/ngx_mail_imap_module.c 
                    src/mail/ngx_mail_imap_handler.c"
    
    MAIL_SMTP_MODULE="ngx_mail_smtp_module"
    MAIL_SMTP_DEPS="src/mail/ngx_mail_smtp_module.h"
    MAIL_SMTP_SRCS="src/mail/ngx_mail_smtp_module.c 
                    src/mail/ngx_mail_smtp_handler.c"
    
    MAIL_SSL_MODULE="ngx_mail_ssl_module"
    MAIL_SSL_DEPS="src/mail/ngx_mail_ssl_module.h"
    MAIL_SSL_SRCS="src/mail/ngx_mail_ssl_module.c"
    
    MAIL_AUTH_HTTP_MODULE="ngx_mail_auth_http_module"
    MAIL_AUTH_HTTP_SRCS="src/mail/ngx_mail_auth_http_module.c"
    
    MAIL_PROXY_MODULE="ngx_mail_proxy_module"
    MAIL_PROXY_SRCS="src/mail/ngx_mail_proxy_module.c"
    

    8 Google PerfTools 模块

    NGX_GOOGLE_PERFTOOLS_MODULE=ngx_google_perftools_module
    NGX_GOOGLE_PERFTOOLS_SRCS=src/misc/ngx_google_perftools_module.c
    

    9 C++ 测试模块

    NGX_CPP_TEST_SRCS=src/misc/ngx_cpp_test_module.cpp
    
  • 相关阅读:
    python 中 print函数的用法详解
    可转债操作一览
    Python基本数据类型
    python的列表
    理财的方法
    92、Multiple commands produce Info.plist 报错
    91、最新cocoaPods安装与使用
    90、引入头文件不提示
    89、instancetype和id的区别
    88、const、static、extern介绍
  • 原文地址:https://www.cnblogs.com/breg/p/4043702.html
Copyright © 2011-2022 走看看