Hi, I just wrote a Makefile + patches to compile nginx ( http://nginx.net/ ) for openwrt. It is quite basic for now (no init scripts, no openwrt-specific config file), and has some hardcoded requirement, but should run ok for those wanting to experiment with it.
The "hardcoded" requirements are for things that nginx want to run on the host, but are OK for a recent 2.6 kernel and GNU userland, I think. License-wise, the sizeof patch has been inspired by autoconf (see http://ac-archive.sourceforge.net/ac-archive/compile_value.html ) and the configure arguments come mainly from the debian package for nginx. I think everything is OK, but I'd appreciate if someone could adivse of any conflict. Things to fix: * Add init scripts * Add a default config file for openwrt /etc/config * Fix the --crossbuild argument to reflect kernel version number * Fix the installation paths, they are debian-standards but may not be well fitted for openwrt Signed-off-by: Benjamin Cama <ben...@free.fr> --- Index: nginx/patches/002-sizeof_test_fix =================================================================== --- nginx/patches/002-sizeof_test_fix (révision 0) +++ nginx/patches/002-sizeof_test_fix (révision 0) @@ -0,0 +1,28 @@ +diff --git a/auto/types/sizeof b/auto/types/sizeof +index 4d65dca..2d5da3e 100644 +--- a/auto/types/sizeof ++++ b/auto/types/sizeof +@@ -23,8 +23,13 @@ $NGX_INCLUDE_UNISTD_H + $NGX_INCLUDE_INTTYPES_H + $NGX_INCLUDE_AUTO_CONFIG_H + ++char object_code_block[] = { ++ '\n', 'e', '4', 'V', 'A', ++ '0', 'x', ('0' + sizeof($ngx_type)), ++ 'Y', '3', 'p', 'M', '\n' ++}; ++ + int main() { +- printf("%d", sizeof($ngx_type)); + return 0; + } + +@@ -38,7 +43,7 @@ eval "$ngx_test >> $NGX_AUTOCONF_ERR 2>&1" + + + if [ -x $NGX_AUTOTEST ]; then +- ngx_size=`$NGX_AUTOTEST` ++ ngx_size=`sed -ne 's/^e4VA0x\(.\)Y3pM$/\1/p' < $NGX_AUTOTEST` + echo " $ngx_size bytes" + fi + Index: nginx/patches/001-feature_test_fix =================================================================== --- nginx/patches/001-feature_test_fix (révision 0) +++ nginx/patches/001-feature_test_fix (révision 0) @@ -0,0 +1,144 @@ +diff --git a/auto/cc/conf b/auto/cc/conf +index 4823900..1e676f4 100644 +--- a/auto/cc/conf ++++ b/auto/cc/conf +@@ -135,7 +135,8 @@ if [ "$NGX_PLATFORM" != win32 ]; then + ngx_feature_test="char buf[30]; buf[0] = '0'; + var(0, buf, \"%d\", 1); + if (buf[0] != '1') return 1" +- . auto/feature ++ #. auto/feature ++ have=$ngx_feature_name . auto/have + + + if [ "$NGX_CC_NAME" = "ccc" ]; then +@@ -151,7 +152,8 @@ if [ "$NGX_PLATFORM" != win32 ]; then + ngx_feature_test="char buf[30]; buf[0] = '0'; + var(0, buf, \"%d\", 1); + if (buf[0] != '1') return 1" +- . auto/feature ++ #. auto/feature ++ have=$ngx_feature_name . auto/have + fi + + +diff --git a/auto/cc/name b/auto/cc/name +index d197fc5..28b74b0 100644 +--- a/auto/cc/name ++++ b/auto/cc/name +@@ -13,12 +13,12 @@ if [ "$NGX_PLATFORM" != win32 ]; then + ngx_feature_test= + . auto/feature + +- if [ $ngx_found = no ]; then +- echo +- echo $0: error: C compiler $CC is not found +- echo +- exit 1 +- fi ++ #if [ $ngx_found = no ]; then ++ # echo ++ # echo $0: error: C compiler $CC is not found ++ # echo ++ # exit 1 ++ #fi + + fi + +diff --git a/auto/os/linux b/auto/os/linux +index 0bd0488..9cb0aa1 100644 +--- a/auto/os/linux ++++ b/auto/os/linux +@@ -49,7 +49,8 @@ ngx_feature_test="int efd = 0, fd = 1, n; + ee.data.ptr = NULL; + efd = epoll_create(100); + if (efd == -1) return 1;" +-. auto/feature ++#. auto/feature ++have=$ngx_feature_name . auto/have + + if [ $ngx_found = yes ]; then + have=NGX_HAVE_CLEAR_EVENT . auto/have +@@ -73,7 +74,8 @@ ngx_feature_test="int s = 0, fd = 1; + ssize_t n; off_t off = 0; + n = sendfile(s, fd, &off, 1); + if (n == -1 && errno == ENOSYS) return 1" +-. auto/feature ++#. auto/feature ++have=$ngx_feature_name . auto/have + + if [ $ngx_found = yes ]; then + CORE_SRCS="$CORE_SRCS $LINUX_SENDFILE_SRCS" +@@ -94,7 +96,8 @@ ngx_feature_test="int s = 0, fd = 1; + ssize_t n; off_t off = 0; + n = sendfile(s, fd, &off, 1); + if (n == -1 && errno == ENOSYS) return 1" +-. auto/feature ++#. auto/feature ++have=$ngx_feature_name . auto/have + + + ngx_include="sys/prctl.h"; . auto/include +@@ -108,7 +111,8 @@ ngx_feature_incs="#include <sys/prctl.h>" + ngx_feature_path= + ngx_feature_libs= + ngx_feature_test="if (prctl(PR_SET_DUMPABLE, 1, 0, 0, 0) == -1) return 1" +-. auto/feature ++#. auto/feature ++have=$ngx_feature_name . auto/have + + + # sched_setaffinity() +diff --git a/auto/unix b/auto/unix +index 687a23a..23e8b78 100755 +--- a/auto/unix ++++ b/auto/unix +@@ -117,7 +117,7 @@ ngx_feature_path= + ngx_feature_libs= + ngx_feature_test="char buf[1024]; long n; n = strerror_r(1, buf, 1024); + if (n < 0 || n > 1024) return 1;" +-. auto/feature ++#. auto/feature + + + # GNU style strerror_r() returns not length, but pointer +@@ -130,7 +130,8 @@ ngx_feature_path= + ngx_feature_libs= + ngx_feature_test="char buf[1024]; long n; n = strerror_r(1, buf, 1024); + if (n >= 0 && n < 1024) return 1;" +-. auto/feature ++#. auto/feature ++have=$ngx_feature_name . auto/have + + + ngx_feature="localtime_r()" +@@ -173,7 +174,8 @@ ngx_feature_test="void *p; + p = mmap(NULL, 4096, PROT_READ|PROT_WRITE, + MAP_ANON|MAP_SHARED, -1, 0); + if (p == MAP_FAILED) return 1;" +-. auto/feature ++#. auto/feature ++have=$ngx_feature_name . auto/have + + + ngx_feature='mmap("/dev/zero", MAP_SHARED)' +@@ -188,7 +190,8 @@ ngx_feature_test='void *p; int fd; + fd = open("/dev/zero", O_RDWR); + p = mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); + if (p == MAP_FAILED) return 1;' +-. auto/feature ++#. auto/feature ++have=$ngx_feature_name . auto/have + + + ngx_feature="System V shared memory" +@@ -202,7 +205,8 @@ ngx_feature_test="int id; + id = shmget(IPC_PRIVATE, 4096, (SHM_R|SHM_W|IPC_CREAT)); + if (id == -1) return 1; + shmctl(id, IPC_RMID, NULL);" +-. auto/feature ++#. auto/feature ++have=$ngx_feature_name . auto/have + + + ngx_feature="struct msghdr.msg_control" Index: nginx/Makefile =================================================================== --- nginx/Makefile (révision 0) +++ nginx/Makefile (révision 0) @@ -0,0 +1,75 @@ +# +# Copyright (C) 2009 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# +# $Id$ + +include $(TOPDIR)/rules.mk + +PKG_NAME:=nginx +PKG_VERSION:=0.7.60 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=http://sysoev.ru/nginx/ +PKG_MD5SUM:=291b2c1a43b0f79949113cdedacd5343 + +include $(INCLUDE_DIR)/package.mk + +define Package/nginx + SECTION:=custom + CATEGORY:=Custom + DEPENDS:=+libpcre +libopenssl + TITLE:=Nginx web server + URL:=http://nginx.net/ +endef + +define Package/nginx/description + Nginx is a free, open-source, high-performance HTTP server + and reverse proxy, as well as an IMAP/POP3 proxy server, + written by Igor Sysoev. +endef + +define Build/Configure + # fix --crossbuild + (cd $(PKG_BUILD_DIR) ;\ + ./configure \ + --crossbuild=Linux::$(ARCH) \ + --prefix=/usr \ + --conf-path=/etc/nginx/nginx.conf \ + --error-log-path=/var/log/nginx/error.log \ + --pid-path=/var/run/nginx.pid \ + --lock-path=/var/lock/nginx.lock \ + --http-log-path=/var/log/nginx/access.log \ + --http-client-body-temp-path=/var/lib/nginx/body \ + --http-proxy-temp-path=/var/lib/nginx/proxy \ + --http-fastcgi-temp-path=/var/lib/nginx/fastcgi \ + --with-cc="$(TARGET_CC)" \ + --with-cc-opt="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" \ + --with-ld-opt="$(TARGET_LDFLAGS)" \ + --with-http_stub_status_module \ + --with-http_ssl_module \ + --with-ipv6 ) +endef + +define Build/Compile + $(MAKE) -C $(PKG_BUILD_DIR) \ + DESTDIR=$(PKG_INSTALL_DIR) \ + build install +endef + +define Package/nginx/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/nginx $(1)/usr/sbin/ + $(INSTALL_DIR) $(1)/etc/nginx + $(CP) $(PKG_INSTALL_DIR)/etc/nginx/* $(1)/etc/nginx + $(INSTALL_DIR) $(1)/var/run + $(INSTALL_DIR) $(1)/var/lock + $(INSTALL_DIR) $(1)/var/log/nginx + $(INSTALL_DIR) $(1)/var/lib/nginx +endef + +$(eval $(call BuildPackage,nginx)) + _______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel