forked from cgreen-devs/cgreen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfatify
executable file
·49 lines (45 loc) · 1.74 KB
/
fatify
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
38
39
40
41
42
43
44
45
46
47
48
49
#! /bin/sh
#
# This script is a part of Cgreen and creates fat versions of
# cgreen-runner and libcgreen.dylib which is necessary if you are
# using e.g. MacPorts gcc which don't have suppport for fat binaries
# built in.
#
# It ensures that both architectures are built, saving them under
# descriptive names and then uses lipo to merge them into fat
# binaries.
#
# At this point there is no way to run this as part of the CMake build
# and install, and since the install target of CMake always rebuilds
# you can't install them except with manual copying.
#
# /thoni56
#
function buildfor() {
cmake -DCMAKE_OSX_ARCHITECTURES=$1 ..
make
cp tools/cgreen-runner tools/cgreen-runner.$1
cp src/libcgreen.dylib src/libcgreen.$1.dylib
}
# Ensure there is at least a build directory
if [ ! -d "build" ]; then
mkdir build
fi
cd build
buildfor i386
buildfor x86_64
lipo -create -o tools/cgreen-runner.fat -arch i386 tools/cgreen-runner.i386 -arch x86_64 tools/cgreen-runner.x86_64
lipo -create -o src/libcgreen.dylib.fat -arch i386 src/libcgreen.i386.dylib -arch x86_64 src/libcgreen.x86_64.dylib
if [ -z "$1" ]; then
echo "Fat binaries build for build/tools/cgreen-runner and build/src/libcgreen.dylib"
echo "Install with:"
echo " sudo cp build/tools/cgreen-runner.fat <installpath>/bin/cgreen-runner"
echo " sudo cp src/libcgreen.dylib.fat <installpath>/lib/libcgreen.dylib"
echo
echo "If <installpath> is the same for bin and lib, such as '/usr/local',"
echo "you can give that as an argument and the script will do that for you."
else
echo "Installing 'cgreen-runner' in $1/bin and 'libcgreen.dylib' in $1/lib..."
sudo cp tools/cgreen-runner.fat $1/bin/cgreen-runner
sudo cp src/libcgreen.dylib.fat $1/lib/libcgreen.dylib
fi