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.

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