# # Copyright (c) ZeroC, Inc. All rights reserved. # # # Override to use another ruby version # RUBY ?= ruby # ---------------------------------------------------------------------- # Don't change anything below this line! # ---------------------------------------------------------------------- ruby-call = $(shell $(RUBY) -e 'require "rbconfig"; puts RbConfig::expand("$1")') # Ruby compiler flags platform_cxx := $(call ruby-call, $$(CXX)) ruby_cppflags := -I$(call ruby-call,$$(rubyhdrdir)) ruby_config_dir := $(call ruby-call,$$(includedir)/$$(arch)/ruby-$$(ruby_version)) ruby_arch := $(call ruby-call,$$(arch)) ifeq ($(wildcard $(ruby_config_dir)/ruby/config.h),) ruby_config_dir := $(call ruby-call,$$(rubyhdrdir)/$$(arch)) endif ifneq ($(wildcard $(ruby_config_dir)/ruby/config.h),) ruby_cppflags += -I$(ruby_config_dir) endif # macOS & macOS with LLVM-Clang > 7.3 and the system version of Ruby require '-Wno-shift-negative-value'. This issue # has been patched in more recent 2.x Ruby versions. ifeq ($(shell uname),Darwin) ifeq ($(shell which $(RUBY)),/usr/bin/ruby) ifeq ($(shell expr $$($(CXX) -v 2>&1 | head -1 | sed -E 's/.*clang-([0-9][0-9][0-9]).*/\1/') \>= 703),1) ruby_cppflags += -Wno-shift-negative-value $(RUBY_FLAGS) endif endif endif ifeq ($(os),Linux) cppflags := $(filter-out -Wredundant-decls -Wshadow,$(cppflags)) endif # Ruby linker flags ruby_ldflags := $(call ruby-call,$$(LIBRUBYARG)) ruby_libdir := $(call ruby-call,$(if $(findstring MINGW,$(shell uname)),$$(bindir),$$(libdir))) ifneq ($(ruby_libdir),) ruby_ldflags := -L$(call ruby-call,$$(libdir)) $(ruby_ldflags) endif # # Ruby installation directory # install_rubydir = $(if $(usr_dir_install),$(ruby_libdir),$(prefix)/ruby) install_rubylibdir = $(if $(usr_dir_install),$(ruby_libdir)/$(ruby_arch),$(prefix)/ruby) # # Rules to build a ruby module. We just compute the name of the ruby module # and delegate to make-shared-module. # mkrbmodulename ?= $(patsubst lib%,%,$(call mkshlibname,$(1))) make-shared-ruby-module = $(call make-shared-module,$(call mkrbmodulename,$1),$2,$3,$4,$5,$6,$7,$8,$9) get-shared-ruby-module-targets = $(call get-shared-module-targets,$(call mkrbmodulename,$1),$2,$3,$4) install-shared-ruby-module = $(call install-shared-module,$(call mkrbmodulename,$1),$2,$3,$4,$5) $(DESTDIR)$(install_rubydir): $(Q)$(MKDIR) -p $@ installdirs += $(install_rubydir) # # $(call make-ruby-package,$1=slicedir,$2=generateddir,$3=package,$4=sliceflags) # # Compile slice files from $(slicedir)/ to ruby/. # define make-ruby-package $2/$3/.depend/%.ice.d: | $2/$3/.depend ; $2/$3/.depend: $(Q)$(MKDIR) -p $$@ .PRECIOUS: $2/$3/.depend/%.ice.d ifeq ($(filter %clean,$(MAKECMDGOALS)),) # Include the dependencies -include $(addprefix $2/$3/.depend/,$(call source-to-dependency,$(wildcard $1/$3/*.ice))) endif $2/$3/%.rb: $1/$3/%.ice $2/$3/.depend/%.ice.d $(slice2rb_path) $(E) "Compiling $$<" $(Q)$(slice2rb_path) -I$1 --output-dir $2/$3 $4 --depend $$< | \ sed 's/\(.*: \\\)/$(subst /,\/,$2)\/$3\/\1/' > $2/$3/.depend/$$(*F).ice.d $(Q)$(slice2rb_path) -I$1 --output-dir $2/$3 $4 $$< distclean clean:: $(E) "Cleaning package $3" $(Q)$(RM) -r $2/$3/.depend $(Q)$(RM) $(patsubst $1/$3/%.ice,$2/$3/%.rb,$(wildcard $1/$3/*.ice)) generate-srcs srcs all:: $(patsubst $1/$3/%.ice,$2/$3/%.rb,$(wildcard $1/$3/*.ice)) $$(eval $$(call install-data-files,$(patsubst $1/$3/%.ice,$2/$3/%.rb,$(wildcard $1/$3/*.ice)),$2,$(install_rubydir),install)) endef