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