Skip to content

Commit

Permalink
Improve check for used toolchain on macOS
Browse files Browse the repository at this point in the history
Don't strictly test for make compliance because XCode is using GNU make
though earlier version of it. This shouldn't break the build process
unless a feature from later version of GNU make would make it into the
Makefile which won't work in XCode's version of make. But this would
draw the whole XCode build broken anyway.

Still, to be on the safe side, this commit makes Configure.pl forcingly
choose /usr/bin/make (which always belongs to XCode) unless GNU
toolchain is requested.
  • Loading branch information
vrurg committed Mar 8, 2019
1 parent bb2dc66 commit 49c1eb0
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions Configure.pl
Expand Up @@ -170,10 +170,17 @@ sub uniq {
# If we're in macOS, let's verify that the toolchain is consistent.
if ($^O eq 'darwin') {
my $gnu_count = 0;
my $gnu_toolchain = exists $args{toolschain} && $args{toolschain} eq 'gnu';

unless ($gnu_toolchain) {
# When XCode toolchain is used then force use of XCode's make if
# available.
$config{make} = '/usr/bin/make' if -x '/usr/bin/make';
}

# Here are the tools that seem to cause trouble.
# If you see other ones, please add them to this list.
my @check_tools = qw/ar cc ld make/;
my @check_tools = qw/ar cc ld/;
for my $tool (map { `which $_` } @config{@check_tools}) {
chomp $tool;
system "grep -b 'gnu' '$tool'"; # Apple utilities don't match `gnu`
Expand All @@ -183,20 +190,14 @@ sub uniq {
}

## For a GNU toolchain, make sure that they're all GNU.
if (exists $args{toolchain} &&
$args{toolchain} eq 'gnu' &&
$gnu_count != scalar @check_tools)
{
if ($gnu_toolchain && $gnu_count != scalar @check_tools) {
print "\nNot all tools in the toolchain are GNU. Please correct this and retry.\n"
. "See README.markdown for more details.\n\n";
exit -1;
}

## Otherwise, make sure that none of them are GNU
elsif ((!exists $args{toolchain} ||
$args{toolchain} ne 'gnu' ) &&
$gnu_count != 0)
{
elsif (!$gnu_toolchain && $gnu_count != 0) {
print "\nGNU tools detected, despite this not being a GNU-oriented build.\n"
." Please correct this and retry. See README.markdown for more details.\n\n";
exit -1;
Expand Down

0 comments on commit 49c1eb0

Please sign in to comment.