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.

286 lines
8.6 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.12.2
  10. PKG_RELEASE:=1
  11. PKG_SOURCE:=nginx-$(PKG_VERSION).tar.gz
  12. PKG_SOURCE_URL:=http://nginx.org/download/
  13. PKG_HASH:=305f379da1d5fb5aefa79e45c829852ca6983c7cd2a79328f8e084a324cf0416
  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. include $(INCLUDE_DIR)/package.mk
  59. define Package/nginx
  60. SECTION:=net
  61. CATEGORY:=Network
  62. SUBMENU:=Web Servers/Proxies
  63. TITLE:=Nginx web server
  64. URL:=http://nginx.org/
  65. DEPENDS:=+NGINX_PCRE:libpcre +(NGINX_SSL||NGINX_HTTP_CACHE||NGINX_HTTP_AUTH_BASIC):libopenssl +NGINX_HTTP_GZIP:zlib +NGINX_LUA:liblua +libpthread
  66. MENU:=1
  67. endef
  68. define Package/nginx/description
  69. nginx is an HTTP and reverse proxy server, as well as a mail proxy server,
  70. written by Igor Sysoev.
  71. endef
  72. define Package/nginx/config
  73. source "$(SOURCE)/Config.in"
  74. endef
  75. config_files=nginx.conf mime.types
  76. define Package/nginx/conffiles
  77. /etc/nginx/
  78. endef
  79. ADDITIONAL_MODULES:=
  80. ifeq ($(CONFIG_NGINX_NAXSI),y)
  81. ADDITIONAL_MODULES += --add-module=$(PKG_BUILD_DIR)/nginx-naxsi/naxsi_src
  82. endif
  83. ifeq ($(CONFIG_NGINX_LUA),y)
  84. ADDITIONAL_MODULES += --add-module=$(PKG_BUILD_DIR)/lua-nginx
  85. endif
  86. ifeq ($(CONFIG_IPV6),y)
  87. ADDITIONAL_MODULES += --with-ipv6
  88. endif
  89. ifeq ($(CONFIG_NGINX_STUB_STATUS),y)
  90. ADDITIONAL_MODULES += --with-http_stub_status_module
  91. endif
  92. ifeq ($(CONFIG_NGINX_FLV),y)
  93. ADDITIONAL_MODULES += --with-http_flv_module
  94. endif
  95. ifeq ($(CONFIG_NGINX_SSL),y)
  96. ADDITIONAL_MODULES += --with-http_ssl_module
  97. endif
  98. ifeq ($(CONFIG_NGINX_DAV),y)
  99. ADDITIONAL_MODULES += --with-http_dav_module
  100. endif
  101. ifneq ($(CONFIG_NGINX_HTTP_CACHE),y)
  102. ADDITIONAL_MODULES += --without-http-cache
  103. endif
  104. ifneq ($(CONFIG_NGINX_PCRE),y)
  105. ADDITIONAL_MODULES += --without-pcre
  106. endif
  107. ifneq ($(CONFIG_NGINX_HTTP_CHARSET),y)
  108. ADDITIONAL_MODULES += --without-http_charset_module
  109. else
  110. config_files += koi-utf koi-win win-utf
  111. endif
  112. ifneq ($(CONFIG_NGINX_HTTP_GZIP),y)
  113. ADDITIONAL_MODULES += --without-http_gzip_module
  114. endif
  115. ifneq ($(CONFIG_NGINX_HTTP_SSI),y)
  116. ADDITIONAL_MODULES += --without-http_ssi_module
  117. endif
  118. ifneq ($(CONFIG_NGINX_HTTP_USERID),y)
  119. ADDITIONAL_MODULES += --without-http_userid_module
  120. endif
  121. ifneq ($(CONFIG_NGINX_HTTP_ACCESS),y)
  122. ADDITIONAL_MODULES += --without-http_access_module
  123. endif
  124. ifneq ($(CONFIG_NGINX_HTTP_AUTH_BASIC),y)
  125. ADDITIONAL_MODULES += --without-http_auth_basic_module
  126. endif
  127. ifeq ($(CONFIG_NGINX_HTTP_AUTH_REQUEST),y)
  128. ADDITIONAL_MODULES += --with-http_auth_request_module
  129. endif
  130. ifneq ($(CONFIG_NGINX_HTTP_AUTOINDEX),y)
  131. ADDITIONAL_MODULES += --without-http_autoindex_module
  132. endif
  133. ifneq ($(CONFIG_NGINX_HTTP_GEO),y)
  134. ADDITIONAL_MODULES += --without-http_geo_module
  135. endif
  136. ifneq ($(CONFIG_NGINX_HTTP_MAP),y)
  137. ADDITIONAL_MODULES += --without-http_map_module
  138. endif
  139. ifneq ($(CONFIG_NGINX_HTTP_SPLIT_CLIENTS),y)
  140. ADDITIONAL_MODULES += --without-http_split_clients_module
  141. endif
  142. ifneq ($(CONFIG_NGINX_HTTP_REFERER),y)
  143. ADDITIONAL_MODULES += --without-http_referer_module
  144. endif
  145. ifneq ($(CONFIG_NGINX_HTTP_REWRITE),y)
  146. ADDITIONAL_MODULES += --without-http_rewrite_module
  147. endif
  148. ifneq ($(CONFIG_NGINX_HTTP_PROXY),y)
  149. ADDITIONAL_MODULES += --without-http_proxy_module
  150. endif
  151. ifneq ($(CONFIG_NGINX_HTTP_FASTCGI),y)
  152. ADDITIONAL_MODULES += --without-http_fastcgi_module
  153. else
  154. config_files += fastcgi_params
  155. endif
  156. ifneq ($(CONFIG_NGINX_HTTP_UWSGI),y)
  157. ADDITIONAL_MODULES += --without-http_uwsgi_module
  158. endif
  159. ifneq ($(CONFIG_NGINX_HTTP_SCGI),y)
  160. ADDITIONAL_MODULES += --without-http_scgi_module
  161. endif
  162. ifneq ($(CONFIG_NGINX_HTTP_MEMCACHED),y)
  163. ADDITIONAL_MODULES += --without-http_memcached_module
  164. endif
  165. ifneq ($(CONFIG_NGINX_HTTP_LIMIT_CONN),y)
  166. ADDITIONAL_MODULES += --without-http_limit_conn_module
  167. endif
  168. ifneq ($(CONFIG_NGINX_HTTP_LIMIT_REQ),y)
  169. ADDITIONAL_MODULES += --without-http_limit_req_module
  170. endif
  171. ifneq ($(CONFIG_NGINX_HTTP_EMPTY_GIF),y)
  172. ADDITIONAL_MODULES += --without-http_empty_gif_module
  173. endif
  174. ifneq ($(CONFIG_NGINX_HTTP_BROWSER),y)
  175. ADDITIONAL_MODULES += --without-http_browser_module
  176. endif
  177. ifneq ($(CONFIG_NGINX_HTTP_UPSTREAM_HASH),y)
  178. ADDITIONAL_MODULES += --without-http_upstream_hash_module
  179. endif
  180. ifneq ($(CONFIG_NGINX_HTTP_UPSTREAM_IP_HASH),y)
  181. ADDITIONAL_MODULES += --without-http_upstream_ip_hash_module
  182. endif
  183. ifneq ($(CONFIG_NGINX_HTTP_UPSTREAM_LEAST_CONN),y)
  184. ADDITIONAL_MODULES += --without-http_upstream_least_conn_module
  185. endif
  186. ifneq ($(CONFIG_NGINX_HTTP_UPSTREAM_KEEPALIVE),y)
  187. ADDITIONAL_MODULES += --without-http_upstream_keepalive_module
  188. endif
  189. ifeq ($(CONFIG_NGINX_HTTP_V2),y)
  190. ADDITIONAL_MODULES += --with-http_v2_module
  191. endif
  192. ifeq ($(CONFIG_NGINX_HTTP_REAL_IP),y)
  193. ADDITIONAL_MODULES += --with-http_realip_module
  194. endif
  195. ifeq ($(CONFIG_NGINX_HTTP_SECURE_LINK),y)
  196. ADDITIONAL_MODULES += --with-http_secure_link_module
  197. endif
  198. TARGET_CFLAGS += -fvisibility=hidden -ffunction-sections -fdata-sections -DNGX_LUA_NO_BY_LUA_BLOCK
  199. TARGET_LDFLAGS += -Wl,--gc-sections
  200. define Build/Configure
  201. ( cd $(PKG_BUILD_DIR) ; \
  202. $(if $(CONFIG_NGINX_LUA),LUA_INC=$(STAGING_DIR)/usr/include LUA_LIB=$(STAGING_DIR)/usr/lib) \
  203. ./configure \
  204. --crossbuild=Linux::$(ARCH) \
  205. --prefix=/usr \
  206. --conf-path=/etc/nginx/nginx.conf \
  207. $(ADDITIONAL_MODULES) \
  208. --error-log-path=/var/log/nginx/error.log \
  209. --pid-path=/var/run/nginx.pid \
  210. --lock-path=/var/lock/nginx.lock \
  211. --http-log-path=/var/log/nginx/access.log \
  212. --http-client-body-temp-path=/var/lib/nginx/body \
  213. --http-proxy-temp-path=/var/lib/nginx/proxy \
  214. --http-fastcgi-temp-path=/var/lib/nginx/fastcgi \
  215. --with-cc="$(TARGET_CC)" \
  216. --with-cc-opt="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" \
  217. --with-ld-opt="$(TARGET_LDFLAGS)" \
  218. --without-http_upstream_zone_module \
  219. )
  220. endef
  221. define Package/nginx/install
  222. $(INSTALL_DIR) $(1)/usr/sbin
  223. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/nginx $(1)/usr/sbin/
  224. $(INSTALL_DIR) $(1)/etc/nginx
  225. $(INSTALL_DATA) $(addprefix $(PKG_INSTALL_DIR)/etc/nginx/,$(config_files)) $(1)/etc/nginx/
  226. $(INSTALL_DIR) $(1)/etc/init.d
  227. $(INSTALL_BIN) ./files/nginx.init $(1)/etc/init.d/nginx
  228. ifeq ($(CONFIG_NGINX_NAXSI),y)
  229. $(INSTALL_DIR) $(1)/etc/nginx
  230. $(INSTALL_BIN) $(PKG_BUILD_DIR)/nginx-naxsi/naxsi_config/naxsi_core.rules $(1)/etc/nginx
  231. chmod 0640 $(1)/etc/nginx/naxsi_core.rules
  232. endif
  233. $(if $(CONFIG_NGINX_NAXSI),$($(INSTALL_BIN) $(PKG_BUILD_DIR)/nginx-naxsi/naxsi_config/naxsi_core.rules $(1)/etc/nginx))
  234. $(if $(CONFIG_NGINX_NAXSI),$(chmod 0640 $(1)/etc/nginx/naxsi_core.rules))
  235. endef
  236. define Build/Prepare
  237. $(call Build/Prepare/Default)
  238. $(if $(CONFIG_NGINX_NAXSI),$(call Prepare/nginx-naxsi))
  239. $(if $(CONFIG_NGINX_LUA),$(call Prepare/lua-nginx))
  240. endef
  241. define Download/nginx-naxsi
  242. VERSION:=cf73f9c8664127252c2a4958d2e169516d3845a1
  243. SUBDIR:=nginx-naxsi
  244. FILE:=nginx-naxsi-module-$(PKG_VERSION)-$$(VERSION).tar.gz
  245. URL:=https://github.com/nbs-system/naxsi.git
  246. PROTO:=git
  247. endef
  248. define Prepare/nginx-naxsi
  249. $(eval $(call Download,nginx-naxsi))
  250. gzip -dc $(DL_DIR)/$(FILE) | tar -C $(PKG_BUILD_DIR) $(TAR_OPTIONS)
  251. endef
  252. define Download/lua-nginx
  253. VERSION:=cdd2ae921f67bf396c743406493127be496e57ce
  254. SUBDIR:=lua-nginx
  255. FILE:=lua-nginx-module-$(PKG_VERSION)-$$(VERSION).tar.gz
  256. URL:=https://github.com/openresty/lua-nginx-module.git
  257. PROTO:=git
  258. endef
  259. define Prepare/lua-nginx
  260. $(eval $(call Download,lua-nginx))
  261. gzip -dc $(DL_DIR)/$(FILE) | tar -C $(PKG_BUILD_DIR) $(TAR_OPTIONS)
  262. $(call PatchDir,$(PKG_BUILD_DIR),./patches-lua-nginx)
  263. endef
  264. $(eval $(call BuildPackage,nginx))