On 3/17/06, Jim Weirich <jim / weirichhouse.org> wrote:
[snip]
> Rake supports dependency files by importing them, like this:
[snip]


Touching 'a.cpp' does not result in a compile, what am I doing wrong?
(Touching 'a.h' works fine.)

prompt> ls
Rakefile        a.cpp           a.h             main.cpp
prompt> rake
(in /Users/simonstrandgaard/rake)
makedepend -f- --  -- a.cpp main.cpp > .depend.mf
makedepend: warning:  a.cpp (reading a.h, line 4): cannot find include
file "string"
        not in /usr/local/lib/gcc-include/string
        not in /usr/include/string
g++ -c -o a.o a.cpp
g++ -c -o main.o main.cpp
g++ a.o main.o -o test.exe
prompt> ./test.exe
test a
prompt> touch a.h
prompt> rake
(in /Users/simonstrandgaard/rake)
g++ -c -o a.o a.cpp
g++ -c -o main.o main.cpp
g++ a.o main.o -o test.exe
prompt> touch a.cpp
prompt> rake
(in /Users/simonstrandgaard/rake)
prompt>



Below are my files



prompt> cat .depend.mf
# DO NOT DELETE

a.o: a.h
main.o: a.h






prompt> cat a.h
#ifndef __A_H__
#define __A_H__

#include <string>

std::string test_a();

#endif // __A_H__






prompt> cat a.cpp
#include "a.h"

std::string test_a()
{
        return std::string("a");
}






prompt> cat main.cpp
#include "a.h"

int main(int argc, char **argv)
{
        std::string s = test_a();
        printf("test %s\n", s.c_str());
        return 0;
}






prompt> cat Rakefile
require 'rake/clean'
require 'rake/loaders/makefile'

APPLICATION = 'test.exe'
CPP_FILES = FileList['*.cpp']
O_FILES = CPP_FILES.sub(/\.cpp$/, '.o')

file '.depend.mf' do
    sh "makedepend -f- --  -- #{CPP_FILES} > .depend.mf"
end

import ".depend.mf"

file APPLICATION => O_FILES do |t|
  sh "g++ #{O_FILES} -o #{t.name}"
end

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

CLEAN.include("**/*.o")
CLEAN.include(APPLICATION)
CLEAN.include(".depend.mf")

task :default => APPLICATION