Commit 390a1449 authored by Samuel Martin's avatar Samuel Martin Committed by Thomas Petazzoni
Browse files

package/nginx: new package

nginx module selection is, by default, the same as the one sets by
the upstream configure script.

Patches improving the cross-compilation support have already been sent
upstream for integration [1-5].

All these patches are needed because nginx uses its own handwritten
build-system, which is cross-platform, but does not properly support
cross-compilation.

Fixes bug: #3427 [6]

[1] http://mailman.nginx.org/pipermail/nginx-devel/2014-August/005722.html
[2] http://mailman.nginx.org/pipermail/nginx-devel/2014-August/005724.html
[3] http://mailman.nginx.org/pipermail/nginx-devel/2014-August/005725.html
[4] http://mailman.nginx.org/pipermail/nginx-devel/2014-August/005723.html
[5] http://mailman.nginx.org/pipermail/nginx-devel/2014-August/005726.html
[6] https://bugs.uclibc.org/show_bug.cgi?id=3427



Signed-off-by: default avatarSamuel Martin <s.martin49@gmail.com>
Cc: Daniele Salvatore Albano <info@daccii.it>
Cc: Maxime Hadjinlian <maxime.hadjinlian@gmail.com>
Cc: Johan Oudinet <johan.oudinet@gmail.com>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: Gustavo Zacarias <gustavo@zacarias.com.ar>
Signed-off-by: default avatarThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Tested-by: default avatarThomas Petazzoni <thomas.petazzoni@free-electrons.com>
parent a8f986c4
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -1035,6 +1035,7 @@ endif
	source "package/network-manager/Config.in"
	source "package/nfacct/Config.in"
	source "package/nftables/Config.in"
	source "package/nginx/Config.in"
	source "package/ngircd/Config.in"
	source "package/ngrep/Config.in"
	source "package/nmap/Config.in"
+326 −0
Original line number Diff line number Diff line
comment "nginx needs a toolchain w/ largefile"
	depends on !BR2_LARGEFILE

menuconfig BR2_PACKAGE_NGINX
	bool "nginx"
	depends on BR2_LARGEFILE
	help
	  nginx is an HTTP and reverse proxy server, as well as a mail proxy
	  server.

	  http://nginx.org/

if BR2_PACKAGE_NGINX

config BR2_PACKAGE_NGINX_FILE_AIO
	bool "file AIO support"

config BR2_PACKAGE_NGINX_HTTP
	bool "http server"
	default y

if BR2_PACKAGE_NGINX_HTTP

config BR2_PACKAGE_NGINX_HTTP_CACHE
	bool "http cache support"
	select BR2_PACKAGE_OPENSSL

comment "http modules"

config BR2_PACKAGE_NGINX_HTTP_SSL_MODULE
	bool "ngx_http_ssl_module"
	select BR2_PACKAGE_OPENSSL
	help
	  Enable ngx_http_ssl_module

config BR2_PACKAGE_NGINX_HTTP_SPDY_MODULE
	bool "ngx_http_spdy_module"
	select BR2_PACKAGE_ZLIB
	help
	  Enable ngx_http_spdy_module

config BR2_PACKAGE_NGINX_HTTP_REALIP_MODULE
	bool "ngx_http_realip_module"
	help
	  Enable ngx_http_realip_module

config BR2_PACKAGE_NGINX_HTTP_ADDITION_MODULE
	bool "ngx_http_addition_module"
	help
	  Enable ngx_http_addition_module

config BR2_PACKAGE_NGINX_HTTP_XSLT_MODULE
	bool "ngx_http_xslt_module"
	select BR2_PACKAGE_LIBXML2
	select BR2_PACKAGE_LIBXSLT
	help
	  Enable ngx_http_xslt_module

config BR2_PACKAGE_NGINX_HTTP_IMAGE_FILTER_MODULE
	bool "ngx_http_image_filter_module"
	select BR2_PACKAGE_GD
	select BR2_PACKAGE_JPEG
	select BR2_PACKAGE_LIBPNG
	help
	  Enable ngx_http_image_filter_module

config BR2_PACKAGE_NGINX_HTTP_SUB_MODULE
	bool "ngx_http_sub_module"
	help
	  Enable ngx_http_sub_module

config BR2_PACKAGE_NGINX_HTTP_DAV_MODULE
	bool "ngx_http_dav_module"
	help
	  Enable ngx_http_dav_module

config BR2_PACKAGE_NGINX_HTTP_FLV_MODULE
	bool "ngx_http_flv_module"
	help
	  Enable ngx_http_flv_module

config BR2_PACKAGE_NGINX_HTTP_MP4_MODULE
	bool "ngx_http_mp4_module"
	help
	  Enable ngx_http_mp4_module

config BR2_PACKAGE_NGINX_HTTP_GUNZIP_MODULE
	bool "ngx_http_gunzip_module"
	select BR2_PACKAGE_ZLIB
	help
	  Enable ngx_http_gunzip_module

config BR2_PACKAGE_NGINX_HTTP_GZIP_STATIC_MODULE
	bool "ngx_http_gzip_static_module"
	select BR2_PACKAGE_ZLIB
	help
	  Enable ngx_http_gzip_static_module

config BR2_PACKAGE_NGINX_HTTP_AUTH_REQUEST_MODULE
	bool "ngx_http_auth_request_module"
	help
	  Enable ngx_http_auth_request_module

config BR2_PACKAGE_NGINX_HTTP_RANDOM_INDEX_MODULE
	bool "ngx_http_random_index_module"
	help
	  Enable ngx_http_random_index_module

config BR2_PACKAGE_NGINX_HTTP_SECURE_LINK_MODULE
	bool "ngx_http_secure_link_module"
	select BR2_PACKAGE_OPENSSL
	help
	  Enable ngx_http_secure_link_module

config BR2_PACKAGE_NGINX_HTTP_DEGRADATION_MODULE
	bool "ngx_http_degradation_module"
	help
	  Enable ngx_http_degradation_module

config BR2_PACKAGE_NGINX_HTTP_STUB_STATUS_MODULE
	bool "ngx_http_stub_status_module"
	help
	  Enable ngx_http_stub_status_module

config BR2_PACKAGE_NGINX_HTTP_CHARSET_MODULE
	bool "ngx_http_charset_module"
	default y
	help
	  Enable ngx_http_charset_module

config BR2_PACKAGE_NGINX_HTTP_GZIP_MODULE
	bool "ngx_http_gzip_module"
	select BR2_PACKAGE_ZLIB
	default y
	help
	  Enable ngx_http_gzip_module

config BR2_PACKAGE_NGINX_HTTP_SSI_MODULE
	bool "ngx_http_ssi_module"
	default y
	help
	  Enable ngx_http_ssi_module

config BR2_PACKAGE_NGINX_HTTP_USERID_MODULE
	bool "ngx_http_userid_module"
	default y
	help
	  Enable ngx_http_userid_module

config BR2_PACKAGE_NGINX_HTTP_ACCESS_MODULE
	bool "ngx_http_access_module"
	default y
	help
	  Enable ngx_http_access_module

config BR2_PACKAGE_NGINX_HTTP_AUTH_BASIC_MODULE
	bool "ngx_http_auth_basic_module"
	default y
	help
	  Enable ngx_http_auth_basic_module

config BR2_PACKAGE_NGINX_HTTP_AUTOINDEX_MODULE
	bool "ngx_http_autoindex_module"
	default y
	help
	  Enable ngx_http_autoindex_module

config BR2_PACKAGE_NGINX_HTTP_GEO_MODULE
	bool "ngx_http_geo_module"
	default y
	help
	  Enable ngx_http_geo_module

config BR2_PACKAGE_NGINX_HTTP_MAP_MODULE
	bool "ngx_http_map_module"
	default y
	help
	  Enable ngx_http_map_module

config BR2_PACKAGE_NGINX_HTTP_SPLIT_CLIENTS_MODULE
	bool "ngx_http_split_clients_module"
	default y
	help
	  Enable ngx_http_split_clients_module

config BR2_PACKAGE_NGINX_HTTP_REFERER_MODULE
	bool "ngx_http_referer_module"
	default y
	help
	  Enable ngx_http_referer_module

config BR2_PACKAGE_NGINX_HTTP_REWRITE_MODULE
	bool "ngx_http_rewrite_module"
	select BR2_PACKAGE_PCRE
	default y
	help
	  Enable ngx_http_rewrite_module

config BR2_PACKAGE_NGINX_HTTP_PROXY_MODULE
	bool "ngx_http_proxy_module"
	default y
	help
	  Enable ngx_http_proxy_module

config BR2_PACKAGE_NGINX_HTTP_FASTCGI_MODULE
	bool "ngx_http_fastcgi_module"
	default y
	help
	  Enable ngx_http_fastcgi_module

config BR2_PACKAGE_NGINX_HTTP_UWSGI_MODULE
	bool "ngx_http_uwsgi_module"
	default y
	help
	  Enable ngx_http_uwsgi_module

config BR2_PACKAGE_NGINX_HTTP_SCGI_MODULE
	bool "ngx_http_scgi_module"
	default y
	help
	  Enable ngx_http_scgi_module

config BR2_PACKAGE_NGINX_HTTP_MEMCACHED_MODULE
	bool "ngx_http_memcached_module"
	default y
	help
	  Enable ngx_http_memcached_module

config BR2_PACKAGE_NGINX_HTTP_LIMIT_CONN_MODULE
	bool "ngx_http_limit_conn_module"
	default y
	help
	  Enable ngx_http_limit_conn_module

config BR2_PACKAGE_NGINX_HTTP_LIMIT_REQ_MODULE
	bool "ngx_http_limit_req_module"
	default y
	help
	  Enable ngx_http_limit_req_module

config BR2_PACKAGE_NGINX_HTTP_EMPTY_GIF_MODULE
	bool "ngx_http_empty_gif_module"
	default y
	help
	  Enable ngx_http_empty_gif_module

config BR2_PACKAGE_NGINX_HTTP_BROWSER_MODULE
	bool "ngx_http_browser_module"
	default y
	help
	  Enable ngx_http_browser_module

config BR2_PACKAGE_NGINX_HTTP_UPSTREAM_IP_HASH_MODULE
	bool "ngx_http_upstream_ip_hash_module"
	default y
	help
	  Enable ngx_http_upstream_ip_hash_module

config BR2_PACKAGE_NGINX_HTTP_UPSTREAM_LEAST_CONN_MODULE
	bool "ngx_http_upstream_least_conn_module"
	default y
	help
	  Enable ngx_http_upstream_least_conn_module

config BR2_PACKAGE_NGINX_HTTP_UPSTREAM_KEEPALIVE_MODULE
	bool "ngx_http_upstream_keepalive_module"
	default y
	help
	  Enable ngx_http_upstream_keepalive_module

endif #BR2_PACKAGE_NGINX_HTTP

config BR2_PACKAGE_NGINX_MAIL
	bool "mail proxy modules"

if BR2_PACKAGE_NGINX_MAIL

config BR2_PACKAGE_NGINX_MAIL_SSL_MODULE
	bool "ngx_mail_ssl_module"
	select BR2_PACKAGE_OPENSSL
	help
	  Enable ngx_mail_ssl_module

config BR2_PACKAGE_NGINX_MAIL_POP3_MODULE
	bool "ngx_mail_pop3_module"
	default y
	help
	  Enable ngx_mail_pop3_module

config BR2_PACKAGE_NGINX_MAIL_IMAP_MODULE
	bool "ngx_mail_imap_module"
	default y
	help
	  Enable ngx_mail_imap_module

config BR2_PACKAGE_NGINX_MAIL_SMTP_MODULE
	bool "ngx_mail_smtp_module"
	default y
	help
	  Enable ngx_mail_smtp_module

endif #BR2_PACKAGE_NGINX_MAIL

comment "misc. modules"

config BR2_PACKAGE_NGINX_RTSIG_MODULE
	bool "ngx_rtsig_module"
	help
	  Enable ngx_rtsig_module

config BR2_PACKAGE_NGINX_SELECT_MODULE
	bool "ngx_select_module"
	help
	  Enable ngx_select_module

config BR2_PACKAGE_NGINX_POLL_MODULE
	bool "ngx_poll_module"
	help
	  Enable ngx_poll_module

config BR2_PACKAGE_NGINX_ADD_MODULES
	string "additional modules"
	help
	  Space separated list of urls of the additional modules

endif

package/nginx/S50nginx

0 → 100755
+25 −0
Original line number Diff line number Diff line
#!/bin/sh
#
# Start/stop nginx
#

PIDFILE=/var/run/nginx.pid

case "$1" in
  start)
	echo "Starting nginx..."
	mkdir -p /var/log/nginx /var/tmp/nginx
	start-stop-daemon -S -x /usr/sbin/nginx -p $PIDFILE
	;;
  stop)
	echo -n "Stopping nginx..."
	start-stop-daemon -K -o -p $PIDFILE
	;;
  restart|reload)
	"$0" stop
	"$0" start
	;;
  *)
	echo "Usage: $0 {start|stop|restart}"
	exit 1
esac
+88 −0
Original line number Diff line number Diff line
From 81289d1d1adaf5a767a4b4d1309c286468cfd37f Mon Sep 17 00:00:00 2001
From: Samuel Martin <s.martin49@gmail.com>
Date: Thu, 24 Apr 2014 23:27:32 +0200
Subject: [PATCH 1/5] auto/type/sizeof: rework autotest to be cross-compilation
 friendly

Rework the sizeof test to do the checks at compile time instead of at
runtime. This way, it does not break when cross-compiling for a
different CPU architecture.

Signed-off-by: Samuel Martin <s.martin49@gmail.com>
---
 auto/types/sizeof | 42 ++++++++++++++++++++++++++++--------------
 1 file changed, 28 insertions(+), 14 deletions(-)

diff --git a/auto/types/sizeof b/auto/types/sizeof
index 9215a54..c2c3ede 100644
--- a/auto/types/sizeof
+++ b/auto/types/sizeof
@@ -14,7 +14,7 @@ END
 
 ngx_size=
 
-cat << END > $NGX_AUTOTEST.c
+cat << _EOF > $NGX_AUTOTEST.c
 
 #include <sys/types.h>
 #include <sys/time.h>
@@ -25,29 +25,43 @@ $NGX_INCLUDE_UNISTD_H
 $NGX_INCLUDE_INTTYPES_H
 $NGX_INCLUDE_AUTO_CONFIG_H
 
-int main() {
-    printf("%d", (int) sizeof($ngx_type));
+#if !defined( PASTE)
+#define PASTE2( x, y) x##y
+#define PASTE( x, y)  PASTE2( x, y)
+#endif /* PASTE */
+
+#define SAY_IF_SIZEOF( typename, type, size)   \\
+    static char PASTE( PASTE( PASTE( sizeof_, typename), _is_), size) \\
+    [(sizeof(type) == (size)) ? 1 : -1]
+
+SAY_IF_SIZEOF(TEST_TYPENAME, TEST_TYPE, TEST_SIZE);
+
+int main(void)
+{
     return 0;
 }
 
-END
-
+_EOF
 
-ngx_test="$CC $CC_TEST_FLAGS $CC_AUX_FLAGS \
-          -o $NGX_AUTOTEST $NGX_AUTOTEST.c $NGX_LD_OPT $ngx_feature_libs"
+_ngx_typename=`echo "$ngx_type" | sed 's/ /_/g;s/\*/p/'`
+ngx_size="-1"
+ngx_size=`for i in 1 2 4 8 16 ; do \
+    $CC $CC_TEST_FLAGS $CC_AUX_FLAGS \
+    -DTEST_TYPENAME="$_ngx_typename" -DTEST_TYPE="$ngx_type" -DTEST_SIZE="$i" \
+    $NGX_AUTOTEST.c -o $NGX_AUTOTEST \
+    $NGX_LD_OPT $ngx_feature_libs >/dev/null 2>&1 || continue ;\
+    echo $i ; break ; done`
 
-eval "$ngx_test >> $NGX_AUTOCONF_ERR 2>&1"
+rm -rf $NGX_AUTOTEST*
 
+if test -z $ngx_size ; then
+    ngx_size=-1
+fi
 
-if [ -x $NGX_AUTOTEST ]; then
-    ngx_size=`$NGX_AUTOTEST`
+if [ $ngx_size -gt 0 ]; then
     echo " $ngx_size bytes"
 fi
 
-
-rm -rf $NGX_AUTOTEST*
-
-
 case $ngx_size in
     4)
         if [ "$ngx_type"="long" ]; then
-- 
1.9.2
+135 −0
Original line number Diff line number Diff line
From ef72be22ad6d58e230f75553d80b470b80c3303a Mon Sep 17 00:00:00 2001
From: Samuel Martin <s.martin49@gmail.com>
Date: Sun, 4 May 2014 00:40:49 +0200
Subject: [PATCH 2/5] auto/feature: add mechanism allowing to force feature run
 test result

Whenever a feature needs to run a test, the ngx_feature_run_force_result
variable can be set to the desired test result, and thus skip the test.

Therefore, the generated config.h file will honor these presets.

This mechanism aims to make easier cross-compilation support.

Signed-off-by: Samuel Martin <s.martin49@gmail.com>
---
 auto/feature | 80 ++++++++++++++++++++++++++++++++++++++++++++----------------
 1 file changed, 59 insertions(+), 21 deletions(-)

diff --git a/auto/feature b/auto/feature
index 1145f28..a194b85 100644
--- a/auto/feature
+++ b/auto/feature
@@ -52,50 +52,88 @@ if [ -x $NGX_AUTOTEST ]; then
     case "$ngx_feature_run" in
 
         yes)
-            # /bin/sh is used to intercept "Killed" or "Abort trap" messages
-            if /bin/sh -c $NGX_AUTOTEST >> $NGX_AUTOCONF_ERR 2>&1; then
-                echo " found"
+            if test -n "$ngx_feature_run_force_result" ; then
+                echo " not tested (maybe cross-compiling)"
+                if test -n "$ngx_feature_name" ; then
+                    if test "$ngx_feature_run_force_result" = "yes" ; then
+                        have=$ngx_have_feature . auto/have
+                    fi
+                fi
                 ngx_found=yes
+            else
 
-                if test -n "$ngx_feature_name"; then
-                    have=$ngx_have_feature . auto/have
+                # /bin/sh is used to intercept "Killed" or "Abort trap" messages
+                if /bin/sh -c $NGX_AUTOTEST >> $NGX_AUTOCONF_ERR 2>&1; then
+                    echo " found"
+                    ngx_found=yes
+
+                    if test -n "$ngx_feature_name"; then
+                        have=$ngx_have_feature . auto/have
+                    fi
+
+                else
+                    echo " found but is not working"
                 fi
 
-            else
-                echo " found but is not working"
             fi
         ;;
 
         value)
-            # /bin/sh is used to intercept "Killed" or "Abort trap" messages
-            if /bin/sh -c $NGX_AUTOTEST >> $NGX_AUTOCONF_ERR 2>&1; then
-                echo " found"
+            if test -n "$ngx_feature_run_force_result" ; then
+                echo " not tested (maybe cross-compiling)"
+                cat << END >> $NGX_AUTO_CONFIG_H
+
+#ifndef $ngx_feature_name
+#define $ngx_feature_name  $ngx_feature_run_force_result
+#endif
+
+END
                 ngx_found=yes
+            else
 
-                cat << END >> $NGX_AUTO_CONFIG_H
+                # /bin/sh is used to intercept "Killed" or "Abort trap" messages
+                if /bin/sh -c $NGX_AUTOTEST >> $NGX_AUTOCONF_ERR 2>&1; then
+                    echo " found"
+                    ngx_found=yes
+
+                    cat << END >> $NGX_AUTO_CONFIG_H
 
 #ifndef $ngx_feature_name
 #define $ngx_feature_name  `$NGX_AUTOTEST`
 #endif
 
 END
-            else
-                echo " found but is not working"
+                else
+                    echo " found but is not working"
+                fi
+
             fi
         ;;
 
         bug)
-            # /bin/sh is used to intercept "Killed" or "Abort trap" messages
-            if /bin/sh -c $NGX_AUTOTEST >> $NGX_AUTOCONF_ERR 2>&1; then
-                echo " not found"
-
-            else
-                echo " found"
+            if test -n "$ngx_feature_run_force_result" ; then
+                echo " not tested (maybe cross-compiling)"
+                if test -n "$ngx_feature_name"; then
+                    if test "$ngx_feature_run_force_result" = "yes" ; then
+                        have=$ngx_have_feature . auto/have
+                    fi
+                fi
                 ngx_found=yes
+            else
 
-                if test -n "$ngx_feature_name"; then
-                    have=$ngx_have_feature . auto/have
+                # /bin/sh is used to intercept "Killed" or "Abort trap" messages
+                if /bin/sh -c $NGX_AUTOTEST >> $NGX_AUTOCONF_ERR 2>&1; then
+                    echo " not found"
+
+                else
+                    echo " found"
+                    ngx_found=yes
+
+                    if test -n "$ngx_feature_name"; then
+                        have=$ngx_have_feature . auto/have
+                    fi
                 fi
+
             fi
         ;;
 
-- 
1.9.2
Loading