summaryrefslogtreecommitdiff
path: root/defs
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-02-06 03:19:42 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-02-06 03:19:42 (GMT)
commit88035b997930bd00c30be7b69de9d855a7f2322e (patch)
treee25117f6ed570b3aea5a7156d71395326b6aa23c /defs
parent7112c6a1c15b26eebf0c020dfee7abd30eebde2d (diff)
mjit headers for universal binary
* common.mk (MJIT_HEADER, MJIT_MIN_HEADER): added hook to separate intermediate headers per archs. * defs/gmake.mk: build mjit headers per -arch options, and then merge the headers with `#ifdef`s. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62245 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'defs')
-rw-r--r--defs/gmake.mk22
-rw-r--r--defs/universal.mk5
2 files changed, 26 insertions, 1 deletions
diff --git a/defs/gmake.mk b/defs/gmake.mk
index 3170b27..4c9eb47 100644
--- a/defs/gmake.mk
+++ b/defs/gmake.mk
@@ -48,7 +48,7 @@ define archcmd
%.i: %.$(1).i
endef
-$(foreach arch,$(filter -arch=%,$(subst -arch ,-arch=,$(ARCH_FLAG))),\
+$(foreach arch,$(arch_flags),\
$(eval $(call archcmd,$(patsubst -arch=%,%,$(value arch)),$(patsubst -arch=%,-arch %,$(value arch)))))
endif
@@ -144,3 +144,23 @@ commit: $(if $(filter commit,$(MAKECMDGOALS)),$(filter-out commit,$(MAKECMDGOALS
ifeq ($(words $(filter update-gems extract-gems,$(MAKECMDGOALS))),2)
extract-gems: update-gems
endif
+
+ifeq ($(filter 0 1,$(words $(arch_flags))),)
+$(foreach x,$(patsubst -arch=%,%,$(arch_flags)), \
+ $(eval $$(MJIT_HEADER:.h=)-$(value x).h \
+ $$(MJIT_MIN_HEADER:.h=)-$(value x).h \
+ : ARCH_FLAG := -arch $(value x)))
+
+mjit_min_headers := $(patsubst -arch=%,$(MJIT_MIN_HEADER:.h=-%.h),$(arch_flags))
+$(MJIT_MIN_HEADER): $(mjit_min_headers)
+ @ set -e; set $(patsubst -arch=%,%,$(arch_flags)); \
+ cd $(@D); h=$(@F:.h=); set -x; \
+ cp $$h-$$1.h $$h.h.new; shift; \
+ for arch; do \
+ mv $$h.h.new $$h.h.tmp; \
+ diff -B -D__$${arch}__ $$h.h.tmp $$h-$$arch.h > $$h.h.new || :; \
+ done
+ $(RM) $@.tmp
+ $(IFCHANGE) $@ $@.new
+
+endif
diff --git a/defs/universal.mk b/defs/universal.mk
new file mode 100644
index 0000000..c34a31b
--- /dev/null
+++ b/defs/universal.mk
@@ -0,0 +1,5 @@
+arch_flags := $(filter -arch=%,$(subst -arch ,-arch=,$(ARCH_FLAG)))
+ifeq ($(filter 0 1,$(words $(arch_flags))),)
+override MJIT_HEADER_SUFFIX = -%
+override MJIT_HEADER_ARCH = -$(word 2,$(ARCH_FLAG))
+endif