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