From: Charles Mills Date: 2004-05-27T04:34:36+09:00 Subject: File.basename() and mkmf.rb When create_makefile() in mkmf.rb builds an array of targets $objs it uses the following code: 801 unless $objs then 802 $objs = [] 803 for f in Dir[File.join(srcdir, "*.{#{SRC_EXT.join(%q{,})}}")] 804 $objs.push(File.basename(f, ".*") << "." << $OBJEXT) 805 end 806 else 807 for i in $objs 808 i.sub!(/\.o\z/, ".#{$OBJEXT}") 809 end 810 end 811 $objs = $objs.join(" ") My problem is that I have files with multiple extensions (ie. 'file.y.c'). I have added rules for these files in ./depends and changed 'SRC_EXT', but the line: 804 $objs.push(File.basename(f, ".*") << "." << $OBJEXT) doesn't do what I want so I just generate $objs myself. File.basename(f, ".*") only gets rid of the first suffix, not both or all suffixes. Is this by design? If it is here is the code I use to generate my targets: ### $objs = [] # create a pattern to match the file extentions in SRC_EXT ext_pattern = ".(#{SRC_EXT.join('|')})\\z".gsub(/\./, '\.') ext_regexp = Regexp.new(ext_pattern) for f in Dir["*.{#{SRC_EXT.join(%q{,})}}"] $objs.push(f.gsub(ext_regexp, ".#{$OBJEXT}")) end ### Any interest in using something like this to generate targets? -Charlie