Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

New mac packager using external Qt libraries

This is a major rewrite of the mac packager. It now uses external Qt libraries as downloaded from the Qt web site.

It adds significant improvement:
- 64 bits application support (both PPC and Intel)
- Universal 32/64 bits support

So far tested with XCode 4.3 on OSX 10.7 and XCode 3.2 on OS X 10.6

Application built on 10.6 will run on 10.5, 10.6 and 10.7
Application built on 10.7 will run on 10.6 and 10.7. There is an easy fix to the 10.6 SDK that can make the applications compatible on 10.5. This will be documented later.

For the time being, the builder only works with very recent master/0.25 and several fixes were added to the code to properly support LLVM compiler.
0.24 support may be added later
  • Loading branch information...
commit 1af486e9af65fc7bec5c3dffddaa1a9b3dcdf102 1 parent abc59b7
Jean-Yves Avenard authored March 05, 2012
62  OSX/build/osx-bundler.pl
@@ -31,20 +31,17 @@
31 31
 # 2) copies them into the bundle's Framework directory
32 32
 # 3) uses install_name_tool to update the library load paths
33 33
 #
34  
-# = KNOWN BUGS
35  
-# Doesn't do anything about Universal Binaries yet
36  
-#
37 34
 # = TO DO
38 35
 # Add more arguments to allow the user to specify
39 36
 # .pinfo fields like CFBundleIdentifier, CFBundleSignature,
40 37
 # NSHumanReadableCopyright, CFBundleGetInfoString, et c.
41 38
 #
42 39
 # = REVISION
43  
-# $Id$
  40
+# 2.0
44 41
 #
45 42
 # = AUTHORS
46 43
 # Nigel Pearson. Based on osx-packager by Jeremiah Morris,
47  
-# with improvements by Geoffrey Kruse and David Abrahams
  44
+# with improvements by Geoffrey Kruse, David Abrahams and Jean-Yves Avenard
48 45
 # ============================================================================
49 46
 
50 47
 use strict;
@@ -67,7 +64,8 @@ ($)
67 64
 # ============================================================================
68 65
 
69 66
 my $verbose = 0;
70  
-my $Id = '$Id$';  # Version of this script. From version control system
  67
+our $arch = "";
  68
+my $Id = '2.0';   # Version of this script
71 69
 my $binary;
72 70
 my $binbase;      # $binary without any directory path
73 71
 my $bundle;
@@ -76,13 +74,15 @@ ($)
76 74
 
77 75
 # Process arguments:
78 76
 
79  
-Getopt::Long::GetOptions('verbose' => \$verbose) or usage(-1);
  77
+Getopt::Long::GetOptions('verbose' => \$verbose, 'arch=s' => \$arch) or usage(-1);
80 78
 
81 79
 $binary  = shift @ARGV;
82 80
 @libdirs = @ARGV;
83 81
 
84 82
 # ============================================================================
85 83
 
  84
+&Verbose("Processing $binary");
  85
+
86 86
 if ( $binary =~ m/(.*)\.app$/ )
87 87
 {
88 88
     $bundle = $binary;
@@ -185,17 +185,37 @@ sub MakeFramework
185 185
     my ($dylib, $dest) = @_;
186 186
 
187 187
     my ($base, $vers) = &BaseVers($dylib);
  188
+    if ( ! defined $vers )
  189
+    {
  190
+        $vers = "1.0";
  191
+    }
188 192
     my $fw_dir = $dest . '/' . $base . '.framework';
189 193
 
  194
+    &Verbose("MakeFramework: fw_fir = $fw_dir, dest = $dest, base = $base, dylib = $dylib");
190 195
     return '' if ( -e $fw_dir );
191 196
 
192 197
     &Verbose("Building $base framework");
193 198
 
194 199
     &Syscall([ '/bin/mkdir', '-p',
195 200
                "$fw_dir/Versions/A/Resources" ]) or die;
196  
-    &Syscall([ '/bin/cp', $dylib,
197  
-               "$fw_dir/Versions/A/$base" ]) or die;
198  
-
  201
+    if ( $arch eq "" )
  202
+    {
  203
+        &Syscall([ '/bin/cp', $dylib,
  204
+                   "$fw_dir/Versions/A/$base" ]) or die;
  205
+    }
  206
+    else
  207
+    {
  208
+        &Verbose("Extracting $arch architecture from $dylib");
  209
+        my @args = ( '/usr/bin/lipo', '-thin', $arch, $dylib, '-o', "$fw_dir/Versions/A/$base" );
  210
+        &Verbose(@args);
  211
+        # try to extract required architecture
  212
+        system(@args);
  213
+        if ( $? )
  214
+        {
  215
+            # if unsuccessful, just copy the lib
  216
+            &Syscall([ '/bin/cp', $dylib, "$fw_dir/Versions/A/$base" ]) or die;
  217
+        }
  218
+    }
199 219
     &Syscall([ '/usr/bin/install_name_tool',
200 220
                '-id', $base, "$fw_dir/Versions/A/$base" ]) or die;
201 221
 
@@ -203,6 +223,19 @@ sub MakeFramework
203 223
     symlink('Versions/Current/Resources', "$fw_dir/Resources") or die;
204 224
     symlink("Versions/A/$base", "$fw_dir/$base") or die;
205 225
 
  226
+    if ( $dylib =~ m/\.framework/ )
  227
+    {
  228
+        my $resdir = dirname($dylib) . "/Resources";
  229
+        if ( -d $resdir )
  230
+        {
  231
+            &Verbose("$resdir exists, copy over $fw_dir/Resources");
  232
+            my @files = glob "$resdir/*";
  233
+            foreach (@files)
  234
+            {
  235
+                &Syscall([ '/bin/cp', '-R', "$_", "$fw_dir/Resources" ]);
  236
+            }
  237
+        }
  238
+    }
206 239
     &Verbose("Writing Info.plist for $base framework");
207 240
     my $plist;
208 241
     unless (open($plist, '>' . "$fw_dir/Versions/A/Resources/Info.plist"))
@@ -345,7 +378,6 @@ (@)
345 378
         foreach my $dep (@deps)
346 379
         {
347 380
             chomp $dep;
348  
-
349 381
             # otool returns lines like:
350 382
             #    libblah-7.dylib   (compatibility version 7, current version 7)
351 383
             # but we only want the file part
@@ -362,7 +394,7 @@ (@)
362 394
 
363 395
             # Any dependency which is already package relative can be ignored
364 396
             next if $dep =~ m/\@executable_path/;
365  
-
  397
+            
366 398
             # skip system library locations
367 399
             next if ($dep =~ m|^/System|  ||
368 400
                      $dep =~ m|^/usr/lib|);
@@ -371,6 +403,7 @@ (@)
371 403
 
372 404
             # Only add this dependency if needed. This assumes that 
373 405
             # we aren't mixing versions of the same library name
  406
+            &Verbose("Process Dep $base");
374 407
             if ( ! -e "$bundle/Contents/Frameworks/$base.framework/$base" )
375 408
             {   $depfiles{$base} = $dep   }
376 409
 
@@ -404,6 +437,11 @@ sub BaseVers
404 437
     {
405 438
         return ($1, undef);
406 439
     }
  440
+    elsif ($filename =~ m|^.*?\.framework.*/(.*?)$|)
  441
+    {
  442
+        &Verbose("Framework : $1");
  443
+        return ($1, undef);
  444
+    }
407 445
 
408 446
     &Verbose("Not a library file: $filename");
409 447
     return $filename;
1,902  OSX/build/osx-packager-qtsdk.pl
... ...
@@ -0,0 +1,1902 @@
  1
+#!/usr/bin/perl
  2
+
  3
+### = file
  4
+### osx-packager-qtsdk.pl
  5
+###
  6
+### = revision
  7
+### 1.0
  8
+###
  9
+### = location
  10
+### https://github.com/MythTV/packaging/raw/master/OSX/build/osx-packager-qtsdk.pl
  11
+###
  12
+### = description
  13
+### Tool for automating frontend builds on Mac OS X.
  14
+### Run "osx-packager.pl -man" for full documentation.
  15
+
  16
+use strict;
  17
+use Getopt::Long qw(:config auto_abbrev);
  18
+use Pod::Usage ();
  19
+use Cwd ();
  20
+use File::Temp qw/ tempfile tempdir /;
  21
+
  22
+### Configuration settings (stuff that might change more often)
  23
+
  24
+# We try to auto-locate the Git client binaries.
  25
+# If they are not in your path, we build them from source
  26
+#
  27
+our $git = `which git`; chomp $git;
  28
+
  29
+# This script used to always delete the installed include and lib dirs.
  30
+# That probably ensures a safe build, but when rebuilding adds minutes to
  31
+# the total build time, and prevents us skipping some parts of a full build
  32
+#
  33
+our $cleanLibs = 1;
  34
+
  35
+# By default, only the frontend is built (i.e. no backend or transcoding)
  36
+#
  37
+our $backend = 0;
  38
+our $jobtools = 0;
  39
+
  40
+# Start with a generic address and let sourceforge
  41
+# figure out which mirror is closest to us.
  42
+#
  43
+our $sourceforge = 'http://downloads.sourceforge.net';
  44
+
  45
+# At the moment, there is mythtv plus...
  46
+our @components = ( 'mythplugins' );
  47
+
  48
+# The OS X programs that we are likely to be interested in.
  49
+our @targets   = ( 'MythFrontend',  'MythWelcome' );
  50
+our @targetsJT = ( 'MythCommFlag', 'MythJobQueue');
  51
+our @targetsBE = ( 'MythBackend',  'MythFillDatabase', 'MythTV-Setup');
  52
+
  53
+# Name of the PlugIns directory in the application bundle
  54
+our $BundlePlugins = "PlugIns";
  55
+our $OSTARGET = "10.5";
  56
+
  57
+# Patches for MythTV source
  58
+our %patches = ();
  59
+
  60
+our %build_profile = (
  61
+  'master'
  62
+   => [
  63
+    'branch' => 'master',
  64
+    'mythtv'
  65
+    => [
  66
+        'ccache',
  67
+        'pkgconfig',
  68
+        'dvdcss',
  69
+        'freetype',
  70
+        'lame',
  71
+        'mysqlclient',
  72
+        #'dbus',
  73
+        'qt',
  74
+        'yasm',
  75
+        'liberation-sans',
  76
+        'firewiresdk',
  77
+       ],
  78
+    'mythplugins'
  79
+    => [
  80
+        'exif',
  81
+# MythMusic needs these:
  82
+        'libtool',
  83
+        'autoconf',
  84
+        'automake',
  85
+        'taglib',
  86
+        'libogg',
  87
+        'vorbis',
  88
+        'flac',
  89
+        'libcddb',
  90
+        'libcdio',
  91
+       ],
  92
+     ],
  93
+  '0.24-fixes'
  94
+  => [
  95
+    'branch' => 'fixes/0.24',
  96
+    'mythtv'
  97
+    =>  [
  98
+        'ccache',
  99
+        'pkgconfig',
  100
+        'dvdcss',
  101
+        'freetype',
  102
+        'lame',
  103
+        'mysqlclient',
  104
+        #'dbus',
  105
+        'qt',
  106
+        'yasm',
  107
+        'liberation-sans',
  108
+        'firewiresdk',
  109
+      ],
  110
+    'mythplugins'
  111
+    =>  [
  112
+        'exif',
  113
+# MythMusic needs these:
  114
+        'libtool',
  115
+        'autoconf',
  116
+        'automake',
  117
+        'taglib',
  118
+        'libogg',
  119
+        'vorbis',
  120
+        'flac',
  121
+      ],
  122
+    ],
  123
+);
  124
+
  125
+=head1 NAME
  126
+
  127
+osx-packager.pl - build OS X binary packages for MythTV
  128
+
  129
+=head1 SYNOPSIS
  130
+
  131
+ osx-packager.pl [options]
  132
+
  133
+ Options:
  134
+  -help              print the usage message
  135
+  -man               print full documentation
  136
+  -verbose           print informative messages during the process
  137
+  -version <str>     custom version suffix (defaults to "gitYYYYMMDD")
  138
+  -noversion         don't use any version suffix
  139
+                     (for building release versions)
  140
+  -distclean         throw away all myth installed and intermediates
  141
+                     files and exit
  142
+  -qtsdk <path>      path to Qt SDK Deskop
  143
+                     (e.g. -qtsdk ~/QtSDK/Desktop/Qt/4.8.0
  144
+  -qtbin <path>      path to Qt utilitities (qmake etc)
  145
+  -qtplugins <path>  path to Qt plugins
  146
+  -m32               build for a 32-bit environment only
  147
+                     (default is to build for the host's architecture)
  148
+  -universal         build for both 32 and 64 bits architectures
  149
+                     (only works with 0.25 or later,
  150
+                     requires Qt libraries)
  151
+  -gitrev <str>      build a specified Git revision or tag
  152
+
  153
+ You must provide either -qtsdk or -qtbin *and * -qtplugins
  154
+
  155
+ Advanced Options:
  156
+  -srcdir  <path>    build using provided root mythtv directory
  157
+  -pkgsrcdir <path>  build using provided packaging directory
  158
+  -force             use myth source directory as-is,
  159
+                     with no GIT validity check
  160
+  -nodistclean       do not perform a distclean prior to building myth
  161
+  -thirdclean        do a clean rebuild of third party packages
  162
+  -thirdskip         don't rebuild the third party packages
  163
+  -mythtvskip        don't rebuild/install mythtv, requires -nodistclean
  164
+  -pluginskip        don't rebuild/install mythplugins
  165
+  -nohead            don't update to HEAD revision of MythTV before
  166
+                     building
  167
+  -clean             clean myth module before rebuilding it (default)
  168
+  -noclean           use with -nohead, do not re-run configure nor clean
  169
+  -usehdimage        perform build inside of a case-sensitive disk image
  170
+  -leavehdimage      leave disk image mounted on exit
  171
+  -enable-backend    build the backend server as well as the frontend
  172
+  -enable-jobtools   build commflag/jobqueue  as well as the frontend
  173
+  -profile           build with compile-type=profile
  174
+  -debug             build with compile-type=debug
  175
+  -plugins <str>     comma-separated list of plugins to include
  176
+  -noparallel        do not use parallel builds
  177
+  -nobundle          only recompile, do not create application bundle
  178
+  -bootstrap         exit after building all thirdparty components
  179
+  -disable-sysroot   compiling with sysroot only works with 0.25 or later
  180
+                     use -disable-sysroot if compiling earlier version of myth
  181
+
  182
+=head1 DESCRIPTION
  183
+
  184
+This script builds a MythTV frontend and all necessary dependencies, along
  185
+with plugins as specified, as a standalone binary package for Mac OS X.
  186
+
  187
+It is designed for building daily Git snapshots,
  188
+and can also be used to create release builds with the '-gitrev' option.
  189
+
  190
+All intermediate files go into an '.osx-packager' directory in the current
  191
+working directory. The finished application is named 'MythFrontend.app' and
  192
+placed in the current working directory.
  193
+ 
  194
+By default, the end application will only run on the architecture of the machine
  195
+used to compile (32 or 64 bits). Use -universal to compile an application for both
  196
+32 and 64 bits. For -universal to work, you must compile on a 64 bits intel host.
  197
+
  198
+=head1 REQUIREMENTS
  199
+ 
  200
+You need to have installed either Qt SDK (64 bits only) or
  201
+Qt libraries package (both 32 and 64 bits) from http://qt.nokia.com/downloads.
  202
+ 
  203
+When using the Qt SDK, use the -qtsdk flag to define the location of the Desktop Qt,
  204
+by default it is ~/QtSDK/Desktop/Qt/[VERSION]/gcc where version is 4.8.0 (SDK 1.2)
  205
+or 473 (SDK 1.1)
  206
+
  207
+When using the Qt libraries package, use the -qtbin and -qtplugins. Values for default
  208
+Qt installation are: -qtbin /usr/bin -qtplugins /Developer/Applications/Qt/plugins.
  209
+Qt Headers must be installed.
  210
+
  211
+=head1 EXAMPLES
  212
+
  213
+Building two snapshots, one with all plugins and one without:
  214
+
  215
+  osx-packager.pl -qtbin /usr/bin -qtplugins /Developer/Applications/Qt/plugins
  216
+  mv MythFrontend.app MythFrontend-plugins.app 
  217
+  osx-packager.pl -nohead -pluginskip -qtbin /usr/bin -qtplugins /Developer/Applications/Qt/plugins
  218
+  mv MythFrontend.app MythFrontend-noplugins.app
  219
+
  220
+Building a "fixes" branch:
  221
+
  222
+  osx-packager.pl -gitrev fixes/0.24 -qtbin /usr/bin -qtplugins /Developer/Applications/Qt/plugins
  223
+
  224
+Note that this script will not build old branches.
  225
+Please try the branched version instead. e.g.
  226
+http://svn.mythtv.org/svn/branches/release-0-21-fixes/mythtv/contrib/OSX/osx-packager.pl
  227
+
  228
+=head1 CREDITS
  229
+
  230
+Written by Jean-Yves Avenard <jyavenard@gmail.com>
  231
+Based on work by Jeremiah Morris <jm@whpress.com>
  232
+
  233
+Includes contributions from Nigel Pearson, Jan Ornstedt, Angel Li, and Andre Pang, Bas Hulsken (bhulsken@hotmail.com)
  234
+
  235
+=cut
  236
+
  237
+# Parse options
  238
+our (%OPT);
  239
+Getopt::Long::GetOptions(\%OPT,
  240
+                         'help|?',
  241
+                         'man',
  242
+                         'verbose',
  243
+                         'version=s',
  244
+                         'noversion',
  245
+                         'distclean',
  246
+                         'thirdclean',
  247
+                         'nodistclean',
  248
+                         'noclean',
  249
+                         'thirdskip',
  250
+                         'mythtvskip',
  251
+                         'pluginskip',
  252
+                         'gitrev=s',
  253
+                         'nohead',
  254
+                         'usehdimage',
  255
+                         'leavehdimage',
  256
+                         'enable-backend',
  257
+                         'enable-jobtools',
  258
+                         'profile',
  259
+                         'debug',
  260
+                         'm32',
  261
+                         'universal',
  262
+                         'plugins=s',
  263
+                         'srcdir=s',
  264
+                         'pkgsrcdir=s',
  265
+                         'force',
  266
+                         'archives=s',
  267
+                         'buildprofile=s',
  268
+                         'bootstrap',
  269
+                         'nohacks',
  270
+                         'noparallel',
  271
+                         'qtsdk=s',
  272
+                         'qtbin=s',
  273
+                         'qtplugins=s',
  274
+                         'nobundle',
  275
+                        ) or Pod::Usage::pod2usage(2);
  276
+Pod::Usage::pod2usage(1) if $OPT{'help'};
  277
+Pod::Usage::pod2usage('-verbose' => 2) if $OPT{'man'};
  278
+
  279
+our $QTSDK = "";
  280
+our $QTBIN = "";
  281
+our $QTLIB = "";
  282
+our $QTPLUGINS = "";
  283
+our $QTVERSION = "";
  284
+if ( $OPT{'qtsdk'} )
  285
+{
  286
+    $QTSDK = $OPT{'qtsdk'};
  287
+}
  288
+
  289
+if ( $OPT{'qtbin'} )
  290
+{
  291
+    $QTBIN = "$OPT{'qtbin'}";
  292
+}
  293
+elsif ( $OPT{'qtsdk'} )
  294
+{
  295
+    $QTBIN = "$OPT{'qtsdk'}/bin";
  296
+}
  297
+if ( $OPT{'qtplugins'} )
  298
+{
  299
+    $QTPLUGINS = "$OPT{'qtplugins'}";
  300
+}
  301
+elsif ( $OPT{'qtsdk'} )
  302
+{
  303
+    $QTPLUGINS = "$QTSDK/plugins";
  304
+}
  305
+
  306
+# Test if Qt conf is valid, all paths must exist
  307
+if ( ! ( (($QTBIN ne "") && ($QTPLUGINS ne "")) &&
  308
+     ( -d $QTBIN && -d $QTPLUGINS )) )
  309
+{
  310
+    &Complain("bin:$QTBIN lib:$QTLIB plugins:$QTPLUGINS You must define a valid Qt SDK path with -qtsdk <path> or -qtbin <path> *and* -qtplugins <path>");
  311
+    exit;
  312
+}
  313
+
  314
+#Determine the version Qt SDK we are using, we need to retrieve the source code to build MySQL Qt plugin
  315
+if ( ! -e "$QTBIN/qmake" )
  316
+{
  317
+    &Complain("$QTBIN isn't a valid Qt bin path (qmake not found)");
  318
+    exit;
  319
+}
  320
+my @ret = `$QTBIN/qmake --version`;
  321
+my $regexp = qr/Qt version (\d+\.\d+\.\d+) in (.*)$/;
  322
+foreach my $line (@ret)
  323
+{
  324
+    chomp $line;
  325
+    next if ($line !~ m/$regexp/);
  326
+    $QTVERSION = $1;
  327
+    $QTLIB = $2;
  328
+    &Verbose("Qt version is $QTVERSION");
  329
+}
  330
+
  331
+if ($QTVERSION eq "")
  332
+{
  333
+    &Complain("Couldn't identify Qt version");
  334
+    exit;
  335
+}
  336
+if ( ! -d $QTLIB )
  337
+{
  338
+    &Complain("$QTLIB doesn't exist. Invalid Qt sdk");
  339
+    exit;
  340
+}
  341
+
  342
+if ( $OPT{'enable-backend'} )
  343
+{   $backend = 1  }
  344
+
  345
+if ( $OPT{'noclean'} )
  346
+{   $cleanLibs = 0  }
  347
+
  348
+if ( $OPT{'enable-jobtools'} )
  349
+{   $jobtools = 1  }
  350
+
  351
+# Get version string sorted out
  352
+if ( $OPT{'gitrev'} && !$OPT{'version'} )
  353
+{
  354
+    $OPT{'version'} = $OPT{'gitrev'};
  355
+}
  356
+$OPT{'version'} = '' if $OPT{'noversion'};
  357
+unless (defined $OPT{'version'})
  358
+{
  359
+    my @lt = gmtime(time);
  360
+    $OPT{'version'} = sprintf('git%04d%02d%02d',
  361
+                              $lt[5] + 1900, $lt[4] + 1, $lt[3]);
  362
+}
  363
+
  364
+if ( $OPT{'srcdir'} )
  365
+{
  366
+    $OPT{'nohead'} = 1;
  367
+    $OPT{'gitrev'} = '';
  368
+}
  369
+
  370
+# Build our temp directories
  371
+our $SCRIPTDIR = Cwd::abs_path(Cwd::getcwd());
  372
+if ( $SCRIPTDIR =~ /\s/ )
  373
+{
  374
+    &Complain(<<END);
  375
+Working directory contains spaces
  376
+
  377
+Error: Your current working path:
  378
+
  379
+   $SCRIPTDIR
  380
+
  381
+contains one or more spaces. This will break the compilation process,
  382
+so the script cannot continue. Please re-run this script from a different
  383
+directory (such as /tmp).
  384
+
  385
+The application produced will run from any directory, the no-spaces
  386
+rule is only for the build process itself.
  387
+
  388
+END
  389
+    die;
  390
+}
  391
+
  392
+our $WORKDIR = "$SCRIPTDIR/.osx-packager";
  393
+mkdir $WORKDIR;
  394
+
  395
+if ( $OPT{'nohead'} && ! $OPT{'force'} && ! $OPT{'srcdir'} )
  396
+{
  397
+    my $GITTOP="$WORKDIR/src/myth-git/.git";
  398
+
  399
+    if ( ! -d $GITTOP )
  400
+    {   die "No source code to build?"   }
  401
+
  402
+    if ( ! `grep refs/heads/master $GITTOP/HEAD` )
  403
+    {   die "Source code does not match GIT master"   }
  404
+}
  405
+elsif ( $OPT{'gitrev'} =~ m,^fixes/, && $OPT{'gitrev'} lt "fixes/0.23" )
  406
+{
  407
+    &Complain(<<END);
  408
+This version of this script can not build old branches.
  409
+Please try the branched version instead. e.g.
  410
+http://svn.mythtv.org/svn/branches/release-0-23-fixes/packaging/OSX/build/osx-packager.pl
  411
+http://svn.mythtv.org/svn/branches/release-0-21-fixes/mythtv/contrib/OSX/osx-packager.pl
  412
+END
  413
+    die;
  414
+}
  415
+
  416
+if ($OPT{usehdimage})
  417
+{   MountHDImage()   }
  418
+
  419
+our $PREFIX = "$WORKDIR/build";
  420
+mkdir $PREFIX;
  421
+
  422
+our $SRCDIR = "$WORKDIR/src";
  423
+mkdir $SRCDIR;
  424
+
  425
+our $ARCHIVEDIR ='';
  426
+if ( $OPT{'archives'} )
  427
+{
  428
+    $ARCHIVEDIR = "$SCRIPTDIR" . '/' . $OPT{'archives'};
  429
+} else {
  430
+    $ARCHIVEDIR = "$SRCDIR";
  431
+}
  432
+
  433
+our %depend_order = '';
  434
+my $gitrevision = 'master';  # Default thingy to checkout
  435
+if ( $OPT{'buildprofile'} && $OPT{'buildprofile'} == '0.24-fixes' )
  436
+{
  437
+    &Verbose('Building using 0.24-fixes profile');
  438
+    %depend_order = @{ $build_profile{'0.24-fixes'} };
  439
+    $gitrevision = 'fixes/0.24'
  440
+} else {
  441
+    &Verbose('Building using master profile');
  442
+    %depend_order = @{ $build_profile{'master'} };
  443
+}
  444
+
  445
+our $GITDIR = "$SRCDIR/myth-git";
  446
+
  447
+our @pluginConf;
  448
+if ( $OPT{plugins} )
  449
+{
  450
+    @pluginConf = split /,/, $OPT{plugins};
  451
+    @pluginConf = grep(s/^/--enable-/, @pluginConf);
  452
+    unshift @pluginConf, '--disable-all';
  453
+}
  454
+else
  455
+{
  456
+    @pluginConf = (
  457
+        '--enable-opengl',
  458
+        '--enable-mythgallery',
  459
+        '--enable-exif',
  460
+        '--enable-new-exif',
  461
+    );
  462
+}
  463
+
  464
+# configure mythplugins, and mythtv, etc
  465
+our %conf = (
  466
+  'mythplugins'
  467
+  =>  [
  468
+        @pluginConf
  469
+      ],
  470
+  'mythtv'
  471
+  =>  [
  472
+        "--runprefix=../Resources",
  473
+        "--firewire-sdk=$PREFIX/lib",
  474
+        "--enable-libmp3lame",
  475
+
  476
+        # To "cross compile" something for a lesser Mac:
  477
+        #'--tune=G3',
  478
+        #'--disable-altivec',
  479
+      ],
  480
+);
  481
+
  482
+# configure mythplugins, and mythtv, etc
  483
+our %makecleanopt = (
  484
+  'mythplugins'
  485
+  =>  [
  486
+        'distclean',
  487
+      ],
  488
+);
  489
+
  490
+use File::Basename;
  491
+our $gitpath = dirname $git;
  492
+
  493
+# Clean the environment
  494
+$ENV{'PATH'} = "$PREFIX/bin:/bin:/usr/bin:/usr/sbin:$gitpath";
  495
+$ENV{'PKG_CONFIG_PATH'} = "$PREFIX/lib/pkgconfig:";
  496
+delete $ENV{'CPP'};
  497
+delete $ENV{'CXX'};
  498
+
  499
+our $DEVROOT = `xcode-select -print-path`; chomp $DEVROOT;
  500
+our $SDKVER = `xcodebuild -showsdks | grep macosx10 | sort | head -n 1 | awk '{ print \$4 }' `; chomp $SDKVER;
  501
+our $SDKNAME = `xcodebuild -showsdks | grep macosx10 | sort | head -n 1 | awk '{ print \$6 }' `; chomp $SDKNAME;
  502
+our $SDKROOT = "$DEVROOT/SDKs/MacOSX$SDKVER.sdk";
  503
+
  504
+$ENV{'DEVROOT'} = $DEVROOT;
  505
+$ENV{'SDKVER'} = $SDKVER;
  506
+$ENV{'SDKROOT'} = $SDKROOT;
  507
+
  508
+# Determine appropriate gcc/g++ path for the selected SDKs
  509
+our $CCBIN = `xcodebuild -find gcc -sdk $SDKNAME`; chomp $CCBIN;
  510
+our $CXXBIN = `xcodebuild -find g++ -sdk $SDKNAME`; chomp $CXXBIN;
  511
+$ENV{'CC'} = $CCBIN;
  512
+$ENV{'CXX'} = $CXXBIN;
  513
+$ENV{'CPP'} = "$CCBIN -E";
  514
+$ENV{'CXXCPP'} = "$CXXBIN -E";
  515
+
  516
+if ( ! -e "$SDKROOT" && ! $OPT{'disable-sysroot'} )
  517
+{
  518
+    #Handle special case for 10.4 where the SDK name is 10.4u.sdk
  519
+    $SDKROOT = "$DEVROOT/SDKs/MacOSX${SDKVER}u.sdk";
  520
+    if ( ! -e "$SDKROOT" )
  521
+    {
  522
+        # Handle XCode 4.3 new location
  523
+        $SDKROOT = "$DEVROOT/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$SDKVER.sdk";
  524
+        if ( ! -e "$SDKROOT" )
  525
+        {
  526
+            &Complain("$SDKROOT doesn't exist");
  527
+            &Complain("Did you set your xcode environmment path properly ? (xcode-select utility)");
  528
+            exit;
  529
+        }
  530
+    }
  531
+}
  532
+
  533
+#Compilation was broken when using sysroots, mythtv code was fixed from 0.25 only. so this makes it configurable
  534
+our $SDKISYSROOT = "-isysroot $SDKROOT -mmacosx-version-min=$OSTARGET";
  535
+our $SDKLSYSROOT = "-Wl,-syslibroot,${SDKROOT} -mmacosx-version-min=$OSTARGET";
  536
+if ( $OPT{'disable-sysroot'} )
  537
+{
  538
+    $SDKISYSROOT = "";
  539
+    $SDKLSYSROOT = "";
  540
+}
  541
+
  542
+# set up Qt environment
  543
+$ENV{'QTDIR'} = "$QTSDK";
  544
+$ENV{'QMAKESPEC'} = 'macx-g++';
  545
+$ENV{'MACOSX_DEPLOYMENT_TARGET'} = $OSTARGET;
  546
+
  547
+$ENV{'CFLAGS'} = $ENV{'CXXFLAGS'} = $ENV{'ECXXFLAGS'} = "$SDKISYSROOT -I$PREFIX/include -I$PREFIX/mysql";
  548
+$ENV{'LDFLAGS'} = "$SDKLSYSROOT -L$PREFIX/lib -F$QTLIB";
  549
+$ENV{'PREFIX'} = $PREFIX;
  550
+$ENV{'SDKROOT'} = $SDKROOT;
  551
+
  552
+# compilation flags used for compiling dependency tools, do not use multi-architecture
  553
+our $CFLAGS    = $ENV{'CFLAGS'};
  554
+our $CXXFLAGS  = $ENV{'CXXFLAGS'};
  555
+our $ECXXFLAGS = $ENV{'ECXXFLAGS'};
  556
+our $LDFLAGS   = $ENV{'LDFLAGS'};
  557
+our $ARCHARG   = "";
  558
+our @ARCHS;
  559
+
  560
+# Check host computer architecture and create list of architecture to build
  561
+my $arch = `sysctl -n hw.machine`; chomp $arch;
  562
+if ( $OPT{'m32'} && ! $OPT{'universal'} )
  563
+{
  564
+    &Verbose('Forcing 32 bits build...');
  565
+    $ENV{'CFLAGS'}    .= ' -m32';
  566
+    $ENV{'CXXFLAGS'}  .= ' -m32';
  567
+    $ENV{'ECXXFLAGS'} .= ' -m32';  # MythTV configure
  568
+    $ENV{'LDFLAGS'}   .= ' -m32';
  569
+    if ( $arch eq "x86_64" || $arch eq "i386" )
  570
+    {
  571
+        $ARCHARG = "-arch i386";
  572
+        push @ARCHS, "i386";
  573
+    }
  574
+    else
  575
+    {
  576
+        # assume PPC, what else could it be?
  577
+        $ARCHARG = "-arch ppc7400";
  578
+        push @ARCHS, "ppc7400";
  579
+    }
  580
+}
  581
+elsif ( $arch eq "x86_64" || $arch eq "ppc64" )
  582
+{
  583
+    if ( $OPT{'universal'} )
  584
+    {
  585
+        # Requested universal, and 64 bits host
  586
+        &Verbose('Building 32/64 bits universal app...');
  587
+        if ( $arch eq "x86_64" )
  588
+        {
  589
+            $ENV{'CFLAGS'}    .= ' -arch i386 -arch x86_64';
  590
+            $ENV{'CXXFLAGS'}  .= ' -arch i386 -arch x86_64';
  591
+            $ENV{'ECXXFLAGS'} .= ' -arch i386 -arch x86_64';  # MythTV configure
  592
+            $ENV{'LDFLAGS'}   .= ' -arch i386 -arch x86_64';
  593
+            $ARCHARG = "-arch i386 -arch x86_64";
  594
+            push @ARCHS, "i386", "x86_64";
  595
+        }
  596
+        else
  597
+        {
  598
+            $ENV{'CFLAGS'}    .= ' -arch ppc7400 -arch ppc64';
  599
+            $ENV{'CXXFLAGS'}  .= ' -arch ppc7400 -arch ppc64';
  600
+            $ENV{'ECXXFLAGS'} .= ' -arch ppc7400 -arch ppc64';  # MythTV configure
  601
+            $ENV{'LDFLAGS'}   .= ' -arch ppc7400 -arch ppc64';
  602
+            $ARCHARG = ' -arch ppc7400 -arch ppc64';
  603
+            push @ARCHS, "ppc7400", "ppc64";
  604
+        }
  605
+    }
  606
+    else
  607
+    {
  608
+        if ( $arch eq "x86_64" )
  609
+        {
  610
+            $ARCHARG = "-arch x86_64";
  611
+            push @ARCHS, "x86_64";
  612
+        }
  613
+        else
  614
+        {
  615
+            $ARCHARG = "-arch ppc64";
  616
+            push @ARCHS, "ppc64";
  617
+        }
  618
+    }
  619
+}
  620
+else
  621
+{
  622
+    if ( $arch eq "i386" )
  623
+    {
  624
+        push @ARCHS, "i386";
  625
+    }
  626
+    else
  627
+    {
  628
+        push @ARCHS, "ppc7400";
  629
+    }
  630
+    $OPT{'universal'} = 0;
  631
+}
  632
+
  633
+# Test if Qt libraries support required architectures. We do so by generating a dummy project and trying to compile it
  634
+&Verbose("Testing Qt environment");
  635
+my $dir = tempdir( );#CLEANUP => 1 );
  636
+my $tmpe = "$dir/test";
  637
+my $tmpcpp = "$dir/test.cpp";
  638
+my $tmppro = "$dir/test.pro";
  639
+my $make = "$dir/Makefile";
  640
+open fdcpp, ">", $tmpcpp;
  641
+print fdcpp "#include <QString>\nint main(void) { QString(); }\n";
  642
+close fdcpp;
  643
+open fdpro, ">", $tmppro;
  644
+my $name = basename($tmpe);
  645
+print fdpro "SOURCES=$tmpcpp\nTARGET=$name\nDESTDIR=$dir\nCONFIG-=app_bundle";
  646
+close fdpro;
  647
+&Syscall("$QTBIN/qmake \"QMAKE_CC=$CCBIN\" \"QMAKE_CXX=$CXXBIN\" \"QMAKE_CXXFLAGS=$ENV{'ECXXFLAGS'}\" \"QMAKE_CFLAGS=$ENV{'CFLAGS'}\" \"QMAKE_LFLAGS+=$ENV{'LDFLAGS'}\" -o $make $tmppro");# 2> /dev/null > /dev/null");
  648
+&Syscall(['/bin/rm' , '-f', $tmpe]);
  649
+my $result = &Syscall("/usr/bin/make -C $dir -f $make $name");# 2>/dev/null >/dev/null");
  650
+
  651
+if ( $result ne "1" )
  652
+{
  653
+    &Complain("Couldn't use Qt for the architectures @ARCHS. If using -universal or -m32, make sure the Qt frameworks is build for those architectures");
  654
+    exit;
  655
+}
  656
+
  657
+# show summary of build parameters.
  658
+&Verbose("DEVROOT = $DEVROOT");
  659
+&Verbose("SDKVER = $SDKVER");
  660
+&Verbose("SDKROOT = $SDKROOT");
  661
+&Verbose("CCBIN = $ENV{'CC'}");
  662
+&Verbose("CXXBIN = $ENV{'CXX'}");
  663
+&Verbose("CFLAGS = $ENV{'CFLAGS'}");
  664
+&Verbose("LDFLAGS = $ENV{'LDFLAGS'}");
  665
+
  666
+# Test if LLVM, mythtv doesn't compile unless you build in debug mode
  667
+my $out = `$CCBIN --version`;
  668
+if ( $out =~ m/llvm/ )
  669
+{
  670
+    $OPT{'debug'} = 1;
  671
+    &Verbose('Using LLVM: Forcing debug compile...');
  672
+}
  673
+
  674
+our $standard_make = '/usr/bin/make';
  675
+our $parallel_make = $standard_make;
  676
+our $parallel_make_flags = '';
  677
+
  678
+my $cmd = "/usr/bin/hostinfo | grep 'processors\$'";
  679
+&Verbose($cmd);
  680
+my $cpus = `$cmd`; chomp $cpus;
  681
+$cpus =~ s/.*, (\d+) processors$/$1/;
  682
+if ( $cpus gt 1 )
  683
+{
  684
+    &Verbose("Using", $cpus+1, "jobs on $cpus parallel CPUs");
  685
+    ++$cpus;
  686
+    $parallel_make_flags = "-j$cpus";
  687
+}
  688
+
  689
+if ($OPT{'noparallel'})
  690
+{
  691
+    $parallel_make_flags = '';
  692
+}
  693
+$parallel_make .= " $parallel_make_flags";
  694
+
  695
+our %depend = (
  696
+
  697
+    'git' =>
  698
+    {
  699
+        'url'           => 'http://www.kernel.org/pub/software/scm/git/git-1.7.3.4.tar.bz2',
  700
+        'parallel-make' => 'yes'
  701
+    },
  702
+
  703
+    'freetype' =>
  704
+    {
  705
+        'url' => "$sourceforge/sourceforge/freetype/freetype-2.4.8.tar.gz",
  706
+    },
  707
+
  708
+    'lame' =>
  709
+    {
  710
+        'url'           =>  "$sourceforge/sourceforge/lame/lame-3.99.5.tar.gz",
  711
+        'conf'          =>  [
  712
+            '--disable-frontend',
  713
+        ],
  714
+    },
  715
+
  716
+    'libmad' =>
  717
+    {
  718
+        'url'           => "$sourceforge/sourceforge/mad/libmad-0.15.0b.tar.gz",
  719
+        'parallel-make' => 'yes'
  720
+    },
  721
+
  722
+    # default generated taglib configure is bugger and won't compile universal file. So need to regenerate it
  723
+    # new version of taglib 1.7 uses cmake which takes excessively long time to compile. So stick with 1.6.3
  724
+    'taglib' =>
  725
+    {
  726
+        'url'           => 'http://developer.kde.org/~wheeler/files/src/taglib-1.6.3.tar.gz',
  727
+        'pre-conf'      => "cp $PREFIX/share/libtool/config/ltmain.sh admin/ ; " .
  728
+            "cp $PREFIX/share/aclocal/libtool.m4 admin/libtool.m4.in ; " .
  729
+            "$PREFIX/bin/autoreconf",
  730
+    },
  731
+
  732
+    'libogg' =>
  733
+    {
  734
+        'url'           => 'http://downloads.xiph.org/releases/ogg/libogg-1.3.0.tar.gz',
  735
+    },
  736
+
  737
+    'vorbis' =>
  738
+    {
  739
+        'url'           => 'http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.2.tar.gz',
  740
+    },
  741
+
  742
+    'flac' =>
  743
+    {
  744
+        'url'  => "$sourceforge/sourceforge/flac/flac-1.2.1.tar.gz",
  745
+        # Workaround Intel problem - Missing _FLAC__lpc_restore_signal_asm_ia32
  746
+        'conf' => [
  747
+            '--disable-asm-optimizations',
  748
+        ],
  749
+        # patch to support universal compilation and fix incorrect sizeof
  750
+        'post-conf' => "echo \"/#define SIZEOF_VOIDP/c\n" .
  751
+            "#ifdef __LP64__\n" .
  752
+            "#define SIZEOF_VOIDP 8\n" .
  753
+            "#else\n" .
  754
+            "#define SIZEOF_VOIDP 4\n" .
  755
+            "#endif\n" .
  756
+            ".\n" .
  757
+            "w\" | /bin/ed config.h ; sed -i -e 's/CC -dynamiclib/CC -dynamiclib $ARCHARG/g' libtool",
  758
+    },
  759
+
  760
+    # pkgconfig 0.26 and above do not include glib which is required to compile
  761
+    # glib requires pkgconfig to compile, so it's a chicken and egg problem.
  762
+    # Use nothing newer than 0.25 on OSX.
  763
+    'pkgconfig' =>
  764
+    {
  765
+        'url'           => "http://pkgconfig.freedesktop.org/releases/pkg-config-0.25.tar.gz",
  766
+        'conf-cmd'      =>  "CFLAGS=\"\" LDFLAGS=\"\" ./configure",
  767
+        'conf'          => [
  768
+            "--prefix=$PREFIX",
  769
+            "--disable-static",
  770
+            "--enable-shared",
  771
+        ],
  772
+        
  773
+    },
  774
+
  775
+    'dvdcss' =>
  776
+    {
  777
+        'url'           =>  'http://download.videolan.org/pub/videolan/libdvdcss/1.2.11/libdvdcss-1.2.11.tar.bz2',
  778
+    },
  779
+
  780
+    'mysqlclient' =>
  781
+    {
  782
+        'url'           => 'http://downloads.mysql.com/archives/mysql-5.1/mysql-5.1.56.tar.gz',
  783
+        'conf'          =>  [
  784
+            '--without-debug',
  785
+            '--without-docs',
  786
+            '--without-man',
  787
+            '--without-bench',
  788
+            '--without-server',
  789
+            '--without-geometry',
  790
+            '--without-extra-tools',
  791
+        ],
  792
+    },
  793
+
  794
+    'dbus' =>
  795
+    {
  796
+        'url' => 'http://dbus.freedesktop.org/releases/dbus/dbus-1.0.3.tar.gz',
  797
+        'post-make' => 'mv $PREFIX/lib/dbus-1.0/include/dbus/dbus-arch-deps.h '.
  798
+        ' $PREFIX/include/dbus-1.0/dbus ; '.
  799
+        'rm -fr $PREFIX/lib/dbus-1.0 ; '.
  800
+        'cd $PREFIX/bin ; '.
  801
+        'echo "#!/bin/sh
  802
+        if [ \"\$2\" = dbus-1 ]; then
  803
+        case \"\$1\" in
  804
+        \"--version\") echo 1.0.3  ;;
  805
+        \"--cflags\")  echo -I$PREFIX/include/dbus-1.0 ;;
  806
+        \"--libs\")    echo \"-L$PREFIX/lib -ldbus-1\" ;;
  807
+        esac
  808
+        fi
  809
+        exit 0"   > pkg-config ; '.
  810
+        'chmod 755 pkg-config'
  811
+    },
  812
+
  813
+    'qt'
  814
+    =>
  815
+    {
  816
+        'url' => "http://download.qt.nokia.com/qt/source/qt-everywhere-opensource-src-${QTVERSION}.tar.gz",
  817
+        'pre-conf'
  818
+        =>  # Get around Qt bug QTBUG-24498 (4.8.0) && stupid thing can't compile in release mode on mac without framework active
  819
+        #also hack for QTBUG-23258
  820
+        "find . -name \"*.pro\" -exec sed -i -e \"s:/Developer/SDKs/:.*:g\" {} \\;",
  821
+        'conf-cmd'
  822
+        =>  "cd src/plugins/sqldrivers/mysql && $QTBIN/qmake \"QMAKE_CC=$CCBIN\" \"QMAKE_CXX=$CXXBIN\" \"QMAKE_CXXFLAGS=$ENV{'ECXXFLAGS'}\" \"QMAKE_CFLAGS=$ENV{'CFLAGS'}\" \"QMAKE_LFLAGS+=$ENV{'LDFLAGS'}\" \"INCLUDEPATH+=$PREFIX/include/mysql\" \"LIBS+=-L$PREFIX/lib/mysql -lmysqlclient_r\" \"target.path=$PREFIX/qtplugins-$QTVERSION\" mysql.pro",
  823
+        'make-cmd' => 'cd src/plugins/sqldrivers/mysql',
  824
+        'make' => [ ],
  825
+        'post-make' => 'cd src/plugins/sqldrivers/mysql ; make install ; '.
  826
+            'make -f Makefile.Release install ; '.
  827
+            'cd $PREFIX/lib ; ln -s mysql lib; '.
  828
+            'rm -f $PREFIX/bin/pkg-config ; '.
  829
+            '',
  830
+        #WebKit in Qt keeps erroring half way on my quad-core when using -jX, use -noparallel
  831
+        'parallel-make' => 'yes'
  832
+    },
  833
+
  834
+    'exif' =>
  835
+    {
  836
+        'url'           => "$sourceforge/sourceforge/libexif/libexif-0.6.20.tar.bz2",
  837
+        'conf'          => [
  838
+            '--disable-docs'
  839
+        ]
  840
+    },
  841
+
  842
+    'yasm' =>
  843
+    {
  844
+        'url'           => 'http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz',
  845
+    },
  846
+
  847
+    'ccache' =>
  848
+    {
  849
+        'url'           => 'http://samba.org/ftp/ccache/ccache-3.1.4.tar.bz2',
  850
+        'parallel-make' => 'yes'
  851
+    },
  852
+
  853
+    'libcddb' =>
  854
+    {
  855
+        'url'           => 'http://prdownloads.sourceforge.net/libcddb/libcddb-1.3.2.tar.bz2',
  856
+    },
  857
+
  858
+    'libcdio' =>
  859
+    {
  860
+        'url'           => 'http://ftp.gnu.org/pub/gnu/libcdio/libcdio-0.83.tar.bz2',
  861
+    },
  862
+
  863
+    'liberation-sans' =>
  864
+    {
  865
+        'url'      => 'https://fedorahosted.org/releases/l/i/liberation-fonts/liberation-fonts-ttf-1.07.1.tar.gz',
  866
+        'conf-cmd' => 'echo "all:" > Makefile',
  867
+        'make'     => [ ],  # override the default 'make all install' targets
  868
+    },
  869
+
  870
+    'firewiresdk' =>
  871
+    {
  872
+        'url'      => 'http://www.avenard.org/files/mac/AVCVideoServices.framework.tar.gz',
  873
+        'conf-cmd' => 'cd',
  874
+        'make-cmd' => "rm -rf $PREFIX/lib/AVCVideoServices.framework ; cp -R . $PREFIX/lib/AVCVideoServices.framework",
  875
+        'make'     => [ ],
  876
+    },
  877
+
  878
+    'cmake'       =>
  879
+    {
  880
+        'url'      => 'http://www.cmake.org/files/v2.8/cmake-2.8.7.tar.gz',
  881
+    },
  882
+
  883
+    'libtool'     =>
  884
+    {
  885
+        'url'     => 'http://ftpmirror.gnu.org/libtool/libtool-2.4.2.tar.gz',
  886
+    },
  887
+
  888
+    'autoconf'    =>
  889
+    {
  890
+        'url'     => 'http://ftp.gnu.org/gnu/autoconf/autoconf-2.68.tar.gz',
  891
+    },
  892
+    'automake'    =>
  893
+    {
  894
+        'url'     => 'http://ftp.gnu.org/gnu/automake/automake-1.11.tar.gz',
  895
+    },
  896
+
  897
+);
  898
+
  899
+
  900
+### Check for app present in target location
  901
+our $MFE = "$SCRIPTDIR/MythFrontend.app";
  902
+if ( -d $MFE && ! $OPT{'nobundle'} && ! $OPT{'distclean'} )
  903
+{
  904
+    &Complain(<<END);
  905
+$MFE already exists
  906
+
  907
+Error: a MythFrontend application exists where we were planning
  908
+to build one. Please move this application away before running
  909
+this script.
  910
+
  911
+END
  912
+    exit;
  913
+}
  914
+
  915
+### Third party packages
  916
+my ( @build_depends, %seen_depends );
  917
+my @comps = ( 'mythtv', @components, 'packaging' );
  918
+
  919
+# Deal with user-supplied skip arguments
  920
+if ( $OPT{'mythtvskip'} )
  921
+{   @comps = grep(!m/mythtv/,      @comps)   }
  922
+if ( $OPT{'pluginskip'} )
  923
+{   @comps = grep(!m/mythplugins/, @comps)   }
  924
+
  925
+if ( ! @comps )
  926
+{
  927
+    &Complain("Nothing to build! Too many ...skip arguments?");
  928
+    exit;
  929
+}
  930
+
  931
+&Verbose("Including components:", @comps);
  932
+
  933
+# If no Git in path, and we are checking something out, build Git:
  934
+if ( ( ! $git || $git =~ m/no git in / ) && ! $OPT{'nohead'} )
  935
+{
  936
+    $git = "$PREFIX/bin/git";
  937
+    @build_depends = ( 'git' );
  938
+}
  939
+
  940
+foreach my $comp (@comps)
  941
+{
  942
+    foreach my $dep (@{ $depend_order{$comp} })
  943
+    {
  944
+        unless (exists $seen_depends{$dep})
  945
+        {
  946
+            push(@build_depends, $dep);
  947
+            $seen_depends{$dep} = 1;
  948
+        }
  949
+    }
  950
+}
  951
+foreach my $sw ( @build_depends )
  952
+{
  953
+    # Get info about this package
  954
+    my $pkg = $depend{$sw};
  955
+    my $url = $pkg->{'url'};
  956
+    my $filename = $url;
  957
+    $filename =~ s|^.+/([^/]+)$|$1|;
  958
+    my $dirname = $filename;
  959
+    $filename = $ARCHIVEDIR . '/' . $filename;
  960
+    $dirname =~ s|\.tar\.gz$||;
  961
+    $dirname =~ s|\.tar\.bz2$||;
  962
+
  963
+    chdir($SRCDIR);
  964
+
  965
+    # Download and decompress
  966
+    unless ( -e $filename )
  967
+    {
  968
+        &Verbose("Downloading $sw");
  969
+        unless (&Syscall([ '/usr/bin/curl', '-f', '-L', $url, '>', $filename ],
  970
+                         'munge' => 1))
  971
+        {
  972
+            &Syscall([ '/bin/rm', $filename ]) if (-e $filename);
  973
+            die;
  974
+        }
  975
+    }
  976
+    else
  977
+    {   &Verbose("Using previously downloaded $sw")   }
  978
+
  979
+    if ( $pkg->{'skip'} )
  980
+    {   next   }
  981
+
  982
+    if ( -d $dirname )
  983
+    {
  984
+        if ( $OPT{'thirdclean'} )
  985
+        {
  986
+            &Verbose("Removing previous build of $sw");
  987
+            &Syscall([ '/bin/rm', '-f', '-r', $dirname ]) or die;
  988
+        }
  989
+
  990
+        if ( $OPT{'thirdskip'} )
  991
+        {
  992
+            &Verbose("Using previous build of $sw");
  993
+            next;
  994
+        }
  995
+
  996
+        &Verbose("Using previously unpacked $sw");
  997
+    }
  998
+    else
  999
+    {
  1000
+        &Verbose("Unpacking $sw");
  1001
+        if ( substr($filename,-3) eq ".gz" )