summaryrefslogtreecommitdiff
path: root/infrastructure/BoxPlatform.pm.in
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2006-07-27 23:18:35 +0000
committerChris Wilson <chris+github@qwirx.com>2006-07-27 23:18:35 +0000
commitc7662795f519d2b6797e4b1ac7fa4a22afa26310 (patch)
treeb1737dfa78d8e7bfb2d5a7e9831bab91869ade97 /infrastructure/BoxPlatform.pm.in
parenta85b710c46ec79e968da349304f30945cb9b7bc1 (diff)
* merge
- This is my current patch queue. I think that all of these are safe to apply. This is just under half of the pending changes in chris/general (the easy half).
Diffstat (limited to 'infrastructure/BoxPlatform.pm.in')
-rw-r--r--infrastructure/BoxPlatform.pm.in64
1 files changed, 57 insertions, 7 deletions
diff --git a/infrastructure/BoxPlatform.pm.in b/infrastructure/BoxPlatform.pm.in
index 04e6cda4..8297b93b 100644
--- a/infrastructure/BoxPlatform.pm.in
+++ b/infrastructure/BoxPlatform.pm.in
@@ -1,16 +1,30 @@
package BoxPlatform;
use Exporter;
@ISA = qw/Exporter/;
-@EXPORT = qw/$build_os $build_cpu $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/;
+@EXPORT = qw/$build_os $build_cpu $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 update_if_changed/;
BEGIN
{
# which OS are we building under?
- $build_os = `uname`;
- chomp $build_os;
- $build_cpu = `uname -p`;
- chomp $build_cpu;
+ $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")
+ {
+ $build_os = "winnt";
+ $build_cpu = "ix86";
+ }
+ else
+ {
+ $build_os = `uname`;
+ chomp $build_os;
+ $build_cpu = `uname -m`;
+ chomp $build_cpu;
+ }
+
# Cygwin Builds usually something like CYGWIN_NT-5.0, CYGWIN_NT-5.1
# Box Backup tried on Win2000,XP only :)
@@ -24,11 +38,18 @@ BEGIN
$platform_compile_line_extra =~ s/ -O2//;
$platform_link_line_extra = '@LDFLAGS@';
$platform_lib_files = '@LIBS@';
- $target_os = '@target_os@';
$platform_exe_ext = '@EXEEXT@';
# get version
- open VERSION,"VERSION.txt" or die "VERSION.txt: $!";
+ if (! -r "VERSION.txt" and -r "../../VERSION.txt")
+ {
+ open VERSION,"../../VERSION.txt" or die "../../VERSION.txt: $!";
+ }
+ else
+ {
+ open VERSION,"VERSION.txt" or die "VERSION.txt: $!";
+ }
+
$product_version = <VERSION>;
chomp $product_version;
$product_name = <VERSION>;
@@ -89,5 +110,34 @@ sub make_flag
return $_[0].'=1';
}
+sub update_if_changed ($)
+{
+ my ($file) = @_;
+ die "$file.new: not found" unless -r "$file.new";
+
+ if (-r $file)
+ {
+ die "$file.new: not found" unless -r "$file.new";
+ if (system("diff --brief $file $file.new") == 0)
+ {
+ unlink "$file.new";
+ return;
+ }
+ }
+
+ if (system("cp $file.new $file") != 0)
+ {
+ die "failed to copy $file.new to $file";
+ }
+
+ if (system("diff --brief $file $file.new") != 0)
+ {
+ die "$file and $file.new are still different";
+ }
+
+ unlink "$file.new";
+ return;
+}
+
1;