From 8691533d88c79c892fee227bbdbbb527f4783a28 Mon Sep 17 00:00:00 2001 From: Matthew Bloch Date: Sat, 9 Jun 2012 02:17:34 +0100 Subject: [PATCH] Added hopeful default path to find rake_utils, turned undefined function warnings into errors, and added expensive header scanning to .c->.o rule to ensure changes to .h files cause recompiles as you'd expect. --- Rakefile | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Rakefile b/Rakefile index 590db27..9d7f8d2 100644 --- a/Rakefile +++ b/Rakefile @@ -1,3 +1,4 @@ +$: << '../rake_utils/lib' require 'rake_utils/debian' include RakeUtils::DSL @@ -9,7 +10,7 @@ SOURCES = ALL_SOURCES.select { |c| c =~ /\.c$/ } OBJECTS = SOURCES.pathmap( "%{^src,build}X.o" ) LIBS = %w( pthread ) -CCFLAGS = %w( -Wall ) +CCFLAGS = %w( -Wall -Werror-implicit-function-declaration ) LDFLAGS = [] LIBCHECK = "/usr/lib/libcheck.a" @@ -68,6 +69,10 @@ def gcc_link(target, objects) objects.join(" ") end +def headers(c) + `gcc -MM #{c}`.gsub("\\\n", " ").split(" ")[2..-1] +end + rule 'build/flexnbd' => OBJECTS do |t| gcc_link(t.name, t.sources) end @@ -110,7 +115,7 @@ end OBJECTS.zip( SOURCES ).each do |o,c| - file o => c do |t| + file o => [c]+headers(c) do |t| FileUtils.mkdir_p File.dirname( o ) sh "gcc -Isrc -c #{CCFLAGS.join(' ')} -o #{o} #{c} " end