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