summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.in2
-rw-r--r--common.mk12
-rw-r--r--defs/gmake.mk22
-rw-r--r--defs/universal.mk5
-rw-r--r--template/GNUmakefile.in1
-rw-r--r--win32/Makefile.sub2
6 files changed, 38 insertions, 6 deletions
diff --git a/Makefile.in b/Makefile.in
index 49b0eaef21a..ea9b480fa8e 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -71,6 +71,8 @@ cppflags = @cppflags@
XCFLAGS = @XCFLAGS@
CPPFLAGS = @CPPFLAGS@ $(INCFLAGS) -DMJIT_HEADER_BUILD_DIR=\""$(EXTOUT)/include/$(arch)"\" -DLIBRUBYARG_SHARED=\""$(LIBRUBYARG_SHARED)"\" -DMJIT_HEADER_INSTALL_DIR=\""include/$(RUBY_BASE_NAME)-$(ruby_version)/$(arch)"\"
MJIT_HEADER_FLAGS = @MJIT_HEADER_FLAGS@
+MJIT_HEADER_SUFFIX =
+MJIT_HEADER_ARCH =
LDFLAGS = @STATIC@ $(CFLAGS) @LDFLAGS@
EXTLDFLAGS = @EXTLDFLAGS@
XLDFLAGS = @XLDFLAGS@ $(EXTLDFLAGS)
diff --git a/common.mk b/common.mk
index 4ed9cde133e..0d2e3d9c48b 100644
--- a/common.mk
+++ b/common.mk
@@ -59,6 +59,7 @@ ENC_TRANS_D = $(TIMESTAMPDIR)/.enc-trans.time
RDOCOUT = $(EXTOUT)/rdoc
HTMLOUT = $(EXTOUT)/html
CAPIOUT = doc/capi
+MJIT_HEADER = rb_mjit_header.h
MJIT_MIN_HEADER = $(EXTOUT)/include/$(arch)/rb_mjit_min_header-$(RUBY_PROGRAM_VERSION).h
INITOBJS = dmyext.$(OBJEXT) dmyenc.$(OBJEXT)
@@ -195,14 +196,15 @@ main: $(SHOWFLAGS) exts $(ENCSTATIC:static=lib)encs $(MJIT_MIN_HEADER)
.PHONY: mjit-headers
mjit-headers: $(MJIT_MIN_HEADER)
-rb_mjit_header.h: PHONY probes.h
+$(MJIT_HEADER:.h=)$(MJIT_HEADER_SUFFIX).h: PHONY probes.h
$(ECHO) building $@
- $(Q) $(CPP) $(MJIT_HEADER_FLAGS) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) -DMJIT_HEADER $(srcdir)/vm.c $(CPPOUTFLAG)vm.new
- $(Q) $(IFCHANGE) $@ vm.new
+ $(Q) $(CPP) $(MJIT_HEADER_FLAGS) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) -DMJIT_HEADER $(srcdir)/vm.c $(CPPOUTFLAG)$(@F).new
+ $(Q) $(IFCHANGE) $@ $(@F).new
-$(MJIT_MIN_HEADER): rb_mjit_header.h $(srcdir)/tool/transform_mjit_header.rb $(PREP)
+$(MJIT_MIN_HEADER:.h=)$(MJIT_HEADER_SUFFIX).h: $(srcdir)/tool/transform_mjit_header.rb $(PREP)
+$(MJIT_MIN_HEADER:.h=)$(MJIT_HEADER_SUFFIX).h: $(MJIT_HEADER:.h=)$(MJIT_HEADER_SUFFIX).h
$(ECHO) building $@
- $(MINIRUBY) $(srcdir)/tool/transform_mjit_header.rb "$(CC) $(ARCH_FLAG)" rb_mjit_header.h $@
+ $(MINIRUBY) $(srcdir)/tool/transform_mjit_header.rb "$(CC) $(ARCH_FLAG)" $(MJIT_HEADER:.h=)$(MJIT_HEADER_ARCH).h $@
.PHONY: showflags
exts enc trans: $(SHOWFLAGS)
diff --git a/defs/gmake.mk b/defs/gmake.mk
index 3170b2755af..4c9eb473af3 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 00000000000..c34a31b3566
--- /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
diff --git a/template/GNUmakefile.in b/template/GNUmakefile.in
index c904d3474e8..f603210bc25 100644
--- a/template/GNUmakefile.in
+++ b/template/GNUmakefile.in
@@ -1,4 +1,5 @@
include Makefile
+include $(srcdir)/defs/universal.mk
-include uncommon.mk
include $(srcdir)/defs/gmake.mk
diff --git a/win32/Makefile.sub b/win32/Makefile.sub
index 01802384fee..cb5fb9c7fef 100644
--- a/win32/Makefile.sub
+++ b/win32/Makefile.sub
@@ -287,6 +287,8 @@ LDSHARED_2 = @if exist $(@).manifest @$(RM) $(@:/=\).manifest
!endif
CPPFLAGS = $(DEFS) $(ARCHDEFS) $(CPPFLAGS) -DMJIT_HEADER_BUILD_DIR=\""$(EXTOUT)/include/$(arch)"\" -DLIBRUBYARG_SHARED=\""$(LIBRUBYARG_SHARED)"\" -DMJIT_HEADER_INSTALL_DIR=\""include/$(RUBY_BASE_NAME)-$(ruby_version)/$(arch)"\"
MJIT_HEADER_FLAGS = -P
+MJIT_HEADER_SUFFIX =
+MJIT_HEADER_ARCH =
DLDFLAGS = $(LDFLAGS) -dll
SOLIBS =