nginx.mk 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. ################################################################################
  2. #
  3. # nginx
  4. #
  5. ################################################################################
  6. NGINX_VERSION = 1.10.3
  7. NGINX_SITE = http://nginx.org/download
  8. NGINX_LICENSE = BSD-2-Clause
  9. NGINX_LICENSE_FILES = LICENSE
  10. NGINX_DEPENDENCIES = host-pkgconf
  11. NGINX_CONF_OPTS = \
  12. --crossbuild=Linux::$(BR2_ARCH) \
  13. --with-cc="$(TARGET_CC)" \
  14. --with-cpp="$(TARGET_CC)" \
  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_epoll=yes \
  35. ngx_force_have_sendfile=yes \
  36. ngx_force_have_sendfile64=yes \
  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_PACKAGE_NGINX_THREADS),--with-threads)
  62. ifeq ($(BR2_PACKAGE_LIBATOMIC_OPS),y)
  63. NGINX_DEPENDENCIES += libatomic_ops
  64. NGINX_CONF_OPTS += --with-libatomic
  65. NGINX_CONF_ENV += ngx_force_have_libatomic=yes
  66. ifeq ($(BR2_sparc_v8)$(BR2_sparc_leon3),y)
  67. NGINX_CFLAGS += "-DAO_NO_SPARC_V9"
  68. endif
  69. else
  70. NGINX_CONF_ENV += ngx_force_have_libatomic=no
  71. endif
  72. ifeq ($(BR2_PACKAGE_PCRE),y)
  73. NGINX_DEPENDENCIES += pcre
  74. NGINX_CONF_OPTS += --with-pcre
  75. else
  76. NGINX_CONF_OPTS += --without-pcre
  77. endif
  78. # modules disabled or not activated because of missing dependencies:
  79. # - google_perftools (googleperftools)
  80. # - http_geoip_module (geoip)
  81. # - http_perl_module (host-perl)
  82. # - pcre-jit (want to rebuild pcre)
  83. # Notes:
  84. # * Feature/module option are *not* symetric.
  85. # If a feature is on by default, only its --without-xxx option exists;
  86. # if a feature is off by default, only its --with-xxx option exists.
  87. # * The configure script fails if unknown options are passed on the command
  88. # line.
  89. # misc. modules
  90. NGINX_CONF_OPTS += \
  91. $(if $(BR2_PACKAGE_NGINX_SELECT_MODULE),--with-select_module,--without-select_module) \
  92. $(if $(BR2_PACKAGE_NGINX_POLL_MODULE),--with-poll_module,--without-poll_module)
  93. ifneq ($(BR2_PACKAGE_NGINX_ADD_MODULES),)
  94. NGINX_CONF_OPTS += \
  95. $(addprefix --add-module=,$(call qstrip,$(BR2_PACKAGE_NGINX_ADD_MODULES)))
  96. endif
  97. # http server modules
  98. ifeq ($(BR2_PACKAGE_NGINX_HTTP),y)
  99. ifeq ($(BR2_PACKAGE_NGINX_HTTP_CACHE),y)
  100. NGINX_DEPENDENCIES += openssl
  101. else
  102. NGINX_CONF_OPTS += --without-http-cache
  103. endif
  104. ifeq ($(BR2_PACKAGE_NGINX_HTTP_V2_MODULE),y)
  105. NGINX_DEPENDENCIES += zlib
  106. NGINX_CONF_OPTS += --with-http_v2_module
  107. endif
  108. ifeq ($(BR2_PACKAGE_NGINX_HTTP_SSL_MODULE),y)
  109. NGINX_DEPENDENCIES += openssl
  110. NGINX_CONF_OPTS += --with-http_ssl_module
  111. endif
  112. ifeq ($(BR2_PACKAGE_NGINX_HTTP_XSLT_MODULE),y)
  113. NGINX_DEPENDENCIES += libxml2 libxslt
  114. NGINX_CONF_OPTS += --with-http_xslt_module
  115. endif
  116. ifeq ($(BR2_PACKAGE_NGINX_HTTP_IMAGE_FILTER_MODULE),y)
  117. NGINX_DEPENDENCIES += gd jpeg libpng
  118. NGINX_CONF_OPTS += --with-http_image_filter_module
  119. endif
  120. ifeq ($(BR2_PACKAGE_NGINX_HTTP_GUNZIP_MODULE),y)
  121. NGINX_DEPENDENCIES += zlib
  122. NGINX_CONF_OPTS += --with-http_gunzip_module
  123. endif
  124. ifeq ($(BR2_PACKAGE_NGINX_HTTP_GZIP_STATIC_MODULE),y)
  125. NGINX_DEPENDENCIES += zlib
  126. NGINX_CONF_OPTS += --with-http_gzip_static_module
  127. endif
  128. ifeq ($(BR2_PACKAGE_NGINX_HTTP_SECURE_LINK_MODULE),y)
  129. NGINX_DEPENDENCIES += openssl
  130. NGINX_CONF_OPTS += --with-http_secure_link_module
  131. endif
  132. ifeq ($(BR2_PACKAGE_NGINX_HTTP_GZIP_MODULE),y)
  133. NGINX_DEPENDENCIES += zlib
  134. else
  135. NGINX_CONF_OPTS += --without-http_gzip_module
  136. endif
  137. ifeq ($(BR2_PACKAGE_NGINX_HTTP_REWRITE_MODULE),y)
  138. NGINX_DEPENDENCIES += pcre
  139. else
  140. NGINX_CONF_OPTS += --without-http_rewrite_module
  141. endif
  142. NGINX_CONF_OPTS += \
  143. $(if $(BR2_PACKAGE_NGINX_HTTP_REALIP_MODULE),--with-http_realip_module) \
  144. $(if $(BR2_PACKAGE_NGINX_HTTP_ADDITION_MODULE),--with-http_addition_module) \
  145. $(if $(BR2_PACKAGE_NGINX_HTTP_SUB_MODULE),--with-http_sub_module) \
  146. $(if $(BR2_PACKAGE_NGINX_HTTP_DAV_MODULE),--with-http_dav_module) \
  147. $(if $(BR2_PACKAGE_NGINX_HTTP_FLV_MODULE),--with-http_flv_module) \
  148. $(if $(BR2_PACKAGE_NGINX_HTTP_MP4_MODULE),--with-http_mp4_module) \
  149. $(if $(BR2_PACKAGE_NGINX_HTTP_AUTH_REQUEST_MODULE),--with-http_auth_request_module) \
  150. $(if $(BR2_PACKAGE_NGINX_HTTP_RANDOM_INDEX_MODULE),--with-http_random_index_module) \
  151. $(if $(BR2_PACKAGE_NGINX_HTTP_DEGRADATION_MODULE),--with-http_degradation_module) \
  152. $(if $(BR2_PACKAGE_NGINX_HTTP_STUB_STATUS_MODULE),--with-http_stub_status_module) \
  153. $(if $(BR2_PACKAGE_NGINX_HTTP_CHARSET_MODULE),,--without-http_charset_module) \
  154. $(if $(BR2_PACKAGE_NGINX_HTTP_SSI_MODULE),,--without-http_ssi_module) \
  155. $(if $(BR2_PACKAGE_NGINX_HTTP_USERID_MODULE),,--without-http_userid_module) \
  156. $(if $(BR2_PACKAGE_NGINX_HTTP_ACCESS_MODULE),,--without-http_access_module) \
  157. $(if $(BR2_PACKAGE_NGINX_HTTP_AUTH_BASIC_MODULE),,--without-http_auth_basic_module) \
  158. $(if $(BR2_PACKAGE_NGINX_HTTP_AUTOINDEX_MODULE),,--without-http_autoindex_module) \
  159. $(if $(BR2_PACKAGE_NGINX_HTTP_GEO_MODULE),,--without-http_geo_module) \
  160. $(if $(BR2_PACKAGE_NGINX_HTTP_MAP_MODULE),,--without-http_map_module) \
  161. $(if $(BR2_PACKAGE_NGINX_HTTP_SPLIT_CLIENTS_MODULE),,--without-http_split_clients_module) \
  162. $(if $(BR2_PACKAGE_NGINX_HTTP_REFERER_MODULE),,--without-http_referer_module) \
  163. $(if $(BR2_PACKAGE_NGINX_HTTP_PROXY_MODULE),,--without-http_proxy_module) \
  164. $(if $(BR2_PACKAGE_NGINX_HTTP_FASTCGI_MODULE),,--without-http_fastcgi_module) \
  165. $(if $(BR2_PACKAGE_NGINX_HTTP_UWSGI_MODULE),,--without-http_uwsgi_module) \
  166. $(if $(BR2_PACKAGE_NGINX_HTTP_SCGI_MODULE),,--without-http_scgi_module) \
  167. $(if $(BR2_PACKAGE_NGINX_HTTP_MEMCACHED_MODULE),,--without-http_memcached_module) \
  168. $(if $(BR2_PACKAGE_NGINX_HTTP_LIMIT_CONN_MODULE),,--without-http_limit_conn_module) \
  169. $(if $(BR2_PACKAGE_NGINX_HTTP_LIMIT_REQ_MODULE),,--without-http_limit_req_module) \
  170. $(if $(BR2_PACKAGE_NGINX_HTTP_EMPTY_GIF_MODULE),,--without-http_empty_gif_module) \
  171. $(if $(BR2_PACKAGE_NGINX_HTTP_BROWSER_MODULE),,--without-http_browser_module) \
  172. $(if $(BR2_PACKAGE_NGINX_HTTP_UPSTREAM_IP_HASH_MODULE),,--without-http_upstream_ip_hash_module) \
  173. $(if $(BR2_PACKAGE_NGINX_HTTP_UPSTREAM_LEAST_CONN_MODULE),,--without-http_upstream_least_conn_module) \
  174. $(if $(BR2_PACKAGE_NGINX_HTTP_UPSTREAM_KEEPALIVE_MODULE),,--without-http_upstream_keepalive_module)
  175. else # !BR2_PACKAGE_NGINX_HTTP
  176. NGINX_CONF_OPTS += --without-http
  177. endif # BR2_PACKAGE_NGINX_HTTP
  178. # mail modules
  179. ifeq ($(BR2_PACKAGE_NGINX_MAIL),y)
  180. NGINX_CONF_OPTS += --with-mail
  181. ifeq ($(BR2_PACKAGE_NGINX_MAIL_SSL_MODULE),y)
  182. NGINX_DEPENDENCIES += openssl
  183. NGINX_CONF_OPTS += --with-mail_ssl_module
  184. endif
  185. NGINX_CONF_OPTS += \
  186. $(if $(BR2_PACKAGE_NGINX_MAIL_POP3_MODULE),,--without-mail_pop3_module) \
  187. $(if $(BR2_PACKAGE_NGINX_MAIL_IMAP_MODULE),,--without-mail_imap_module) \
  188. $(if $(BR2_PACKAGE_NGINX_MAIL_SMTP_MODULE),,--without-mail_smtp_module)
  189. endif # BR2_PACKAGE_NGINX_MAIL
  190. # stream modules
  191. ifeq ($(BR2_PACKAGE_NGINX_STREAM),y)
  192. NGINX_CONF_OPTS += --with-stream
  193. ifeq ($(BR2_PACKAGE_NGINX_STREAM_SSL_MODULE),y)
  194. NGINX_DEPENDENCIES += openssl
  195. NGINX_CONF_OPTS += --with-stream_ssl_module
  196. endif
  197. NGINX_CONF_OPTS += \
  198. $(if $(BR2_PACKAGE_NGINX_STREAM_LIMIT_CONN_MODULE),,--without-stream_limit_conn_module) \
  199. $(if $(BR2_PACKAGE_NGINX_STREAM_ACCESS_MODULE),,--without-stream_access_module) \
  200. $(if $(BR2_PACKAGE_NGINX_STREAM_UPSTREAM_HASH_MODULE),,--without-stream_upstream_hash_module) \
  201. $(if $(BR2_PACKAGE_NGINX_STREAM_UPSTREAM_LEAST_CONN_MODULE),,--without-stream_upstream_least_conn_module) \
  202. $(if $(BR2_PACKAGE_NGINX_STREAM_UPSTREAM_ZONE_MODULE),,--without-stream_upstream_zone_module)
  203. endif # BR2_PACKAGE_NGINX_STREAM
  204. # external modules
  205. ifeq ($(BR2_PACKAGE_NGINX_UPLOAD),y)
  206. NGINX_CONF_OPTS += $(addprefix --add-module=,$(NGINX_UPLOAD_DIR))
  207. NGINX_DEPENDENCIES += nginx-upload
  208. endif
  209. ifeq ($(BR2_PACKAGE_NGINX_DAV_EXT),y)
  210. NGINX_CONF_OPTS += --add-module=$(NGINX_DAV_EXT_DIR)
  211. NGINX_DEPENDENCIES += nginx-dav-ext
  212. endif
  213. ifeq ($(BR2_PACKAGE_NGINX_NAXSI),y)
  214. NGINX_DEPENDENCIES += nginx-naxsi
  215. NGINX_CONF_OPTS += --add-module=$(NGINX_NAXSI_DIR)/naxsi_src
  216. endif
  217. # Debug logging
  218. NGINX_CONF_OPTS += $(if $(BR2_PACKAGE_NGINX_DEBUG),--with-debug)
  219. define NGINX_DISABLE_WERROR
  220. $(SED) 's/-Werror//g' -i $(@D)/auto/cc/*
  221. endef
  222. NGINX_PRE_CONFIGURE_HOOKS += NGINX_DISABLE_WERROR
  223. define NGINX_CONFIGURE_CMDS
  224. cd $(@D) ; $(NGINX_CONF_ENV) \
  225. PKG_CONFIG="$(PKG_CONFIG_HOST_BINARY)" \
  226. GDLIB_CONFIG=$(STAGING_DIR)/usr/bin/gdlib-config \
  227. ./configure $(NGINX_CONF_OPTS) \
  228. --with-cc-opt="$(TARGET_CFLAGS) $(NGINX_CFLAGS)"
  229. endef
  230. define NGINX_BUILD_CMDS
  231. $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)
  232. endef
  233. define NGINX_INSTALL_TARGET_CMDS
  234. $(TARGET_MAKE_ENV) $(MAKE) -C $(@D) DESTDIR=$(TARGET_DIR) install
  235. $(RM) $(TARGET_DIR)/usr/sbin/nginx.old
  236. $(INSTALL) -D -m 0664 package/nginx/nginx.logrotate \
  237. $(TARGET_DIR)/etc/logrotate.d/nginx
  238. endef
  239. define NGINX_INSTALL_INIT_SYSTEMD
  240. $(INSTALL) -D -m 0644 package/nginx/nginx.service \
  241. $(TARGET_DIR)/usr/lib/systemd/system/nginx.service
  242. mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants
  243. ln -fs ../../../../usr/lib/systemd/system/nginx.service \
  244. $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/nginx.service
  245. endef
  246. define NGINX_INSTALL_INIT_SYSV
  247. $(INSTALL) -D -m 0755 package/nginx/S50nginx \
  248. $(TARGET_DIR)/etc/init.d/S50nginx
  249. endef
  250. $(eval $(generic-package))