]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - make/install-extras.pl
Fix makefile remake target to work in BSD make and avoid looping when .config.cache...
[user/henk/code/inspircd.git] / make / install-extras.pl
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
4
5 my $mode = shift;
6 my %installed;
7
8 for my $dir (qw(src src/modules)) {
9         opendir(DIRHANDLE, $dir);
10         for my $file (sort readdir(DIRHANDLE)) {
11                 next unless $file =~ /\.cpp$/;
12                 open CPP, '<', "$dir/$file" or die "Can't open $dir/$file to scan it: $!";
13                 while (<CPP>) {
14                         if (/\/\* \$CopyInstall: (\S+) (\S+) \*\//i) {
15                                 my($ifile, $idir) = ($1,$2);
16                                 next if exists $installed{$1.' '.$2};
17                                 $installed{$1.' '.$2}++;
18                                 $idir =~ s/\$\(([^)]+)\)/$ENV{$1}/eg;
19                                 if ($mode eq 'install') {
20                                         system "install $ifile $idir";
21                                 } else {
22                                         $ifile =~ s/.*\///g;
23                                         system "rm $idir/$ifile";
24                                 }
25                         }
26                 }
27         }
28         closedir(DIRHANDLE);
29 }