解剖 Nginx ·自動腳本篇(3)源碼相關變量腳本 auto/sources

  • Author: Poechant
  • Blog: blog.CSDN.net/Poechant
  • Email: zhongchao.ustc#gmail.com (#->@)
  • Date: March 6th, 2012
  • Copyright © 柳大·Poechant

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

-

轉載請註明來自“柳大的CSDN博客”:blog.csdn.net/Poechant

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章