~ubuntu-branches/ubuntu/oneiric/kdesdk/oneiric-updates

« back to all changes in this revision

Viewing changes to scripts/unsercmake

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2010-07-08 06:17:28 UTC
  • mfrom: (1.1.46 upstream)
  • Revision ID: james.westby@ubuntu.com-20100708061728-mawara3nop8lnch5
Tags: 4:4.4.92-0ubuntu1
* New upstream rc release
  - Bump kde-sc-dev-latest
  - Refresh patches
  - Update install files
  - Update not-installed

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/perl
2
 
# Copyright (C) 2006 Thomas Zander <zander@kde.org>
 
2
# Copyright (C) 2006-2010 Thomas Zander <zander@kde.org>
3
3
$COMMAND = "unsercmake";
4
 
$VERSION = "$COMMAND 0.14";
 
4
$VERSION = "$COMMAND 0.32";
5
5
# This script allows you to build a target library including dependency checking, but it
6
6
# limits the dependency checking to the current dir and its subdirs meaning a lot of
7
7
# unwanted steps are skipped.
8
 
# This script assumes the presence of cmake 2.4.3 or greater and the Makefiles it created.
9
8
 
10
9
 
11
10
# user settings...
19
18
$buildDirType = "";
20
19
 
21
20
##########################
22
 
# Copyright (c) 2006 Thomas Zander <zander@kde.org>
 
21
# Copyright (c) 2006-2010 Thomas Zander <zander@kde.org>
23
22
#
24
23
# This program is free software; you can redistribute it and/or modify
25
24
# it under the terms of the GNU General Public License as published by
219
218
        if(defined $just_print) {
220
219
            next;
221
220
        }
 
221
        foreach $h (@actualTargets) {
 
222
            if($h=~/(\b$lib\_automoc)/) {
 
223
                system ("make $jobs $verbose $1");
 
224
                last;
 
225
            }
 
226
        }
 
227
 
222
228
        my $rc = system ("make $jobs $verbose $lib/fast");
223
229
        if(!(defined $keep_going) && $rc != 0) {
224
230
            exit 1;
225
231
        }
226
 
        if($doInstall == 1 && $rc == 0) {
227
 
            # install libs
228
 
            &install("$builddir/$locations{$lib}/cmake_install.cmake", 1);
229
 
        }
230
232
    }
231
233
    elsif(! defined $quiet) {
232
234
        print "Skipping lib: $lib (in $dir)\n";
241
243
        print "\n";
242
244
    }
243
245
    if(! defined $just_print) {
244
 
        &install("$builddir/cmake_install.cmake", 0);
 
246
        @output=`(cd $builddir && make install/fast)`;
 
247
        my $line;
 
248
        foreach $line (@output) {
 
249
            if ($line=~/^-- (Installing: .*)$/) {
 
250
                print "$1\n";
 
251
            }
 
252
        }
245
253
    }
246
254
}
247
255
 
451
459
    return 0;
452
460
}
453
461
 
454
 
 
455
 
sub install() {
456
 
    my $inputFile=shift(@_);
457
 
    my $limitToLibs=shift(@_);
458
 
 
459
 
    my @subdirs;
460
 
    open FILE, "$inputFile";
461
 
    foreach $line (<FILE>) {
462
 
        if($limitToLibs == 0 && $line=~/^INCLUDE\(\"(.*)\"\)/) {
463
 
            push @subdirs, $1;
464
 
        }
465
 
        elsif($line=~/^FILE\(INSTALL DESTINATION \"(.*)\" TYPE (SHARED_LIBRARY|EXECUTABLE|FILE|MODULE)(.+?)FILES \"(.*)\"\)$/) {
466
 
            my $dest=$1;
467
 
            my $type=$2;
468
 
            my $options=$3;
469
 
            my $input=$4;
470
 
            if($limitToLibs==1 && !($type eq "SHARED_LIBRARY" || $type eq "MODULE")) {
471
 
                next;
472
 
            }
473
 
            $input=~/.*\/(.*)/;
474
 
            $filename=$1;
475
 
            if($type eq "FILE" && $options=~/RENAME \"(.*)\"/) {
476
 
                $filename = $1;
477
 
            }
478
 
            #print " a: '$dest', b: $type, c: '$options', d: '$filename'\n";
479
 
            my $copy=0;
480
 
 
481
 
            if($filename=~/\.so$/) { # cmake may be lying to us in this case about the source path
482
 
                my @sourceInfo = stat "$input";
483
 
                if (@sourceInfo == 0) {
484
 
                    # in this case cmake moved the .so to the [build]/lib/ dir. Which sucks as we don't know what the build dir is!
485
 
                    my $testPath = $input;
486
 
                    while (1) {
487
 
                        $testPath=~/(.*)\/.*/; # aka 'cd ..'
488
 
                        $testPath = $1;
489
 
                        if ($testPath eq "") { last; }
490
 
                        if (-f "$testPath/lib/$filename") {
491
 
                            # found it!
492
 
                            $input = "$testPath/lib/$filename";
493
 
                            last;
494
 
                        }
495
 
                    }
496
 
                }
497
 
            }
498
 
 
499
 
            my @destInfo = stat "$dest/$filename";
500
 
            if(@destInfo == 0) {
501
 
                #print "dest not exist\n";
502
 
                $copy=1;
503
 
            }
504
 
            else {
505
 
                my @sourceInfo = stat "$input";
506
 
                if(@destInfo[7] != @sourceInfo[7]) { # filesize
507
 
                    #print "different size\n";
508
 
                    $copy=1;
509
 
                }
510
 
                elsif(abs(@destInfo[9] - @sourceInfo[9]) > 2) { # mtime
511
 
                    #print "different date\n";
512
 
                    $copy=1;
513
 
                }
514
 
            }
515
 
            if($copy == 1) {
516
 
                system("install -d $dest"); # create dir
517
 
                my $doSymlinks=0;
518
 
                my $ver="";
519
 
                my $sover;
520
 
                if($type eq "SHARED_LIBRARY") {
521
 
                    if($options=~/VERSION ([\d\.]+)/) { # do symlinks since its got versions.
522
 
                        $ver=".$1";
523
 
                        $doSymlinks=1;
524
 
                        $options=~/SOVERSION ([\d\.]+)/;
525
 
                        $sover=".$1";
526
 
                    }
527
 
                }
528
 
                system "install -d $dest" || die "Can not create dir '$dest'";
529
 
                unlink "$dest/$filename$ver";
530
 
                system "cp", "--preserve=timestamps,mode", "$input", "$dest/$filename$ver";
531
 
                if($type eq "EXECUTABLE") {
532
 
                    chmod 0755, "$dest/$filename";
533
 
                }
534
 
                #print "    cp $input $dest/$filename$ver\n";
535
 
                if($doSymlinks) {
536
 
                    if(!-l "$dest/$filename$sover") {
537
 
                        unlink("$dest/$filename$sover"); #if its a normal file
538
 
                        symlink "$filename$ver", "$dest/$filename$sover";
539
 
                    }
540
 
                    if(!-l "$dest/$filename") {
541
 
                        unlink("$dest/$filename"); #if its a normal file
542
 
                        symlink "$filename$sover", "$dest/$filename";
543
 
                    }
544
 
                }
545
 
                if($limitToLibs == 1) {
546
 
                    print "Installing";
547
 
                }
548
 
                print "  $dest/$filename$ver\n";
549
 
            }
550
 
        }
551
 
    }
552
 
    close FILE;
553
 
 
554
 
    foreach $subdir (@subdirs) {
555
 
        &install($subdir, $limitToLibs);
556
 
    }
557
 
}