@@ -30,17 +30,66 @@ VENDOR_GEM_DIR=/usr/ruby/$(RUBY_VERSION)/lib/ruby/vendor_ruby/gems/$(RUBY_LIB_VE
3030# <component_name>.gemspec
3131GEMSPEC =$(COMPONENT_NAME ) .gemspec
3232
33-
3433# Some gems projects have to be built using rake
3534# Allow GEM build/install commands to be overwritten
3635# to account for possible differences
3736GEM_BUILD_ACTION =(cd $(@D ) ; $(GEM ) build $(GEM_BUILD_ARGS ) $(GEMSPEC ) )
3837
38+ define ruby-rule
39+ $(BUILD_DIR ) /%-$(1 ) /.built: RUBY_VERSION=$(1 )
40+ $(BUILD_DIR ) /%-$(1 ) /.built: RUBY_LIB_VERSION=$(RUBY_LIB_VERSION.$(1 ) )
41+ $(BUILD_DIR ) /%-$(1 ) /.installed: RUBY_VERSION=$(1 )
42+ $(BUILD_DIR ) /%-$(1 ) /.installed: RUBY_LIB_VERSION=$(RUBY_LIB_VERSION.$(1 ) )
43+ $(BUILD_DIR ) /%-$(1 ) /.tested: RUBY_VERSION=$(1 )
44+ $(BUILD_DIR ) /%-$(1 ) /.tested: RUBY_LIB_VERSION=$(RUBY_LIB_VERSION.$(1 ) )
45+ $(BUILD_DIR ) /%-$(1 ) /.tested-and-compared: RUBY_VERSION=$(1 )
46+ $(BUILD_DIR ) /%-$(1 ) /.tested-and-compared: RUBY_LIB_VERSION=$(RUBY_LIB_VERSION.$(1 ) )
47+ endef
48+
49+ $(foreach rbver, $(RUBY_VERSIONS), $(eval $(call ruby-rule,$(rbver))))
50+
51+ $(BUILD_DIR ) /$(MACH32 ) -% /.built : BITS=32
52+ $(BUILD_DIR ) /$(MACH64 ) -% /.built : BITS=64
53+ $(BUILD_DIR ) /$(MACH32 ) -% /.installed : BITS=32
54+ $(BUILD_DIR ) /$(MACH64 ) -% /.installed : BITS=64
55+ $(BUILD_DIR ) /$(MACH32 ) -% /.tested : BITS=32
56+ $(BUILD_DIR ) /$(MACH64 ) -% /.tested : BITS=64
57+ $(BUILD_DIR ) /$(MACH32 ) -% /.tested-and-compared : BITS=32
58+ $(BUILD_DIR ) /$(MACH64 ) -% /.tested-and-compared : BITS=64
59+
60+ BUILD_32 = $(RUBY_32_VERSIONS:%=$(BUILD_DIR ) /$(MACH32 ) -%/.built )
61+ BUILD_64 = $(RUBY_64_VERSIONS:%=$(BUILD_DIR ) /$(MACH64 ) -%/.built )
62+ BUILD_NO_ARCH = $(RUBY_VERSIONS:%=$(BUILD_DIR ) /$(MACH ) -%/.built )
63+
64+ ifeq ($(filter-out $(RUBY_64_ONLY_VERSIONS ) , $(RUBY_VERSION ) ) ,)
65+ BUILD_32_and_64 = $(BUILD_64 )
66+ endif
67+
68+ ifeq ($(filter-out $(RUBY_32_ONLY_VERSIONS ) , $(RUBY_VERSION ) ) ,)
69+ BUILD_32_and_64 = $(BUILD_32 )
70+ endif
71+
72+ INSTALL_32 = $(RUBY_32_VERSIONS:%=$(BUILD_DIR ) /$(MACH32 ) -%/.installed )
73+ INSTALL_64 = $(RUBY_64_VERSIONS:%=$(BUILD_DIR ) /$(MACH64 ) -%/.installed )
74+ INSTALL_NO_ARCH = $(RUBY_VERSIONS:%=$(BUILD_DIR ) /$(MACH ) -%/.installed )
75+
76+ # If we are building Ruby 2.6 support, build it and install it
77+ # before Ruby 2.3, so 2.3 is installed last and is the canonical version.
78+ # When we change the default, the new default should go last.
79+ ifneq ($(findstring 2.6,$(RUBY_VERSIONS ) ) ,)
80+ $(BUILD_DIR ) /% -2.3/.built : $(BUILD_DIR ) /% -2.6/.built
81+ $(BUILD_DIR ) /% -2.3/.installed : $(BUILD_DIR ) /% -2.6/.installed
82+ endif
83+
84+ ifeq ($(strip $(RUBY_BUILD_DOCS ) ) ,yes)
3985# Build install args in a more readable fashion
4086ifeq ($(firstword $(subst .,$(space ) ,$(RUBY_VERSION ) ) ) ,2)
4187# gem install 2.x does docs differently. Continue to generate both types
4288GEM_INSTALL_ARGS += --document rdoc,ri
4389endif
90+ else
91+ GEM_INSTALL_ARGS += --no-document
92+ endif
4493
4594GEM_INSTALL_ARGS += -V --local --force
4695GEM_INSTALL_ARGS += --install-dir $(PROTO_DIR ) /$(VENDOR_GEM_DIR )
0 commit comments