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.

353 lines
10 KiB

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