1#!/usr/bin/perl 2# 3# Copyright (c) 2006 Apple Computer, Inc. All rights reserved. 4# 5# @APPLE_LICENSE_HEADER_START@ 6# 7# This file contains Original Code and/or Modifications of Original Code 8# as defined in and that are subject to the Apple Public Source License 9# Version 2.0 (the 'License'). You may not use this file except in 10# compliance with the License. Please obtain a copy of the License at 11# http://www.opensource.apple.com/apsl/ and read it before using this 12# file. 13# 14# The Original Code and all software distributed under the License are 15# distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 16# EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 17# INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 18# FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 19# Please see the License for the specific language governing rights and 20# limitations under the License. 21# 22# @APPLE_LICENSE_HEADER_END@ 23 24use strict; 25 26# exec make, but first run make with a target of no64. If it outputs YES, 27# then remove 64-bit arches from RC_CFLAGS and RC_ARCHS, remover RC_xxx, 28# where xxx is a 64-bit architecture. If there are no archs left, just 29# return success. 30 31my $dir = '.'; 32 33for(0...$#ARGV) { 34 if($ARGV[$_] eq '-C') { 35 $dir = $ARGV[$_ + 1]; 36 last; 37 } 38} 39 40my $no64 = `make -C $dir no64`; 41chomp($no64); 42 43if($no64 eq 'YES') { 44 my @archs; 45 my @arch64; 46 my @cflags; 47 my $arch = 0; 48 for(split(" ", $ENV{RC_CFLAGS})) { 49 if($arch) { 50 if(/64/) { 51 push(@arch64, $_); 52 } else { 53 push(@cflags, '-arch', $_); 54 push(@archs, $_); 55 } 56 $arch = 0; 57 next; 58 } 59 if($_ eq '-arch') { 60 $arch = 1; 61 next; 62 } 63 push(@cflags, $_); 64 } 65 unless(scalar(@archs) > 0) { 66 print "Not building:\tmake @ARGV\n"; 67 exit 0; 68 } 69 $ENV{RC_CFLAGS} = join(' ', @cflags); 70 $ENV{RC_ARCHS} = join(' ', @archs); 71 push(@ARGV, "RC_CFLAGS=$ENV{RC_CFLAGS}", "RC_ARCHS=$ENV{RC_ARCHS}"); 72 for(@arch64) { 73 delete($ENV{"RC_$_"}); 74 push(@ARGV, "RC_$_="); 75 } 76} 77print "make @ARGV\n"; 78exec {'make'} 'make', @ARGV; 79