From: "Iñaki Baz Castillo" Date: 2012-05-08T02:53:02+09:00 Subject: Re: [C exten] mkmf: how to include .c and .h files within a subdirectory? 2012/5/7 Kubo Takehiro : > On Mon, May 7, 2012 at 7:58 AM, Iñaki Baz Castillo wrote: >> Hi, having the following file tree under my ext/ directory: >> >> my_ext/ >>   extconf.rb >>   my_ext.c >>   utils/ >>      utils.c >>      utils.h >> >> How to say in extconf.rb that files under utils/ subdirectory must >> also be compiled? > > Though, IMO, there is no official way, here is a hack. > ---------------------------------- > require 'mkmf' > > # set all object files to $objs before create_makefile. > $objs = ["my_ext.o", "utils/utils.o"] > > create_makefile("my_ext") > > # to clean up object files under util subdirectory. > open('Makefile', 'a') do |f| >  f.write < > CLEANOBJS := $(CLEANOBJS) utils/*.#{CONFIG["OBJEXT"]} > EOS > end > ---------------------------------- > > I have tested this with ruby 1.9.3p194 on linux. > But it doesn't work for rubinius. Thanks a lot. Very useful information. -- Iñaki Baz Castillo