2 # swig-depcomp: Wrap call to SWIG and generate and adjust dependencies.
4 # Copyright 2012,2013 Olly Betts
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License as
8 # published by the Free Software Foundation; either version 2 of the
9 # License, or (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
25 die "Syntax: $0 SWIG ARGS...\n";
28 my $swig = shift @ARGV;
29 my @swig_args = @ARGV;
31 my $tmp_deps = 'swig_d.tmp';
33 unshift @swig_args, ('-MD', '-MF', $tmp_deps);
35 system($swig, @swig_args) == 0 or die $!;
37 open TMPDEPS
, '<', $tmp_deps or die $!;
40 open DEPS
, '>', "${tmp_deps}2" or die $!;
46 if (!defined $target) {
49 if (exists $ENV{'stamp'}) {
50 $_ = "$ENV{'stamp'}: \\\n";
61 # Generate dummy rules for the sources, so that if one gets removed we can
62 # still rebuild successfully.
69 $target =~ s/(?:\..*)$/.d/;
70 rename "${tmp_deps}2", $target or die $!;