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.

334 lines
9.6 KiB

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