Advertisement
Guest User

Untitled

a guest
Mar 2nd, 2012
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 64.09 KB | None | 0 0
  1. jyaimac:build jyavenard$ cat newbundler.patch
  2. diff --git a/OSX/build/osx-bundler.pl b/OSX/build/osx-bundler.pl
  3. index 73e5ae6..0b95324 100755
  4. --- a/OSX/build/osx-bundler.pl
  5. +++ b/OSX/build/osx-bundler.pl
  6. @@ -31,20 +31,17 @@ osx-bundler.pl target1.app/Contents/Resources/lib/extra.dylib [lib-dir...]
  7. # 2) copies them into the bundle's Framework directory
  8. # 3) uses install_name_tool to update the library load paths
  9. #
  10. -# = KNOWN BUGS
  11. -# Doesn't do anything about Universal Binaries yet
  12. -#
  13. # = TO DO
  14. # Add more arguments to allow the user to specify
  15. # .pinfo fields like CFBundleIdentifier, CFBundleSignature,
  16. # NSHumanReadableCopyright, CFBundleGetInfoString, et c.
  17. #
  18. # = REVISION
  19. -# $Id$
  20. +# 2.0
  21. #
  22. # = AUTHORS
  23. # Nigel Pearson. Based on osx-packager by Jeremiah Morris,
  24. -# with improvements by Geoffrey Kruse and David Abrahams
  25. +# with improvements by Geoffrey Kruse, David Abrahams and Jean-Yves Avenard
  26. # ============================================================================
  27.  
  28. use strict;
  29. @@ -67,7 +64,8 @@ if ( $#ARGV < 0 )
  30. # ============================================================================
  31.  
  32. my $verbose = 0;
  33. -my $Id = '$Id$'; # Version of this script. From version control system
  34. +our $arch = "";
  35. +my $Id = '2.0'; # Version of this script
  36. my $binary;
  37. my $binbase; # $binary without any directory path
  38. my $bundle;
  39. @@ -76,13 +74,15 @@ my $target; # Full path to the binary under $bundle
  40.  
  41. # Process arguments:
  42.  
  43. -Getopt::Long::GetOptions('verbose' => \$verbose) or usage(-1);
  44. +Getopt::Long::GetOptions('verbose' => \$verbose, 'arch=s' => \$arch) or usage(-1);
  45.  
  46. $binary = shift @ARGV;
  47. @libdirs = @ARGV;
  48.  
  49. # ============================================================================
  50.  
  51. +&Verbose("Processing $binary");
  52. +
  53. if ( $binary =~ m/(.*)\.app$/ )
  54. {
  55. $bundle = $binary;
  56. @@ -185,17 +185,37 @@ sub MakeFramework
  57. my ($dylib, $dest) = @_;
  58.  
  59. my ($base, $vers) = &BaseVers($dylib);
  60. + if ( ! defined $vers )
  61. + {
  62. + $vers = "1.0";
  63. + }
  64. my $fw_dir = $dest . '/' . $base . '.framework';
  65.  
  66. + &Verbose("MakeFramework: fw_fir = $fw_dir, dest = $dest, base = $base, dylib = $dylib");
  67. return '' if ( -e $fw_dir );
  68.  
  69. &Verbose("Building $base framework");
  70.  
  71. &Syscall([ '/bin/mkdir', '-p',
  72. "$fw_dir/Versions/A/Resources" ]) or die;
  73. - &Syscall([ '/bin/cp', $dylib,
  74. - "$fw_dir/Versions/A/$base" ]) or die;
  75. -
  76. + if ( $arch eq "" )
  77. + {
  78. + &Syscall([ '/bin/cp', $dylib,
  79. + "$fw_dir/Versions/A/$base" ]) or die;
  80. + }
  81. + else
  82. + {
  83. + &Verbose("Extracting $arch architecture from $dylib");
  84. + my @args = ( '/usr/bin/lipo', '-thin', $arch, $dylib, '-o', "$fw_dir/Versions/A/$base" );
  85. + &Verbose(@args);
  86. + # try to extract required architecture
  87. + system(@args);
  88. + if ( $? )
  89. + {
  90. + # if unsuccessful, just copy the lib
  91. + &Syscall([ '/bin/cp', $dylib, "$fw_dir/Versions/A/$base" ]) or die;
  92. + }
  93. + }
  94. &Syscall([ '/usr/bin/install_name_tool',
  95. '-id', $base, "$fw_dir/Versions/A/$base" ]) or die;
  96.  
  97. @@ -203,6 +223,19 @@ sub MakeFramework
  98. symlink('Versions/Current/Resources', "$fw_dir/Resources") or die;
  99. symlink("Versions/A/$base", "$fw_dir/$base") or die;
  100.  
  101. + if ( $dylib =~ m/\.framework/ )
  102. + {
  103. + my $resdir = dirname($dylib) . "/Resources";
  104. + if ( -d $resdir )
  105. + {
  106. + &Verbose("$resdir exists, copy over $fw_dir/Resources");
  107. + my @files = glob "$resdir/*";
  108. + foreach (@files)
  109. + {
  110. + &Syscall([ '/bin/cp', '-R', "$_", "$fw_dir/Resources" ]);
  111. + }
  112. + }
  113. + }
  114. &Verbose("Writing Info.plist for $base framework");
  115. my $plist;
  116. unless (open($plist, '>' . "$fw_dir/Versions/A/Resources/Info.plist"))
  117. @@ -345,7 +378,6 @@ sub ProcessDependencies(@)
  118. foreach my $dep (@deps)
  119. {
  120. chomp $dep;
  121. -
  122. # otool returns lines like:
  123. # libblah-7.dylib (compatibility version 7, current version 7)
  124. # but we only want the file part
  125. @@ -362,7 +394,7 @@ sub ProcessDependencies(@)
  126.  
  127. # Any dependency which is already package relative can be ignored
  128. next if $dep =~ m/\@executable_path/;
  129. -
  130. +
  131. # skip system library locations
  132. next if ($dep =~ m|^/System| ||
  133. $dep =~ m|^/usr/lib|);
  134. @@ -371,6 +403,7 @@ sub ProcessDependencies(@)
  135.  
  136. # Only add this dependency if needed. This assumes that
  137. # we aren't mixing versions of the same library name
  138. + &Verbose("Process Dep $base");
  139. if ( ! -e "$bundle/Contents/Frameworks/$base.framework/$base" )
  140. { $depfiles{$base} = $dep }
  141.  
  142. @@ -404,6 +437,11 @@ sub BaseVers
  143. {
  144. return ($1, undef);
  145. }
  146. + elsif ($filename =~ m|^.*?\.framework.*/(.*?)$|)
  147. + {
  148. + &Verbose("Framework : $1");
  149. + return ($1, undef);
  150. + }
  151.  
  152. &Verbose("Not a library file: $filename");
  153. return $filename;
  154. diff --git a/OSX/build/osx-packager-qtsdk.pl b/OSX/build/osx-packager-qtsdk.pl
  155. new file mode 100755
  156. index 0000000..9d40183
  157. --- /dev/null
  158. +++ b/OSX/build/osx-packager-qtsdk.pl
  159. @@ -0,0 +1,1891 @@
  160. +#!/usr/bin/perl
  161. +
  162. +### = file
  163. +### osx-packager-qtsdk.pl
  164. +###
  165. +### = revision
  166. +### 1.0
  167. +###
  168. +### = location
  169. +### https://github.com/MythTV/packaging/raw/master/OSX/build/osx-packager-qtsdk.pl
  170. +###
  171. +### = description
  172. +### Tool for automating frontend builds on Mac OS X.
  173. +### Run "osx-packager.pl -man" for full documentation.
  174. +
  175. +use strict;
  176. +use Getopt::Long qw(:config auto_abbrev);
  177. +use Pod::Usage ();
  178. +use Cwd ();
  179. +
  180. +### Configuration settings (stuff that might change more often)
  181. +
  182. +# We try to auto-locate the Git client binaries.
  183. +# If they are not in your path, we build them from source
  184. +#
  185. +our $git = `which git`; chomp $git;
  186. +
  187. +# This script used to always delete the installed include and lib dirs.
  188. +# That probably ensures a safe build, but when rebuilding adds minutes to
  189. +# the total build time, and prevents us skipping some parts of a full build
  190. +#
  191. +our $cleanLibs = 1;
  192. +
  193. +# By default, only the frontend is built (i.e. no backend or transcoding)
  194. +#
  195. +our $backend = 0;
  196. +our $jobtools = 0;
  197. +
  198. +# Start with a generic address and let sourceforge
  199. +# figure out which mirror is closest to us.
  200. +#
  201. +our $sourceforge = 'http://downloads.sourceforge.net';
  202. +
  203. +# At the moment, there is mythtv plus...
  204. +our @components = ( 'mythplugins' );
  205. +
  206. +# The OS X programs that we are likely to be interested in.
  207. +our @targets = ( 'MythFrontend', 'MythAVTest', 'MythWelcome' );
  208. +our @targetsJT = ( 'MythCommFlag', 'MythJobQueue');
  209. +our @targetsBE = ( 'MythBackend', 'MythFillDatabase', 'MythTV-Setup');
  210. +
  211. +# Name of the PlugIns directory in the application bundle
  212. +our $BundlePlugins = "PlugIns";
  213. +
  214. +# Patches for MythTV source
  215. +our %patches = ();
  216. +
  217. +our %build_profile = (
  218. + 'master'
  219. + => [
  220. + 'branch' => 'master',
  221. + 'mythtv'
  222. + => [
  223. + 'ccache',
  224. + 'pkgconfig',
  225. + 'dvdcss',
  226. + 'freetype',
  227. + 'lame',
  228. + 'mysqlclient',
  229. + #'dbus',
  230. + 'qt',
  231. + 'yasm',
  232. + 'liberation-sans',
  233. + 'firewiresdk',
  234. + ],
  235. + 'mythplugins'
  236. + => [
  237. + 'exif',
  238. +# MythMusic needs these:
  239. + 'libtool',
  240. + 'autoconf',
  241. + 'automake',
  242. + 'taglib',
  243. + 'libogg',
  244. + 'vorbis',
  245. + 'flac',
  246. + 'libcddb',
  247. + 'libcdio',
  248. + ],
  249. + ],
  250. + '0.24-fixes'
  251. + => [
  252. + 'branch' => 'fixes/0.24',
  253. + 'mythtv'
  254. + => [
  255. + 'ccache',
  256. + 'pkgconfig',
  257. + 'dvdcss',
  258. + 'freetype',
  259. + 'lame',
  260. + 'mysqlclient',
  261. + #'dbus',
  262. + 'qt',
  263. + 'yasm',
  264. + 'liberation-sans',
  265. + 'firewiresdk',
  266. + ],
  267. + 'mythplugins'
  268. + => [
  269. + 'exif',
  270. +# MythMusic needs these:
  271. + 'libtool',
  272. + 'autoconf',
  273. + 'automake',
  274. + 'taglib',
  275. + 'libogg',
  276. + 'vorbis',
  277. + 'flac',
  278. + ],
  279. + ],
  280. +);
  281. +
  282. +=head1 NAME
  283. +
  284. +osx-packager.pl - build OS X binary packages for MythTV
  285. +
  286. +=head1 SYNOPSIS
  287. +
  288. + osx-packager.pl [options]
  289. +
  290. + Options:
  291. + -help print the usage message
  292. + -man print full documentation
  293. + -verbose print informative messages during the process
  294. + -version <str> custom version suffix (defaults to "gitYYYYMMDD")
  295. + -noversion don't use any version suffix
  296. + (for building release versions)
  297. + -distclean throw away all intermediate files and exit
  298. + -thirdclean do a clean rebuild of third party packages
  299. + -thirdskip don't rebuild the third party packages
  300. + -mythtvskip don't rebuild/install mythtv
  301. + -pluginskip don't rebuild/install mythplugins
  302. + -clean do a clean rebuild of MythTV
  303. + -gitrev <str> build a specified Git revision or tag
  304. + -nohead don't update to HEAD revision of MythTV before
  305. + building
  306. + -usehdimage perform build inside of a case-sensitive disk image
  307. + -leavehdimage leave disk image mounted on exit
  308. + -enable-backend build the backend server as well as the frontend
  309. + -enable-jobtools build commflag/jobqueue as well as the frontend
  310. + -profile build with compile-type=profile
  311. + -debug build with compile-type=debug
  312. + -m32 build for a 32-bit environment
  313. + -universal build for both 32 and 64 bits architectures
  314. + (Intel only)
  315. + -plugins <str> comma-separated list of plugins to include
  316. + -srcdir <path> build using provided root mythtv directory
  317. + -pkgsrcdir <path> build using provided packaging directory
  318. + -force Use myth source directory as-is,
  319. + with no GIT validity check
  320. + -noclean use with -nohead, do not re-run configure nor clean
  321. + -bootstrap exit after building all thirdparty components
  322. + -nohacks don't use Nigel's hacks
  323. + -noparallel do not use parallel builds
  324. + -nobundle Only recompile, do not create application bundle
  325. + -qtsdk <path> Path to Qt SDK Deskop
  326. + (e.g. -qtsdk ~/QtSDK/Desktop/Qt/4.8.0
  327. + -qtbin <path> Path to Qt utilitities (qmake etc)
  328. + -qtplugins <path> Path to Qt plugins
  329. +
  330. + Use either -qtsdk or -qtbin *and * -qtplugins
  331. +
  332. +
  333. +=head1 DESCRIPTION
  334. +
  335. +This script builds a MythTV frontend and all necessary dependencies, along
  336. +with plugins as specified, as a standalone binary package for Mac OS X.
  337. +
  338. +It is designed for building daily Git snapshots,
  339. +and can also be used to create release builds with the '-gitrev' option.
  340. +
  341. +All intermediate files go into an '.osx-packager' directory in the current
  342. +working directory. The finished application is named 'MythFrontend.app' and
  343. +placed in the current working directory.
  344. +
  345. +By default, the end application will only run on the architecture of the machine
  346. +used to compile (32 or 64 bits). Use -universal to compile an application for both
  347. +32 and 64 bits. For -universal to work, you must compile on a 64 bits intel host.
  348. +
  349. +=head1 REQUIREMENTS
  350. +
  351. +You need to have installed either Qt SDK (64 bits only) or
  352. +Qt libraries package (both 32 and 64 bits) from http://qt.nokia.com/downloads.
  353. +
  354. +When using the Qt SDK, use the -qtsdk flag to define the location of the Desktop Qt,
  355. +by default it is ~/QtSDK/Desktop/Qt/[VERSION]/gcc where version is 4.8.0 (SDK 1.2)
  356. +or 473 (SDK 1.1)
  357. +
  358. +When using the Qt libraries package, use the -qtbin and -qtplugins. Values for default
  359. +Qt installation are: -qtbin /usr/bin -qtplugins /Developer/Applications/Qt/plugins.
  360. +Qt Headers must be installed.
  361. +
  362. +=head1 EXAMPLES
  363. +
  364. +Building two snapshots, one with plugins and one without:
  365. +
  366. + osx-packager.pl -clean -plugins mythvideo,mythweather -qtsdk ~/QtSDK/Desktop/Qt/4.8.0/gcc
  367. + mv MythFrontend.app MythFrontend-plugins.app
  368. + osx-packager.pl -nohead -qtbin /usr/bin -qtplugins /Developer/Applications/Qt/plugins
  369. + mv MythFrontend.app MythFrontend-noplugins.app
  370. +
  371. +Building a "fixes" branch:
  372. +
  373. + osx-packager.pl -distclean -qtbin /usr/bin -qtplugins /Developer/Applications/Qt/plugins
  374. + osx-packager.pl -gitrev fixes/0.24 -qtbin /usr/bin -qtplugins /Developer/Applications/Qt/plugins
  375. +
  376. +Note that this script will not build old branches.
  377. +Please try the branched version instead. e.g.
  378. +http://svn.mythtv.org/svn/branches/release-0-21-fixes/mythtv/contrib/OSX/osx-packager.pl
  379. +
  380. +=head1 CREDITS
  381. +
  382. +Written by Jean-Yves Avenard <jyavenard@gmail.com>
  383. +Based on work by Jeremiah Morris <jm@whpress.com>
  384. +
  385. +Includes contributions from Nigel Pearson, Jan Ornstedt, Angel Li, and Andre Pang, Bas Hulsken (bhulsken@hotmail.com)
  386. +
  387. +=cut
  388. +
  389. +# Parse options
  390. +our (%OPT);
  391. +Getopt::Long::GetOptions(\%OPT,
  392. + 'help|?',
  393. + 'man',
  394. + 'verbose',
  395. + 'version=s',
  396. + 'noversion',
  397. + 'distclean',
  398. + 'thirdclean',
  399. + 'thirdskip',
  400. + 'mythtvskip',
  401. + 'pluginskip',
  402. + 'clean',
  403. + 'gitrev=s',
  404. + 'nohead',
  405. + 'usehdimage',
  406. + 'leavehdimage',
  407. + 'enable-backend',
  408. + 'enable-jobtools',
  409. + 'profile',
  410. + 'debug',
  411. + 'm32',
  412. + 'universal',
  413. + 'plugins=s',
  414. + 'srcdir=s',
  415. + 'pkgsrcdir=s',
  416. + 'force',
  417. + 'noclean',
  418. + 'archives=s',
  419. + 'buildprofile=s',
  420. + 'bootstrap',
  421. + 'nohacks',
  422. + 'noparallel',
  423. + 'qtsdk=s',
  424. + 'qtbin=s',
  425. + 'qtplugins=s',
  426. + 'nobundle',
  427. + ) or Pod::Usage::pod2usage(2);
  428. +Pod::Usage::pod2usage(1) if $OPT{'help'};
  429. +Pod::Usage::pod2usage('-verbose' => 2) if $OPT{'man'};
  430. +
  431. +our $QTSDK = "";
  432. +our $QTBIN = "";
  433. +our $QTLIB = "";
  434. +our $QTPLUGINS = "";
  435. +our $QTVERSION = "";
  436. +if ( $OPT{'qtsdk'} )
  437. +{
  438. + $QTSDK = $OPT{'qtsdk'};
  439. +}
  440. +
  441. +if ( $OPT{'qtbin'} )
  442. +{
  443. + $QTBIN = "$OPT{'qtbin'}";
  444. +}
  445. +elsif ( $OPT{'qtsdk'} )
  446. +{
  447. + $QTBIN = "$OPT{'qtsdk'}/bin";
  448. +}
  449. +if ( $OPT{'qtplugins'} )
  450. +{
  451. + $QTPLUGINS = "$OPT{'qtplugins'}";
  452. +}
  453. +elsif ( $OPT{'qtsdk'} )
  454. +{
  455. + $QTPLUGINS = "$QTSDK/plugins";
  456. +}
  457. +
  458. +# Test if Qt conf is valid, all paths must exist
  459. +if ( ! ( (($QTBIN ne "") && ($QTPLUGINS ne "")) &&
  460. + ( -d $QTBIN && -d $QTPLUGINS )) )
  461. +{
  462. + &Complain("bin:$QTBIN lib:$QTLIB plugins:$QTPLUGINS You must define a valid Qt SDK path with -qtsdk <path> or -qtbin <path> *and* -qtplugins <path>");
  463. + exit;
  464. +}
  465. +
  466. +#Determine the version Qt SDK we are using, we need to retrieve the source code to build MySQL Qt plugin
  467. +if ( ! -e "$QTBIN/qmake" )
  468. +{
  469. + &Complain("$QTBIN isn't a valid Qt bin path (qmake not found)");
  470. + exit;
  471. +}
  472. +my @ret = `$QTBIN/qmake --version`;
  473. +my $regexp = qr/Qt version (\d+\.\d+\.\d+) in (.*)$/;
  474. +foreach my $line (@ret)
  475. +{
  476. + chomp $line;
  477. + next if ($line !~ m/$regexp/);
  478. + $QTVERSION = $1;
  479. + $QTLIB = $2;
  480. + &Verbose("Qt version is $QTVERSION");
  481. +}
  482. +
  483. +if ($QTVERSION eq "")
  484. +{
  485. + &Complain("Couldn't identify Qt version");
  486. + exit;
  487. +}
  488. +if ( ! -d $QTLIB )
  489. +{
  490. + &Complain("$QTLIB doesn't exist. Invalid Qt sdk");
  491. + exit;
  492. +}
  493. +
  494. +if ( $OPT{'enable-backend'} )
  495. +{ $backend = 1 }
  496. +
  497. +if ( $OPT{'clean'} )
  498. +{ $cleanLibs = 1 }
  499. +
  500. +if ( $OPT{'noclean'} )
  501. +{ $cleanLibs = 0 }
  502. +
  503. +if ( $OPT{'enable-jobtools'} )
  504. +{ $jobtools = 1 }
  505. +
  506. +# Get version string sorted out
  507. +if ( $OPT{'gitrev'} && !$OPT{'version'} )
  508. +{
  509. + $OPT{'version'} = $OPT{'gitrev'};
  510. +}
  511. +$OPT{'version'} = '' if $OPT{'noversion'};
  512. +unless (defined $OPT{'version'})
  513. +{
  514. + my @lt = gmtime(time);
  515. + $OPT{'version'} = sprintf('git%04d%02d%02d',
  516. + $lt[5] + 1900, $lt[4] + 1, $lt[3]);
  517. +}
  518. +
  519. +if ( $OPT{'srcdir'} )
  520. +{
  521. + $OPT{'nohead'} = 1;
  522. + $OPT{'gitrev'} = '';
  523. +}
  524. +
  525. +# Build our temp directories
  526. +our $SCRIPTDIR = Cwd::abs_path(Cwd::getcwd());
  527. +if ( $SCRIPTDIR =~ /\s/ )
  528. +{
  529. + &Complain(<<END);
  530. +Working directory contains spaces
  531. +
  532. +Error: Your current working path:
  533. +
  534. + $SCRIPTDIR
  535. +
  536. +contains one or more spaces. This will break the compilation process,
  537. +so the script cannot continue. Please re-run this script from a different
  538. +directory (such as /tmp).
  539. +
  540. +The application produced will run from any directory, the no-spaces
  541. +rule is only for the build process itself.
  542. +
  543. +END
  544. + die;
  545. +}
  546. +
  547. +our $WORKDIR = "$SCRIPTDIR/.osx-packager";
  548. +mkdir $WORKDIR;
  549. +
  550. +if ( $OPT{'nohead'} && ! $OPT{'force'} && ! $OPT{'srcdir'} )
  551. +{
  552. + my $GITTOP="$WORKDIR/src/myth-git/.git";
  553. +
  554. + if ( ! -d $GITTOP )
  555. + { die "No source code to build?" }
  556. +
  557. + if ( ! `grep refs/heads/master $GITTOP/HEAD` )
  558. + { die "Source code does not match GIT master" }
  559. +}
  560. +elsif ( $OPT{'gitrev'} =~ m,^fixes/, && $OPT{'gitrev'} lt "fixes/0.23" )
  561. +{
  562. + &Complain(<<END);
  563. +This version of this script can not build old branches.
  564. +Please try the branched version instead. e.g.
  565. +http://svn.mythtv.org/svn/branches/release-0-23-fixes/packaging/OSX/build/osx-packager.pl
  566. +http://svn.mythtv.org/svn/branches/release-0-21-fixes/mythtv/contrib/OSX/osx-packager.pl
  567. +END
  568. + die;
  569. +}
  570. +
  571. +if ($OPT{usehdimage})
  572. +{ MountHDImage() }
  573. +
  574. +our $PREFIX = "$WORKDIR/build";
  575. +mkdir $PREFIX;
  576. +
  577. +our $SRCDIR = "$WORKDIR/src";
  578. +mkdir $SRCDIR;
  579. +
  580. +our $ARCHIVEDIR ='';
  581. +if ( $OPT{'archives'} )
  582. +{
  583. + $ARCHIVEDIR = "$SCRIPTDIR" . '/' . $OPT{'archives'};
  584. +} else {
  585. + $ARCHIVEDIR = "$SRCDIR";
  586. +}
  587. +
  588. +our %depend_order = '';
  589. +my $gitrevision = 'master'; # Default thingy to checkout
  590. +if ( $OPT{'buildprofile'} && $OPT{'buildprofile'} == '0.24-fixes' )
  591. +{
  592. + &Verbose('Building using 0.24-fixes profile');
  593. + %depend_order = @{ $build_profile{'0.24-fixes'} };
  594. + $gitrevision = 'fixes/0.24'
  595. +} else {
  596. + &Verbose('Building using master profile');
  597. + %depend_order = @{ $build_profile{'master'} };
  598. +}
  599. +
  600. +our $GITDIR = "$SRCDIR/myth-git";
  601. +
  602. +our @pluginConf;
  603. +if ( $OPT{plugins} )
  604. +{
  605. + @pluginConf = split /,/, $OPT{plugins};
  606. + @pluginConf = grep(s/^/--enable-/, @pluginConf);
  607. + unshift @pluginConf, '--disable-all';
  608. +}
  609. +else
  610. +{
  611. + @pluginConf = (
  612. + '--enable-opengl',
  613. + '--enable-mythgallery',
  614. + '--enable-exif',
  615. + '--enable-new-exif',
  616. + );
  617. +}
  618. +
  619. +
  620. +# configure mythplugins, and mythtv, etc
  621. +our %conf = (
  622. + 'mythplugins'
  623. + => [
  624. + @pluginConf
  625. + ],
  626. + 'mythtv'
  627. + => [
  628. + "--runprefix=../Resources",
  629. + "--firewire-sdk=$PREFIX/lib",
  630. + "--enable-libmp3lame",
  631. +
  632. + # To "cross compile" something for a lesser Mac:
  633. + #'--tune=G3',
  634. + #'--disable-altivec',
  635. + ],
  636. +);
  637. +
  638. +# configure mythplugins, and mythtv, etc
  639. +our %makecleanopt = (
  640. + 'mythplugins'
  641. + => [
  642. + 'distclean',
  643. + ],
  644. +);
  645. +
  646. +### Distclean?
  647. +if ( $OPT{'distclean'} )
  648. +{
  649. + &Distclean("");
  650. + exit;
  651. +}
  652. +
  653. +use File::Basename;
  654. +our $gitpath = dirname $git;
  655. +
  656. +# Clean the environment
  657. +$ENV{'PATH'} = "$PREFIX/bin:/bin:/usr/bin:/usr/sbin:$gitpath";
  658. +$ENV{'PKG_CONFIG_PATH'} = "$PREFIX/lib/pkgconfig:";
  659. +delete $ENV{'CPP'};
  660. +delete $ENV{'CXX'};
  661. +
  662. +our $DEVROOT = `xcode-select -print-path`; chomp $DEVROOT;
  663. +our $SDKVER = `xcodebuild -showsdks | grep macosx10 | sort | head -n 1 | awk '{ print \$4 }' `; chomp $SDKVER;
  664. +our $SDKNAME = `xcodebuild -showsdks | grep macosx10 | sort | head -n 1 | awk '{ print \$6 }' `; chomp $SDKNAME;
  665. +our $SDKROOT = "$DEVROOT/SDKs/MacOSX$SDKVER.sdk";
  666. +
  667. +$ENV{'DEVROOT'} = $DEVROOT;
  668. +$ENV{'SDKVER'} = $SDKVER;
  669. +$ENV{'SDKROOT'} = $SDKROOT;
  670. +
  671. +# Determine appropriate gcc/g++ path for the selected SDKs
  672. +our $CCBIN = `xcodebuild -find gcc -sdk $SDKNAME`; chomp $CCBIN;
  673. +our $CXXBIN = `xcodebuild -find g++ -sdk $SDKNAME`; chomp $CXXBIN;
  674. +$ENV{'CC'} = $CCBIN;
  675. +$ENV{'CXX'} = $CXXBIN;
  676. +$ENV{'CPP'} = "$CCBIN -E";
  677. +$ENV{'CXXCPP'} = "$CXXBIN -E";
  678. +
  679. +# Test if LLVM, mythtv doesn't compile unless you build in debug mode
  680. +my $out = `$CCBIN --version`;
  681. +if ( $out =~ m/llvm/ )
  682. +{
  683. + $OPT{'debug'} = 1;
  684. + &Verbose('Using LLVM: Forcing debug compile...');
  685. +}
  686. +
  687. +if ( ! -e "$SDKROOT" )
  688. +{
  689. + #Handle special case for 10.4 where the SDK name is 10.4u.sdk
  690. + $SDKROOT = "$DEVROOT/SDKs/MacOSX${SDKVER}u.sdk";
  691. + if ( ! -e "$SDKROOT" )
  692. + {
  693. + # Handle XCode 4.3 new location
  694. + $SDKROOT = "$DEVROOT/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$SDKVER.sdk";
  695. + if ( ! -e "$SDKROOT" )
  696. + {
  697. + &Complain("$SDKROOT doesn't exist");
  698. + &Complain("Did you set your xcode environmment path properly ? (xcode-select utility)");
  699. + exit;
  700. + }
  701. + }
  702. +}
  703. +
  704. +our $OSTARGET = "10.5";
  705. +
  706. +# set up Qt environment
  707. +$ENV{'QTDIR'} = "$QTSDK";
  708. +$ENV{'QMAKESPEC'} = 'macx-g++';
  709. +$ENV{'MACOSX_DEPLOYMENT_TARGET'} = $OSTARGET;
  710. +
  711. +$ENV{'CFLAGS'} = $ENV{'CXXFLAGS'} = "-isysroot $SDKROOT -mmacosx-version-min=$OSTARGET -I$PREFIX/include -I$PREFIX/mysql";
  712. +$ENV{'LDFLAGS'} = "-Wl,-syslibroot,${SDKROOT} -mmacosx-version-min=$OSTARGET -L$PREFIX/lib -F$QTLIB";
  713. +$ENV{'PREFIX'} = $PREFIX;
  714. +$ENV{'SDKROOT'} = $SDKROOT;
  715. +
  716. +our $standard_make = '/usr/bin/make';
  717. +our $parallel_make = $standard_make;
  718. +our $parallel_make_flags = '';
  719. +
  720. +my $cmd = "/usr/bin/hostinfo | grep 'processors\$'";
  721. +&Verbose($cmd);
  722. +my $cpus = `$cmd`; chomp $cpus;
  723. +$cpus =~ s/.*, (\d+) processors$/$1/;
  724. +if ( $cpus gt 1 )
  725. +{
  726. + &Verbose("Using", $cpus+1, "jobs on $cpus parallel CPUs");
  727. + ++$cpus;
  728. + $parallel_make_flags = "-j$cpus";
  729. +}
  730. +
  731. +if ($OPT{'noparallel'})
  732. +{
  733. + $parallel_make_flags = '';
  734. +}
  735. +$parallel_make .= " $parallel_make_flags";
  736. +
  737. +# compilation flags used for compiling dependency tools, do not use multi-architecture
  738. +our $CFLAGS = $ENV{'CFLAGS'};
  739. +our $CXXFLAGS = $ENV{'CXXFLAGS'};
  740. +our $ECXXFLAGS = $ENV{'ECXXFLAGS'};
  741. +our $LDFLAGS = $ENV{'LDFLAGS'};
  742. +our $ARCHARG = "";
  743. +our @ARCHS;
  744. +
  745. +# Check host computer architecture and create list of architecture to build
  746. +my $arch = `sysctl -n hw.machine`; chomp $arch;
  747. +if ( $OPT{'m32'} && ! $OPT{'universal'} )
  748. +{
  749. + &Verbose('Forcing 32 bits build...');
  750. + $ENV{'CFLAGS'} .= ' -m32';
  751. + $ENV{'CXXFLAGS'} .= ' -m32';
  752. + $ENV{'ECXXFLAGS'} .= ' -m32'; # MythTV configure
  753. + $ENV{'LDFLAGS'} .= ' -m32';
  754. + if ( $arch eq "x86_64" || $arch eq "i386" )
  755. + {
  756. + $ARCHARG = "-arch i386";
  757. + push @ARCHS, "i386";
  758. + }
  759. + else
  760. + {
  761. + # assume PPC, what else could it be?
  762. + $ARCHARG = "-arch ppc7400";
  763. + push @ARCHS, "ppc7400";
  764. + }
  765. +}
  766. +elsif ( $arch eq "x86_64" || $arch eq "ppc64" )
  767. +{
  768. + if ( $OPT{'universal'} )
  769. + {
  770. + # Requested universal, and 64 bits host
  771. + &Verbose('Building 32/64 bits universal app...');
  772. + if ( $arch eq "x86_64" )
  773. + {
  774. + $ENV{'CFLAGS'} .= ' -arch i386 -arch x86_64';
  775. + $ENV{'CXXFLAGS'} .= ' -arch i386 -arch x86_64';
  776. + $ENV{'ECXXFLAGS'} .= ' -arch i386 -arch x86_64'; # MythTV configure
  777. + $ENV{'LDFLAGS'} .= ' -arch i386 -arch x86_64';
  778. + $ARCHARG = "-arch i386 -arch x86_64";
  779. + push @ARCHS, "i386", "x86_64";
  780. + }
  781. + else
  782. + {
  783. + $ENV{'CFLAGS'} .= ' -arch ppc7400 -arch ppc64';
  784. + $ENV{'CXXFLAGS'} .= ' -arch ppc7400 -arch ppc64';
  785. + $ENV{'ECXXFLAGS'} .= ' -arch ppc7400 -arch ppc64'; # MythTV configure
  786. + $ENV{'LDFLAGS'} .= ' -arch ppc7400 -arch ppc64';
  787. + $ARCHARG = ' -arch ppc7400 -arch ppc64';
  788. + push @ARCHS, "ppc7400", "ppc64";
  789. + }
  790. + }
  791. + else
  792. + {
  793. + if ( $arch eq "x86_64" )
  794. + {
  795. + $ARCHARG = "-arch x86_64";
  796. + push @ARCHS, "x86_64";
  797. + }
  798. + else
  799. + {
  800. + $ARCHARG = "-arch ppc64";
  801. + push @ARCHS, "ppc64";
  802. + }
  803. + }
  804. +}
  805. +else
  806. +{
  807. + if ( $arch eq "i386" )
  808. + {
  809. + push @ARCHS, "i386";
  810. + }
  811. + else
  812. + {
  813. + push @ARCHS, "ppc7400";
  814. + }
  815. + $OPT{'universal'} = 0;
  816. +}
  817. +
  818. +# show summary of build parameters.
  819. +&Verbose("DEVROOT = $DEVROOT");
  820. +&Verbose("SDKVER = $SDKVER");
  821. +&Verbose("SDKROOT = $SDKROOT");
  822. +&Verbose("CCBIN = $ENV{'CC'}");
  823. +&Verbose("CXXBIN = $ENV{'CXX'}");
  824. +&Verbose("CFLAGS = $ENV{'CFLAGS'}");
  825. +&Verbose("LDFLAGS = $ENV{'LDFLAGS'}");
  826. +
  827. +our %depend = (
  828. +
  829. + 'git' =>
  830. + {
  831. + 'url' => 'http://www.kernel.org/pub/software/scm/git/git-1.7.3.4.tar.bz2',
  832. + 'parallel-make' => 'yes'
  833. + },
  834. +
  835. + 'freetype' =>
  836. + {
  837. + 'url' => "$sourceforge/sourceforge/freetype/freetype-2.4.8.tar.gz",
  838. + },
  839. +
  840. + 'lame' =>
  841. + {
  842. + 'url' => "$sourceforge/sourceforge/lame/lame-3.99.5.tar.gz",
  843. + 'conf' => [
  844. + '--disable-frontend',
  845. + ],
  846. + },
  847. +
  848. + 'libmad' =>
  849. + {
  850. + 'url' => "$sourceforge/sourceforge/mad/libmad-0.15.0b.tar.gz",
  851. + 'parallel-make' => 'yes'
  852. + },
  853. +
  854. + # default generated taglib configure is bugger and won't compile universal file. So need to regenerate it
  855. + # new version of taglib 1.7 uses cmake which takes excessively long time to compile. So stick with 1.6.3
  856. + 'taglib' =>
  857. + {
  858. + 'url' => 'http://developer.kde.org/~wheeler/files/src/taglib-1.6.3.tar.gz',
  859. + 'pre-conf' => "cp $PREFIX/share/libtool/config/ltmain.sh admin/ ; " .
  860. + "cp $PREFIX/share/aclocal/libtool.m4 admin/libtool.m4.in ; " .
  861. + "$PREFIX/bin/autoreconf",
  862. + },
  863. +
  864. + 'libogg' =>
  865. + {
  866. + 'url' => 'http://downloads.xiph.org/releases/ogg/libogg-1.1.2.tar.gz',
  867. + },
  868. +
  869. + 'vorbis' =>
  870. + {
  871. + 'url' => 'http://downloads.xiph.org/releases/ogg/libogg-1.3.0.tar.gz',
  872. + },
  873. +
  874. + 'flac' =>
  875. + {
  876. + 'url' => "$sourceforge/sourceforge/flac/flac-1.2.1.tar.gz",
  877. + # Workaround Intel problem - Missing _FLAC__lpc_restore_signal_asm_ia32
  878. + 'conf' => [
  879. + '--disable-asm-optimizations',
  880. + ],
  881. + # patch to support universal compilation and fix incorrect sizeof
  882. + 'post-conf' => "echo \"/#define SIZEOF_VOIDP/c\n" .
  883. + "#ifdef __LP64__\n" .
  884. + "#define SIZEOF_VOIDP 8\n" .
  885. + "#else\n" .
  886. + "#define SIZEOF_VOIDP 4\n" .
  887. + "#endif\n" .
  888. + ".\n" .
  889. + "w\" | /bin/ed config.h ; sed -i -e 's/CC -dynamiclib/CC -dynamiclib $ARCHARG/g' libtool",
  890. + },
  891. +
  892. + # pkgconfig 0.26 and above do not include glib which is required to compile
  893. + # glib requires pkgconfig to compile, so it's a chicken and egg problem.
  894. + # Use nothing newer than 0.25 on OSX.
  895. + 'pkgconfig' =>
  896. + {
  897. + 'url' => "http://pkgconfig.freedesktop.org/releases/pkg-config-0.25.tar.gz",
  898. + 'conf-cmd' => "CFLAGS=\"\" LDFLAGS=\"\" ./configure",
  899. + 'conf' => [
  900. + "--prefix=$PREFIX",
  901. + "--disable-static",
  902. + "--enable-shared",
  903. + ],
  904. +
  905. + },
  906. +
  907. + 'dvdcss' =>
  908. + {
  909. + 'url' => 'http://download.videolan.org/pub/videolan/libdvdcss/1.2.11/libdvdcss-1.2.11.tar.bz2',
  910. + },
  911. +
  912. + 'mysqlclient' =>
  913. + {
  914. + 'url' => 'http://downloads.mysql.com/archives/mysql-5.1/mysql-5.1.56.tar.gz',
  915. + 'conf' => [
  916. + '--without-debug',
  917. + '--without-docs',
  918. + '--without-man',
  919. + '--without-bench',
  920. + '--without-server',
  921. + '--without-geometry',
  922. + '--without-extra-tools',
  923. + ],
  924. + },
  925. +
  926. + 'dbus' =>
  927. + {
  928. + 'url' => 'http://dbus.freedesktop.org/releases/dbus/dbus-1.0.3.tar.gz',
  929. + 'post-make' => 'mv $PREFIX/lib/dbus-1.0/include/dbus/dbus-arch-deps.h '.
  930. + ' $PREFIX/include/dbus-1.0/dbus ; '.
  931. + 'rm -fr $PREFIX/lib/dbus-1.0 ; '.
  932. + 'cd $PREFIX/bin ; '.
  933. + 'echo "#!/bin/sh
  934. + if [ \"\$2\" = dbus-1 ]; then
  935. + case \"\$1\" in
  936. + \"--version\") echo 1.0.3 ;;
  937. + \"--cflags\") echo -I$PREFIX/include/dbus-1.0 ;;
  938. + \"--libs\") echo \"-L$PREFIX/lib -ldbus-1\" ;;
  939. + esac
  940. + fi
  941. + exit 0" > pkg-config ; '.
  942. + 'chmod 755 pkg-config'
  943. + },
  944. +
  945. + 'qt'
  946. + =>
  947. + {
  948. + 'url' => "http://download.qt.nokia.com/qt/source/qt-everywhere-opensource-src-${QTVERSION}.tar.gz",
  949. + 'pre-conf'
  950. + => # Get around Qt bug QTBUG-24498 (4.8.0) && stupid thing can't compile in release mode on mac without framework active
  951. + #also hack for QTBUG-23258
  952. + "find . -name \"*.pro\" -exec sed -i -e \"s:/Developer/SDKs/:.*:g\" {} \\;",
  953. + 'conf-cmd'
  954. + => "cd src/plugins/sqldrivers/mysql && $QTBIN/qmake \"QMAKE_CC=$CCBIN\" \"QMAKE_CXX=$CXXBIN\" \"QMAKE_CXXFLAGS=$ENV{'CXXFLAGS'}\" \"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",
  955. + 'make-cmd' => 'cd src/plugins/sqldrivers/mysql',
  956. + 'make' => [ ],
  957. + 'post-make' => 'cd src/plugins/sqldrivers/mysql ; make install ; '.
  958. + 'make -f Makefile.Release install ; '.
  959. + 'cd $PREFIX/lib ; ln -s mysql lib; '.
  960. + 'rm -f $PREFIX/bin/pkg-config ; '.
  961. + '',
  962. + #WebKit in Qt keeps erroring half way on my quad-core when using -jX, use -noparallel
  963. + 'parallel-make' => 'yes'
  964. + },
  965. +
  966. + 'exif' =>
  967. + {
  968. + 'url' => "$sourceforge/sourceforge/libexif/libexif-0.6.20.tar.bz2",
  969. + 'conf' => [
  970. + '--disable-docs'
  971. + ]
  972. + },
  973. +
  974. + 'yasm' =>
  975. + {
  976. + 'url' => 'http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz',
  977. + },
  978. +
  979. + 'ccache' =>
  980. + {
  981. + 'url' => 'http://samba.org/ftp/ccache/ccache-3.1.4.tar.bz2',
  982. + 'parallel-make' => 'yes'
  983. + },
  984. +
  985. + 'libcddb' =>
  986. + {
  987. + 'url' => 'http://prdownloads.sourceforge.net/libcddb/libcddb-1.3.2.tar.bz2',
  988. + },
  989. +
  990. + 'libcdio' =>
  991. + {
  992. + 'url' => 'http://ftp.gnu.org/pub/gnu/libcdio/libcdio-0.83.tar.bz2',
  993. + },
  994. +
  995. + 'liberation-sans' =>
  996. + {
  997. + 'url' => 'https://fedorahosted.org/releases/l/i/liberation-fonts/liberation-fonts-ttf-1.07.1.tar.gz',
  998. + 'conf-cmd' => 'echo "all:" > Makefile',
  999. + 'make' => [ ], # override the default 'make all install' targets
  1000. + },
  1001. +
  1002. + 'firewiresdk' =>
  1003. + {
  1004. + 'url' => 'http://www.avenard.org/files/mac/AVCVideoServices.framework.tar.gz',
  1005. + 'conf-cmd' => 'cd',
  1006. + 'make-cmd' => "rm -rf $PREFIX/lib/AVCVideoServices.framework ; cp -R . $PREFIX/lib/AVCVideoServices.framework",
  1007. + 'make' => [ ],
  1008. + },
  1009. +
  1010. + 'cmake' =>
  1011. + {
  1012. + 'url' => 'http://www.cmake.org/files/v2.8/cmake-2.8.7.tar.gz',
  1013. + },
  1014. +
  1015. + 'libtool' =>
  1016. + {
  1017. + 'url' => 'http://ftpmirror.gnu.org/libtool/libtool-2.4.2.tar.gz',
  1018. + },
  1019. +
  1020. + 'autoconf' =>
  1021. + {
  1022. + 'url' => 'http://ftp.gnu.org/gnu/autoconf/autoconf-2.68.tar.gz',
  1023. + },
  1024. + 'automake' =>
  1025. + {
  1026. + 'url' => 'http://ftp.gnu.org/gnu/automake/automake-1.11.tar.gz',
  1027. + },
  1028. +
  1029. +);
  1030. +
  1031. +
  1032. +### Check for app present in target location
  1033. +our $MFE = "$SCRIPTDIR/MythFrontend.app";
  1034. +if ( -d $MFE && ! $OPT{'nobundle'} )
  1035. +{
  1036. + &Complain(<<END);
  1037. +$MFE already exists
  1038. +
  1039. +Error: a MythFrontend application exists where we were planning
  1040. +to build one. Please move this application away before running
  1041. +this script.
  1042. +
  1043. +END
  1044. + exit;
  1045. +}
  1046. +
  1047. +### Third party packages
  1048. +my ( @build_depends, %seen_depends );
  1049. +my @comps = ( 'mythtv', @components, 'packaging' );
  1050. +
  1051. +# Deal with user-supplied skip arguments
  1052. +if ( $OPT{'mythtvskip'} )
  1053. +{ @comps = grep(!m/mythtv/, @comps) }
  1054. +if ( $OPT{'pluginskip'} )
  1055. +{ @comps = grep(!m/mythplugins/, @comps) }
  1056. +
  1057. +if ( ! @comps )
  1058. +{
  1059. + &Complain("Nothing to build! Too many ...skip arguments?");
  1060. + exit;
  1061. +}
  1062. +
  1063. +&Verbose("Including components:", @comps);
  1064. +
  1065. +# If no Git in path, and we are checking something out, build Git:
  1066. +if ( ( ! $git || $git =~ m/no git in / ) && ! $OPT{'nohead'} )
  1067. +{
  1068. + $git = "$PREFIX/bin/git";
  1069. + @build_depends = ( 'git' );
  1070. +}
  1071. +
  1072. +foreach my $comp (@comps)
  1073. +{
  1074. + foreach my $dep (@{ $depend_order{$comp} })
  1075. + {
  1076. + unless (exists $seen_depends{$dep})
  1077. + {
  1078. + push(@build_depends, $dep);
  1079. + $seen_depends{$dep} = 1;
  1080. + }
  1081. + }
  1082. +}
  1083. +foreach my $sw ( @build_depends )
  1084. +{
  1085. + # Get info about this package
  1086. + my $pkg = $depend{$sw};
  1087. + my $url = $pkg->{'url'};
  1088. + my $filename = $url;
  1089. + $filename =~ s|^.+/([^/]+)$|$1|;
  1090. + my $dirname = $filename;
  1091. + $filename = $ARCHIVEDIR . '/' . $filename;
  1092. + $dirname =~ s|\.tar\.gz$||;
  1093. + $dirname =~ s|\.tar\.bz2$||;
  1094. +
  1095. + chdir($SRCDIR);
  1096. +
  1097. + # Download and decompress
  1098. + unless ( -e $filename )
  1099. + {
  1100. + &Verbose("Downloading $sw");
  1101. + unless (&Syscall([ '/usr/bin/curl', '-f', '-L', $url, '>', $filename ],
  1102. + 'munge' => 1))
  1103. + {
  1104. + &Syscall([ '/bin/rm', $filename ]) if (-e $filename);
  1105. + die;
  1106. + }
  1107. + }
  1108. + else
  1109. + { &Verbose("Using previously downloaded $sw") }
  1110. +
  1111. + if ( $pkg->{'skip'} )
  1112. + { next }
  1113. +
  1114. + if ( -d $dirname )
  1115. + {
  1116. + if ( $OPT{'thirdclean'} )
  1117. + {
  1118. + &Verbose("Removing previous build of $sw");
  1119. + &Syscall([ '/bin/rm', '-f', '-r', $dirname ]) or die;
  1120. + }
  1121. +
  1122. + if ( $OPT{'thirdskip'} )
  1123. + {
  1124. + &Verbose("Using previous build of $sw");
  1125. + next;
  1126. + }
  1127. +
  1128. + &Verbose("Using previously unpacked $sw");
  1129. + }
  1130. + else
  1131. + {
  1132. + &Verbose("Unpacking $sw");
  1133. + if ( substr($filename,-3) eq ".gz" )
  1134. + { &Syscall([ '/usr/bin/tar', '-xzf', $filename ]) or die }
  1135. + elsif ( substr($filename,-4) eq ".bz2" )
  1136. + { &Syscall([ '/usr/bin/tar', '-xjf', $filename ]) or die }
  1137. + else
  1138. + {
  1139. + &Complain("Cannot unpack file $filename");
  1140. + exit;
  1141. + }
  1142. + }
  1143. +
  1144. + # Configure
  1145. + chdir($dirname);
  1146. + unless (-e '.osx-config')
  1147. + {
  1148. + &Verbose("Configuring $sw");
  1149. + if ( $pkg->{'pre-conf'} )
  1150. + { &Syscall([ $pkg->{'pre-conf'} ], 'munge' => 1) or die }
  1151. +
  1152. + my (@configure, $munge);
  1153. +
  1154. + if ( $pkg->{'conf-cmd'} )
  1155. + {
  1156. + my $tmp = $pkg->{'conf-cmd'};
  1157. + push(@configure, $tmp);
  1158. + $munge = 1;
  1159. + }
  1160. + else
  1161. + {
  1162. + push(@configure, "./configure",
  1163. + "--prefix=$PREFIX",
  1164. + "--disable-static",
  1165. + "--enable-shared");
  1166. + if ( $OPT{'universal'} )
  1167. + {
  1168. + push(@configure, "--disable-dependency-tracking");
  1169. + }
  1170. + }
  1171. + if ( $pkg->{'conf'} )
  1172. + {
  1173. + push(@configure, @{ $pkg->{'conf'} });
  1174. + }
  1175. + &Syscall(\@configure, 'interpolate' => 1, 'munge' => $munge) or die;
  1176. + if ( $pkg->{'post-conf'} )
  1177. + {
  1178. + &Syscall([ $pkg->{'post-conf'} ], 'munge' => 1) or die;
  1179. + }
  1180. + &Syscall([ '/usr/bin/touch', '.osx-config' ]) or die;
  1181. + }
  1182. + else
  1183. + { &Verbose("Using previously configured $sw") }
  1184. +
  1185. + # Build and install
  1186. + unless (-e '.osx-built')
  1187. + {
  1188. + &Verbose("Making $sw");
  1189. + my (@make);
  1190. +
  1191. + if ( $pkg->{'make-cmd' } )
  1192. + {
  1193. + push(@make, $pkg->{'make-cmd' });
  1194. + }
  1195. + else
  1196. + {
  1197. + push(@make, $standard_make);
  1198. + if ( $pkg->{'parallel-make'} && $parallel_make_flags )
  1199. + { push(@make, $parallel_make_flags) }
  1200. + }
  1201. + if ( $pkg->{'make'} )
  1202. + { push(@make, @{ $pkg->{'make'} }) }
  1203. + else
  1204. + { push(@make, 'all', 'install') }
  1205. +
  1206. + &Syscall(\@make) or die;
  1207. + if ( $pkg->{'post-make'} )
  1208. + {
  1209. + &Syscall([ $pkg->{'post-make'} ], 'munge' => 1) or die;
  1210. + }
  1211. + &Syscall([ '/usr/bin/touch', '.osx-built' ]) or die;
  1212. + }
  1213. + else
  1214. + {
  1215. + &Verbose("Using previously built $sw");
  1216. + }
  1217. +}
  1218. +
  1219. +if ( $OPT{'bootstrap'} )
  1220. +{
  1221. + exit;
  1222. +}
  1223. +
  1224. +#
  1225. +# Work out Git branches, revisions and tags.
  1226. +# Note these vars are unused if nohead or srcdir set!
  1227. +#
  1228. +my $gitrepository = 'git://github.com/MythTV/mythtv.git';
  1229. +my $gitpackaging = 'git://github.com/MythTV/packaging.git';
  1230. +
  1231. +my $gitfetch = 0; # Synchronise cloned database copy before checkout?
  1232. +my $gitpull = 1; # Cause a fast-forward
  1233. +my $gitrevSHA = 0;
  1234. +my $gitrevert = 0; # Undo any local changes?
  1235. +
  1236. +if ( $OPT{'gitrev'} )
  1237. +{
  1238. + # This arg. could be '64d9d7c5...' (up to 40 hex digits),
  1239. + # a branch like 'mythtv-rec', 'nigelfixes' or 'master',
  1240. + # or a tag name like 'fixes/0.24'.
  1241. +
  1242. + $gitrevision = $OPT{'gitrev'};
  1243. +
  1244. + # If it is a hex revision, we checkout and don't pull mythtv src
  1245. + if ( $gitrevision =~ /^[0-9a-f]{7,40}$/ )
  1246. + {
  1247. + $gitrevSHA = 1;
  1248. + $gitfetch = 1; # Rev. might be newer than local cache
  1249. + $gitpull = 0; # Checkout creates "detached HEAD", git pull will fail
  1250. + }
  1251. +}
  1252. +
  1253. +# Retrieve source
  1254. +if ( $OPT{'srcdir'} )
  1255. +{
  1256. + chdir($SCRIPTDIR);
  1257. + &Syscall(['rm', '-fr', $GITDIR]);
  1258. + &Syscall(['mkdir', '-p', $GITDIR]);
  1259. + foreach my $dir ( @comps )
  1260. + {
  1261. + if ($dir eq 'packaging' && $OPT{'pkgsrcdir'})
  1262. + {
  1263. + &Syscall(['cp', '-pR', "$OPT{'pkgsrcdir'}", "$GITDIR/$dir"]);
  1264. + }
  1265. + else
  1266. + {
  1267. + &Syscall(['cp', '-pR', "$OPT{'srcdir'}/$dir", "$GITDIR/$dir"]);
  1268. + }
  1269. + }
  1270. + &Syscall("mkdir -p $GITDIR/mythtv/config")
  1271. +}
  1272. +elsif ( ! $OPT{'nohead'} )
  1273. +{
  1274. + # Only do 'git clone' if mythtv directory does not exist.
  1275. + # Always do 'git checkout' to make sure we have the right branch,
  1276. + # then 'git pull' to get up to date.
  1277. + if ( ! -e $GITDIR )
  1278. + {
  1279. + Verbose("Checking out source code");
  1280. + &Syscall([ $git, 'clone', $gitrepository, $GITDIR ]) or die;
  1281. + }
  1282. + if ( ! -e "$GITDIR/packaging" )
  1283. + {
  1284. + Verbose("Checking out packaging code");
  1285. + &Syscall([ $git, 'clone',
  1286. + $gitpackaging, $GITDIR . '/packaging' ]) or die;
  1287. + }
  1288. +
  1289. + # Remove Nigel's frontend building speedup hack
  1290. + chdir "$GITDIR/mythtv" or die;
  1291. + &DoSpeedupHacks('programs/programs.pro', '') unless $OPT{'nohacks'};
  1292. +
  1293. + my @gitcheckoutflags;
  1294. +
  1295. + if ( $gitrevert )
  1296. + { @gitcheckoutflags = ( 'checkout', '--force', $gitrevision ) }
  1297. + else
  1298. + { @gitcheckoutflags = ( 'checkout', '--merge', $gitrevision ) }
  1299. +
  1300. +
  1301. + chdir $GITDIR;
  1302. + if ( $gitfetch ) # Update Git DB
  1303. + { &Syscall([ $git, 'fetch' ]) or die }
  1304. + &Syscall([ $git, @gitcheckoutflags ]) or die;
  1305. + if ( $gitpull ) # Fast-forward
  1306. + { &Syscall([ $git, 'pull' ]) or die }
  1307. +
  1308. + chdir "$GITDIR/packaging";
  1309. + if ( $gitfetch ) # Update Git DB
  1310. + { &Syscall([ $git, 'fetch' ]) or die }
  1311. + if ( $gitrevSHA )
  1312. + {
  1313. + &Syscall([ $git, 'checkout', 'master' ]) or die;
  1314. + &Syscall([ $git, 'merge', 'master' ]) or die;
  1315. + }
  1316. + else
  1317. + {
  1318. + &Syscall([ $git, @gitcheckoutflags ]) or die;
  1319. + if ( $gitpull ) # Fast-forward
  1320. + { &Syscall([ $git, 'pull' ]) or die }
  1321. + }
  1322. +}
  1323. +
  1324. +# Make a convenience (non-hidden) directory for editing src code:
  1325. +system("ln -sf $GITDIR $SCRIPTDIR/src");
  1326. +
  1327. +foreach my $arch (@ARCHS)
  1328. +{
  1329. + ### build MythTV
  1330. + &Verbose("Compiling for $arch architecture");
  1331. +
  1332. + # Clean any previously installed libraries
  1333. + if ( $cleanLibs )
  1334. + {
  1335. + if ( $OPT{'mythtvskip'} )
  1336. + {
  1337. + &Complain("Cannot skip building mythtv src if also cleaning");
  1338. + exit;
  1339. + }
  1340. + &Verbose("Cleaning previous installs of MythTV for arch: $arch");
  1341. + &Distclean($arch);
  1342. + }
  1343. +
  1344. + $ENV{'CFLAGS'} = "-arch $arch $CFLAGS";
  1345. + $ENV{'CXXFLAGS'} = "-arch $arch $CXXFLAGS";
  1346. + $ENV{'ECXXFLAGS'} = "-arch $arch $ECXXFLAGS";
  1347. + $ENV{'LDFLAGS'} = "-arch $arch $LDFLAGS";
  1348. +
  1349. + # show summary of build parameters.
  1350. + &Verbose("CFLAGS = $ENV{'CFLAGS'}");
  1351. + &Verbose("LDFLAGS = $ENV{'LDFLAGS'}");
  1352. +
  1353. + # Build MythTV and any plugins
  1354. + foreach my $comp (@comps)
  1355. + {
  1356. + my $compdir = "$GITDIR/$comp/" ;
  1357. +
  1358. + chdir $compdir || die "No source directory $compdir";
  1359. +
  1360. + if ( ! -e "$comp.pro" and ! -e 'Makefile' and ! -e 'configure' )
  1361. + {
  1362. + &Complain("Nothing to configure/make in $compdir");
  1363. + next;
  1364. + }
  1365. +
  1366. + if ( $OPT{'clean'} && -e 'Makefile' )
  1367. + {
  1368. + &Verbose("Cleaning $comp");
  1369. + &Syscall([ $standard_make, 'distclean' ]) or die;
  1370. + }
  1371. + #else
  1372. + #{
  1373. + # # clean the Makefiles, as process requires PREFIX hacking
  1374. + # &CleanMakefiles();
  1375. + #}
  1376. +
  1377. + # Apply any nasty mac-specific patches
  1378. + if ( $patches{$comp} )
  1379. + {
  1380. + &Syscall([ "echo '$patches{$comp}' | patch -p0 --forward" ]);
  1381. + }
  1382. +
  1383. + # configure and make
  1384. + if ( $makecleanopt{$comp} && -e 'Makefile' && ! $OPT{'noclean'} )
  1385. + {
  1386. + my @makecleancom = $standard_make;
  1387. + push(@makecleancom, @{ $makecleanopt{$comp} }) if $makecleanopt{$comp};
  1388. + &Syscall([ @makecleancom ]) or die;
  1389. + }
  1390. + if ( -e 'configure' && ! $OPT{'noclean'} )
  1391. + {
  1392. + &Verbose("Configuring $comp");
  1393. + my @config = './configure';
  1394. + push(@config, @{ $conf{$comp} }) if $conf{$comp};
  1395. + push @config, "--prefix=$PREFIX/$arch";
  1396. + push @config, "--cc=$CCBIN";
  1397. + push @config, "--cxx=$CXXBIN";
  1398. + push @config, "--qmake=$QTBIN/qmake";
  1399. + push @config, "--extra-libs=-F$QTLIB";
  1400. +
  1401. + if ( $OPT{'profile'} )
  1402. + {
  1403. + push @config, '--compile-type=profile'
  1404. + }
  1405. + if ( $OPT{'debug'} )
  1406. + {
  1407. + push @config, '--compile-type=debug'
  1408. + }
  1409. + &Syscall([ @config ]) or die;
  1410. + }
  1411. + if ( (! -e 'configure') && -e "$comp.pro" && ! $OPT{'noclean'} )
  1412. + {
  1413. + &Verbose("Running qmake for $comp");
  1414. + my @qmake_opts = (
  1415. + "\"QMAKE_CC=$CCBIN\" \"QMAKE_CXX=$CXXBIN\" \"QMAKE_CXXFLAGS=$ENV{'CXXFLAGS'}\" \"QMAKE_CFLAGS=$ENV{'CFLAGS'}\" \"QMAKE_LFLAGS+=$ENV{'LDFLAGS'}\"",
  1416. + "INCLUDEPATH+=\"$PREFIX/include\"",
  1417. + "LIBS+=\"-F$QTLIB -L\"$PREFIX/lib\"",
  1418. + );
  1419. + &Syscall([ "$QTBIN/qmake",
  1420. + 'PREFIX=../Resources',
  1421. + @qmake_opts,
  1422. + "$comp.pro" ]) or die;
  1423. + }
  1424. + if ( $comp eq 'mythtv' )
  1425. + {
  1426. + # Remove/add Nigel's frontend building speedup hack
  1427. + &DoSpeedupHacks('programs/programs.pro',
  1428. + 'mythfrontend mythavtest mythpreviewgen mythwelcome') unless $OPT{'nohacks'};
  1429. + }
  1430. +
  1431. + &Verbose("Making $comp");
  1432. + &Syscall([ $parallel_make ]) or die;
  1433. +
  1434. + &Verbose("Installing $comp");
  1435. + &Syscall([ $standard_make,
  1436. + 'install' ]) or die;
  1437. +
  1438. + if ( $cleanLibs && $comp eq 'mythtv' )
  1439. + {
  1440. + # If we cleaned the libs, make install will have recopied them,
  1441. + # which means any dynamic libraries that the static libraries depend on
  1442. + # are newer than the table of contents. Hence we need to regenerate it:
  1443. + my @mythlibs = glob "$PREFIX/lib/libmyth*.a";
  1444. + if ( scalar @mythlibs )
  1445. + {
  1446. + &Verbose("Running ranlib on reinstalled static libraries");
  1447. + foreach my $lib (@mythlibs)
  1448. + { &Syscall("ranlib $lib") or die }
  1449. + }
  1450. + }
  1451. + }
  1452. +}
  1453. +
  1454. +&Complain("Compilation done ..");
  1455. +
  1456. +### Create universal binaries
  1457. +### BIN files
  1458. +&MakeFilesUniversal("bin", glob "$PREFIX/$ARCHS[0]/bin/*");
  1459. +
  1460. +### Libs
  1461. +&MakeFilesUniversal("lib", glob "$PREFIX/$ARCHS[0]/lib/*");
  1462. +
  1463. +&RecursiveCopy("$PREFIX/$ARCHS[0]/share", "$PREFIX");
  1464. +&RecursiveCopy("$PREFIX/$ARCHS[0]/include", "$PREFIX");
  1465. +
  1466. +# stop here if no bundle is to be created
  1467. +if ( $OPT{'nobundle'} )
  1468. +{
  1469. + exit;
  1470. +}
  1471. +
  1472. +### Build version string
  1473. +our $VERS = `find $PREFIX/lib -name 'libmyth-[0-9].[0-9][0-9].[0-9].dylib'`;
  1474. +chomp $VERS;
  1475. +$VERS =~ s/^.*\-(.*)\.dylib$/$1/s;
  1476. +$VERS .= '.' . $OPT{'version'} if $OPT{'version'};
  1477. +
  1478. +### Program which creates bundles:
  1479. +our @bundler = "$GITDIR/packaging/OSX/build/osx-bundler.pl";
  1480. +if ( $OPT{'verbose'} )
  1481. +{ push @bundler, '--verbose' }
  1482. +
  1483. +# Strip unused architectures, this reduces the size quite significantly
  1484. +if ( (`sysctl -n hw.machine` eq "x86_64\n" && $OPT{'m32'}) || `sysctl -n hw.machine` eq "i386\n" )
  1485. +{
  1486. + push @bundler, "--arch", "i386";
  1487. +}
  1488. +elsif ( `sysctl -n hw.machine` eq "x86_64\n" && !$OPT{'universal'} )
  1489. +{
  1490. + #not universal bundle, on 64 bits host: only keep 64 bits binaries
  1491. + push @bundler, "--arch", "x86_64";
  1492. +}
  1493. +
  1494. +### Create each package.
  1495. +### Note that this is a bit of a waste of disk space,
  1496. +### because there are now multiple copies of each library.
  1497. +
  1498. +if ( $jobtools )
  1499. +{ push @targets, @targetsJT }
  1500. +
  1501. +if ( $backend )
  1502. +{ push @targets, @targetsBE }
  1503. +
  1504. +my @libs = ( "$PREFIX/lib/", "$PREFIX/lib/mysql", "$QTLIB" );
  1505. +foreach my $target ( @targets )
  1506. +{
  1507. + my $finalTarget = "$SCRIPTDIR/$target.app";
  1508. + my $builtTarget = lc $target;
  1509. +
  1510. + # Get a fresh copy of the binary
  1511. + &Verbose("Building self-contained $target");
  1512. + &Syscall([ 'rm', '-fr', $finalTarget ]) or die;
  1513. + &Syscall([ 'cp', "$PREFIX/bin/$builtTarget",
  1514. + "$SCRIPTDIR/$target" ]) or die;
  1515. +
  1516. + # Convert it to a bundled .app
  1517. + &Syscall([ @bundler, "$SCRIPTDIR/$target", @libs ]) or die;
  1518. +
  1519. + # Remove copy of binary
  1520. + unlink "$SCRIPTDIR/$target" or die;
  1521. +
  1522. + # Themes are required by all GUI apps. The filters and plugins are not
  1523. + # used by mythtv-setup or mythwelcome, but for simplicity, do them all.
  1524. + if ( $target eq "MythAVTest" or $target eq "MythFrontend" or
  1525. + $target eq "MythWelcome" or $target =~ m/^MythTV-/ )
  1526. + {
  1527. + my $res = "$finalTarget/Contents/Resources";
  1528. + my $libs = "$res/lib";
  1529. + my $plug = "$libs/mythtv/plugins";
  1530. +
  1531. + # Install themes, filters, etc.
  1532. + &Verbose("Installing resources into $target");
  1533. + mkdir $res; mkdir $libs;
  1534. + &RecursiveCopy("$PREFIX/lib/mythtv", $libs);
  1535. + mkdir "$res/share";
  1536. + &RecursiveCopy("$PREFIX/share/mythtv", "$res/share");
  1537. +
  1538. + # Correct the library paths for the filters and plugins
  1539. + foreach my $lib ( glob "$libs/mythtv/*/*" )
  1540. + { &Syscall([ @bundler, $lib, @libs ]) or die }
  1541. +
  1542. + if ( -e $plug )
  1543. + {
  1544. + # Allow Finder's 'Get Info' to manage plugin list:
  1545. + &Syscall([ 'mv', $plug, "$finalTarget/Contents/$BundlePlugins" ]) or die;
  1546. + &Syscall([ 'ln', '-s', "../../../$BundlePlugins", $plug ]) or die;
  1547. + }
  1548. +
  1549. + # The icon
  1550. + &Syscall([ 'cp',
  1551. + "$GITDIR/mythtv/programs/mythfrontend/mythfrontend.icns",
  1552. + "$res/application.icns" ]) or die;
  1553. + &Syscall([ 'xcrun', '-sdk', "$SDKNAME", 'SetFile', '-a', 'C', $finalTarget ])
  1554. + or die;
  1555. +
  1556. + # Create PlugIns directory
  1557. + mkdir("$finalTarget/Contents/PlugIns");
  1558. +
  1559. + # Tell Qt to use the PlugIns directory (doesn't work due QTBUG-24541, but in case they fix it)
  1560. + open FH, ">$res/qt.conf";
  1561. + print FH "[Paths]\nPlugins = $BundlePlugins\n";
  1562. + close FH;
  1563. +
  1564. + # Copy the required Qt plugins
  1565. + foreach my $plugin ( "sqldrivers", "imageformats")
  1566. + {
  1567. + &Syscall([ 'mkdir', "$finalTarget/Contents/$BundlePlugins/$plugin" ]) or die;
  1568. + # Have to create links in application folder due to QTBUG-24541
  1569. + &Syscall([ 'ln', '-s', "../$BundlePlugins/$plugin", "$finalTarget/Contents/MacOs/$plugin" ]) or die;
  1570. + }
  1571. +
  1572. + # copy the MySQL sqldriver
  1573. + &Syscall([ 'cp', "$PREFIX/qtplugins-$QTVERSION/libqsqlmysql.dylib", "$finalTarget/Contents/$BundlePlugins/sqldrivers/" ])
  1574. + or die;
  1575. + &Syscall([ @bundler, "$finalTarget/Contents/$BundlePlugins/sqldrivers/libqsqlmysql.dylib", @libs ])
  1576. + or die;
  1577. +
  1578. + foreach my $plugin ( 'imageformats/libqgif.dylib', 'imageformats/libqjpeg.dylib' )
  1579. + {
  1580. + my $pluginSrc = "$QTSDK/plugins/$plugin";
  1581. + if ( -e $pluginSrc )
  1582. + {
  1583. + &Syscall([ 'cp', "$QTSDK/plugins/$plugin",
  1584. + "$finalTarget/Contents/$BundlePlugins/$plugin" ])
  1585. + or die;
  1586. + &Syscall([ @bundler,
  1587. + "$finalTarget/Contents/$BundlePlugins/$plugin", @libs ])
  1588. + or die;
  1589. + }
  1590. + }
  1591. +
  1592. + # A font the Terra theme uses:
  1593. + my $url = $depend{'liberation-sans'}->{'url'};
  1594. + my $dirname = $url;
  1595. + $dirname =~ s|^.+/([^/]+)$|$1|;
  1596. + $dirname =~ s|\.tar\.gz$||;
  1597. + $dirname =~ s|\.tar\.bz2$||;
  1598. +
  1599. + my $fonts = "$res/share/mythtv/fonts";
  1600. + mkdir $fonts;
  1601. + &RecursiveCopy("$SRCDIR/$dirname/LiberationSans-Regular.ttf", $fonts);
  1602. + &EditPList("$finalTarget/Contents/Info.plist",
  1603. + 'ATSApplicationFontsPath', 'share/mythtv/fonts');
  1604. + }
  1605. +
  1606. + if ( $target eq "MythFrontend" )
  1607. + {
  1608. + my $extralib;
  1609. +
  1610. + foreach my $extra ( 'ignyte', 'mythpreviewgen', 'mtd' )
  1611. + {
  1612. + if ( -e "$PREFIX/bin/$extra" )
  1613. + {
  1614. + &Verbose("Installing $extra into $target");
  1615. + &Syscall([ 'cp', "$PREFIX/bin/$extra",
  1616. + "$finalTarget/Contents/MacOS" ]) or die;
  1617. +
  1618. + &Verbose('Updating lib paths of',
  1619. + "$finalTarget/Contents/MacOS/$extra");
  1620. + &Syscall([ @bundler, "$finalTarget/Contents/MacOS/$extra", @libs ])
  1621. + or die;
  1622. + &AddFakeBinDir($finalTarget);
  1623. + }
  1624. + }
  1625. +
  1626. + # Allow playback of region encoded DVDs
  1627. + $extralib = "libdvdcss.2.dylib";
  1628. + &Syscall([ 'cp', "$PREFIX/lib/$extralib",
  1629. + "$finalTarget/Contents/$BundlePlugins" ]) or die;
  1630. + &Syscall([ @bundler, "$finalTarget/Contents/$BundlePlugins/$extralib", @libs ])
  1631. + or die;
  1632. +
  1633. + }
  1634. +
  1635. + if ( $target eq "MythWelcome" )
  1636. + {
  1637. + &Verbose("Installing mythfrontend into $target");
  1638. + &Syscall([ 'cp', "$PREFIX/bin/mythfrontend",
  1639. + "$finalTarget/Contents/MacOS" ]) or die;
  1640. + &Syscall([ @bundler, "$finalTarget/Contents/MacOS/mythfrontend", @libs ])
  1641. + or die;
  1642. + &AddFakeBinDir($finalTarget);
  1643. +
  1644. + # For some unknown reason, mythfrontend looks here for support files:
  1645. + &Syscall([ 'ln', '-s', "../Resources/share", # themes
  1646. + "../Resources/lib", # filters/plugins
  1647. + "$finalTarget/Contents/MacOS" ]) or die;
  1648. + }
  1649. +
  1650. + # rebase segfault on my mac, so disable it for the time being
  1651. + # Run 'rebase' on all the frameworks, for slightly faster loading.
  1652. + # Note that we process the real library, not symlinks to it,
  1653. + # to prevent rebase erroneously creating copies:
  1654. + #my @libs = glob "$finalTarget/Contents/Frameworks/*";
  1655. + #@libs = grep(s,(.*/)(\w+).framework$,$1$2.framework/Versions/A/$2, , @libs);
  1656. +
  1657. + # Also process all the filters/plugins:
  1658. + #push(@libs, glob "$finalTarget/Contents/Resources/lib/mythtv/*/*.dylib");
  1659. + #push(@libs, glob "$finalTarget/Contents/PlugIns/*/*.dylib");
  1660. +
  1661. + #if ( $OPT{'verbose'} )
  1662. + #{ &Syscall([ 'rebase', '-v', @libs ]) or die }
  1663. + #else
  1664. + #{ &Syscall([ 'rebase', @libs ]) or die }
  1665. +
  1666. +}
  1667. +
  1668. +if ( $backend && grep(m/MythBackend/, @targets) )
  1669. +{
  1670. + my $BE = "$SCRIPTDIR/MythBackend.app";
  1671. +
  1672. + # Copy XML files that UPnP requires:
  1673. + my $share = "$BE/Contents/Resources/share/mythtv";
  1674. + &Syscall([ 'mkdir', '-p', $share ]) or die;
  1675. + &Syscall([ 'cp', glob("$PREFIX/share/mythtv/*.xml"), $share ]) or die;
  1676. +
  1677. + # Same for default web server page:
  1678. + &Syscall([ 'cp', '-pR', "$PREFIX/share/mythtv/html", $share ]) or die;
  1679. +
  1680. + # The backend gets all the useful binaries it might call:
  1681. + foreach my $binary ( 'mythjobqueue', 'mythcommflag',
  1682. + 'mythpreviewgen', 'mythtranscode', 'mythfilldatabase' )
  1683. + {
  1684. + my $SRC = "$PREFIX/bin/$binary";
  1685. + if ( -e $SRC )
  1686. + {
  1687. + &Verbose("Installing $SRC into $BE");
  1688. + &Syscall([ '/bin/cp', $SRC, "$BE/Contents/MacOS" ]) or die;
  1689. +
  1690. + &Verbose("Updating lib paths of $BE/Contents/MacOS/$binary");
  1691. + &Syscall([ @bundler, "$BE/Contents/MacOS/$binary", @libs ]) or die;
  1692. + }
  1693. + }
  1694. + &AddFakeBinDir($BE);
  1695. +}
  1696. +
  1697. +if ( $backend && grep(m/MythTV-Setup/, @targets) )
  1698. +{
  1699. + my $SET = "$SCRIPTDIR/MythTV-Setup.app";
  1700. + my $SRC = "$PREFIX/bin/mythfilldatabase";
  1701. + if ( -e $SRC )
  1702. + {
  1703. + &Verbose("Installing $SRC into $SET");
  1704. + &Syscall([ '/bin/cp', $SRC, "$SET/Contents/MacOS" ]) or die;
  1705. +
  1706. + &Verbose("Updating lib paths of $SET/Contents/MacOS/mythfilldatabase");
  1707. + &Syscall([ @bundler, "$SET/Contents/MacOS/mythfilldatabase", @libs ]) or die;
  1708. + }
  1709. + &AddFakeBinDir($SET);
  1710. +}
  1711. +
  1712. +if ( $jobtools )
  1713. +{
  1714. + # JobQueue also gets some binaries it might call:
  1715. + my $JQ = "$SCRIPTDIR/MythJobQueue.app";
  1716. + my $DEST = "$JQ/Contents/MacOS";
  1717. + my $SRC = "$PREFIX/bin/mythcommflag";
  1718. +
  1719. + &Syscall([ '/bin/cp', $SRC, $DEST ]) or die;
  1720. + &AddFakeBinDir($JQ);
  1721. + &Verbose("Updating lib paths of $DEST/mythcommflag");
  1722. + &Syscall([ @bundler, "$DEST/mythcommflag", @libs ]) or die;
  1723. +
  1724. + $SRC = "$PREFIX/bin/mythtranscode.app/Contents/MacOS/mythtranscode";
  1725. + if ( -e $SRC )
  1726. + {
  1727. + &Verbose("Installing $SRC into $JQ");
  1728. + &Syscall([ '/bin/cp', $SRC, $DEST ]) or die;
  1729. + &Verbose("Updating lib paths of $DEST/mythtranscode");
  1730. + &Syscall([ @bundler, "$DEST/mythtranscode", @libs ]) or die;
  1731. + }
  1732. +}
  1733. +
  1734. +# Clean tmp files. Most of these are leftovers from configure:
  1735. +#
  1736. +&Verbose('Cleaning build tmp directory');
  1737. +&Syscall([ 'rm', '-fr', $WORKDIR . '/tmp' ]) or die;
  1738. +&Syscall([ 'mkdir', $WORKDIR . '/tmp' ]) or die;
  1739. +
  1740. +if ($OPT{usehdimage} && !$OPT{leavehdimage} )
  1741. +{
  1742. + Verbose("Dismounting case-sensitive build device");
  1743. + UnmountHDImage();
  1744. +}
  1745. +
  1746. +&Verbose("Build complete. Self-contained package is at:\n\n $MFE\n");
  1747. +
  1748. +### end script
  1749. +exit 0;
  1750. +
  1751. +
  1752. +######################################
  1753. +## RecursiveCopy copies a directory tree, stripping out .git
  1754. +## directories and properly managing static libraries.
  1755. +######################################
  1756. +
  1757. +sub RecursiveCopy($$)
  1758. +{
  1759. + my ($src, $dst) = @_;
  1760. +
  1761. + # First copy absolutely everything
  1762. + &Syscall([ '/bin/cp', '-pR', "$src", "$dst"]) or die;
  1763. +
  1764. + # Then strip out any .git directories
  1765. + my @files = map { chomp $_; $_ } `find $dst -name .git`;
  1766. + if ( scalar @files )
  1767. + {
  1768. + &Syscall([ '/bin/rm', '-f', '-r', @files ]);
  1769. + }
  1770. +
  1771. + # And make sure any static libraries are properly relocated.
  1772. + my @libs = map { chomp $_; $_ } `find $dst -name "lib*.a"`;
  1773. + if ( scalar @libs )
  1774. + {
  1775. + &Syscall([ 'ranlib', '-s', @libs ]);
  1776. + }
  1777. +}
  1778. +
  1779. +######################################
  1780. +## CleanMakefiles removes every generated Makefile
  1781. +## from our MythTV build that contains PREFIX.
  1782. +## Necessary when we change the
  1783. +## PREFIX variable.
  1784. +######################################
  1785. +
  1786. +sub CleanMakefiles
  1787. +{
  1788. + &Verbose("Cleaning MythTV makefiles containing PREFIX");
  1789. + &Syscall([ 'find', '.', '-name', 'Makefile', '-exec',
  1790. + 'egrep', '-q', 'qmake.*PREFIX', '{}', ';', '-delete' ]) or die;
  1791. +} # end CleanMakefiles
  1792. +
  1793. +
  1794. +######################################
  1795. +## Syscall wrappers the Perl "system"
  1796. +## routine with verbosity and error
  1797. +## checking.
  1798. +######################################
  1799. +
  1800. +sub Syscall($%)
  1801. +{
  1802. + my ($arglist, %opts) = @_;
  1803. +
  1804. + unless (ref $arglist)
  1805. + {
  1806. + $arglist = [ $arglist ];
  1807. + }
  1808. + if ( $opts{'interpolate'} )
  1809. + {
  1810. + my @args;
  1811. + foreach my $arg (@$arglist)
  1812. + {
  1813. + $arg =~ s/\$PREFIX/$PREFIX/ge;
  1814. + $arg =~ s/\$SDKROOT/$SDKROOT/ge;
  1815. + $arg =~ s/\$CFLAGS/$ENV{'CFLAGS'};/ge;
  1816. + $arg =~ s/\$LDFLAGS/$ENV{'LDFLAGS'};/ge;
  1817. + $arg =~ s/\$parallel_make_flags/$parallel_make_flags/ge;
  1818. + push(@args, $arg);
  1819. + }
  1820. + $arglist = \@args;
  1821. + }
  1822. + if ( $opts{'munge'} )
  1823. + {
  1824. + $arglist = [ join(' ', @$arglist) ];
  1825. + }
  1826. + # clean out any null arguments
  1827. + $arglist = [ map $_, @$arglist ];
  1828. + &Verbose(@$arglist);
  1829. + my $ret = system(@$arglist);
  1830. + if ( $ret )
  1831. + {
  1832. + &Complain('Failed system call: "', @$arglist,
  1833. + '" with error code', $ret >> 8);
  1834. + }
  1835. + return ($ret == 0);
  1836. +} # end Syscall
  1837. +
  1838. +
  1839. +######################################
  1840. +## Verbose prints messages in verbose
  1841. +## mode.
  1842. +######################################
  1843. +
  1844. +sub Verbose
  1845. +{
  1846. + print STDERR '[osx-pkg] ' . join(' ', @_) . "\n"
  1847. + if $OPT{'verbose'};
  1848. +} # end Verbose
  1849. +
  1850. +
  1851. +######################################
  1852. +## Complain prints messages in any
  1853. +## verbosity mode.
  1854. +######################################
  1855. +
  1856. +sub Complain
  1857. +{
  1858. + print STDERR '[osx-pkg] ' . join(' ', @_) . "\n";
  1859. +} # end Complain
  1860. +
  1861. +
  1862. +######################################
  1863. +## Manage usehdimage disk image
  1864. +######################################
  1865. +
  1866. +sub MountHDImage
  1867. +{
  1868. + if ( ! HDImageDevice() )
  1869. + {
  1870. + if ( -e "$SCRIPTDIR/.osx-packager.dmg" )
  1871. + {
  1872. + Verbose("Mounting existing UFS disk image for the build");
  1873. + }
  1874. + else
  1875. + {
  1876. + Verbose("Creating a case-sensitive (UFS) disk image for the build");
  1877. + Syscall(['hdiutil', 'create', '-size', '2048m',
  1878. + "$SCRIPTDIR/.osx-packager.dmg", '-volname',
  1879. + 'MythTvPackagerHDImage', '-fs', 'UFS', '-quiet']) || die;
  1880. + }
  1881. +
  1882. + &Syscall(['hdiutil', 'mount',
  1883. + "$SCRIPTDIR/.osx-packager.dmg",
  1884. + '-mountpoint', $WORKDIR, '-quiet']) || die;
  1885. + }
  1886. +
  1887. + # configure defaults to /tmp and OSX barfs when mv crosses
  1888. + # filesystems so tell configure to put temp files on the image
  1889. +
  1890. + $ENV{TMPDIR} = $WORKDIR . "/tmp";
  1891. + mkdir $ENV{TMPDIR};
  1892. +}
  1893. +
  1894. +sub UnmountHDImage
  1895. +{
  1896. + my $device = HDImageDevice();
  1897. + if ( $device )
  1898. + {
  1899. + &Syscall(['hdiutil', 'detach', $device, '-force']);
  1900. + }
  1901. +}
  1902. +
  1903. +sub HDImageDevice
  1904. +{
  1905. + my @dev = split ' ', `/sbin/mount | grep $WORKDIR`;
  1906. + $dev[0];
  1907. +}
  1908. +
  1909. +sub CaseSensitiveFilesystem
  1910. +{
  1911. + my $funky = $SCRIPTDIR . "/.osx-packager.FunkyStuff";
  1912. + my $unfunky = substr($funky, 0, -10) . "FUNKySTuFF";
  1913. +
  1914. + unlink $funky if -e $funky;
  1915. + `touch $funky`;
  1916. + my $sensitivity = ! -e $unfunky;
  1917. + unlink $funky;
  1918. +
  1919. + return $sensitivity;
  1920. +}
  1921. +
  1922. +
  1923. +######################################
  1924. +## Remove or add Nigel's speedup hacks
  1925. +######################################
  1926. +
  1927. +sub DoSpeedupHacks($$)
  1928. +{
  1929. + my ($file, $subdirs) = @_;
  1930. +
  1931. + &Verbose("Removing Nigel's hacks from file $file");
  1932. +
  1933. + open(IN, $file) or die;
  1934. + open(OUT, ">$file.orig") or die;
  1935. + while ( <IN> )
  1936. + {
  1937. + if ( m/^# Nigel/ ) # Skip
  1938. + { last }
  1939. + print OUT;
  1940. + }
  1941. + if ( ! $backend && ! $jobtools && $subdirs )
  1942. + {
  1943. + # Nigel's hack to speedup building
  1944. + print OUT "# Nigel\'s speedup hack:\n";
  1945. + print OUT "SUBDIRS = $subdirs\n";
  1946. + }
  1947. + close IN; close OUT;
  1948. + rename("$file.orig", $file);
  1949. +}
  1950. +
  1951. +#######################################################
  1952. +## Parts of MythTV try to call helper apps like this:
  1953. +## gContext->GetInstallPrefix() + "/bin/mythtranscode";
  1954. +## which means we need a bin directory.
  1955. +#######################################################
  1956. +
  1957. +sub AddFakeBinDir($)
  1958. +{
  1959. + my ($target) = @_;
  1960. +
  1961. + &Syscall("mkdir -p $target/Contents/Resources");
  1962. + &Syscall(['ln', '-sf', '../MacOS', "$target/Contents/Resources/bin"]);
  1963. +}
  1964. +
  1965. +###################################################################
  1966. +## Update or add <dict> properties in a (non-binary) .plist file ##
  1967. +###################################################################
  1968. +
  1969. +sub EditPList($$$)
  1970. +{
  1971. + my ($file, $key, $value) = @_;
  1972. +
  1973. + &Verbose("Looking for property $key in file $file");
  1974. +
  1975. + open(IN, $file) or die;
  1976. + open(OUT, ">$file.edit") or die;
  1977. + while ( <IN> )
  1978. + {
  1979. + if ( m,\s<key>$key</key>, )
  1980. + {
  1981. + <IN>;
  1982. + &Verbose("Value was $_"); # Does this work?
  1983. + print OUT "<key>$key</key>\n<string>$value</string>\n";
  1984. + next;
  1985. + }
  1986. + elsif ( m,^</dict>$, ) # Not there. Add at end
  1987. + {
  1988. + print OUT "<key>$key</key>\n<string>$value</string>\n";
  1989. + print OUT "</dict>\n</plist>\n";
  1990. + last;
  1991. + }
  1992. +
  1993. + print OUT;
  1994. + }
  1995. + close IN; close OUT;
  1996. + rename("$file.edit", $file);
  1997. +}
  1998. +
  1999. +sub Distclean($)
  2000. +{
  2001. + my $arch = $_;
  2002. + if ( ! $arch eq "" )
  2003. + {
  2004. + $arch .= "/";
  2005. + }
  2006. + &Syscall("/bin/rm -f $PREFIX/${arch}bin/myth*" );
  2007. + &Syscall("/bin/rm -fr $PREFIX/${arch}lib/libmyth*");
  2008. + &Syscall("/bin/rm -fr $PREFIX/${arch}lib/mythtv" );
  2009. + &Syscall("/bin/rm -fr $PREFIX/${arch}share/mythtv");
  2010. + &Syscall("/bin/rm -fr $PREFIX/${arch}share/mythtv");
  2011. + &Syscall([ 'find', "$GITDIR/", '-name', '*.o', '-delete' ]);
  2012. + &Syscall([ 'find', "$GITDIR/", '-name', '*.a', '-delete' ]);
  2013. + &Syscall([ 'find', "$GITDIR/", '-name', '*.dylib', '-delete' ]);
  2014. + &Syscall([ 'find', "$GITDIR/", '-name', '*.orig', '-delete' ]);
  2015. + &Syscall([ 'find', "$GITDIR/", '-name', '*.rej', '-delete' ]);
  2016. +}
  2017. +
  2018. +#########################################################################
  2019. +## Go through the list of files recursively and combine all architectures
  2020. +# together to form a "fat" universal file
  2021. +#########################################################################
  2022. +
  2023. +sub MakeFilesUniversal($@)
  2024. +{
  2025. + my ($base, @files) = @_;
  2026. + if ( ! -d "$PREFIX/$base" )
  2027. + {
  2028. + &Syscall([ '/bin/mkdir', "$PREFIX/$base" ]);
  2029. + }
  2030. + for my $bin (@files)
  2031. + {
  2032. + my @lipo = "/usr/bin/lipo";
  2033. + my $name = basename($bin);
  2034. + if ( -f $bin )
  2035. + {
  2036. + for my $arch (@ARCHS)
  2037. + {
  2038. + push @lipo, "$PREFIX/$arch/$base/$name";
  2039. + }
  2040. + push @lipo, "-create", "-output", "$PREFIX/$base/$name";
  2041. + &Syscall([ @lipo ]);
  2042. + }
  2043. + elsif ( -d $bin )
  2044. + {
  2045. + &MakeFilesUniversal("$base/$name", glob "$PREFIX/$arch/$base/$name/*")
  2046. + }
  2047. + }
  2048. +}
  2049. +### end file
  2050. +1;
  2051. jyaimac:build jyavenard$
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement