this repo has no description
at develop 2.7 kB view raw
1# 2# Main authors: 3# Christian Schulte <schulte@gecode.org> 4# 5# Copyright: 6# Christian Schulte, 2005 7# 8# This file is part of Gecode, the generic constraint 9# development environment: 10# http://www.gecode.org 11# 12# Permission is hereby granted, free of charge, to any person obtaining 13# a copy of this software and associated documentation files (the 14# "Software"), to deal in the Software without restriction, including 15# without limitation the rights to use, copy, modify, merge, publish, 16# distribute, sublicense, and/or sell copies of the Software, and to 17# permit persons to whom the Software is furnished to do so, subject to 18# the following conditions: 19# 20# The above copyright notice and this permission notice shall be 21# included in all copies or substantial portions of the Software. 22# 23# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 27# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 28# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 29# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 30# 31# 32 33# 34# Ultra-simplistic makedepend: Just find existing files 35# Relies on: 36# - all filenames are relative to root directory, which is the first argument 37# - #ifdef can be safely ignored 38# 39use File::Basename; 40 41$i=0; 42 43$root = $ARGV[$i++]; 44 45while ($target = $ARGV[$i++]) { 46 my @todo = (); 47 my %done = (); 48 push @todo, $target; 49 while ($f = pop @todo) { 50 open FILE, "$root/$f" or 51 open FILE, "$f" or die "File missing: $root/$f\n"; 52 53 while ($l = <FILE>) { 54 if ($l =~ /^\#include <(gecode\/.*)>/ ) { 55 $g = $1; 56 $g =~ s|^\./||og; 57 if (!($g =~ /^gecode\/third-party/) && !$done{$g}) { 58 push @todo, $g; 59 if (-e "$root/$g") { 60 $done{$g} = "$root/"; 61 } else { 62 $done{$g} = ""; 63 } 64 } 65 } elsif ($l =~ /^\#include "(.*)"/) { 66 $g = $1; 67 $g =~ s|^\./||og; 68 if (! -e $g && ! -e "$root/$g") { 69 $dir = dirname("$f"); 70 $g = "$dir/$g"; 71 } 72 if (!$done{$g}) { 73 push @todo, $g; 74 if (-e "$root/$g") { 75 $done{$g} = "$root/"; 76 } else { 77 $done{$g} = ""; 78 } 79 } 80 } 81 } 82 close FILE; 83 } 84 $target =~ s|\.cpp?||og; 85 print "$target\$(OBJSUFFIX) $target\$(SBJSUFFIX): "; 86 $l = 3; 87 foreach $g (sort(keys(%done))) { 88 if ($l == 3) { 89 print "\\\n\t"; 90 $l = 0; 91 } 92 print "$done{$g}$g "; 93 $l++; 94 } 95 print "\n"; 96} 97