nginx.mk 9.5 KB

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