Skip to content

Instantly share code, notes, and snippets.

@davefinster
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davefinster/4e89acb08f5610e007b9 to your computer and use it in GitHub Desktop.
Save davefinster/4e89acb08f5610e007b9 to your computer and use it in GitHub Desktop.
#!/bin/bash
#install a set of pre-req packages
sudo pkgin in build-essential git libX11 xproto xcb-proto xextproto inputproto checkperms renderproto libtool nbpatch kbproto xproto xcb-proto xextproto inputproto xineramaproto dri2proto glproto damageproto fixesproto xf86vidmodeproto xf86driproto randrproto freetype2 ghostscript libXrender urw-fonts libiconv libdrm
#clone from development
git clone --recursive https://github.com/wkhtmltopdf/wkhtmltopdf.git
cd wkhtmltopdf
cd qt
#fetch the set of patches
#this primarily includes the patches applied to vanilla Qt by
#the pkgsrc maintainers to get it to compile on SmartOS
#there are a few extras that address specific issues with the
#build process. those with 'custom' in the name were modified
#from their original to account for minor differences in the
#Qt source from the vanilla version
wget http://pkgsrc.seymourwhyte.com.au/patches.tar.gz
tar -zxvf patches.tar.gz
#start pkgsrc patches for SmartOS
patch -p0 < patches/patch-aa
patch -p0 < patches/patch-ab
patch -p0 < patches/patch-ac
patch -p0 < patches/patch-ad
patch -p0 < patches/patch-ae
patch -p0 < patches/patch-af
patch -p0 < patches/patch-ag
patch -p0 < patches/patch-ah
patch -p0 < patches/patch-ai
patch -p0 < patches/patch-aj
patch -p0 < patches/patch-ak
patch -p0 < patches/patch-al
patch -p0 < patches/patch-am
patch -p0 < patches/patch-an
patch -p0 < patches/patch-ao
patch -p0 < patches/patch-ap
patch -p0 < patches/patch-aq
patch -p0 < patches/patch-ar
patch -p0 < patches/patch-as
patch -p0 < patches/patch-au
patch -p0 < patches/patch-av
patch -p0 < patches/patch-aw
patch -p0 < patches/patch-ay
patch -p0 < patches/patch-ba
patch -p0 < patches/patch-bb
patch -p0 < patches/patch-bc
patch -p0 < patches/patch-bd
patch -p0 < patches/patch-be
patch -p0 < patches/patch-bf
patch -p0 < patches/patch-bg
patch -p0 < patches/patch-ca
patch -p0 < patches/patch-cb
patch -p0 < patches/patch-cg
patch -p0 < patches/patch-qmake_generators_makefile.cpp
patch -p0 < patches/patch-src_3rdparty_clucene_src_CLucene_search_FieldCacheImpl.cpp
patch -p0 < patches/patch-src_3rdparty_clucene_src_CLucene_util_Arrays.h
patch -p0 < patches/patch-src_3rdparty_javascriptcore_JavaScriptCore_runtime_Collector.cpp
patch -p0 < patches/patch-src_3rdparty_javascriptcore_JavaScriptCore_runtime_Structure.cpp
patch -p0 < patches/patch-src_3rdparty_javascriptcore_JavaScriptCore_runtime_Structure.h
patch -p0 < patches/patch-custom-src_3rdparty_javascriptcore_JavaScriptCore_wtf_HashTable.h
patch -p0 < patches/patch-src_3rdparty_javascriptcore_JavaScriptCore_wtf_RefCountedLeakCounter.h
patch -p0 < patches/patch-custom-src_3rdparty_javascriptcore_JavaScriptCore_wtf_Threading.h
patch -p0 < patches/patch-src_3rdparty_javascriptcore_JavaScriptCore_wtf_TypeTraits.h
patch -p0 < patches/patch-src_3rdparty_webkit_Source_JavaScriptCore_heap_MachineStackMarker.cpp
patch -p0 < patches/patch-src_3rdparty_webkit_Source_JavaScriptCore_heap_MarkedSpace.cpp
patch -p0 < patches/patch-src_3rdparty_webkit_Source_JavaScriptCore_heap_MarkedSpace.h
patch -p0 < patches/patch-src_3rdparty_webkit_Source_JavaScriptCore_jit_JITStubs.cpp
patch -p0 < patches/patch-src_3rdparty_webkit_Source_JavaScriptCore_parser_JSParser.cpp
patch -p0 < patches/patch-src_3rdparty_webkit_Source_JavaScriptCore_wtf_Atomics.h
patch -p0 < patches/patch-src_3rdparty_webkit_Source_JavaScriptCore_wtf_HashSet.h
patch -p0 < patches/patch-src_3rdparty_webkit_Source_JavaScriptCore_wtf_MathExtras.h
patch -p0 < patches/patch-custom-src_3rdparty_webkit_Source_JavaScriptCore_wtf_NullPtr.h
patch -p0 < patches/patch-src_3rdparty_webkit_Source_JavaScriptCore_wtf_RefCountedLeakCounter.h
patch -p0 < patches/patch-src_3rdparty_webkit_Source_JavaScriptCore_wtf_StringImpl.h
patch -p0 < patches/patch-src_3rdparty_webkit_Source_JavaScriptCore_wtf_Threading.h
patch -p0 < patches/patch-src_3rdparty_webkit_Source_JavaScriptCore_wtf_ThreadSafeRefCounted.h
patch -p0 < patches/patch-src_3rdparty_webkit_Source_WebCore_dom_Element.cpp
patch -p0 < patches/patch-src_3rdparty_webkit_Source_WebCore_platform_DefaultLocalizationStrategy.cpp
patch -p0 < patches/patch-src_3rdparty_webkit_Source_WebCore_platform_graphics_MediaPlayer.cpp
patch -p0 < patches/patch-src_3rdparty_webkit_Source_WebCore_platform_qt_PlatformKeyboardEventQt.cpp
patch -p0 < patches/patch-src_corelib_io_io.pri
patch -p0 < patches/patch-src_corelib_io_qfilesystemwatcher.cpp
patch -p0 < patches/patch-src_network_ssl_qsslsocket__openssl__symbols__p.h
patch -p0 < patches/patch-src_network_ssl_qsslsocket__openssl__symbols.cpp
patch -p0 < patches/patch-src_plugins_accessible_widgets_itemviews.cpp
patch -p0 < patches/patch-src_scripttools_debugging_qscriptdebuggerconsole.cpp
patch -p0 < patches/patch-src_scripttools_debugging_qscriptdebuggerco
#end pkgsrc patches for SmartOS
#the qmake.conf patch just removes a -DX_OPEN_SOURCE argument from build commands
patch -p0 < patches/patch-qmake.conf
#instructs build to use system malloc() rather than the Qt version.
#using the Qt version causes Seg Faults in 64-bit SmartOS
#32-bit version works without this fix
patch -p0 < patches/patch-malloc-javascriptcore-wtf-platform.h
#configure argument was calculated by meshing the pkgsrc recommendations with the requirements
#of wkhtmltopdf
./configure -opensource -confirm-license -fast -static -graphicssystem raster -webkit -exceptions -xmlpatterns -no-accessibility -no-javascript-jit -no-stl -no-qt3support -no-phonon -no-phonon-backend -no-opengl -no-declarative -no-scripttools -no-sql-ibase -no-sql-mysql -no-sql-odbc -no-sql-psql -no-sql-sqlite -no-sql-sqlite2 -no-mmx -no-3dnow -no-sse -no-sse2 -no-multimedia -nomake demos -nomake docs -nomake tests -nomake translations -nomake examples -xrender -largefile -iconv -openssl -qt-libtiff -rpath -no-dbus -no-nis -no-cups -no-pch -no-gtkstyle -no-nas-sound -no-sm -no-xshape -no-xcursor -no-xfixes -no-xrandr -no-mitshm -no-xinput -no-xkb -no-glib -D ENABLE_VIDEO=0 -no-openvg -no-xsync -no-audio-backend -no-sse3 -no-ssse3 -no-sse4.1 -no-sse4.2 -no-avx -no-neon -qt-zlib -qt-libpng -qt-libjpeg -qt-libmng -platform solaris-g++-64 -I/usr/include -I/opt/local/include/libdrm -I/opt/local/include/freetype2 -I/opt/local/include -L/opt/local/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.3 -L/opt/local/lib -L/usr/lib/amd64 --prefix=/home/admin/wkhtmltopdf/static-build/posix-local/qt
#this will fail when linking uitools under tools/designer/src/uitools - patch the makefile
make -j 20
#specifics in the makefile, but the link command is malformed
patch -p0 < patches/patch-tools-designer-src-uitools-Makefile
make -j 20
#encounters multiple inclusion errors at the link stage
patch -p0 < patches/patch-lib-QtUiTools.la
cd tools/linguist/linguist
#this has to be manually 'make'd otherwise the module gets rebuilt
make
cd ../../../
make -j 20
#have to remove the project file for this one as the 'make install'
#causes the Makefile to be regenerated and the module to be re-built
#which brings you back to the above error condition
mv tools/designer/src/uitools/uitools.pro tools/designer/src/uitools/uitools.pro.orig
touch tools/designer/src/uitools/uitools.pro
make install -j 20
#copy the Qt binaries and codecs across
#these don't get included for some reason
cp bin/moc ../static-build/posix-local/qt/bin/
cp bin/rcc ../static-build/posix-local/qt/bin/
cp plugins/codecs/*.a ../static-build/posix-local/qt/plugins/codecs/
cd ../static-build/posix-local/
mkdir app
cd app
#setup the wkhtmltopdf project Makefile
../qt/bin/qmake ../../../wkhtmltopdf.pro
make -j 20
#this make fails for the same reason as the uitools module. A malformed link command
patch -p0 < ../../../qt/patches/patch-static-build-posix-local-app-Makefile
#race to the finish
make -j 20
#fun and profit :)
@ashkulz
Copy link

ashkulz commented Jun 24, 2014

Why are you not using -nomake tools? Also, your inclusion of -L/opt/local/gcc47/lib/gcc/x86_64-sun-solaris2.11/4.7.3 in the configure args seems to be causing issues. I also do not think that all the pkgsrc patches are relevant to you (a lot of them deal with NetBSD) -- just make a single patch with all of them squashed together. After that, just download the source, apply the patch and try a posix-local build and see if it works -- that is a more reliable way of asking people to check that it works OK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment