Radix cross Linux

The main Radix cross Linux repository contains the build scripts of packages, which have the most complete and common functionality for desktop machines

452 Commits   2 Branches   1 Tag

COMPONENT_TARGETS  = $(HARDWARE_INTEL_PC32)
COMPONENT_TARGETS += $(HARDWARE_INTEL_PC64)
COMPONENT_TARGETS += $(HARDWARE_EBOX_3350DX2)
COMPONENT_TARGETS += $(HARDWARE_CB1X)
COMPONENT_TARGETS += $(HARDWARE_CB2X)
COMPONENT_TARGETS += $(HARDWARE_CB3X)
COMPONENT_TARGETS += $(HARDWARE_ORANGE_PP2E)
COMPONENT_TARGETS += $(HARDWARE_NANOPI_NEO)
COMPONENT_TARGETS += $(HARDWARE_ORANGE_PP)
COMPONENT_TARGETS += $(HARDWARE_ORANGE_PL2)
COMPONENT_TARGETS += $(HARDWARE_ORANGE_PI5)
COMPONENT_TARGETS += $(HARDWARE_ORANGE_PI5B)
COMPONENT_TARGETS += $(HARDWARE_ORANGE_PI5P)
COMPONENT_TARGETS += $(HARDWARE_ROCK_5B)
COMPONENT_TARGETS += $(HARDWARE_WECHIP_TX6)
COMPONENT_TARGETS += $(HARDWARE_REPKA_PI3)
COMPONENT_TARGETS += $(HARDWARE_FFRK3288)
COMPONENT_TARGETS += $(HARDWARE_POIN2)
COMPONENT_TARGETS += $(HARDWARE_RK3328_CC)
COMPONENT_TARGETS += $(HARDWARE_KHADAS_EDGE)
COMPONENT_TARGETS += $(HARDWARE_LEEZ_P710)
COMPONENT_TARGETS += $(HARDWARE_M201)
COMPONENT_TARGETS += $(HARDWARE_MXV)
COMPONENT_TARGETS += $(HARDWARE_P201)
COMPONENT_TARGETS += $(HARDWARE_NEXBOX_A95X)
COMPONENT_TARGETS += $(HARDWARE_ODROID_C2)
COMPONENT_TARGETS += $(HARDWARE_P212)
COMPONENT_TARGETS += $(HARDWARE_KHADAS_VIM)
COMPONENT_TARGETS += $(HARDWARE_Q201)
COMPONENT_TARGETS += $(HARDWARE_ENYBOX_X2)
COMPONENT_TARGETS += $(HARDWARE_KHADAS_VIM2)
COMPONENT_TARGETS += $(HARDWARE_NIT6Q)
COMPONENT_TARGETS += $(HARDWARE_OKMX6DL_C)
COMPONENT_TARGETS += $(HARDWARE_OKMX6Q_C)
COMPONENT_TARGETS += $(HARDWARE_BONE_BLACK)
COMPONENT_TARGETS += $(HARDWARE_OMAP5UEVM)
COMPONENT_TARGETS += $(HARDWARE_DRA7XXEVM)
COMPONENT_TARGETS += $(HARDWARE_CI20)
COMPONENT_TARGETS += $(HARDWARE_BAIKAL_T1)
COMPONENT_TARGETS += $(HARDWARE_BAIKAL_M1)
COMPONENT_TARGETS += $(HARDWARE_S824L)
COMPONENT_TARGETS += $(HARDWARE_VESNIN)
COMPONENT_TARGETS += $(HARDWARE_S824L_LSB)
COMPONENT_TARGETS += $(HARDWARE_VESNIN_LSB)
COMPONENT_TARGETS += $(HARDWARE_TL2WK2)
COMPONENT_TARGETS += $(HARDWARE_TL2SV2)
COMPONENT_TARGETS += $(HARDWARE_TL2WK2_LSB)
COMPONENT_TARGETS += $(HARDWARE_TL2SV2_LSB)
COMPONENT_TARGETS += $(HARDWARE_VISIONFIVE2)
COMPONENT_TARGETS += $(HARDWARE_SIFIVE_U740)


NEED_ABS_PATH      = true
COMPONENT_IS_3PP   = true


include ../../../build-system/constants.mk


SOURCE_REQUIRES    = sources/packages/n/nginx


REQUIRES           = libs/libxslt/1.1.34
REQUIRES          += libs/libgd/2.3.3
REQUIRES          += libs/pcre/8.44
REQUIRES          += libs/zlib/1.2.13
REQUIRES          += net/openssl/1.1.1r
REQUIRES          += net/geoip/1.16.2
REQUIRES          += net/libnsl/1.3.0
REQUIRES          += dev/perl/5.36.0

# ======= __END_OF_REQUIRES__ =======


version            = 1.20.2
tar_gz_archive     = $(SRC_PACKAGE_PATH)/packages/n/nginx/nginx-$(version).tar.gz
SRC_ARCHIVE        = $(tar_gz_archive)
SRC_DIR            = $(TARGET_BUILD_DIR)/nginx-$(version)
src_dir_name       = nginx-$(version)
src_done           = $(TARGET_BUILD_DIR)/.source_done

PATCHES = PATCHES

build_target       = $(TARGET_BUILD_DIR)/.build_done
install_target     = $(TARGET_BUILD_DIR)/.install_done


####### Targets

PKG_GROUP = net

#
# *PKG_NAME & *PKG_VERSION shouldn't be a reference to value.
#
NGINX_PKG_NAME                = nginx
NGINX_PKG_VERSION             = 1.20.2
NGINX_PKG_ARCH                = $(PKGARCH)
NGINX_PKG_DISTRO_NAME         = $(DISTRO_NAME)
NGINX_PKG_DISTRO_VERSION      = $(DISTRO_VERSION)
NGINX_PKG_GROUP               = $(PKG_GROUP)
###                            |---handy-ruler-------------------------------|
NGINX_PKG_SHORT_DESCRIPTION   = http/imap/pop3 proxy
NGINX_PKG_URL                 = $(BUG_URL)
NGINX_PKG_LICENSE             = custom
NGINX_PKG_DESCRIPTION_FILE    = $(TARGET_BUILD_DIR)/$(NGINX_PKG_NAME)-pkg-description
NGINX_PKG_DESCRIPTION_FILE_IN = $(NGINX_PKG_NAME)-pkg-description.in
NGINX_PKG_INSTALL_SCRIPT      = $(NGINX_PKG_NAME)-pkg-install.sh

NGINX_PKG        = $(CURDIR)/$(TARGET_BUILD_DIR)/$(NGINX_PKG_NAME)-package

pkg_basename     = $(NGINX_PKG_NAME)-$(NGINX_PKG_VERSION)-$(NGINX_PKG_ARCH)-$(NGINX_PKG_DISTRO_NAME)-$(NGINX_PKG_DISTRO_VERSION)

pkg_archive      = $(TARGET_BUILD_DIR)/$(PKG_GROUP)/$(pkg_basename).$(pkg_arch_suffix)
pkg_certificate  = $(call cert-name,$(pkg_archive))
pkg_signature    = $(call sign-name,$(pkg_archive))
pkg_description  = $(call desc-name,$(pkg_archive))
products         = $(call pkg-files,$(pkg_archive))

BUILD_TARGETS    = $(build_target)
BUILD_TARGETS   += $(install_target)

PRODUCT_TARGETS  = $(products)

ROOTFS_TARGETS   = $(pkg_archive)


include ../../../build-system/core.mk


env_sysroot  = DESTDIR=$(NGINX_PKG)


#
# Common Perl5 Environment:
# ========================
#
perl_environment  = INSTALLDIRS=vendor

perl_environment += PERL_LIB='$(TARGET_DEST_DIR)/usr/share/perl5'
perl_environment += PERL_ARCHLIB='$(TARGET_DEST_DIR)/usr/lib$(LIBSUFFIX)/perl5'
perl_environment += PERL_INC='$(TARGET_DEST_DIR)/usr/lib$(LIBSUFFIX)/perl5/CORE'

perl_environment += SITELIBEXP='/usr/share/perl5/site_perl'
perl_environment += SITEARCHEXP='/usr/lib$(LIBSUFFIX)/perl5/site_perl'
perl_environment += VENDORLIBEXP='/usr/share/perl5/vendor_perl'
perl_environment += VENDORARCHEXP='/usr/lib$(LIBSUFFIX)/perl5/vendor_perl'

perl_environment += PERLPREFIX='/usr'
perl_environment += INSTALLPRIVLIB='/usr/share/perl5'
perl_environment += INSTALLARCHLIB='/usr/lib$(LIBSUFFIX)/perl5'

perl_environment += SITEPREFIX='/usr'
perl_environment += INSTALLSITELIB='/usr/share/perl5/site_perl'
perl_environment += INSTALLSITEARCH='/usr/lib$(LIBSUFFIX)/perl5/site_perl'

perl_environment += VENDORPREFIX='/usr'
perl_environment += INSTALLVENDORLIB='/usr/share/perl5/vendor_perl'
perl_environment += INSTALLVENDORARCH='/usr/lib$(LIBSUFFIX)/perl5/vendor_perl'

perl_environment += INSTALLBIN='/usr/bin'
perl_environment += INSTALLSITEBIN='/usr/bin'
perl_environment += INSTALLVENDORBIN='/usr/bin'

perl_environment += INSTALLSCRIPT='/usr/bin'
perl_environment += INSTALLSITESCRIPT='/usr/bin'
perl_environment += INSTALLVENDORSCRIPT='/usr/bin'

perl_environment += INSTALLMAN1DIR='/usr/share/man/man1'
perl_environment += INSTALLSITEMAN1DIR='/usr/share/man/man1'
perl_environment += INSTALLVENDORMAN1DIR='/usr/share/man/man1'

perl_environment += INSTALLMAN3DIR='/usr/share/man/man3'
perl_environment += INSTALLSITEMAN3DIR='/usr/share/man/man3'
perl_environment += INSTALLVENDORMAN3DIR='/usr/share/man/man3'

#
# HW Specific Perl5 Environment:
# =============================
#
suppress-warnings = -Wno-unused-function -Wno-unused-parameter

perl_environment += AR=$(AR)
perl_environment += RANLIB=$(RANLIB)
perl_environment += CC='$(CC) --sysroot=$(TARGET_DEST_DIR) $(ARCH_OPTIMIZATION) $(ARCH_FLAGS) $(ARCH_DEFS)'
perl_environment += LD='$(CC) --sysroot=$(TARGET_DEST_DIR) -shared'
perl_environment += LDFLAGS='$(LDFLAGS) -L$(TARGET_DEST_DIR)/usr/lib$(LIBSUFFIX)/perl5/CORE'
perl_environment += CCFLAGS='$(CFLAGS) -I$(TARGET_DEST_DIR)/usr/lib$(LIBSUFFIX)/perl5/CORE $(suppress-warnings)'
perl_environment += LDDLFLAGS='$(LDFLAGS) -L$(TARGET_DEST_DIR)/usr/lib$(LIBSUFFIX)/perl5/CORE'
perl_environment += CCCDLFLAGS='-fPIC'
perl_environment += CCDLFLAGS='-Wl,-E -Wl,-rpath,/usr/lib$(LIBSUFFIX)/perl5/CORE'
perl_environment += FULL_AR=$(AR)
perl_environment += OSNAME=linux
perl_environment += OSVERS=
perl_environment += LIBC=

perl_local_pod = usr/lib$(LIBSUFFIX)/perl5/perllocal.pod


#
# Nginx Configuration:
# ===================
#
DYNAMIC_MODULE  = =dynamic

extra_configure_switches  = --sbin-path=/usr/sbin/nginx
extra_configure_switches += --conf-path=/etc/nginx/nginx.conf
extra_configure_switches += --pid-path=/var/run/nginx.pid
extra_configure_switches += --lock-path=/var/lock/subsys
extra_configure_switches += --user=nginx
extra_configure_switches += --group=nginx
extra_configure_switches += --error-log-path=/var/log/nginx/error.log
extra_configure_switches += --http-log-path=/var/log/nginx/access.log
extra_configure_switches += --http-client-body-temp-path=/var/lib/nginx/client-body
extra_configure_switches += --http-proxy-temp-path=/var/lib/nginx/proxy
extra_configure_switches += --http-fastcgi-temp-path=/var/lib/nginx/fastcgi
extra_configure_switches += --http-uwsgi-temp-path=/var/lib/nginx/uwsgi
extra_configure_switches += --http-scgi-temp-path=/var/lib/nginx/scgi
extra_configure_switches += --modules-path=/usr/lib$(LIBSUFFIX)/nginx/modules
extra_configure_switches += --with-file-aio
extra_configure_switches += --with-select_module
extra_configure_switches += --with-poll_module
extra_configure_switches += --with-http_ssl_module
extra_configure_switches += --with-http_v2_module
extra_configure_switches += --with-http_realip_module
extra_configure_switches += --with-http_addition_module
extra_configure_switches += --with-http_xslt_module$(DYNAMIC_MODULE)
extra_configure_switches += --with-http_image_filter_module$(DYNAMIC_MODULE)
extra_configure_switches += --with-http_sub_module
extra_configure_switches += --with-http_dav_module
extra_configure_switches += --with-http_flv_module
extra_configure_switches += --with-http_mp4_module
extra_configure_switches += --with-http_gunzip_module
extra_configure_switches += --with-http_gzip_static_module
extra_configure_switches += --with-http_auth_request_module
extra_configure_switches += --with-http_random_index_module
extra_configure_switches += --with-http_secure_link_module
extra_configure_switches += --with-http_degradation_module
extra_configure_switches += --with-http_slice_module
extra_configure_switches += --with-http_stub_status_module
extra_configure_switches += --with-http_perl_module$(DYNAMIC_MODULE)
extra_configure_switches += --with-mail$(DYNAMIC_MODULE)
extra_configure_switches += --with-mail_ssl_module
extra_configure_switches += --with-stream$(DYNAMIC_MODULE)
extra_configure_switches += --with-stream_ssl_module
extra_configure_switches += --with-stream_realip_module
extra_configure_switches += --with-stream_ssl_preread_module
extra_configure_switches += --with-cpp_test_module
extra_configure_switches += --with-compat
extra_configure_switches += --with-pcre
extra_configure_switches += --with-pcre-jit
extra_configure_switches += --with-threads

#
# HAVE_GCC_ATOMIC:
#
# extra_configure_switches += --with-libatomic

#
# GeoIP: required GeoIP Legacy C Library: https://github.com/maxmind/geoip-api-c/
#
extra_configure_switches += --with-http_geoip_module=dynamic
extra_configure_switches += --with-stream_geoip_module$(DYNAMIC_MODULE)

#
# GPERF: required Google perftools library
#
# extra_configure_switches += --with-google_perftools_module

# Extra modules not included with stock nginx can be added by passing them as a
# variable to the slackbuild as a space separated list of full paths to modules.
# List of extra 3rd party modules available at http://wiki.nginx.org/3rdPartyModules.
#
# Additional modules not included in nginx:
#   --add-dynamic-module="/tmp/passenger-release-5.0.13/ext/nginx" or
#   --add-module="/tmp/passenger-release-5.0.13/ext/nginx"
#

CFLAGS  += -I$(TARGET_DEST_DIR)/usr/lib$(LIBSUFFIX)/perl5/CORE $(suppress-warnings)
LDFLAGS += -L$(TARGET_DEST_DIR)/usr/lib$(LIBSUFFIX)/perl5/CORE

extra_configure_switches += --with-cc='$(CROSS_PREFIX)gcc'
extra_configure_switches += --with-cc-opt='--sysroot=$(TARGET_DEST_DIR) $(CFLAGS)'
extra_configure_switches += --with-ld-opt='--sysroot=$(TARGET_DEST_DIR) $(LDFLAGS)'

#
# Nginx known following architectures:
#               i386 | i686 | i86pc     NGX_HAVE_NONALIGNED, NGX_MACH_CACHE_LINE=32
#                    amd64 | x86_64     NGX_HAVE_NONALIGNED, NGX_MACH_CACHE_LINE=64
#   sun4u | sun4v | sparc | sparc64     NGX_ALIGNMENT,       NGX_MACH_CACHE_LINE=64  value=16
#                              ia64     NGX_ALIGNMENT,       NGX_MACH_CACHE_LINE=64  value=16
#                           aarch64     NGX_ALIGNMENT,       NGX_MACH_CACHE_LINE=64  value=16
# for others Nginx sets:                NGX_ALIGNMENT,       NGX_MACH_CACHE_LINE=32  value=16
#

ifneq ($(filter $(TOOLCHAIN),$(TOOLCHAIN_A1X_GLIBC)    $(TOOLCHAIN_A2X_GLIBC)    \
                             $(TOOLCHAIN_H3_GLIBC)     $(TOOLCHAIN_RK328X_GLIBC) \
                             $(TOOLCHAIN_S8XX_GLIBC)   $(TOOLCHAIN_IMX6_GLIBC)   \
                             $(TOOLCHAIN_AM335X_GLIBC) $(TOOLCHAIN_OMAP543X_GLIBC)),)
cpu_arch = arm
cpu_name = generic
endif
ifneq ($(filter $(TOOLCHAIN),$(TOOLCHAIN_H5_GLIBC)     $(TOOLCHAIN_RK33XX_GLIBC) \
                             $(TOOLCHAIN_RK339X_GLIBC) $(TOOLCHAIN_RK358X_GLIBC) \
                             $(TOOLCHAIN_S9XX_GLIBC)   \
                             $(TOOLCHAIN_A311X_GLIBC)  $(TOOLCHAIN_M1000_GLIBC)),)
cpu_arch = aarch64
cpu_name = generic
endif
ifneq ($(filter $(TOOLCHAIN),$(TOOLCHAIN_JZ47XX_GLIBC) $(TOOLCHAIN_P5600_GLIBC)),)
cpu_arch = mips
cpu_name = generic
endif
ifneq ($(filter $(TOOLCHAIN),$(TOOLCHAIN_POWER8_GLIBC) $(TOOLCHAIN_POWER9_GLIBC)),)
cpu_arch = ppc64
cpu_name = ppc64
endif
ifneq ($(filter $(TOOLCHAIN),$(TOOLCHAIN_POWER8LE_GLIBC) $(TOOLCHAIN_POWER9LE_GLIBC)),)
cpu_arch = ppc64
cpu_name = ppc64
endif
ifneq ($(filter $(TOOLCHAIN),$(TOOLCHAIN_RISCV64_GLIBC)),)
cpu_arch = riscv64
cpu_name = generic
endif
ifneq ($(filter $(TOOLCHAIN),$(TOOLCHAIN_I586_GLIBC) $(TOOLCHAIN_I686_GLIBC)),)
cpu_arch = i386
cpu_name = generic
endif
ifneq ($(filter $(TOOLCHAIN),$(TOOLCHAIN_X86_64_GLIBC)),)
cpu_arch = x86_64
cpu_name = generic
endif


PERL_LIB_RPATH = /usr/lib$(LIBSUFFIX):/usr/lib$(LIBSUFFIX)/perl5/CORE


####### Dependencies

$(src_done): $(SRC_ARCHIVE) $(PATCHES_DEP)
	$(UNPACK_SRC_ARCHIVE)
	$(APPLY_PATCHES)
	# ======= Suppress -Werror option =======
	@( cd $(SRC_DIR) ; \
	   sed -i 's, -Werror,,' auto/cc/gcc ; \
	 )
	# ======= Change the nginx.conf file for html and virtual server directory =======
	@( cd $(SRC_DIR) ; \
	   sed -i -e '/^#user[ ]*nobody/s|nobody|nginx|'                   \
	          -e '/root[ ]*html/s|html;|/srv/nginx/vhosts/sysoev/&|'   \
	          -e '$$s|.*|    include /etc/nginx/conf.d/\*.conf;\n\n&|' \
	          -e '$$s|.*|    #\n&|'                                    \
	          -e '$$s|.*|    # Other Nginx congigs:\n&|'               \
	          -e '$$s|.*|    #\n&|'                                    \
	          -e '$$s|.*|    include /etc/nginx/vhosts/\*.conf;\n\n&|' \
	          -e '$$s|.*|    #\n&|'                                    \
	          -e '$$s|.*|    # Nginx hosted sites:\n&|'                \
	          -e '$$s|.*|    #\n&|'                                    conf/nginx.conf ; \
	 )
	# ======= Add if dynamic modules conf path to nginx.conf =======
	@( cd $(SRC_DIR) ; \
	   sed -i 's|^events.*|include /etc/nginx/modules/\*.conf;\n\n&|' conf/nginx.conf ; \
	 )
	@touch $@

$(build_target): $(src_done)
	@( cd $(SRC_DIR) ; \
	   CC='$(CROSS_PREFIX)gcc' \
	   NGX_PLATFORM='Linux'    \
	   NGX_CC_NAME='gcc' ./configure --crossbuild=Linux:$(cpu_arch) --with-cpu-opt=$(cpu_name) \
	      --prefix=/usr                  \
	      $(extra_configure_switches) ;  \
	 )
	@cd $(SRC_DIR) && $(BUILD_ENVIRONMENT) $(MAKE) $(perl_environment)
	@touch $@

$(install_target): $(build_target)
	@mkdir -p $(NGINX_PKG)
	@cd $(SRC_DIR) && $(BUILD_ENVIRONMENT) $(MAKE) -j1 install $(perl_environment) $(env_sysroot)
	@mkdir -p $(NGINX_PKG)/srv/nginx/{vhosts,cgi-bin}
	@mkdir -p $(NGINX_PKG)/srv/nginx/vhosts/sysoev
	@mv $(NGINX_PKG)/usr/html $(NGINX_PKG)/srv/nginx/vhosts/sysoev
	@cp $(CURDIR)/conf/favicon.ico $(NGINX_PKG)/srv/nginx/vhosts/sysoev/html
	@mkdir -p $(NGINX_PKG)/etc/nginx/{conf.d,modules,vhosts}
	@mkdir -p $(NGINX_PKG)/var/{lib,log}/nginx
	@chmod 0700 $(NGINX_PKG)/var/lib/nginx
	@chmod 0750 $(NGINX_PKG)/var/log/nginx
	# ======= Remove unneeded Perl5 pod and .pkglist =======
	@find $(NGINX_PKG) -name '.packlist' -delete
	@rm -f $(NGINX_PKG)/$(perl_local_pod)
	# ======= Install Nginx manpages =======
	@mkdir -p $(NGINX_PKG)/usr/share/man/man8
	@install -m 0644 $(SRC_DIR)/objs/nginx.8 $(NGINX_PKG)/usr/share/man/man8/nginx.8
	# ======= Check Permissions =======
	@find $(NGINX_PKG) -perm 444 -exec chmod 0644 {} \;
	@find $(NGINX_PKG) -perm 555 -exec chmod 0755 {} \;
	# ======= Install init/logrotate scripts =======
	@mkdir -p $(NGINX_PKG)/etc/rc.d
	@cat $(CURDIR)/conf/rc.nginx > $(NGINX_PKG)/etc/rc.d/rc.nginx.new
	@mkdir -p $(NGINX_PKG)/etc/logrotate.d
	@sed -e "s,@USER@,nginx," -e "s,@GROUP@,nginx," $(CURDIR)/conf/logrotate.nginx \
                  > $(NGINX_PKG)/etc/logrotate.d/nginx.new
	@( cd $(NGINX_PKG)/etc/nginx ; \
	   for file in fastcgi.conf fastcgi_params mime.types nginx.conf scgi_params uwsgi_params ; do \
	     mv $${file} $${file}.new ; \
	   done ; \
	 )
	# ======= Configure loading of dynamic modules =======
	@for module in $(NGINX_PKG)/usr/lib$(LIBSUFFIX)/nginx/modules/* ; do \
	   modname=`basename $${module} | sed 's|\.so||' | tr _ -` ; \
	   moddir=`dirname $${module} | sed 's|$(NGINX_PKG)||'` ; \
	   echo "load_module \"$${moddir}/`basename $${module}`\";" \
	    >> $(NGINX_PKG)/etc/nginx/modules/ngx-modules.conf ; \
	 done
	# ======= Swap the order of loading 'ngx_stream_geoip' and 'ngx_stream' modules =======
	@sed -i -e :a \
	        -e '$$!N;s/\(.*ngx_stream_geoip_module.*\)\n\(.*ngx_stream_module.*\)/\2\n\1/;ta' \
	        -e 'P;D' $(NGINX_PKG)/etc/nginx/modules/ngx-modules.conf
	# ======= Install Documentation =======
	@if [ -d $(NGINX_PKG)/usr/share/man ]; then \
	  ( cd $(NGINX_PKG)/usr/share/man ; \
	    for manpagedir in `find . -type d -name "man*"` ; do \
	      ( cd $$manpagedir ; \
	        for eachpage in `find . -type l -maxdepth 1` ; do \
	          ln -s `readlink $$eachpage`.gz $$eachpage.gz ; \
	          rm $$eachpage ; \
	        done ; \
	        gzip -9 *.?  ; \
	      ) \
	    done \
	  ) \
	 fi
	@mkdir -p $(NGINX_PKG)/usr/doc/$(src_dir_name)
	@cp -a $(SRC_DIR)/LICENSE \
	       $(NGINX_PKG)/usr/doc/$(src_dir_name)
	@mkdir -p $(NGINX_PKG)/usr/share/doc/$(src_dir_name)
	@( cd $(SRC_DIR) ; \
	   cp -a README \
	         $(NGINX_PKG)/usr/share/doc/$(src_dir_name) ; \
	 )
	@( cd $(SRC_DIR) ; \
	   if [ -r CHANGES ]; then \
	     DOCSDIR=`echo $(NGINX_PKG)/usr/share/doc/$(src_dir_name)` ; \
	     cat CHANGES | head -n 1000 > $$DOCSDIR/CHANGES ; \
	     touch -r CHANGES $$DOCSDIR/CHANGES ; \
	   fi \
	 )
	@( cd $(SRC_DIR) ; \
	   if [ -r CHANGES.ru ]; then \
	     DOCSDIR=`echo $(NGINX_PKG)/usr/share/doc/$(src_dir_name)` ; \
	     cat CHANGES.ru | head -n 1000 > $$DOCSDIR/CHANGES.ru ; \
	     touch -r CHANGES.ru $$DOCSDIR/CHANGES.ru ; \
	   fi \
	 )
	# ======= Install the same to $(TARGET_DEST_DIR) =======
	$(call install-into-devenv, $(NGINX_PKG))
	# ======= Strip binaries =======
	@( cd $(NGINX_PKG) ; \
	   find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs $(STRIP) --strip-unneeded 2> /dev/null ; \
	   find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs $(STRIP) --strip-unneeded 2> /dev/null ; \
	 )
ifneq ($(PATCHELF),)
	# ======= Set RPATH/RUNPATH for target shared objects =======
	@( cd $(NGINX_PKG)/usr/lib$(LIBSUFFIX) ; \
	   for file in `find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs echo` ; do \
	     rpath=`$(PATCHELF) --print-rpath $$file 2> /dev/null` ; \
	     if echo "$$rpath" | grep -q "$(BUILDSYSTEM)" ; then \
	       $(PATCHELF) --set-rpath $(PERL_LIB_RPATH) $$file 1> /dev/null 2> /dev/null ; \
	     fi ; \
	   done ; \
	 )
endif
	@touch $@

$(NGINX_PKG_DESCRIPTION_FILE): $(NGINX_PKG_DESCRIPTION_FILE_IN)
	@cat $< | $(SED) -e "s/@VERSION@/$(version)/g" > $@

$(pkg_certificate) : $(pkg_archive) ;
$(pkg_signature)   : $(pkg_archive) ;
$(pkg_description) : $(pkg_archive) ;

$(pkg_archive): $(install_target) $(NGINX_PKG_DESCRIPTION_FILE) $(NGINX_PKG_INSTALL_SCRIPT)
	@cp $(NGINX_PKG_DESCRIPTION_FILE) $(NGINX_PKG)/.DESCRIPTION
	@cp $(NGINX_PKG_INSTALL_SCRIPT) $(NGINX_PKG)/.INSTALL
	@$(BUILD_PKG_REQUIRES) $(NGINX_PKG)/.REQUIRES
	@echo "pkgname=$(NGINX_PKG_NAME)"                            >  $(NGINX_PKG)/.PKGINFO ; \
	 echo "pkgver=$(NGINX_PKG_VERSION)"                          >> $(NGINX_PKG)/.PKGINFO ; \
	 echo "arch=$(NGINX_PKG_ARCH)"                               >> $(NGINX_PKG)/.PKGINFO ; \
	 echo "distroname=$(NGINX_PKG_DISTRO_NAME)"                  >> $(NGINX_PKG)/.PKGINFO ; \
	 echo "distrover=$(NGINX_PKG_DISTRO_VERSION)"                >> $(NGINX_PKG)/.PKGINFO ; \
	 echo "group=$(NGINX_PKG_GROUP)"                             >> $(NGINX_PKG)/.PKGINFO ; \
	 echo "short_description=\"$(NGINX_PKG_SHORT_DESCRIPTION)\"" >> $(NGINX_PKG)/.PKGINFO ; \
	 echo "url=$(NGINX_PKG_URL)"                                 >> $(NGINX_PKG)/.PKGINFO ; \
	 echo "license=$(NGINX_PKG_LICENSE)"                         >> $(NGINX_PKG)/.PKGINFO
	@$(PSEUDO) sh -c "cd $(NGINX_PKG) && \
	                  chown -R root:root . && \
	                  chown -R  243:243  srv/nginx     && \
	                  chown -R  243:243  var/lib/nginx && \
	                  chown -R  243:243  var/log/nginx && \
	                  $(MAKE_PACKAGE) -J --linkadd=yes $(GNUPG_OPTIONS) -m -d .. ."