Permalink
Browse files

Added objs attrib to Generator. Removed redundant .so rule.

Added and clarified a comment or two. Updated changelog.



git-svn-id: http://mkrf.rubyforge.org/svn/trunk@31 6e48df83-f314-0410-b1e7-e69642b30866
  • Loading branch information...
1 parent f7c195f commit 2f5a25f32c329bd94e10bda6d0aaaeb8240a8aa0 johnmg committed Sep 19, 2006
Showing with 20 additions and 9 deletions.
  1. +2 −0 CHANGELOG
  2. +2 −0 TODO
  3. +16 −9 lib/mkrf/generator.rb
View
@@ -1,4 +1,6 @@
= svn
+* [NEW] Added objs to Generator. Access it as you might ldshared. -John G.
+* [CLEAN-UP] Removed the redundant .so rule from the generated rakefile. -John G.
* [FIXED] Correct defaults in Availability. [29]
* [NEW] Using rubylibdir from rbconfig for library path. [29]
* [NEW] Availability options go straight to availability without generator modification. [29]
View
2 TODO
@@ -15,4 +15,6 @@ Two more things.
1) How do I add arbitrary strings to the gcc options such as the values of LDFLAGS, CPPFLAGS, and CFLAGS?
+A) For now, users may modify them directly via the objs and cflags accessors.
+
2) RMagick uses about 100 feature test symbols (HAVE_xxx, etc.), too many to specify on the command line. It must be possible to create a configuration header file from a template, like the file created by AC_CONFIG_HEADERS.
View
@@ -31,9 +31,18 @@ class Generator
CONFIG = Config::CONFIG
- attr_accessor :additional_code # Any extra code to be added to the Rakefile as a string
+ # Any extra code, given as a string, to be appended to the Rakefile.
+ attr_accessor :additional_code
- attr_accessor :ldshared, :cflags
+ # You may append to these attributes directly in your Generator.new block,
+ # for example: <tt>g.objs << ' ../common/foo.o ../common/bar.so -lmystuff'</tt> or
+ # <tt>g.cflags << ' -ansi -Wall'</tt>
+ #
+ # Note the extra space at the beginning of those strings.
+ attr_accessor :objs, :cflags
+
+ # Your system-specific linker command to build a shared library.
+ attr_accessor :ldshared
# Create a new generator which will write a new +Rakefile+ to the local
# filesystem.
@@ -47,6 +56,7 @@ def initialize(extension_name, source_patterns = ["lib/*.c"], availability_optio
@available = Mkrf::Availability.new(availability_options)
@defines = []
+ @objs = ''
@ldshared = CONFIG['LDSHARED']
@cflags = "#{CONFIG['CCDLFLAGS']} #{CONFIG['CFLAGS']} #{CONFIG['ARCH_FLAG']}"
@@ -136,32 +146,29 @@ def rakefile_contents # :nodoc:
OBJ = SRC.ext('o')
CC = "gcc"
+OBJS = "#{@objs}"
LDSHARED = "#{@ldshared}"
LIBPATH = '-L"#{CONFIG['rubylibdir']}"'
INCLUDES = "#{@available.includes_compile_string}"
LIBS = "#{@available.library_compile_string}"
-CFLAGS = "#{@cflags} #{defines_compile_string}"
+CFLAGS = "#{@cflags} #{defines_compile_string}"
task :default => ['#{@extension_name}']
rule '.o' => '.c' do |t|
sh "\#{CC} \#{CFLAGS} \#{INCLUDES} -c -o \#{t.name} \#{t.source}"
end
-rule '.so' => '.o' do |t|
- sh "\#{LDSHARED} \#{LIBPATH} -o \#{OBJ} \#{LOCAL_LIBS} \#{LIBS}"
-end
-
desc "Build this extension"
file '#{@extension_name}' => OBJ do
- sh "\#{LDSHARED} \#{LIBPATH} -o #{@extension_name} \#{OBJ} \#{LIBS}"
+ sh "\#{LDSHARED} \#{LIBPATH} -o #{@extension_name} \#{OBJ} \#{OBJS} \#{LIBS}"
end
#{additional_code}
END_RAKEFILE
end
end
-end
+end

0 comments on commit 2f5a25f

Please sign in to comment.