1################################################################################ 2# 3# nginx 4# 5################################################################################ 6 7NGINX_VERSION = 1.24.0 8NGINX_SITE = https://nginx.org/download 9NGINX_LICENSE = BSD-2-Clause 10NGINX_LICENSE_FILES = LICENSE 11NGINX_CPE_ID_VENDOR = f5 12NGINX_DEPENDENCIES = \ 13 host-pkgconf \ 14 $(if $(BR2_PACKAGE_LIBXCRYPT),libxcrypt) 15 16NGINX_CONF_OPTS = \ 17 --crossbuild=Linux::$(BR2_ARCH) \ 18 --with-cc="$(TARGET_CC)" \ 19 --with-cpp="$(TARGET_CC)" \ 20 --with-ld-opt="$(TARGET_LDFLAGS)" 21 22# www-data user and group are used for nginx. Because these user and group 23# are already set by buildroot, it is not necessary to redefine them. 24# See system/skeleton/etc/passwd 25# username: www-data uid: 33 26# groupname: www-data gid: 33 27# 28# So, we just need to create the directories used by nginx with the right 29# ownership. 30define NGINX_PERMISSIONS 31 /var/lib/nginx d 755 33 33 - - - - - 32endef 33 34# disable external libatomic_ops because its detection fails. 35NGINX_CONF_ENV += \ 36 ngx_force_c_compiler=yes \ 37 ngx_force_c99_have_variadic_macros=yes \ 38 ngx_force_gcc_have_variadic_macros=yes \ 39 ngx_force_gcc_have_atomic=yes \ 40 ngx_force_have_epoll=yes \ 41 ngx_force_have_sendfile=yes \ 42 ngx_force_have_sendfile64=yes \ 43 ngx_force_have_pr_set_dumpable=yes \ 44 ngx_force_have_timer_event=yes \ 45 ngx_force_have_map_anon=yes \ 46 ngx_force_have_map_devzero=yes \ 47 ngx_force_have_sysvshm=yes \ 48 ngx_force_have_posix_sem=yes 49 50# prefix: nginx root configuration location 51NGINX_CONF_OPTS += \ 52 --force-endianness=$(call qstrip,$(call LOWERCASE,$(BR2_ENDIAN))) \ 53 --prefix=/usr \ 54 --conf-path=/etc/nginx/nginx.conf \ 55 --sbin-path=/usr/sbin/nginx \ 56 --pid-path=/run/nginx.pid \ 57 --lock-path=/run/lock/nginx.lock \ 58 --user=www-data \ 59 --group=www-data \ 60 --error-log-path=/var/log/nginx/error.log \ 61 --http-log-path=/var/log/nginx/access.log \ 62 --http-client-body-temp-path=/var/cache/nginx/client-body \ 63 --http-proxy-temp-path=/var/cache/nginx/proxy \ 64 --http-fastcgi-temp-path=/var/cache/nginx/fastcgi \ 65 --http-scgi-temp-path=/var/cache/nginx/scgi \ 66 --http-uwsgi-temp-path=/var/cache/nginx/uwsgi 67 68NGINX_CONF_OPTS += \ 69 $(if $(BR2_PACKAGE_NGINX_FILE_AIO),--with-file-aio) \ 70 $(if $(BR2_PACKAGE_NGINX_THREADS),--with-threads) 71 72ifeq ($(BR2_PACKAGE_LIBATOMIC_OPS),y) 73NGINX_DEPENDENCIES += libatomic_ops 74NGINX_CONF_OPTS += --with-libatomic 75NGINX_CONF_ENV += ngx_force_have_libatomic=yes 76ifeq ($(BR2_sparc_v8)$(BR2_sparc_leon3),y) 77NGINX_CFLAGS += "-DAO_NO_SPARC_V9" 78endif 79else 80NGINX_CONF_ENV += ngx_force_have_libatomic=no 81endif 82 83ifeq ($(BR2_PACKAGE_PCRE2),y) 84NGINX_DEPENDENCIES += pcre2 85NGINX_CONF_OPTS += --with-pcre 86else 87NGINX_CONF_OPTS += --without-pcre 88endif 89 90# modules disabled or not activated because of missing dependencies: 91# - google_perftools (googleperftools) 92# - http_perl_module (host-perl) 93# - pcre-jit (want to rebuild pcre) 94 95# Notes: 96# * Feature/module option are *not* symetric. 97# If a feature is on by default, only its --without-xxx option exists; 98# if a feature is off by default, only its --with-xxx option exists. 99# * The configure script fails if unknown options are passed on the command 100# line. 101 102# misc. modules 103NGINX_CONF_OPTS += \ 104 $(if $(BR2_PACKAGE_NGINX_SELECT_MODULE),--with-select_module,--without-select_module) \ 105 $(if $(BR2_PACKAGE_NGINX_POLL_MODULE),--with-poll_module,--without-poll_module) 106 107ifneq ($(BR2_PACKAGE_NGINX_ADD_MODULES),) 108NGINX_CONF_OPTS += \ 109 $(addprefix --add-module=,$(call qstrip,$(BR2_PACKAGE_NGINX_ADD_MODULES))) 110endif 111 112# http server modules 113ifeq ($(BR2_PACKAGE_NGINX_HTTP),y) 114ifeq ($(BR2_PACKAGE_NGINX_HTTP_CACHE),y) 115NGINX_DEPENDENCIES += openssl 116else 117NGINX_CONF_OPTS += --without-http-cache 118endif 119 120ifeq ($(BR2_PACKAGE_NGINX_HTTP_V2_MODULE),y) 121NGINX_DEPENDENCIES += zlib 122NGINX_CONF_OPTS += --with-http_v2_module 123endif 124 125ifeq ($(BR2_PACKAGE_NGINX_HTTP_SSL_MODULE),y) 126NGINX_DEPENDENCIES += openssl 127NGINX_CONF_OPTS += --with-http_ssl_module 128endif 129 130ifeq ($(BR2_PACKAGE_NGINX_HTTP_XSLT_MODULE),y) 131NGINX_DEPENDENCIES += libxml2 libxslt 132NGINX_CONF_OPTS += --with-http_xslt_module 133endif 134 135ifeq ($(BR2_PACKAGE_NGINX_HTTP_IMAGE_FILTER_MODULE),y) 136NGINX_DEPENDENCIES += gd jpeg libpng 137NGINX_CONF_OPTS += --with-http_image_filter_module 138endif 139 140ifeq ($(BR2_PACKAGE_NGINX_HTTP_GEOIP_MODULE),y) 141NGINX_DEPENDENCIES += geoip 142NGINX_CONF_OPTS += --with-http_geoip_module 143endif 144 145ifeq ($(BR2_PACKAGE_NGINX_HTTP_GUNZIP_MODULE),y) 146NGINX_DEPENDENCIES += zlib 147NGINX_CONF_OPTS += --with-http_gunzip_module 148endif 149 150ifeq ($(BR2_PACKAGE_NGINX_HTTP_GZIP_STATIC_MODULE),y) 151NGINX_DEPENDENCIES += zlib 152NGINX_CONF_OPTS += --with-http_gzip_static_module 153endif 154 155ifeq ($(BR2_PACKAGE_NGINX_HTTP_SECURE_LINK_MODULE),y) 156NGINX_DEPENDENCIES += openssl 157NGINX_CONF_OPTS += --with-http_secure_link_module 158endif 159 160ifeq ($(BR2_PACKAGE_NGINX_HTTP_GZIP_MODULE),y) 161NGINX_DEPENDENCIES += zlib 162else 163NGINX_CONF_OPTS += --without-http_gzip_module 164endif 165 166ifeq ($(BR2_PACKAGE_NGINX_HTTP_REWRITE_MODULE),y) 167NGINX_DEPENDENCIES += pcre2 168else 169NGINX_CONF_OPTS += --without-http_rewrite_module 170endif 171 172NGINX_CONF_OPTS += \ 173 $(if $(BR2_PACKAGE_NGINX_HTTP_REALIP_MODULE),--with-http_realip_module) \ 174 $(if $(BR2_PACKAGE_NGINX_HTTP_ADDITION_MODULE),--with-http_addition_module) \ 175 $(if $(BR2_PACKAGE_NGINX_HTTP_SUB_MODULE),--with-http_sub_module) \ 176 $(if $(BR2_PACKAGE_NGINX_HTTP_DAV_MODULE),--with-http_dav_module) \ 177 $(if $(BR2_PACKAGE_NGINX_HTTP_FLV_MODULE),--with-http_flv_module) \ 178 $(if $(BR2_PACKAGE_NGINX_HTTP_MP4_MODULE),--with-http_mp4_module) \ 179 $(if $(BR2_PACKAGE_NGINX_HTTP_AUTH_REQUEST_MODULE),--with-http_auth_request_module) \ 180 $(if $(BR2_PACKAGE_NGINX_HTTP_RANDOM_INDEX_MODULE),--with-http_random_index_module) \ 181 $(if $(BR2_PACKAGE_NGINX_HTTP_DEGRADATION_MODULE),--with-http_degradation_module) \ 182 $(if $(BR2_PACKAGE_NGINX_HTTP_SLICE_MODULE),--with-http_slice_module) \ 183 $(if $(BR2_PACKAGE_NGINX_HTTP_STUB_STATUS_MODULE),--with-http_stub_status_module) \ 184 $(if $(BR2_PACKAGE_NGINX_HTTP_CHARSET_MODULE),,--without-http_charset_module) \ 185 $(if $(BR2_PACKAGE_NGINX_HTTP_SSI_MODULE),,--without-http_ssi_module) \ 186 $(if $(BR2_PACKAGE_NGINX_HTTP_USERID_MODULE),,--without-http_userid_module) \ 187 $(if $(BR2_PACKAGE_NGINX_HTTP_ACCESS_MODULE),,--without-http_access_module) \ 188 $(if $(BR2_PACKAGE_NGINX_HTTP_AUTH_BASIC_MODULE),,--without-http_auth_basic_module) \ 189 $(if $(BR2_PACKAGE_NGINX_HTTP_AUTOINDEX_MODULE),,--without-http_autoindex_module) \ 190 $(if $(BR2_PACKAGE_NGINX_HTTP_GEO_MODULE),,--without-http_geo_module) \ 191 $(if $(BR2_PACKAGE_NGINX_HTTP_MAP_MODULE),,--without-http_map_module) \ 192 $(if $(BR2_PACKAGE_NGINX_HTTP_SPLIT_CLIENTS_MODULE),,--without-http_split_clients_module) \ 193 $(if $(BR2_PACKAGE_NGINX_HTTP_REFERER_MODULE),,--without-http_referer_module) \ 194 $(if $(BR2_PACKAGE_NGINX_HTTP_PROXY_MODULE),,--without-http_proxy_module) \ 195 $(if $(BR2_PACKAGE_NGINX_HTTP_FASTCGI_MODULE),,--without-http_fastcgi_module) \ 196 $(if $(BR2_PACKAGE_NGINX_HTTP_UWSGI_MODULE),,--without-http_uwsgi_module) \ 197 $(if $(BR2_PACKAGE_NGINX_HTTP_SCGI_MODULE),,--without-http_scgi_module) \ 198 $(if $(BR2_PACKAGE_NGINX_HTTP_MEMCACHED_MODULE),,--without-http_memcached_module) \ 199 $(if $(BR2_PACKAGE_NGINX_HTTP_LIMIT_CONN_MODULE),,--without-http_limit_conn_module) \ 200 $(if $(BR2_PACKAGE_NGINX_HTTP_LIMIT_REQ_MODULE),,--without-http_limit_req_module) \ 201 $(if $(BR2_PACKAGE_NGINX_HTTP_EMPTY_GIF_MODULE),,--without-http_empty_gif_module) \ 202 $(if $(BR2_PACKAGE_NGINX_HTTP_BROWSER_MODULE),,--without-http_browser_module) \ 203 $(if $(BR2_PACKAGE_NGINX_HTTP_UPSTREAM_IP_HASH_MODULE),,--without-http_upstream_ip_hash_module) \ 204 $(if $(BR2_PACKAGE_NGINX_HTTP_UPSTREAM_LEAST_CONN_MODULE),,--without-http_upstream_least_conn_module) \ 205 $(if $(BR2_PACKAGE_NGINX_HTTP_UPSTREAM_RANDOM_MODULE),,--without-http_upstream_random_module) \ 206 $(if $(BR2_PACKAGE_NGINX_HTTP_UPSTREAM_KEEPALIVE_MODULE),,--without-http_upstream_keepalive_module) \ 207 $(if $(BR2_PACKAGE_NGINX_HTTP_UPSTREAM_ZONE_MODULE),,--without-http_upstream_zone_module) 208 209else # !BR2_PACKAGE_NGINX_HTTP 210NGINX_CONF_OPTS += --without-http 211endif # BR2_PACKAGE_NGINX_HTTP 212 213# mail modules 214ifeq ($(BR2_PACKAGE_NGINX_MAIL),y) 215NGINX_CONF_OPTS += --with-mail 216 217ifeq ($(BR2_PACKAGE_NGINX_MAIL_SSL_MODULE),y) 218NGINX_DEPENDENCIES += openssl 219NGINX_CONF_OPTS += --with-mail_ssl_module 220endif 221 222NGINX_CONF_OPTS += \ 223 $(if $(BR2_PACKAGE_NGINX_MAIL_POP3_MODULE),,--without-mail_pop3_module) \ 224 $(if $(BR2_PACKAGE_NGINX_MAIL_IMAP_MODULE),,--without-mail_imap_module) \ 225 $(if $(BR2_PACKAGE_NGINX_MAIL_SMTP_MODULE),,--without-mail_smtp_module) 226 227endif # BR2_PACKAGE_NGINX_MAIL 228 229# stream modules 230ifeq ($(BR2_PACKAGE_NGINX_STREAM),y) 231NGINX_CONF_OPTS += --with-stream 232 233ifeq ($(BR2_PACKAGE_NGINX_STREAM_REALIP_MODULE),y) 234NGINX_CONF_OPTS += --with-stream_realip_module 235endif 236 237ifeq ($(BR2_PACKAGE_NGINX_STREAM_SET_MODULE),) 238NGINX_CONF_OPTS += --without-stream_set_module 239endif 240 241ifeq ($(BR2_PACKAGE_NGINX_STREAM_SSL_MODULE),y) 242NGINX_DEPENDENCIES += openssl 243NGINX_CONF_OPTS += --with-stream_ssl_module 244endif 245 246ifeq ($(BR2_PACKAGE_NGINX_STREAM_GEOIP_MODULE),y) 247NGINX_DEPENDENCIES += geoip 248NGINX_CONF_OPTS += --with-stream_geoip_module 249endif 250 251ifeq ($(BR2_PACKAGE_NGINX_STREAM_SSL_PREREAD_MODULE),y) 252NGINX_CONF_OPTS += --with-stream_ssl_preread_module 253endif 254 255NGINX_CONF_OPTS += \ 256 $(if $(BR2_PACKAGE_NGINX_STREAM_LIMIT_CONN_MODULE),,--without-stream_limit_conn_module) \ 257 $(if $(BR2_PACKAGE_NGINX_STREAM_ACCESS_MODULE),,--without-stream_access_module) \ 258 $(if $(BR2_PACKAGE_NGINX_STREAM_GEO_MODULE),,--without-stream_geo_module) \ 259 $(if $(BR2_PACKAGE_NGINX_STREAM_MAP_MODULE),,--without-stream_map_module) \ 260 $(if $(BR2_PACKAGE_NGINX_STREAM_SPLIT_CLIENTS_MODULE),,--without-stream_split_clients_module) \ 261 $(if $(BR2_PACKAGE_NGINX_STREAM_RETURN_MODULE),,--without-stream_return_module) \ 262 $(if $(BR2_PACKAGE_NGINX_STREAM_UPSTREAM_HASH_MODULE),,--without-stream_upstream_hash_module) \ 263 $(if $(BR2_PACKAGE_NGINX_STREAM_UPSTREAM_LEAST_CONN_MODULE),,--without-stream_upstream_least_conn_module) \ 264 $(if $(BR2_PACKAGE_NGINX_STREAM_UPSTREAM_RANDOM_MODULE),,--without-stream_upstream_random_module) \ 265 $(if $(BR2_PACKAGE_NGINX_STREAM_UPSTREAM_ZONE_MODULE),,--without-stream_upstream_zone_module) 266 267endif # BR2_PACKAGE_NGINX_STREAM 268 269# external modules 270ifeq ($(BR2_PACKAGE_NGINX_UPLOAD),y) 271NGINX_CONF_OPTS += $(addprefix --add-module=,$(NGINX_UPLOAD_DIR)) 272NGINX_DEPENDENCIES += nginx-upload 273endif 274 275ifeq ($(BR2_PACKAGE_NGINX_DAV_EXT),y) 276NGINX_CONF_OPTS += --add-module=$(NGINX_DAV_EXT_DIR) 277NGINX_DEPENDENCIES += nginx-dav-ext 278endif 279 280ifeq ($(BR2_PACKAGE_NGINX_NAXSI),y) 281NGINX_DEPENDENCIES += nginx-naxsi 282NGINX_CONF_OPTS += --add-module=$(NGINX_NAXSI_DIR)/naxsi_src 283endif 284 285ifeq ($(BR2_PACKAGE_NGINX_MODSECURITY),y) 286NGINX_DEPENDENCIES += nginx-modsecurity 287NGINX_CONF_OPTS += --add-module=$(NGINX_MODSECURITY_DIR) 288endif 289 290# Debug logging 291NGINX_CONF_OPTS += $(if $(BR2_PACKAGE_NGINX_DEBUG),--with-debug) 292 293define NGINX_DISABLE_WERROR 294 $(SED) 's/-Werror//g' -i $(@D)/auto/cc/* 295endef 296 297NGINX_PRE_CONFIGURE_HOOKS += NGINX_DISABLE_WERROR 298 299define NGINX_CONFIGURE_CMDS 300 cd $(@D) ; $(NGINX_CONF_ENV) \ 301 PKG_CONFIG="$(PKG_CONFIG_HOST_BINARY)" \ 302 ./configure $(NGINX_CONF_OPTS) \ 303 --with-cc-opt="$(TARGET_CFLAGS) $(NGINX_CFLAGS)" 304endef 305 306define NGINX_BUILD_CMDS 307 $(TARGET_MAKE_ENV) $(MAKE) -C $(@D) 308endef 309 310define NGINX_INSTALL_TARGET_CMDS 311 $(TARGET_MAKE_ENV) $(MAKE) -C $(@D) DESTDIR=$(TARGET_DIR) install 312 $(RM) $(TARGET_DIR)/usr/sbin/nginx.old 313 $(INSTALL) -D -m 0664 package/nginx/nginx.logrotate \ 314 $(TARGET_DIR)/etc/logrotate.d/nginx 315endef 316 317define NGINX_INSTALL_INIT_SYSTEMD 318 $(INSTALL) -D -m 0644 package/nginx/nginx.service \ 319 $(TARGET_DIR)/usr/lib/systemd/system/nginx.service 320endef 321 322define NGINX_INSTALL_INIT_SYSV 323 $(INSTALL) -D -m 0755 package/nginx/S50nginx \ 324 $(TARGET_DIR)/etc/init.d/S50nginx 325endef 326 327$(eval $(generic-package)) 328