summaryrefslogtreecommitdiff
path: root/infrastructure/BoxPlatform.pm.in
diff options
context:
space:
mode:
Diffstat (limited to 'infrastructure/BoxPlatform.pm.in')
-rw-r--r--infrastructure/BoxPlatform.pm.in112
1 files changed, 69 insertions, 43 deletions
diff --git a/infrastructure/BoxPlatform.pm.in b/infrastructure/BoxPlatform.pm.in
index 59ab5d85..8f9daa81 100644
--- a/infrastructure/BoxPlatform.pm.in
+++ b/infrastructure/BoxPlatform.pm.in
@@ -1,34 +1,70 @@
package BoxPlatform;
use Exporter;
@ISA = qw/Exporter/;
-@EXPORT = qw/$build_os $target_os $make_command $bsd_make $platform_define $platform_cpu $gcc_v3 $product_version $product_name $install_into_dir $sub_make_options $platform_compile_line_extra $platform_link_line_extra $platform_lib_files $platform_exe_ext $target_windows/;
+@EXPORT = qw/$build_os $build_os_ver $ac_target $ac_target_cpu $ac_target_vendor $ac_target_os $make_command $bsd_make $platform_define $platform_cpu $gcc_v3 $product_version $product_name $install_into_dir $sub_make_options $platform_compile_line_extra $platform_link_line_extra $platform_lib_files $platform_exe_ext $target_windows $target_msvc/;
BEGIN
{
# which OS are we building under?
- $target_os = '@target_os@';
+ $ac_target = '@target@';
+ $ac_target_cpu = '@target_cpu@';
+ $ac_target_vendor = '@target_vendor@';
+ $ac_target_os = '@target_os@';
$target_windows = 0;
- $target_windows = 1 if $target_os =~ m'^mingw32'
- or $target_os eq "winnt";
if ($^O eq "MSWin32" and not -x "/usr/bin/uname")
{
+ $target_windows = 1;
+ $target_msvc = 1;
$build_os = "winnt";
+ eval "use Win32";
+ $build_os_ver = Win32::GetOSName();
}
else
{
+ $target_windows = 1 if $ac_target_os =~ m'^mingw32'
+ or $ac_target_os eq "winnt";
+ $target_msvc = 0;
$build_os = `uname`;
+ $build_os_ver = `uname -r`;
chomp $build_os;
+ chomp $build_os_ver;
}
# Cygwin Builds usually something like CYGWIN_NT-5.0, CYGWIN_NT-5.1
# Box Backup tried on Win2000,XP only :)
$build_os = 'CYGWIN' if $build_os =~ m/CYGWIN/;
+ $build_os = 'MINGW32' if $build_os =~ m/MINGW32/;
- $make_command = ($build_os eq 'Darwin') ? 'bsdmake' : ($build_os eq 'SunOS') ? 'gmake' : 'make';
+ if ($build_os eq 'Darwin') {
+ $xcode_ver = `xcodebuild -version | awk '/^Xcode/ {print \$2}'`
+ }
- $bsd_make = ($build_os ne 'Linux' && $build_os ne 'CYGWIN' &&
- $build_os ne "SunOS" && $build_os ne 'GNU/kFreeBSD');
+ if ($build_os eq 'Darwin' and $xcode_ver < 4)
+ {
+ $make_command = 'bsdmake';
+ $bsd_make = 1;
+ }
+ elsif ($build_os eq 'SunOS')
+ {
+ if ($build_os_ver <= 5.10)
+ {
+ $make_command = 'gmake';
+ $bsd_make = 0;
+ }
+ else
+ {
+ $make_command = 'bmake';
+ $bsd_make = 1;
+ }
+ }
+ else
+ {
+ $make_command = 'make';
+ $bsd_make = ($build_os ne 'Linux' && $build_os ne 'CYGWIN' &&
+ $build_os ne "MINGW32" && $build_os ne 'GNU/kFreeBSD' &&
+ $build_os ne 'Darwin');
+ }
# blank extra flags by default
$platform_compile_line_extra = '';
@@ -50,49 +86,39 @@ BEGIN
if($product_version =~ /USE_SVN_VERSION/)
{
- # for developers, use SVN version
- my $svnversion = `svnversion .`;
- chomp $svnversion;
- $svnversion =~ tr/0-9A-Za-z/_/c;
- open INFO,'svn info . |';
- my $svnurl;
- while(<INFO>)
- {
- if(m/^URL: (.+?)[\n\r]+/)
- {
- $svnurl = $1
- }
- }
- close INFO;
-
- my $svndir;
- if ($svnurl =~ m!/box/(.+)$!)
- {
- $svndir = $1;
- }
- elsif ($svnurl =~ m'/(boxi/.+)/boxi/boxbackup')
- {
- $svndir = $1;
- }
-
- $svndir =~ tr/0-9A-Za-z/_/c;
- $product_version =~ s/USE_SVN_VERSION/$svndir.'_'.$svnversion/e;
+ # for developers, use Git version (SVN is no more):
+ my $gitversion = `git rev-parse HEAD`;
+ chomp $gitversion;
+ $product_version =~ s/USE_SVN_VERSION/git_$gitversion/;
}
# where to put the files
$install_into_dir = '@sbindir_expanded@';
+ # see how many processors there are, and set make flags accordingly
+ if($build_os eq 'Darwin' || $build_os =~ /(Free|Net|Open)BSD/)
+ {
+ $cpus = `sysctl -n hw.ncpu`;
+ }
+ elsif($build_os eq 'Linux')
+ {
+ $cpus = `grep -c ^processor /proc/cpuinfo`;
+ }
+ elsif($build_os eq 'SunOS')
+ {
+ $cpus = `psrinfo -p`;
+ }
+
+ chomp $cpus;
+ if($cpus > 1)
+ {
+ print STDERR "$cpus processors detected, will set make to perform concurrent jobs\n";
+ $sub_make_options = ' -j '.($cpus + 1);
+ }
+
# if it's Darwin,
if($build_os eq 'Darwin')
{
- # see how many processors there are, and set make flags accordingly
- my $cpus = `sysctl hw.ncpu`;
- if($cpus =~ m/hw.ncpu:\s(\d+)/ && $1 > 1)
- {
- print STDERR "$1 processors detected, will set make to perform concurrent jobs\n";
- $sub_make_options = ' -j '.($1 + 1);
- }
-
# test for fink installation
if(-d '/sw/include' && -d '/sw/lib')
{
@@ -114,7 +140,7 @@ sub make_flag
sub parcel_root
{
- my $tos = $_[1] || $target_os;
+ my $tos = $_[1] || $ac_target;
return $product_name.'-'.$product_version.'-'.$_[0].'-'.$tos;
}