@@ -70,26 +70,6 @@ def make(env, target)
7070 return
7171end
7272
73- # We're going to need to run `make` using prism's `Makefile`.
74- # We want to use the same toolchain (compiler, flags, etc) to compile libprism.a and
75- # the C extension since they will be linked together.
76- # The C extension uses RbConfig, which contains values from the toolchain that built the running Ruby.
77- env = RbConfig ::CONFIG . slice ( "SOEXT" , "CPPFLAGS" , "CFLAGS" , "CC" , "AR" , "ARFLAGS" , "MAKEDIRS" , "RMALL" )
78-
79- # It's possible that the Ruby that is being run wasn't actually compiled on this
80- # machine, in which case parts of RbConfig might be incorrect. In this case
81- # we'll need to do some additional checks and potentially fall back to defaults.
82- if env . key? ( "CC" ) && !File . exist? ( env [ "CC" ] )
83- env . delete ( "CC" )
84- env . delete ( "CFLAGS" )
85- env . delete ( "CPPFLAGS" )
86- end
87-
88- if env . key? ( "AR" ) && !File . exist? ( env [ "AR" ] )
89- env . delete ( "AR" )
90- env . delete ( "ARFLAGS" )
91- end
92-
9373require "mkmf"
9474
9575# First, ensure that we can find the header for the prism library.
@@ -133,18 +113,21 @@ def make(env, target)
133113archive_target = "build/libprism.a"
134114archive_path = File . expand_path ( "../../#{ archive_target } " , __dir__ )
135115
136- make ( env , archive_target ) unless File . exist? ( archive_path )
137- $LOCAL_LIBS << " #{ archive_path } "
116+ def src_list ( path )
117+ srcdir = path . dup
118+ RbConfig . expand ( srcdir ) # mutates srcdir :-/
119+ Dir [ File . join ( srcdir , "*.{#{ SRC_EXT . join ( %q{,} ) } }" ) ]
120+ end
121+
122+ def add_libprism_source ( path )
123+ $VPATH << path
124+ src_list path
125+ end
126+
127+ $srcs = src_list ( "$(srcdir)" ) +
128+ add_libprism_source ( "$(srcdir)/../../src" ) +
129+ add_libprism_source ( "$(srcdir)/../../src/util" )
138130
139131# Finally, we'll create the `Makefile` that is going to be used to configure and
140132# build the C extension.
141133create_makefile ( "prism/prism" )
142-
143- # Now that the `Makefile` for the C extension is built, we'll append on an extra
144- # rule that dictates that the extension should be rebuilt if the archive is
145- # updated.
146- File . open ( "Makefile" , "a" ) do |mf |
147- mf . puts
148- mf . puts ( "# Automatically rebuild the extension if libprism.a changed" )
149- mf . puts ( "$(TARGET_SO): $(LOCAL_LIBS)" )
150- end
0 commit comments