Rakefile1 670 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. # Example Rakefile -*- ruby -*-
  2. task :default => [:main]
  3. file "a.o" => ["a.c"] do |t|
  4. src = t.name.sub(/\.o$/, '.c')
  5. sh "gcc #{src} -c -o #{t.name}"
  6. end
  7. file "b.o" => ["b.c"] do |t|
  8. src = t.name.sub(/\.o$/, '.c')
  9. sh "gcc #{src} -c -o #{t.name}"
  10. end
  11. file "main.o" => ["main.c"] do |t|
  12. src = t.name.sub(/\.o$/, '.c')
  13. sh "gcc #{src} -c -o #{t.name}"
  14. end
  15. OBJFILES = ["a.o", "b.o", "main.o"]
  16. task :obj => OBJFILES
  17. file "main" => OBJFILES do |t|
  18. sh "gcc -o #{t.name} main.o a.o b.o"
  19. end
  20. task :clean do
  21. rm_f FileList['*.o']
  22. Dir['*~'].each { |fn| rm_f fn }
  23. end
  24. task :clobber => [:clean] do
  25. rm_f "main"
  26. end
  27. task :run => ["main"] do
  28. sh "./main"
  29. end