]>
git.saurik.com Git - apple/xnu.git/blob - libsyscall/xcodescripts/compile-syscalls.pl
3 # Copyright (c) 2010 Apple Inc. All rights reserved.
5 # @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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. The rights granted to you under the License
11 # may not be used to create, or enable the creation or redistribution of,
12 # unlawful or unlicensed copies of an Apple operating system, or to
13 # circumvent, violate, or enable the circumvention or violation of, any
14 # terms of an Apple operating system software license agreement.
16 # Please obtain a copy of the License at
17 # http://www.opensource.apple.com/apsl/ and read it before using this file.
19 # The Original Code and all software distributed under the License are
20 # distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
21 # EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
22 # INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
23 # FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
24 # Please see the License for the specific language governing rights and
25 # limitations under the License.
27 # @APPLE_OSREFERENCE_LICENSE_HEADER_END@
36 use File
::Basename
();
38 my $basename = File
::Basename
::basename
($0);
41 print "$basename: <source list> <output archive>";
45 usage
unless scalar(@ARGV) == 2;
47 my $sourceList = $ARGV[0];
48 my $outputFile = $ARGV[1];
50 my $f = IO
::File-
>new($sourceList, 'r');
51 die "$basename: $sourceList: $!\n" unless defined($f);
54 my @archs = split / /, $ENV{"ARCHS"};
61 chomp(my $CC = `xcrun -sdk "$ENV{'SDKROOT'}" -find cc`);
63 "-x assembler-with-cpp",
65 "-isysroot", $ENV{'SDKROOT'} || "/",
66 "-I".$ENV{"SDKROOT"}."/System/Library/Frameworks/System.framework/PrivateHeaders",
69 chomp(my $LIBTOOL = `xcrun -sdk "$ENV{'SDKROOT'}" -find libtool`);
75 for my $arch (@archs) {
76 push(@CFLAGS, "-arch $arch");
80 my $jobs = `sysctl -n hw.ncpu` + 2;
82 for my $src (@sources) {
87 printf "wait exited with -1 (no children) and exhausted allowed jobs. Exiting.\n";
92 printf "$CC exited with value %d\n", $? >> 8;
97 (my $o = $src) =~ s/\.s$/\.o/;
98 my $compileCommand = "$CC " . join(' ', @CFLAGS) . " -o $o $src";
99 printf $compileCommand . "\n";
104 exec($compileCommand);
111 printf "$CC exited with value %d\n", $? >> 8;
116 printf "Finished assembly, beginning link.\n";
120 if (-f
$outputFile) {
124 my $linkCommand = "$LIBTOOL " . join(' ', @LIBTOOLFLAGS) . " -o $outputFile " . join(' ', @objects);
126 printf $linkCommand . "\n";
127 system($linkCommand);
129 print "$LIBTOOL exited with value %d\n", $? >> 8;