2
1

nginx.mk 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. ################################################################################
  2. #
  3. # nginx
  4. #
  5. ################################################################################
  6. NGINX_VERSION = 1.6.2
  7. NGINX_SITE = http://nginx.org/download
  8. NGINX_LICENSE = BSD-2c
  9. NGINX_LICENSE_FILES = LICENSE
  10. NGINX_CONF_OPTS = \
  11. --crossbuild=Linux::$(BR2_ARCH) \
  12. --with-cc="$(TARGET_CC)" \
  13. --with-cpp="$(TARGET_CC)" \
  14. --with-cc-opt="$(TARGET_CFLAGS)" \
  15. --with-ld-opt="$(TARGET_LDFLAGS)"
  16. # www-data user and group are used for nginx. Because these user and group
  17. # are already set by buildroot, it is not necessary to redefine them.
  18. # See system/skeleton/passwd
  19. # username: www-data uid: 33
  20. # groupname: www-data gid: 33
  21. #
  22. # So, we just need to create the directories used by nginx with the right
  23. # ownership.
  24. define NGINX_PERMISSIONS
  25. /var/lib/nginx d 755 33 33 - - - - -
  26. endef
  27. # disable external libatomic_ops because its detection fails.
  28. NGINX_CONF_ENV += \
  29. ngx_force_c_compiler=yes \
  30. ngx_force_c99_have_variadic_macros=yes \
  31. ngx_force_gcc_have_variadic_macros=yes \
  32. ngx_force_gcc_have_atomic=yes \
  33. ngx_force_have_libatomic=no \
  34. ngx_force_have_epoll=yes \
  35. ngx_force_have_sendfile=yes \
  36. ngx_force_have_sendfile64=$(if $(BR2_LARGEFILE),yes,no) \
  37. ngx_force_have_pr_set_dumpable=yes \
  38. ngx_force_have_timer_event=yes \
  39. ngx_force_have_map_anon=yes \
  40. ngx_force_have_map_devzero=yes \
  41. ngx_force_have_sysvshm=yes \
  42. ngx_force_have_posix_sem=yes
  43. # prefix: nginx root configuration location
  44. NGINX_CONF_OPTS += \
  45. --prefix=/usr \
  46. --conf-path=/etc/nginx/nginx.conf \
  47. --sbin-path=/usr/sbin/nginx \
  48. --pid-path=/var/run/nginx.pid \
  49. --lock-path=/var/run/lock/nginx.lock \
  50. --user=www-data \
  51. --group=www-data \
  52. --error-log-path=/var/log/nginx/error.log \
  53. --http-log-path=/var/log/nginx/access.log \
  54. --http-client-body-temp-path=/var/tmp/nginx/client-body \
  55. --http-proxy-temp-path=/var/tmp/nginx/proxy \
  56. --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi \
  57. --http-scgi-temp-path=/var/tmp/nginx/scgi \
  58. --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi
  59. NGINX_CONF_OPTS += \
  60. $(if $(BR2_PACKAGE_NGINX_FILE_AIO),--with-file-aio) \
  61. $(if $(BR2_INET_IPV6),--with-ipv6)
  62. ifeq ($(BR2_PACKAGE_PCRE),y)
  63. NGINX_DEPENDENCIES += pcre
  64. NGINX_CONF_OPTS += --with-pcre
  65. else
  66. NGINX_CONF_OPTS += --without-pcre
  67. endif
  68. # modules disabled or not activated because of missing dependencies:
  69. # - google_perftools (googleperftools)
  70. # - http_geoip_module (geoip)
  71. # - http_perl_module (host-perl)
  72. # - pcre-jit (want to rebuild pcre)
  73. # Notes:
  74. # * Feature/module option are *not* symetric.
  75. # If a feature is on by default, only its --without-xxx option exists;
  76. # if a feature is off by default, only its --with-xxx option exists.
  77. # * The configure script fails if unknown options are passed on the command
  78. # line.
  79. # misc. modules
  80. NGINX_CONF_OPTS += \
  81. $(if $(BR2_PACKAGE_NGINX_SELECT_MODULE),--with-select_module,--without-select_module) \
  82. $(if $(BR2_PACKAGE_NGINX_POLL_MODULE),--with-poll_module,--without-poll_module)
  83. ifneq ($(BR2_PACKAGE_NGINX_ADD_MODULES),)
  84. NGINX_CONF_OPTS += \
  85. $(addprefix --add-module=,$(call qstrip,$(BR2_PACKAGE_NGINX_ADD_MODULES)))
  86. endif
  87. # http server modules
  88. ifeq ($(BR2_PACKAGE_NGINX_HTTP),y)
  89. ifeq ($(BR2_PACKAGE_NGINX_HTTP_CACHE),y)
  90. NGINX_DEPENDENCIES += openssl
  91. else
  92. NGINX_CONF_OPTS += --without-http-cache
  93. endif
  94. ifeq ($(BR2_PACKAGE_NGINX_HTTP_SPDY_MODULE),y)
  95. NGINX_DEPENDENCIES += zlib
  96. NGINX_CONF_OPTS += --with-http_spdy_module
  97. endif
  98. ifeq ($(BR2_PACKAGE_NGINX_HTTP_SSL_MODULE),y)
  99. NGINX_DEPENDENCIES += openssl
  100. NGINX_CONF_OPTS += --with-http_ssl_module
  101. endif
  102. ifeq ($(BR2_PACKAGE_NGINX_HTTP_XSLT_MODULE),y)
  103. NGINX_DEPENDENCIES += libxml2 libxslt
  104. NGINX_CONF_OPTS += --with-http_xslt_module
  105. NGINX_CONF_ENV += \
  106. ngx_feature_path_libxslt=$(STAGING_DIR)/usr/include/libxml2
  107. endif
  108. ifeq ($(BR2_PACKAGE_NGINX_HTTP_IMAGE_FILTER_MODULE),y)
  109. NGINX_DEPENDENCIES += gd jpeg libpng
  110. NGINX_CONF_OPTS += --with-http_image_filter_module
  111. endif
  112. ifeq ($(BR2_PACKAGE_NGINX_HTTP_GUNZIP_MODULE),y)
  113. NGINX_DEPENDENCIES += zlib
  114. NGINX_CONF_OPTS += --with-http_gunzip_module
  115. endif
  116. ifeq ($(BR2_PACKAGE_NGINX_HTTP_GZIP_STATIC_MODULE),y)
  117. NGINX_DEPENDENCIES += zlib
  118. NGINX_CONF_OPTS += --with-http_gzip_static_module
  119. endif
  120. ifeq ($(BR2_PACKAGE_NGINX_HTTP_SECURE_LINK_MODULE),y)
  121. NGINX_DEPENDENCIES += openssl
  122. NGINX_CONF_OPTS += --with-http_secure_link_module
  123. endif
  124. ifeq ($(BR2_PACKAGE_NGINX_HTTP_GZIP_MODULE),y)
  125. NGINX_DEPENDENCIES += zlib
  126. else
  127. NGINX_CONF_OPTS += --without-http_gzip_module
  128. endif
  129. ifeq ($(BR2_PACKAGE_NGINX_HTTP_REWRITE_MODULE),y)
  130. NGINX_DEPENDENCIES += pcre
  131. else
  132. NGINX_CONF_OPTS += --without-http_rewrite_module
  133. endif
  134. NGINX_CONF_OPTS += \
  135. $(if $(BR2_PACKAGE_NGINX_HTTP_REALIP_MODULE),--with-http_realip_module) \
  136. $(if $(BR2_PACKAGE_NGINX_HTTP_ADDITION_MODULE),--with-http_addition_module) \
  137. $(if $(BR2_PACKAGE_NGINX_HTTP_SUB_MODULE),--with-http_sub_module) \
  138. $(if $(BR2_PACKAGE_NGINX_HTTP_DAV_MODULE),--with-http_dav_module) \
  139. $(if $(BR2_PACKAGE_NGINX_HTTP_FLV_MODULE),--with-http_flv_module) \
  140. $(if $(BR2_PACKAGE_NGINX_HTTP_MP4_MODULE),--with-http_mp4_module) \
  141. $(if $(BR2_PACKAGE_NGINX_HTTP_AUTH_REQUEST_MODULE),--with-http_auth_request_module) \
  142. $(if $(BR2_PACKAGE_NGINX_HTTP_RANDOM_INDEX_MODULE),--with-http_random_index_module) \
  143. $(if $(BR2_PACKAGE_NGINX_HTTP_DEGRADATION_MODULE),--with-http_degradation_module) \
  144. $(if $(BR2_PACKAGE_NGINX_HTTP_STUB_STATUS_MODULE),--with-http_stub_status_module) \
  145. $(if $(BR2_PACKAGE_NGINX_HTTP_CHARSET_MODULE),,--without-http_charset_module) \
  146. $(if $(BR2_PACKAGE_NGINX_HTTP_SSI_MODULE),,--without-http_ssi_module) \
  147. $(if $(BR2_PACKAGE_NGINX_HTTP_USERID_MODULE),,--without-http_userid_module) \
  148. $(if $(BR2_PACKAGE_NGINX_HTTP_ACCESS_MODULE),,--without-http_access_module) \
  149. $(if $(BR2_PACKAGE_NGINX_HTTP_AUTH_BASIC_MODULE),,--without-http_auth_basic_module) \
  150. $(if $(BR2_PACKAGE_NGINX_HTTP_AUTOINDEX_MODULE),,--without-http_autoindex_module) \
  151. $(if $(BR2_PACKAGE_NGINX_HTTP_GEO_MODULE),,--without-http_geo_module) \
  152. $(if $(BR2_PACKAGE_NGINX_HTTP_MAP_MODULE),,--without-http_map_module) \
  153. $(if $(BR2_PACKAGE_NGINX_HTTP_SPLIT_CLIENTS_MODULE),,--without-http_split_clients_module) \
  154. $(if $(BR2_PACKAGE_NGINX_HTTP_REFERER_MODULE),,--without-http_referer_module) \
  155. $(if $(BR2_PACKAGE_NGINX_HTTP_PROXY_MODULE),,--without-http_proxy_module) \
  156. $(if $(BR2_PACKAGE_NGINX_HTTP_FASTCGI_MODULE),,--without-http_fastcgi_module) \
  157. $(if $(BR2_PACKAGE_NGINX_HTTP_UWSGI_MODULE),,--without-http_uwsgi_module) \
  158. $(if $(BR2_PACKAGE_NGINX_HTTP_SCGI_MODULE),,--without-http_scgi_module) \
  159. $(if $(BR2_PACKAGE_NGINX_HTTP_MEMCACHED_MODULE),,--without-http_memcached_module) \
  160. $(if $(BR2_PACKAGE_NGINX_HTTP_LIMIT_CONN_MODULE),,--without-http_limit_conn_module) \
  161. $(if $(BR2_PACKAGE_NGINX_HTTP_LIMIT_REQ_MODULE),,--without-http_limit_req_module) \
  162. $(if $(BR2_PACKAGE_NGINX_HTTP_EMPTY_GIF_MODULE),,--without-http_empty_gif_module) \
  163. $(if $(BR2_PACKAGE_NGINX_HTTP_BROWSER_MODULE),,--without-http_browser_module) \
  164. $(if $(BR2_PACKAGE_NGINX_HTTP_UPSTREAM_IP_HASH_MODULE),,--without-http_upstream_ip_hash_module) \
  165. $(if $(BR2_PACKAGE_NGINX_HTTP_UPSTREAM_LEAST_CONN_MODULE),,--without-http_upstream_least_conn_module) \
  166. $(if $(BR2_PACKAGE_NGINX_HTTP_UPSTREAM_KEEPALIVE_MODULE),,--without-http_upstream_keepalive_module)
  167. else # !BR2_PACKAGE_NGINX_HTTP
  168. NGINX_CONF_OPTS += --without-http
  169. endif # BR2_PACKAGE_NGINX_HTTP
  170. # mail modules
  171. ifeq ($(BR2_PACKAGE_NGINX_MAIL),y)
  172. ifeq ($(BR2_PACKAGE_NGINX_MAIL_SSL_MODULE),y)
  173. NGINX_DEPENDENCIES += openssl
  174. NGINX_CONF_OPTS += --with-mail_ssl_module
  175. endif
  176. NGINX_CONF_OPTS += \
  177. $(if $(BR2_PACKAGE_NGINX_MAIL_POP3_MODULE),,--without-mail_pop3_module) \
  178. $(if $(BR2_PACKAGE_NGINX_MAIL_IMAP_MODULE),,--without-mail_imap_module) \
  179. $(if $(BR2_PACKAGE_NGINX_MAIL_SMTP_MODULE),,--without-mail_smtp_module)
  180. endif # BR2_PACKAGE_NGINX_MAIL
  181. define NGINX_DISABLE_WERROR
  182. $(SED) 's/-Werror//g' -i $(@D)/auto/cc/*
  183. endef
  184. NGINX_PRE_CONFIGURE_HOOKS += NGINX_DISABLE_WERROR
  185. define NGINX_CONFIGURE_CMDS
  186. cd $(@D) ; $(NGINX_CONF_ENV) ./configure $(NGINX_CONF_OPTS)
  187. endef
  188. define NGINX_BUILD_CMDS
  189. $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)
  190. endef
  191. define NGINX_INSTALL_TARGET_CMDS
  192. $(TARGET_MAKE_ENV) $(MAKE) -C $(@D) DESTDIR=$(TARGET_DIR) install
  193. -$(RM) $(TARGET_DIR)/usr/bin/nginx.old
  194. $(INSTALL) -D -m 0664 package/nginx/nginx.logrotate \
  195. $(TARGET_DIR)/etc/logrotate.d/nginx
  196. endef
  197. define NGINX_INSTALL_INIT_SYSTEMD
  198. $(INSTALL) -D -m 0644 package/nginx/nginx.service \
  199. $(TARGET_DIR)/usr/lib/systemd/system/nginx.service
  200. endef
  201. define NGINX_INSTALL_INIT_SYSV
  202. $(INSTALL) -D -m 0755 package/nginx/S50nginx \
  203. $(TARGET_DIR)/etc/init.d/S50nginx
  204. endef
  205. $(eval $(generic-package))