+ # We are creating files for mass distribution, so work harder to make smaller files.
+ $ENV{GZIP} = -9;
+ $ENV{BZIP2} = -9;
+ # xz documents minimum file sizes for levels higher than -6 to be useful and each
+ # requires more RAM on the decompressing system. Exim tarball currently 24MiB so
+ # using -8.
+ $ENV{XZ_DEFAULTS} = -8;
+
+ GetOptions(
+ $context,
+ qw(workspace|tmp=s website_base|webgen_base=s tar_cmd|tar-cmd=s make_cmd|make-cmd=s
+ docs|build-docs! web|build-web! sizes!
+ delete! cleanup! quick|quick-release! minimal),
+ 'sign!' => \$context->{gpg}{sign},
+ 'key=s' => \$context->{gpg}{key},
+ 'verbose!' => \$verbose,
+ 'compressors=s@' => sub {
+ die "$0: can't parse compressors string `$_[1]'\n" unless $_[1] =~ /^[+=-]?\w+(?:[+=-]\w+)*$/;
+ while ($_[1] =~ /(?<act>[+=-])?(?<name>\w+)\b/g) {
+ die "$0: Unknown compressor $+{name}"
+ unless $context->{compressors}{$+{name}};
+ if (not defined $+{act} or $+{act} eq '=') {
+ $_->{use} = 0
+ for values %{$context->{compressors}};
+ $context->{compressors}{$+{name}}{use}++;
+ }
+ elsif ($+{act} eq '+') { $context->{compressors}{$+{name}}{use}++; }
+ elsif ($+{act} eq '-') { $context->{compressors}{$+{name}}{use}--; }
+ }
+ },
+ 'debug:s' => \$debug,
+ 'quick' => sub { $context->{web}--; $context->{quick} = 1 },
+ 'help|?' => sub { pod2usage(-verbose => 1, -exit => 0) },
+ 'man!' => sub { pod2usage(-verbose => 2, -exit => 0, -noperldoc => system('perldoc -V >/dev/null 2>&1')) },
+ ) and (@ARGV == 2 or ($context->{quick} and @ARGV >= 1))
+ or pod2usage;
+
+ -f '.exim-project-root'
+ or die "$ME: please call this script from the root of the Exim project sources\n";
+
+ $context->{OUTDIR} = pop @ARGV;
+
+ if ($context->{gpg}{sign}) {
+ $context->{gpg}{key} //= do { chomp($_ = qx/git config user.signingkey/); $_ }
+ || $ENV{EXIM_KEY}
+ || do {
+ warn "$ME: No GPG key, using default\n";
+ undef;
+ }
+ }
+
+
+ warn "$ME: changed umask to 022\n" if umask(022) != 022;
+
+ $context->check_version(shift); # may be undef for a quick release