Index: Makefile
===================================================================
--- Makefile (nonexistent)
+++ Makefile (revision 5)
@@ -0,0 +1,222 @@
+
+COMPONENT_TARGETS = $(HARDWARE_INTEL_PC64)
+
+NEED_ABS_PATH = true
+COMPONENT_IS_3PP = true
+
+CREATE_X86_32_PACKAGE = true
+
+
+include ../../../build-system/constants.mk
+
+
+SOURCE_REQUIRES = sources/packages/d/ruby
+
+REQUIRES = dev/ruby/3.2.0
+REQUIRES += libs/gmp/6.2.1-x86_32
+REQUIRES += libs/libffi/3.4.4-x86_32
+REQUIRES += libs/libyaml/0.2.5-x86_32
+REQUIRES += libs/readline/8.2-x86_32
+REQUIRES += libs/zlib/1.2.13-x86_32
+REQUIRES += libs/gdbm/1.23-x86_32
+REQUIRES += net/openssl/1.1.1r-x86_32
+
+
+# ======= __END_OF_REQUIRES__ =======
+
+
+version = 3.2.0
+short_version = $(shell echo $(version) | cut -f1,2 -d'.')
+tar_xz_archive = $(SRC_PACKAGE_PATH)/packages/d/ruby/ruby-$(version).tar.xz
+SRC_ARCHIVE = $(tar_xz_archive)
+SRC_DIR = $(TARGET_BUILD_DIR)/ruby-$(version)
+src_dir_name = ruby-$(version)
+src_done = $(TARGET_BUILD_DIR)/.source_done
+
+PATCHES = PATCHES
+
+build_dir = $(TARGET_BUILD_DIR)/build
+build_target = $(TARGET_BUILD_DIR)/.build_done
+install_target = $(TARGET_BUILD_DIR)/.install_done
+
+
+####### Targets
+
+PKG_GROUP = dev
+
+#
+# *PKG_NAME & *PKG_VERSION shouldn't be a reference to value.
+#
+RUBY_32_PKG_NAME = ruby-x32
+RUBY_32_PKG_VERSION = 3.2.0
+RUBY_32_PKG_ARCH = $(PKGARCH)
+RUBY_32_PKG_DISTRO_NAME = $(DISTRO_NAME)
+RUBY_32_PKG_DISTRO_VERSION = $(DISTRO_VERSION)
+RUBY_32_PKG_GROUP = $(PKG_GROUP)
+### |---handy-ruler-------------------------------|
+RUBY_32_PKG_SHORT_DESCRIPTION = Interpreted object-oriented language
+RUBY_32_PKG_URL = $(BUG_URL)
+RUBY_32_PKG_LICENSE = BSD
+RUBY_32_PKG_DESCRIPTION_FILE = $(TARGET_BUILD_DIR)/$(RUBY_32_PKG_NAME)-pkg-description
+RUBY_32_PKG_DESCRIPTION_FILE_IN = $(RUBY_32_PKG_NAME)-pkg-description.in
+RUBY_32_PKG_INSTALL_SCRIPT = $(RUBY_32_PKG_NAME)-pkg-install.sh
+
+RUBY_32_PKG = $(CURDIR)/$(TARGET_BUILD_DIR)/$(RUBY_32_PKG_NAME)-package
+
+pkg_basename = $(RUBY_32_PKG_NAME)-$(RUBY_32_PKG_VERSION)-$(RUBY_32_PKG_ARCH)-$(RUBY_32_PKG_DISTRO_NAME)-$(RUBY_32_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=$(RUBY_32_PKG)
+
+
+extra_configure_switches = --libdir=/usr/lib$(MULTILIB_X86_32_SUFFIX)
+extra_configure_switches += --docdir=/usr/share/doc/$(src_dir_name)
+extra_configure_switches += --mandir=/usr/share/man
+extra_configure_switches += --datadir=/usr/share
+
+extra_configure_switches += --bindir=/usr/bin/32
+
+extra_configure_switches += --sysconfdir=/etc
+extra_configure_switches += --localstatedir=/var
+
+extra_configure_switches += --with-ruby-version=$(version)
+
+extra_configure_switches += --enable-shared
+extra_configure_switches += --enable-pthread
+extra_configure_switches += --disable-install-capi
+
+
+ruby_cpu_arch = $(word 1,$(subst -, ,$(TARGET32)))
+
+ruby_cpu_target = $(subst $(word 1,$(subst -, ,$(TARGET32)))-,$(ruby_cpu_arch)-,$(TARGET32))
+ruby_target_vendor = $(word 2,$(subst -, ,$(TARGET32)))
+
+arch_dir_name = $(ruby_cpu_arch)-linux
+
+BUILD_ARCH = $(word 1,$(subst -, ,$(BUILD)))
+BUILD_ALIAS = $(shell echo $(BUILD) | sed 's,-gnu$$,,')
+BUILD_VENDOR = $(word 2,$(subst -, ,$(BUILD)))
+
+
+TARGET_LIB_RPATH = /usr/lib$(MULTILIB_X86_32_SUFFIX)
+
+
+####### Dependencies
+
+$(src_done): $(SRC_ARCHIVE) $(PATCHES_DEP)
+ $(UNPACK_SRC_ARCHIVE)
+ $(APPLY_PATCHES)
+ @touch $@
+
+$(build_target): $(src_done)
+ @mkdir -p $(build_dir)
+ @cd $(build_dir) && \
+ $(BUILD_ENVIRONMENT) ../$(src_dir_name)/configure \
+ --prefix=/usr \
+ --build=$(BUILD) \
+ --host=$(TARGET32) \
+ $(extra_configure_switches)
+ @cd $(build_dir) && $(BUILD_ENVIRONMENT) $(MAKE)
+ @touch $@
+
+$(install_target): $(build_target)
+ @mkdir -p $(RUBY_32_PKG)
+ @cd $(build_dir) && $(BUILD_ENVIRONMENT) $(MAKE) -j1 install $(env_sysroot)
+ @rm -rf $(RUBY_32_PKG)/usr/include/ruby-$(version)/ruby{,.h}
+ @rm -rf $(RUBY_32_PKG)/usr/share
+ # ======= Remove toolchain path from target pkg-config *.pc files =======
+ @( cd $(RUBY_32_PKG)/usr/lib$(MULTILIB_X86_32_SUFFIX)/pkgconfig ; \
+ sed -i "s,@LIBPATH@,/usr/lib$(MULTILIB_X86_32_SUFFIX),g" ruby-$(short_version).pc ; \
+ sed -i "s,$(TARGET_DEST_DIR),,g" ruby-$(short_version).pc ; \
+ )
+ # ======= Install the same to $(TARGET_DEST_DIR) =======
+ $(call install-into-devenv, $(RUBY_32_PKG))
+ # ======= Tune pkg-config *.pc search path to the target destination for development =======
+ @( cd $(TARGET_DEST_DIR)/usr/lib$(MULTILIB_X86_32_SUFFIX)/pkgconfig ; \
+ sed -i "s,/usr,$(TARGET_DEST_DIR)/usr,g" ruby-$(short_version).pc ; \
+ sed -i "s,L/lib,L$(TARGET_DEST_DIR)/lib,g" ruby-$(short_version).pc ; \
+ )
+ # ======= Tune rbconfig.rb to the target destination =======
+ @( cd $(RUBY_32_PKG)/usr/lib$(MULTILIB_X86_32_SUFFIX)/ruby/$(version)/$(arch_dir_name) ; \
+ sed -i "s,$(BUILD_ALIAS)-gnu,$(ruby_cpu_target),g" rbconfig.rb ; \
+ sed -i "s,$(CCACHE),,g" rbconfig.rb ; \
+ sed -i "s,$(TARGET_DEST_DIR),,g" rbconfig.rb ; \
+ sed -i "s,$(BUILD),$(TARGET32),g" rbconfig.rb ; \
+ sed -i "s,$(BUILD_ALIAS),$(TARGET32),g" rbconfig.rb ; \
+ sed -i "s,$(CROSS_PREFIX),/usr/bin/,g" rbconfig.rb ; \
+ sed -i "s, --sysroot=,,g" rbconfig.rb ; \
+ sed -i "s,$(BUILD_VENDOR),$(ruby_target_vendor),g" rbconfig.rb ; \
+ sed -i "s,$(BUILD_ARCH),$(ruby_cpu_arch),g" rbconfig.rb ; \
+ sed -i "s,$(ruby_cpu_target),$(TARGET32),g" rbconfig.rb ; \
+ )
+ # ======= Remove build stuff from the target destination =======
+ @rm -rf $(RUBY_32_PKG)/usr/lib$(MULTILIB_X86_32_SUFFIX)/ruby/gems/$(version)/gems/rbs-*/ext
+ @rm -rf $(RUBY_32_PKG)/usr/lib$(MULTILIB_X86_32_SUFFIX)/ruby/gems/$(version)/gems/debug-*/ext
+ @find $(RUBY_32_PKG)/usr/lib$(MULTILIB_X86_32_SUFFIX)/ruby/gems/$(version)/extensions -name 'gem_make.out' -delete
+ @find $(RUBY_32_PKG)/usr/lib$(MULTILIB_X86_32_SUFFIX)/ruby/gems/$(version)/extensions -name 'gem.build_complete' -delete
+ # ======= Strip binaries =======
+ @( cd $(RUBY_32_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 binaries =======
+ @( cd $(RUBY_32_PKG)/usr/bin/32 ; \
+ for file in `find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs echo` ; do \
+ rpath=`$(PATCHELF) --print-rpath $$file 2> /dev/null` ; \
+ if echo "$$rpath" | grep -q "$(CURDIR)/$(TARGET_BUILD_DIR)" ; then \
+ $(PATCHELF) --set-rpath $(TARGET_LIB_RPATH) $$file 1> /dev/null 2> /dev/null ; \
+ fi ; \
+ done ; \
+ )
+ # ======= Set RPATH/RUNPATH for target shared objects =======
+ @( cd $(RUBY_32_PKG)/usr/lib$(MULTILIB_X86_32_SUFFIX) ; \
+ 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 "$(CURDIR)/$(TARGET_BUILD_DIR)" ; then \
+ $(PATCHELF) --set-rpath $(TARGET_LIB_RPATH) $$file 1> /dev/null 2> /dev/null ; \
+ fi ; \
+ done ; \
+ )
+endif
+ @touch $@
+
+$(RUBY_32_PKG_DESCRIPTION_FILE): $(RUBY_32_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) $(RUBY_32_PKG_DESCRIPTION_FILE) $(RUBY_32_PKG_INSTALL_SCRIPT)
+ @cp $(RUBY_32_PKG_DESCRIPTION_FILE) $(RUBY_32_PKG)/.DESCRIPTION
+ @cp $(RUBY_32_PKG_INSTALL_SCRIPT) $(RUBY_32_PKG)/.INSTALL
+ @$(BUILD_PKG_REQUIRES) $(RUBY_32_PKG)/.REQUIRES
+ @echo "pkgname=$(RUBY_32_PKG_NAME)" > $(RUBY_32_PKG)/.PKGINFO ; \
+ echo "pkgver=$(RUBY_32_PKG_VERSION)" >> $(RUBY_32_PKG)/.PKGINFO ; \
+ echo "arch=$(RUBY_32_PKG_ARCH)" >> $(RUBY_32_PKG)/.PKGINFO ; \
+ echo "distroname=$(RUBY_32_PKG_DISTRO_NAME)" >> $(RUBY_32_PKG)/.PKGINFO ; \
+ echo "distrover=$(RUBY_32_PKG_DISTRO_VERSION)" >> $(RUBY_32_PKG)/.PKGINFO ; \
+ echo "group=$(RUBY_32_PKG_GROUP)" >> $(RUBY_32_PKG)/.PKGINFO ; \
+ echo "short_description=\"$(RUBY_32_PKG_SHORT_DESCRIPTION)\"" >> $(RUBY_32_PKG)/.PKGINFO ; \
+ echo "url=$(RUBY_32_PKG_URL)" >> $(RUBY_32_PKG)/.PKGINFO ; \
+ echo "license=$(RUBY_32_PKG_LICENSE)" >> $(RUBY_32_PKG)/.PKGINFO
+ @$(PSEUDO) sh -c "cd $(RUBY_32_PKG) && \
+ chown -R root:root . && \
+ $(MAKE_PACKAGE) -J --linkadd=yes $(GNUPG_OPTIONS) -m -d .. ."