#!@PERL@ use strict; use lib 'infrastructure'; use BoxPlatform; my @parcels; my %parcel_contents; sub starts_with ($$) { my ($string,$expected) = @_; return substr($string, 0, length $expected) eq $expected; } sub os_matches ($) { my ($prefix_string) = @_; my @prefixes = split m'\,', $prefix_string; foreach my $prefix (@prefixes) { return 1 if starts_with($build_os, $prefix); return 1 if starts_with($target_os, $prefix); } return 0; } my $copy_command = "cp -p"; if ($build_os eq 'CYGWIN') { $copy_command = "cp -pu"; # faster } open PARCELS,"parcels.txt" or die "Can't open parcels file"; { my $cur_parcel = ''; while() { chomp; s/#.+\Z//; s/\s+\Z//; s/\s+/ /g; next unless m/\S/; # omit bits on some platforms? next if m/\AEND-OMIT/; if(m/\AOMIT:(.+)/) { if (os_matches($1)) { while() { last if m/\AEND-OMIT/; } } next; } if (m'\AONLY:(.+)') { if (not os_matches($1)) { while () { last if m'\AEND-ONLY'; } } next; } next if (m'\AEND-ONLY'); if (m'\AEXCEPT:(.+)') { if (os_matches($1)) { while () { last if m'\AEND-EXCEPT'; } } next; } next if (m'\AEND-EXCEPT'); # new parcel, or a new parcel definition? if(m/\A\s+(.+)\Z/) { push @{$parcel_contents{$cur_parcel}},$1 } else { $cur_parcel = $_; push @parcels,$_; } } } close PARCELS; # create parcels directory mkdir "parcels",0755; mkdir "parcels/scripts",0755; # write master makefile open MAKE,">Makefile" or die "Can't open master Makefile for writing"; print MAKE <<__E; # # AUTOMATICALLY GENERATED FILE # do not edit! # # MAKE = $make_command __E print MAKE "all:\t",join(' ',map {"build-".$_} @parcels),"\n\n"; print MAKE <<__END_OF_FRAGMENT; test: release/common/test release/common/test: ./runtest.pl ALL release .PHONY: docs docs: cd docs; \$(MAKE) __END_OF_FRAGMENT my $release_flag = BoxPlatform::make_flag('RELEASE'); my @clean_deps; for my $parcel (@parcels) { my $version = BoxPlatform::parcel_root($parcel); my $target = BoxPlatform::parcel_target($parcel); my $dir = BoxPlatform::parcel_dir($parcel); my @parcel_deps; unless ($target_windows) { open SCRIPT,">parcels/scripts/install-$parcel" or die "Can't open installer script for $parcel for writing"; print SCRIPT "#!/bin/sh\n\n"; } for(@{$parcel_contents{$parcel}}) { my @args = split /\s+/; my ($type,$name,$dest) = @args; my $optional = 0; my $install = 1; if ($type eq 'optional') { $optional = 1; shift @args; ($type,$name,$dest) = @args; } if ($type eq 'noinstall') { $install = 0; shift @args; ($type,$name,$dest) = @args; } if($type eq 'bin') { my $exeext = $platform_exe_ext; print MAKE < $root.tgz )\n"; print MAKE "\n"; unless ($target_windows) { print MAKE "install-$parcel:\n"; print MAKE "\t(cd $dir; ./install-$parcel)\n\n"; } } print MAKE <local/install.msg" or die "Can't open install message file for writing"; print INSTALLMSG <<__E; Parcels need to be installed separately, and as root. Type one of the following: __E for(@parcels) { print INSTALLMSG " $make_command install-".$_."\n"; } print INSTALLMSG "\n"; close INSTALLMSG;