I am playing with Rake to build c projects and I run into this problem

#########
task :default => ['main.out']

file 'main.out'

rule '.out' => ['.o'] do |t|
   sh "cc #{t.source} -o #{t.name}"
end

rule '.o' => ['.c'] do |t|
   sh "cc #{t.source} -c -o #{t.name}"
end
#########

fails with the error

in /home/phelan/ruby/rake)
cc main.o -o main.out
cc: main.o: No such file or directory
cc: no input files
rake aborted!
Command failed with status (1): [cc main.o -o main.out...]
/home/phelan/ruby/rake/rakefile.rb:6
(See full trace by running task with --trace)

but the following works fine

task :default => ['main.out']

# file 'main.out'

rule '.out' => ['.o'] do |t|
   sh "cc #{t.source} -o #{t.name}"
end

rule '.o' => ['.c'] do |t|
   sh "cc #{t.source} -c -o #{t.name}"
end

Where is the subtlety that I am missing here?

--
Brad Phelan
http://xtargets.com