forked from ghc-ios/ghc-ios-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharm-apple-darwin10-ld
executable file
·37 lines (28 loc) · 1.4 KB
/
arm-apple-darwin10-ld
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/sh
TARGET_PLATFORM=`xcrun --show-sdk-platform-path --sdk iphoneos`
TARGET_BIN=`xcrun --show-sdk-platform-path --sdk iphoneos`/Developer/usr/bin
TARGET_LD=$TARGET_BIN/ld
TARGET_LDFLAGS="-L$TARGET_PLATFORM/usr/lib/ -ios_version_min 7.0"
# echo "LINKING WITH: $@"
args=$@
# Check if we're building an object file by looking for "-o file.o", and find its filename
# sed's -E allows extended regexes (cleaner syntax), -n suppresses non-matching input, the |p flag prints matches.
outFileName=$(echo "$args" | sed -En 's|.*-o ([^.]*)\.o.*|\1|p')
# Only need lipo when we're building object files
if [ -n "$outFileName" ]
then
# Create filename variants for armV7 and armV7s
fileNameForArmv7=$outFileName-armv7
fileNameForArmv7s=$outFileName-armv7s
# Call gcc twice, once for each architecture, outputting to our filename variants
$TARGET_LD $TARGET_LDFLAGS -arch armv7 ${args//$outFileName.o/$fileNameForArmv7.o}
$TARGET_LD $TARGET_LDFLAGS -arch armv7s ${args//$outFileName.o/$fileNameForArmv7s.o}
# Lipo the two filename variants together
lipo $fileNameForArmv7.o $fileNameForArmv7s.o -create -output $outFileName.o
# Clean up
rm $fileNameForArmv7.o $fileNameForArmv7s.o
else
# echo "Non-object-generating link command: $TARGET_LD $TARGET_LDFLAGS -arch armv7s $@"
# If not building object files, call regularly. Still need to include an arch to configure ld for arm mode.
exec $TARGET_LD $TARGET_LDFLAGS -arch armv7s "$@"
fi