Rakefile2 599 B

1234567891011121314151617181920212223242526272829303132333435
  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