#!/usr/bin/ruby -w # See the LICENSE file for copyright and distribution information require "mkmf" def help print < HELP end if ARGV.include?( "--help" ) or ARGV.include?( "-h" ) help() exit 0 end if enable_config("error-handler", true) $CFLAGS += " -DUSE_ERROR_HANDLER" end #$LIBPATH.push(Config::CONFIG['libdir']) def crash(str) printf(" extconf failure: %s\n", str) exit 1 end dir_config( 'xml2' ) dir_config( 'xslt' ) have_library "xml2", "xmlParseDoc" || crash("need libxml2") have_library "xslt", "xsltParseStylesheetFile" || crash("need libxslt") if enable_config("exslt", true) have_library "exslt", "exsltRegisterAll" $CFLAGS += " -DUSE_EXSLT" end $CFLAGS = '-g -Wall ' + `xml2-config --cflags`.chomp + " " + `xslt-config --cflags`.chomp + " " + $CFLAGS create_header() create_makefile("xml/xslt_lib") File.rename( "Makefile", "Makefile.orig" ) File.open( "Makefile.orig" ) do |oldmkfl| File.open( "Makefile", "w" ) do |newmkfl| oldmkfl.each_line do |line| case(line) when /^all:/ newmkfl.puts(line) newmkfl.puts("") newmkfl.puts("test: all") # insert the "test" target newmkfl.puts("\t\t@cd tests && ruby test.rb && cd ..") newmkfl.puts("doc: all") # insert the "doc" target newmkfl.puts("\t\t@rdoc -S -t \"Ruby/XSLT Documentation\" README AUTHORS ChangeLog xslt_lib.c lib/xslt.rb") when /^distclean:/ newmkfl.puts(line) newmkfl.puts("\t\t@-$(RM) Makefile.orig") newmkfl.puts("\t\t@-$(RM)r doc") else newmkfl.puts(line) end end end end