Makefile 8.1 KB

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