#!/usr/bin/perl use warnings; use strict; use FindBin; use lib "$FindBin::Bin"; use do_common; # ## ### #### Initialization ### ## # my $type = shift @ARGV; die "Bad arguments" unless defined($type); my $resume = shift @ARGV; my $config_only = defined($resume) && ($resume eq 'configonly'); my $clean_only = defined($resume) && ($resume eq 'cleanonly'); $resume = undef if $config_only || $clean_only; chdir($basedir) or die "Failed to change directory to $basedir: $!\n"; open(LOG, '>', 'build.log') or die "Failed to open log file for writing: $!\n"; open(FH, '>&', STDOUT) or die "Failed to reopen STDOUT: $!\n"; open(STDOUT, '>&', LOG) or die "Failed to redirect STDOUT: $!\n"; open(STDERR, '>&', LOG) or die "Failed to redirect STDERR: $!\n"; # ## ### #### Set up Environment Variables ### ## # $ENV{ACLOCAL_LOCALDIR} = "$prefix/share/aclocal"; system("mkdir -p $ENV{ACLOCAL_LOCALDIR}") and do { print FH "Failed to make aclocal directory.\n"; die }; if (defined($ENV{ACLOCAL}) && $ENV{ACLOCAL}) { $ENV{ACLOCAL} = "$ENV{ACLOCAL} -I $ENV{ACLOCAL_LOCALDIR}"; } else { $ENV{ACLOCAL} = "aclocal -I $ENV{ACLOCAL_LOCALDIR}"; } if (defined($ENV{PKG_CONFIG_PATH}) && $ENV{PKG_CONFIG_PATH}) { $ENV{PKG_CONFIG_PATH} = "$prefix/lib/pkgconfig:$ENV{PKG_CONFIG_PATH}"; } else { $ENV{PKG_CONFIG_PATH} = "$prefix/lib/pkgconfig"; } unless (defined($ENV{FONTPATH}) && $ENV{FONTPATH}) { $ENV{FONTPATH}="$prefix/lib/X11/fonts/misc/,$prefix/lib/X11/fonts/Type1/,$prefix/lib/X11/fonts/75dpi/,$prefix/lib/X11/fonts/100dpi/,$prefix/lib/X11/fonts/cyrillic/,$prefix/lib/X11/fonts/TTF/"; } system("mkdir -p $prefix/var/log") and do { print FH "Failed to make var/log directory.\n"; die }; # ## ### #### Read configuration and perform build ### ## # my $ref = &read_config($basedir, "$FindBin::Bin/do_build.conf", $type); for (@$ref) { my ($dir, $args) = @$_; # Check resume (second argument) if (defined($resume) && $resume eq $dir) { $resume = undef; } elsif (defined($resume)) { next; } # Change directories chdir("$basedir/$dir") or do { print FH "Failed to change directory to $basedir/$dir: $!\n"; die }; chomp(my $pwd = `pwd`); my $cmd; # Clean/configure unless ($args =~ /noclean/) { print FH "CLEAN in $pwd...\n"; $cmd = "sh autogen.sh --prefix=$prefix "; if (defined($mod_specific_configuration{$dir})) { $cmd .= $mod_specific_configuration{$dir}; } system($cmd) and do { print FH "ERROR: Autogen of '$dir' was UNSUCCESSFUL!!!\n"; die }; exit if $config_only; if ($clean_only) { system('make distclean') and do { print FH "ERROR: Clean of '$dir' was UNSUCCESSFUL!!!\n"; die }; next; } system('make clean') and do { print FH "ERROR: Clean of '$dir' was UNSUCCESSFUL!!!\n"; die }; } # Build print FH "MAKE in $pwd...\n"; system('make') and do { print FH "ERROR: Make of '$dir' was UNSUCCESSFUL!!!\n"; die }; # Install print FH "INSTALL in $pwd...\n"; my $target = 'install'; if ($args =~ /install:([\w-]+)/) { $target = $1; } system("make $target") and do { print FH "ERROR: Install of '$dir' was UNSUCCESSFUL!!!\n"; die }; if ($args =~ /distcheck/) { print FH "MAKE-DISTCHECK\n"; system('make distcheck') and do { print FH "ERROR: Make-Distcheck of libxcb was UNSUCCESSFUL!!!\n"; die }; } } close(FH); close(LOG); close(STDOUT); close(STDERR); exec("/sbin/fixfiles restore $prefix/bin");