Skip to content

Instantly share code, notes, and snippets.

@mrkn
Created February 6, 2014 05:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrkn/8838644 to your computer and use it in GitHub Desktop.
Save mrkn/8838644 to your computer and use it in GitHub Desktop.
diff --git a/ChangeLog b/ChangeLog
index e1a43e5..7879e10 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+Thu Feb 6 09:06:00 2014 Kenta Murata <mrkn@cookpad.com>
+
+ * configure.in (POSTLINK): sign built program using RUBY_CODESIGN identity.
+
+ * Makefile.in (PROGRAM): ditto.
+
+ * Makefile.in (LIBRUBY_SO): ditto.
+
+ * lib/mkmf.rb (LINK_SO): sign extensions too. replace empty line with
+ default command.
+
+ * enc/depend (link_so): prefix $(Q) for each commands.
+
+ * tool/mkconfig.rb: restore embedded newlines.
+
Wed Feb 5 13:43:02 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
* string.c (rb_str_modify_expand): enable capacity and disable
diff --git a/Makefile.in b/Makefile.in
index 41ea412..680f761 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -71,6 +71,7 @@ ARCHMINIOBJS = @MINIOBJS@
BUILTIN_ENCOBJS = @BUILTIN_ENCOBJS@
BUILTIN_TRANSSRCS = @BUILTIN_TRANSSRCS@
BUILTIN_TRANSOBJS = @BUILTIN_TRANSOBJS@
+POSTLINK = @POSTLINK@
RUBY_BASE_NAME=@RUBY_BASE_NAME@
RUBY_PROGRAM_VERSION=@RUBY_PROGRAM_VERSION@
@@ -169,6 +170,7 @@ $(PROGRAM):
@$(RM) $@
$(ECHO) linking $@
$(Q) $(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(MAINOBJ) $(EXTOBJS) $(LIBRUBYARG) $(MAINLIBS) $(LIBS) $(OUTFLAG)$@
+ $(Q) $(POSTLINK)
# We must `rm' the library each time this rule is invoked because "updating" a
# MAB library on Apple/NeXT (see --enable-fat-binary in configure) is not
@@ -184,6 +186,7 @@ $(LIBRUBY_SO):
$(ECHO) linking shared-library $@
$(Q) $(LDSHARED) $(DLDFLAGS) $(OBJS) $(DLDOBJS) $(SOLIBS) $(OUTFLAG)$@
-$(Q) $(OBJCOPY) -w -L '$(SYMBOL_PREFIX)Init_*' -L '$(SYMBOL_PREFIX)*_threadptr_*' $@
+ $(Q) $(POSTLINK)
@-$(MINIRUBY) -e 'ARGV.each{|link| File.delete link if File.exist? link; \
File.symlink "$(LIBRUBY_SO)", link}' \
$(LIBRUBY_ALIASES) || true
diff --git a/configure.in b/configure.in
index 549914e..ea46148 100644
--- a/configure.in
+++ b/configure.in
@@ -1022,6 +1022,12 @@ main()
if test "$rb_cv_broken_crypt" = yes; then
AC_DEFINE(BROKEN_CRYPT, 1)
fi
+ AC_CHECK_PROGS(codesign, codesign)
+ if test -n "$codesign"; then
+ POSTLINK="test -z '\$(RUBY_CODESIGN)' || $codesign -s '\$(RUBY_CODESIGN)' -f \$@"
+ LINK_SO="$LINK_SO
+\$(POSTLINK)"
+ fi
],
[hpux*], [ LIBS="-lm $LIBS"
ac_cv_c_inline=no],
diff --git a/enc/depend b/enc/depend
index 8e930d5..d42aa5c 100644
--- a/enc/depend
+++ b/enc/depend
@@ -103,7 +103,7 @@ $(TRANSOBJS): ruby.h intern.h config.h defines.h missing.h encoding.h oniguruma.
% end
% end
-% link_so = LINK_SO.gsub(/\n/, "\n\t")
+% link_so = LINK_SO.gsub(/([^\\])\n/, "\\1\n$(Q) ").gsub(/\n/, "\n\t")
% link_so.gsub!(/(-(?:implib|pdb):\S+)-\$\(arch\)\./, '\1.')
% dependencies.each do |e|
% obj = "enc/#{e}.$(OBJEXT)"
diff --git a/lib/mkmf.rb b/lib/mkmf.rb
index f5e4e92..898e4a7 100644
--- a/lib/mkmf.rb
+++ b/lib/mkmf.rb
@@ -2308,13 +2308,14 @@ COMPILE_CXX = config_string('COMPILE_CXX') || '$(CXX) $(INCFLAGS) $(CPPFLAGS) $(
TRY_LINK = config_string('TRY_LINK') ||
"$(CC) #{OUTFLAG}conftest $(INCFLAGS) $(CPPFLAGS) " \
"$(CFLAGS) $(src) $(LIBPATH) $(LDFLAGS) $(ARCH_FLAG) $(LOCAL_LIBS) $(LIBS)"
-LINK_SO = config_string('LINK_SO') ||
+LINK_SO = (config_string('LINK_SO') || "").sub(/^$/) do
if CONFIG["DLEXT"] == $OBJEXT
"ld $(DLDFLAGS) -r -o $@ $(OBJS)\n"
else
"$(LDSHARED) #{OUTFLAG}$@ $(OBJS) " \
"$(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)"
end
+end
LIBPATHFLAG = config_string('LIBPATHFLAG') || ' -L"%s"'
RPATHFLAG = config_string('RPATHFLAG') || ''
LIBARG = config_string('LIBARG') || '-l%s'
diff --git a/tool/mkconfig.rb b/tool/mkconfig.rb
index 6d87511..bddf381 100755
--- a/tool/mkconfig.rb
+++ b/tool/mkconfig.rb
@@ -62,6 +62,7 @@ File.foreach "config.status" do |line|
next if !continued_line
continued_line << $1
next if $2
+ continued_line.each {|s| s.sub!(/\\n\z/, "\n")}
val = continued_line.join
name = continued_name
continued_line = nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment