forked from ariya/phantomjs
/
build-mac.sh
executable file
·135 lines (106 loc) · 3.54 KB
/
build-mac.sh
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/bin/bash
QT_VERSION=4.8.0
QT_FOLDER=Qt-$QT_VERSION
QT_TARBALL=qt-everywhere-opensource-src-$QT_VERSION.tar.gz
# Tip: change this to local/shared mirror
QT_URL=http://get.qt.nokia.com/qt/source/$QT_TARBALL
COMPILE_JOBS=4
# Step 1: Download Qt source tarball
# Note: only if it does not exist yet in the current directory
if [ ! -f $QT_TARBALL ]
then
echo "Downloading Qt $QT_VERSION from Nokia. Please wait..."
if ! curl -C - -O -S $QT_URL
then
echo
echo "Fatal error: fail to download from $QT_URL !"
exit 1
fi
fi
# Step 2: Extract Qt source
[ -d $QT_FOLDER ] && rm -rf $QT_FOLDER
echo "Extracting Qt $QT_VERSION source tarball..."
echo
tar xzf $QT_TARBALL
mv qt-everywhere-opensource-src-$QT_VERSION Qt-$QT_VERSION
# Step 3: Apply some patches
cd $QT_FOLDER
patch configure ../allow-static-qtwebkit.patch
patch -p1 < ../qapplication_skip_qtmenu.patch
patch -p1 < ../disable_quicktime_video.patch
patch -p1 < ../qt48_enable_file_input_click.patch
rm -rf src/3rdparty/webkit/Source/WebKit/qt/tests
# Step 4: Build Qt
echo "Building Qt $QT_VERSION. Please wait..."
echo
CFG=''
CFG+=' -opensource' # Use the open-source license
CFG+=' -confirm-license' # Silently acknowledge the license confirmation
CFG+=' -release' # Build only for release (no debugging support)
CFG+=' -static' # Compile for static libraries
CFG+=' -fast' # Accelerate Makefiles generation
CFG+=' -nomake demos' # Don't build with the demos
CFG+=' -nomake docs' # Don't generate the documentatio
CFG+=' -nomake examples' # Don't build any examples
CFG+=' -nomake translations' # Ignore the translations
CFG+=' -nomake tools' # Don't built the tools
CFG+=' -no-exceptions' # Don't use C++ exception
CFG+=' -no-stl' # No need for STL compatibility
# Irrelevant Qt features
CFG+=' -no-libmng'
CFG+=' -no-libtiff'
# Unnecessary Qt modules
CFG+=' -no-declarative'
CFG+=' -no-multimedia'
CFG+=' -no-opengl'
CFG+=' -no-openvg'
CFG+=' -no-phonon'
CFG+=' -no-qt3support'
CFG+=' -no-script'
CFG+=' -no-scripttools'
CFG+=' -no-svg'
CFG+=' -no-xmlpatterns'
# Sets the default graphics system to the raster engine
CFG+=' -graphicssystem raster'
# Mac
CFG+=' -cocoa' # Cocoa only, ignore Carbon
CFG+=' -no-cups' # Disable CUPS support
CFG+=' -no-dwarf2'
# Unix
CFG+=' -no-dbus' # Disable D-Bus feature
CFG+=' -no-glib' # No need for Glib integration
CFG+=' -no-gstreamer' # Turn off GStreamer support
CFG+=' -no-gtkstyle' # Disable theming integration with Gtk+
CFG+=' -no-sm'
CFG+=' -no-xinerama'
CFG+=' -no-xkb'
# Use the bundled libraries, vs system-installed
CFG+=' -qt-libjpeg'
CFG+=' -qt-libpng'
# Useless styles
CFG+=' -D QT_NO_STYLESHEET'
CFG+=' -D QT_NO_STYLE_CDE'
CFG+=' -D QT_NO_STYLE_CLEANLOOKS'
CFG+=' -D QT_NO_STYLE_MOTIF'
./configure -prefix $PWD $CFG -arch x86
make -j$COMPILE_JOBS
cd ..
# Extra step to ensure the static libraries are found
cp -rp $QT_FOLDER/src/3rdparty/webkit/Source/JavaScriptCore/release/* $QT_FOLDER/lib
cp -rp $QT_FOLDER/src/3rdparty/webkit/Source/WebCore/release/* $QT_FOLDER/lib
# Step 5: Build PhantomJS
echo "Building PhantomJS. Please wait..."
echo
cd ..
[ -f Makefile ] && make distclean
deploy/$QT_FOLDER/bin/qmake
make -j$COMPILE_JOBS
# Step 6: Prepare for deployment
echo "Compressing PhantomJS executable..."
echo
strip bin/phantomjs
if [ `command -v upx` ]; then
upx -9 bin/phantomjs
else
echo "You don't have UPX. Consider installing it to reduce the executable size."
fi