Makefile.ksplice: Rewrite ksplice-cow-check as a wrapper function.
[ksplice.git] / ksplice-cc.pl
blob214696134a34b362b68aef3889218ac8dd37d49f
1 #!/usr/bin/perl
3 # Copyright (C) 2008-2009 Ksplice, Inc.
4 # Authors: Anders Kaseorg, Jeff Arnold, Tim Abbott
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License, version 2.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
17 # 02110-1301, USA.
19 use strict;
20 use warnings;
21 use IPC::Open3;
22 use Cwd qw(abs_path);
23 use File::Basename;
25 my $dir = abs_path(dirname($0) . "/ksplice-patch");
26 my @cmd;
27 foreach (@ARGV) {
28 if (/^-ksplice-cflags-api=1$/) {
29 push @cmd, "-I$dir";
30 push @cmd, qw(-D__DATE__="<{DATE...}>" -D__TIME__="<{TIME}>");
31 } else {
32 push @cmd, $_;
36 my $pid = open3('<&STDIN', '>&STDOUT', \*ERROR, @cmd);
37 while (<ERROR>) {
38 next if /^<command[- ]line>(?::\d+:\d+)?: warning: "(?:__DATE__|__TIME__)" redefined$/;
39 print STDERR;
41 close ERROR;
42 waitpid($pid, 0) == $pid and ($? & 127) == 0 or die;
43 exit($? >> 8);