#!/usr/bin/env perl =head1 NAME distccgrove - populate /usr/lib/distcc with links for using mingw32 gcc/g++ crosscompilers =cut use warnings; use strict; my $DEBUGGING = 0; use Path::Class; # on Debian & alikes do "apt-get install libpath-class-perl" as su # use Path::Class::File::Stat; use constant Externalcmd => q|dpkg -L mingw32|; # change if necessary use constant Distcclibpathprefix => q|/usr/lib/distcc|; # ditto use constant Distccbinpath => q|/usr/bin/distcc|; # ditto use constant Prefixpath => q|/usr/bin/|; # ditto -- DO have trailing "/" my $leading = Prefixpath; my $distccbin = file(Distccbinpath); my $distcc_rel = $distccbin->relative(Distcclibpathprefix); print "Relative path to distcc binary is $distcc_rel\n"; my (@compiler, @unversioned, @isversioned); @compiler = grep $_=~ m%^ $leading # leading path ( # capt filename part i\d86-mingw32 # like "i586-mingw32" (?:msvc)? # in the Debian plg, always expect to see this - # hyphen between "arch" part and "app" part (g[+c]{2} # g++ or gcc (-[-.0-9]{2,})? # possible hyphen and version number "tail" ))$ # end of capt, end of string %x && do { if ($3) { push @isversioned, file($1); warn "Missing file: $isversioned[$#isversioned]\n" , " ...Distcc is not installed correctly!" unless -f $leading.$isversioned[$#isversioned]; } else { push @unversioned, file($1); warn "Missing file: $unversioned[$#unversioned]\n" , " ...Distcc is not installed correctly!" unless -f $leading.$unversioned[$#unversioned]; } } => qx/@{[Externalcmd]}/; chomp @compiler; printf "%-28s %s\n" => "Found compiler", $_ for @compiler; printf "%-28s %s\n" => "Found versioned compiler", $_ for @isversioned; printf "%-28s %s\n" => "Found unversioned compiler", $_ for @unversioned; chdir(Distcclibpathprefix) or die "Cannot chdir to ", Distcclibpathprefix; for my $cc_name (@isversioned, @unversioned) { print "Building link grove for variations on $cc_name\n"; for my $pcmachine ("-pc", "") { print "\n"; YOLOLO: for my $inTel_gener (3,4,5,6) { my $linkfile; my $spt = substr($cc_name,4); my $sans_crtname = file("i".$inTel_gener."86".$pcmachine.$spt); my $with_crtname = file("i".$inTel_gener."86".$pcmachine.$spt); $sans_crtname =~ s{-mingw32msvc-} {-mingw32-}; $linkfile = file(Distcclibpathprefix, $sans_crtname); # without "msvc" # unlink $linkfile and print "\nunlinked $linkfile"; next YOLOLO; if (! $DEBUGGING) { -l $linkfile && print "symlink $linkfile already in place\n" || # test if a link for this is already there, if not do: ( symlink($distcc_rel, $linkfile) and print "Made symlink for $sans_crtname\n" ); } else { print "Would be making symlink for $sans_crtname to $distcc_rel\n"; } $linkfile = file(Distcclibpathprefix, $with_crtname); # with "msvc" # unlink $linkfile and print "\nunlinked $linkfile"; next YOLOLO; if (! $DEBUGGING) { -l $linkfile && print "symlink $linkfile already in place\n" || # test if a link for this is already there, if not do: ( symlink($distcc_rel, $linkfile) and print "Made symlink for $with_crtname\n" ); } else { print "Would be making symlink for $with_crtname to $distcc_rel\n"; } print "\n"; } } print "\n"; } __END__ =head1 SYNOPSIS C<$ distccgrove> =head1 DESCRIPTION The distcc distributed C/C++ compiler client-server software allows machines to share compilation tasks across the network. The mingw32 Debian GNU/Linux package allows a GNU/Linux host to "cross-compile" C and C++ source code to binaries that will run (be "hosted on") MS Windows systems. This script is a utility to assist in setting up a set of "symlink groves" that will facilitate the use of multiple hosts running distccd (the daemon server end of distcc) in compiling for MinGW. Since there are complications that can result from the various names a cross compiler might be installed as or invoked as, this utility creates a number of permutations of the possible names by which the compiler might be looked for (by distcc). It iterates through these possible permutations and for each one it creates a symlink under the distcc lib dir (usually C if the Debian GNU/Linux distcc package is the way in which distcc has been provided), each one pointing at ../../bin/distcc. It is expected that this utility will only need to be run once after the mingw32 package is installed or updated. =head1 AUTHOR Soren Andersen =head1 COPYRIGHT AND LICENSE This program is Copyright (C) 2007 Soren Andersen, Some Rights Reserved. This work is licensed under the Creative Commons "Attribution" License (version 3.0) To view a copy of this license, visit L or send a letter to Creative Commons 171 2nd Street, Suite 300 San Francisco, California, 94105 USA =cut