Skip to content

Commit a1d7fef

Browse files
committed
Make libtruffleruby a order-only-prerequisite
* So rebuilding libtruffleruby does not rebuild other C extensions. * See https://www.gnu.org/software/make/manual/html_node/Prerequisite-Types.html for the definition of order-only-prerequisites.
1 parent c639679 commit a1d7fef

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/main/c/Makefile

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,15 @@ RUBY_HEADERS := $(wildcard $(ROOT)/lib/cext/include/*.h) $(wildcard $(ROOT)/lib/
2727
RBCONFIG := $(ROOT)/lib/truffle/rbconfig.rb
2828
RBCONFIG_MKMF := $(ROOT)/lib/truffle/rbconfig-for-mkmf.rb
2929
MKMF := $(ROOT)/lib/mri/mkmf.rb
30+
LIBTRUFFLERUBY = cext/libtruffleruby.$(DLEXT)
3031
BASIC_EXTCONF_DEPS := $(SPAWN_HELPER) $(TRUFFLE_POSIX) $(RUBY_HEADERS) $(RBCONFIG) $(RBCONFIG_MKMF) $(MKMF)
31-
# These libraries are needed for try_link() in extconf.rb
32-
EXTCONF_DEPS := $(BASIC_EXTCONF_DEPS) cext/libtruffleruby.$(DLEXT)
32+
# C extensions link against libtruffleruby (and might do have_func() checks against it), so it needs to be there before.
33+
# However, if libtruffleruby is recompiled, there is no need to rebuild C extensions, so it's a order-only-prerequisite.
34+
EXTCONF_DEPS := $(BASIC_EXTCONF_DEPS) | $(LIBTRUFFLERUBY)
3335

3436
IF_EXTCONF_FAIL := ( echo "`pwd`/extconf.rb failed:" 1>&2 && cat mkmf.log && false )
3537

36-
all: cext/libtruffleruby.$(DLEXT) openssl/openssl.$(DLEXT) zlib/zlib.$(DLEXT) \
38+
all: $(LIBTRUFFLERUBY) openssl/openssl.$(DLEXT) zlib/zlib.$(DLEXT) \
3739
psych/psych.$(DLEXT) syslog/syslog.$(DLEXT) nkf/nkf.$(DLEXT) \
3840
etc/etc.$(DLEXT) rbconfig-sizeof/sizeof.$(DLEXT)
3941

@@ -43,7 +45,7 @@ clean_truffleposix:
4345
$(Q) rm -f $(TRUFFLE_POSIX) truffleposix/*.o
4446

4547
clean_cexts:
46-
$(Q) rm -f cext/Makefile cext/*.o cext/libtruffleruby.$(DLEXT)
48+
$(Q) rm -f cext/Makefile cext/*.o $(LIBTRUFFLERUBY)
4749
$(Q) rm -f openssl/Makefile openssl/*.o openssl/openssl.$(DLEXT)
4850
$(Q) rm -f zlib/Makefile zlib/*.o zlib/zlib.$(DLEXT)
4951
$(Q) rm -f psych/Makefile psych/*.o psych/yaml/*.o psych/psych.$(DLEXT)
@@ -64,7 +66,7 @@ $(TRUFFLE_POSIX): truffleposix/Makefile truffleposix/truffleposix.c
6466
cext/Makefile: cext/extconf.rb $(BASIC_EXTCONF_DEPS)
6567
$(Q) cd cext && $(RUBY) extconf.rb || $(IF_EXTCONF_FAIL)
6668

67-
cext/libtruffleruby.$(DLEXT): cext/Makefile cext/*.c
69+
$(LIBTRUFFLERUBY): cext/Makefile cext/*.c
6870
$(Q) cd cext && $(MAKE)
6971

7072
# openssl

0 commit comments

Comments
 (0)