/tools/Ruby/lib/ruby/gems/1.8/gems/rake-0.9.2/doc/example/Rakefile2

http://github.com/agross/netopenspace · #! · 35 lines · 27 code · 8 blank · 0 comment · 0 complexity · 93d02bece2c5357198e051e8ce4d96c0 MD5 · raw file

  1. # Example Rakefile -*- ruby -*-
  2. # Using the power of Ruby
  3. task :default => [:main]
  4. def ext(fn, newext)
  5. fn.sub(/\.[^.]+$/, newext)
  6. end
  7. SRCFILES = Dir['*.c']
  8. OBJFILES = SRCFILES.collect { |fn| ext(fn,".o") }
  9. OBJFILES.each do |objfile|
  10. srcfile = ext(objfile, ".c")
  11. file objfile => [srcfile] do |t|
  12. sh "gcc #{srcfile} -c -o #{t.name}"
  13. end
  14. end
  15. file "main" => OBJFILES do |t|
  16. sh "gcc -o #{t.name} main.o a.o b.o"
  17. end
  18. task :clean do
  19. rm_f FileList['*.o']
  20. Dir['*~'].each { |fn| rm_f fn }
  21. end
  22. task :clobber => [:clean] do
  23. rm_f "main"
  24. end
  25. task :run => ["main"] do
  26. sh "./main"
  27. end