You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

323 lines
9.8 KiB

  1. #
  2. # Copyright (C) 2012-2016 OpenWrt.org
  3. #
  4. # This is free software, licensed under the GNU General Public License v2.
  5. # See /LICENSE for more information.
  6. #
  7. include $(TOPDIR)/rules.mk
  8. PKG_NAME:=nginx
  9. PKG_VERSION:=1.14.0
  10. PKG_RELEASE:=1
  11. PKG_SOURCE:=nginx-$(PKG_VERSION).tar.gz
  12. PKG_SOURCE_URL:=http://nginx.org/download/
  13. PKG_HASH:=5d15becbf69aba1fe33f8d416d97edd95ea8919ea9ac519eff9bafebb6022cb5
  14. PKG_MAINTAINER:=Thomas Heil <heil@terminal-consulting.de>
  15. PKG_LICENSE:=2-clause BSD-like license
  16. PKG_BUILD_DIR:=$(BUILD_DIR)/nginx-$(PKG_VERSION)
  17. PKG_BUILD_PARALLEL:=1
  18. PKG_INSTALL:=1
  19. PKG_CONFIG_DEPENDS := \
  20. CONFIG_NGINX_SSL \
  21. CONFIG_NGINX_DAV \
  22. CONFIG_NGINX_FLV \
  23. CONFIG_NGINX_STUB_STATUS \
  24. CONFIG_NGINX_HTTP_CHARSET \
  25. CONFIG_NGINX_HTTP_GZIP \
  26. CONFIG_NGINX_HTTP_SSI \
  27. CONFIG_NGINX_HTTP_USERID \
  28. CONFIG_NGINX_HTTP_ACCESS \
  29. CONFIG_NGINX_HTTP_AUTH_BASIC \
  30. CONFIG_NGINX_HTTP_AUTH_REQUEST \
  31. CONFIG_NGINX_HTTP_AUTOINDEX \
  32. CONFIG_NGINX_HTTP_GEO \
  33. CONFIG_NGINX_HTTP_MAP \
  34. CONFIG_NGINX_HTTP_SPLIT_CLIENTS \
  35. CONFIG_NGINX_HTTP_REFERER \
  36. CONFIG_NGINX_HTTP_REWRITE \
  37. CONFIG_NGINX_HTTP_PROXY \
  38. CONFIG_NGINX_HTTP_FASTCGI \
  39. CONFIG_NGINX_HTTP_UWSGI \
  40. CONFIG_NGINX_HTTP_SCGI \
  41. CONFIG_NGINX_HTTP_MEMCACHED \
  42. CONFIG_NGINX_HTTP_LIMIT_CONN \
  43. CONFIG_NGINX_HTTP_LIMIT_REQ \
  44. CONFIG_NGINX_HTTP_EMPTY_GIF \
  45. CONFIG_NGINX_HTTP_BROWSER \
  46. CONFIG_NGINX_HTTP_UPSTREAM_HASH \
  47. CONFIG_NGINX_HTTP_UPSTREAM_IP_HASH \
  48. CONFIG_NGINX_HTTP_UPSTREAM_LEAST_CONN \
  49. CONFIG_NGINX_HTTP_UPSTREAM_KEEPALIVE \
  50. CONFIG_NGINX_HTTP_UPSTREAM_ZONE \
  51. CONFIG_NGINX_HTTP_CACHE \
  52. CONFIG_NGINX_HTTP_V2 \
  53. CONFIG_NGINX_PCRE \
  54. CONFIG_NGINX_NAXSI \
  55. CONFIG_NGINX_LUA \
  56. CONFIG_NGINX_HTTP_REAL_IP \
  57. CONFIG_NGINX_HTTP_SECURE_LINK \
  58. CONFIG_NGINX_HTTP_BROTLI \
  59. CONFIG_NGINX_HEADERS_MORE
  60. include $(INCLUDE_DIR)/package.mk
  61. define Package/nginx
  62. SECTION:=net
  63. CATEGORY:=Network
  64. SUBMENU:=Web Servers/Proxies
  65. TITLE:=Nginx web server
  66. URL:=http://nginx.org/
  67. DEPENDS:=+NGINX_PCRE:libpcre +(NGINX_SSL||NGINX_HTTP_CACHE||NGINX_HTTP_AUTH_BASIC):libopenssl +NGINX_HTTP_GZIP:zlib +NGINX_LUA:liblua +libpthread
  68. MENU:=1
  69. endef
  70. define Package/nginx/description
  71. nginx is an HTTP and reverse proxy server, as well as a mail proxy server,
  72. written by Igor Sysoev.
  73. endef
  74. define Package/nginx/config
  75. source "$(SOURCE)/Config.in"
  76. endef
  77. config_files=nginx.conf mime.types
  78. define Package/nginx/conffiles
  79. /etc/nginx/
  80. endef
  81. ADDITIONAL_MODULES:=
  82. ifeq ($(CONFIG_NGINX_NAXSI),y)
  83. ADDITIONAL_MODULES += --add-module=$(PKG_BUILD_DIR)/nginx-naxsi/naxsi_src
  84. endif
  85. ifeq ($(CONFIG_NGINX_LUA),y)
  86. ADDITIONAL_MODULES += --add-module=$(PKG_BUILD_DIR)/lua-nginx
  87. endif
  88. ifeq ($(CONFIG_IPV6),y)
  89. ADDITIONAL_MODULES += --with-ipv6
  90. endif
  91. ifeq ($(CONFIG_NGINX_STUB_STATUS),y)
  92. ADDITIONAL_MODULES += --with-http_stub_status_module
  93. endif
  94. ifeq ($(CONFIG_NGINX_FLV),y)
  95. ADDITIONAL_MODULES += --with-http_flv_module
  96. endif
  97. ifeq ($(CONFIG_NGINX_SSL),y)
  98. ADDITIONAL_MODULES += --with-http_ssl_module
  99. endif
  100. ifeq ($(CONFIG_NGINX_DAV),y)
  101. ADDITIONAL_MODULES += --with-http_dav_module
  102. endif
  103. ifneq ($(CONFIG_NGINX_HTTP_CACHE),y)
  104. ADDITIONAL_MODULES += --without-http-cache
  105. endif
  106. ifneq ($(CONFIG_NGINX_PCRE),y)
  107. ADDITIONAL_MODULES += --without-pcre
  108. endif
  109. ifneq ($(CONFIG_NGINX_HTTP_CHARSET),y)
  110. ADDITIONAL_MODULES += --without-http_charset_module
  111. else
  112. config_files += koi-utf koi-win win-utf
  113. endif
  114. ifneq ($(CONFIG_NGINX_HTTP_GZIP),y)
  115. ADDITIONAL_MODULES += --without-http_gzip_module
  116. endif
  117. ifneq ($(CONFIG_NGINX_HTTP_SSI),y)
  118. ADDITIONAL_MODULES += --without-http_ssi_module
  119. endif
  120. ifneq ($(CONFIG_NGINX_HTTP_USERID),y)
  121. ADDITIONAL_MODULES += --without-http_userid_module
  122. endif
  123. ifneq ($(CONFIG_NGINX_HTTP_ACCESS),y)
  124. ADDITIONAL_MODULES += --without-http_access_module
  125. endif
  126. ifneq ($(CONFIG_NGINX_HTTP_AUTH_BASIC),y)
  127. ADDITIONAL_MODULES += --without-http_auth_basic_module
  128. endif
  129. ifeq ($(CONFIG_NGINX_HTTP_AUTH_REQUEST),y)
  130. ADDITIONAL_MODULES += --with-http_auth_request_module
  131. endif
  132. ifneq ($(CONFIG_NGINX_HTTP_AUTOINDEX),y)
  133. ADDITIONAL_MODULES += --without-http_autoindex_module
  134. endif
  135. ifneq ($(CONFIG_NGINX_HTTP_GEO),y)
  136. ADDITIONAL_MODULES += --without-http_geo_module
  137. endif
  138. ifneq ($(CONFIG_NGINX_HTTP_MAP),y)
  139. ADDITIONAL_MODULES += --without-http_map_module
  140. endif
  141. ifneq ($(CONFIG_NGINX_HTTP_SPLIT_CLIENTS),y)
  142. ADDITIONAL_MODULES += --without-http_split_clients_module
  143. endif
  144. ifneq ($(CONFIG_NGINX_HTTP_REFERER),y)
  145. ADDITIONAL_MODULES += --without-http_referer_module
  146. endif
  147. ifneq ($(CONFIG_NGINX_HTTP_REWRITE),y)
  148. ADDITIONAL_MODULES += --without-http_rewrite_module
  149. endif
  150. ifneq ($(CONFIG_NGINX_HTTP_PROXY),y)
  151. ADDITIONAL_MODULES += --without-http_proxy_module
  152. endif
  153. ifneq ($(CONFIG_NGINX_HTTP_FASTCGI),y)
  154. ADDITIONAL_MODULES += --without-http_fastcgi_module
  155. else
  156. config_files += fastcgi_params
  157. endif
  158. ifneq ($(CONFIG_NGINX_HTTP_UWSGI),y)
  159. ADDITIONAL_MODULES += --without-http_uwsgi_module
  160. endif
  161. ifneq ($(CONFIG_NGINX_HTTP_SCGI),y)
  162. ADDITIONAL_MODULES += --without-http_scgi_module
  163. endif
  164. ifneq ($(CONFIG_NGINX_HTTP_MEMCACHED),y)
  165. ADDITIONAL_MODULES += --without-http_memcached_module
  166. endif
  167. ifneq ($(CONFIG_NGINX_HTTP_LIMIT_CONN),y)
  168. ADDITIONAL_MODULES += --without-http_limit_conn_module
  169. endif
  170. ifneq ($(CONFIG_NGINX_HTTP_LIMIT_REQ),y)
  171. ADDITIONAL_MODULES += --without-http_limit_req_module
  172. endif
  173. ifneq ($(CONFIG_NGINX_HTTP_EMPTY_GIF),y)
  174. ADDITIONAL_MODULES += --without-http_empty_gif_module
  175. endif
  176. ifneq ($(CONFIG_NGINX_HTTP_BROWSER),y)
  177. ADDITIONAL_MODULES += --without-http_browser_module
  178. endif
  179. ifneq ($(CONFIG_NGINX_HTTP_UPSTREAM_HASH),y)
  180. ADDITIONAL_MODULES += --without-http_upstream_hash_module
  181. endif
  182. ifneq ($(CONFIG_NGINX_HTTP_UPSTREAM_IP_HASH),y)
  183. ADDITIONAL_MODULES += --without-http_upstream_ip_hash_module
  184. endif
  185. ifneq ($(CONFIG_NGINX_HTTP_UPSTREAM_LEAST_CONN),y)
  186. ADDITIONAL_MODULES += --without-http_upstream_least_conn_module
  187. endif
  188. ifneq ($(CONFIG_NGINX_HTTP_UPSTREAM_KEEPALIVE),y)
  189. ADDITIONAL_MODULES += --without-http_upstream_keepalive_module
  190. endif
  191. ifeq ($(CONFIG_NGINX_HTTP_V2),y)
  192. ADDITIONAL_MODULES += --with-http_v2_module
  193. endif
  194. ifeq ($(CONFIG_NGINX_HTTP_REAL_IP),y)
  195. ADDITIONAL_MODULES += --with-http_realip_module
  196. endif
  197. ifeq ($(CONFIG_NGINX_HTTP_SECURE_LINK),y)
  198. ADDITIONAL_MODULES += --with-http_secure_link_module
  199. endif
  200. ifeq ($(CONFIG_NGINX_HEADERS_MORE),y)
  201. ADDITIONAL_MODULES += --add-module=$(PKG_BUILD_DIR)/nginx-headers-more
  202. endif
  203. ifeq ($(CONFIG_NGINX_HTTP_BROTLI),y)
  204. ADDITIONAL_MODULES += --add-module=$(PKG_BUILD_DIR)/nginx-brotli
  205. endif
  206. TARGET_CFLAGS += -fvisibility=hidden -ffunction-sections -fdata-sections -DNGX_LUA_NO_BY_LUA_BLOCK
  207. TARGET_LDFLAGS += -Wl,--gc-sections
  208. define Build/Configure
  209. ( cd $(PKG_BUILD_DIR) ; \
  210. $(if $(CONFIG_NGINX_LUA),LUA_INC=$(STAGING_DIR)/usr/include LUA_LIB=$(STAGING_DIR)/usr/lib) \
  211. ./configure \
  212. --crossbuild=Linux::$(ARCH) \
  213. --prefix=/usr \
  214. --conf-path=/etc/nginx/nginx.conf \
  215. $(ADDITIONAL_MODULES) \
  216. --error-log-path=/var/log/nginx/error.log \
  217. --pid-path=/var/run/nginx.pid \
  218. --lock-path=/var/lock/nginx.lock \
  219. --http-log-path=/var/log/nginx/access.log \
  220. --http-client-body-temp-path=/var/lib/nginx/body \
  221. --http-proxy-temp-path=/var/lib/nginx/proxy \
  222. --http-fastcgi-temp-path=/var/lib/nginx/fastcgi \
  223. --with-cc="$(TARGET_CC)" \
  224. --with-cc-opt="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" \
  225. --with-ld-opt="$(TARGET_LDFLAGS)" \
  226. --without-http_upstream_zone_module \
  227. )
  228. endef
  229. define Package/nginx/install
  230. $(INSTALL_DIR) $(1)/usr/sbin
  231. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/nginx $(1)/usr/sbin/
  232. $(INSTALL_DIR) $(1)/etc/nginx
  233. $(INSTALL_DATA) $(addprefix $(PKG_INSTALL_DIR)/etc/nginx/,$(config_files)) $(1)/etc/nginx/
  234. $(INSTALL_DIR) $(1)/etc/init.d
  235. $(INSTALL_BIN) ./files/nginx.init $(1)/etc/init.d/nginx
  236. ifeq ($(CONFIG_NGINX_NAXSI),y)
  237. $(INSTALL_DIR) $(1)/etc/nginx
  238. $(INSTALL_BIN) $(PKG_BUILD_DIR)/nginx-naxsi/naxsi_config/naxsi_core.rules $(1)/etc/nginx
  239. chmod 0640 $(1)/etc/nginx/naxsi_core.rules
  240. endif
  241. $(if $(CONFIG_NGINX_NAXSI),$($(INSTALL_BIN) $(PKG_BUILD_DIR)/nginx-naxsi/naxsi_config/naxsi_core.rules $(1)/etc/nginx))
  242. $(if $(CONFIG_NGINX_NAXSI),$(chmod 0640 $(1)/etc/nginx/naxsi_core.rules))
  243. endef
  244. define Build/Prepare
  245. $(call Build/Prepare/Default)
  246. $(if $(CONFIG_NGINX_NAXSI),$(call Prepare/nginx-naxsi))
  247. $(if $(CONFIG_NGINX_LUA),$(call Prepare/lua-nginx))
  248. $(if $(CONFIG_NGINX_HTTP_BROTLI),$(call Prepare/nginx-brotli))
  249. $(if $(CONFIG_NGINX_HEADERS_MORE),$(call Prepare/nginx-headers-more))
  250. endef
  251. define Download/nginx-headers-more
  252. VERSION:=a9f7c7e86cc7441d04e2f11f01c2e3a9c4b0301d
  253. SUBDIR:=nginx-headers-more
  254. FILE:=headers-more-nginx-module-$(PKG_VERSION)-$$(VERSION).tar.gz
  255. URL:=https://github.com/openresty/headers-more-nginx-module.git
  256. PROTO:=git
  257. endef
  258. define Prepare/nginx-headers-more
  259. $(eval $(call Download,nginx-headers-more))
  260. gzip -dc $(DL_DIR)/$(FILE) | tar -C $(PKG_BUILD_DIR) $(TAR_OPTIONS)
  261. endef
  262. define Download/nginx-brotli
  263. VERSION:=37ab9b2933a0b756ba3447000b7f31d432ed8228
  264. SUBDIR:=nginx-brotli
  265. FILE:=ngx-brotli-module-$(PKG_VERSION)-$$(VERSION).tar.gz
  266. URL:=https://github.com/eustas/ngx_brotli.git
  267. PROTO:=git
  268. endef
  269. define Prepare/nginx-brotli
  270. $(eval $(call Download,nginx-brotli))
  271. gzip -dc $(DL_DIR)/$(FILE) | tar -C $(PKG_BUILD_DIR) $(TAR_OPTIONS)
  272. endef
  273. define Download/nginx-naxsi
  274. VERSION:=fc4740f9734cabc1ce4c9d4cddc4b472eab1cc4b
  275. SUBDIR:=nginx-naxsi
  276. FILE:=nginx-naxsi-module-$(PKG_VERSION)-$$(VERSION).tar.gz
  277. URL:=https://github.com/nbs-system/naxsi.git
  278. PROTO:=git
  279. endef
  280. define Prepare/nginx-naxsi
  281. $(eval $(call Download,nginx-naxsi))
  282. gzip -dc $(DL_DIR)/$(FILE) | tar -C $(PKG_BUILD_DIR) $(TAR_OPTIONS)
  283. endef
  284. define Download/lua-nginx
  285. VERSION:=55743aeba3075b34a250380b32bad6366eae6c30
  286. SUBDIR:=lua-nginx
  287. FILE:=lua-nginx-module-$(PKG_VERSION)-$$(VERSION).tar.gz
  288. URL:=https://github.com/openresty/lua-nginx-module.git
  289. PROTO:=git
  290. endef
  291. define Prepare/lua-nginx
  292. $(eval $(call Download,lua-nginx))
  293. gzip -dc $(DL_DIR)/$(FILE) | tar -C $(PKG_BUILD_DIR) $(TAR_OPTIONS)
  294. $(call PatchDir,$(PKG_BUILD_DIR),./patches-lua-nginx)
  295. endef
  296. $(eval $(call BuildPackage,nginx))