# Tanım: Dooble,güvenli webkit tarayıcısı
# URL: http://dooble.sourceforge.net/
# Paketçi: milisarge
# Gerekler: libpng qt5 openssl libspoton qt5-webkit

isim=dooble
surum=1.56c
devir=1
kaynak=(https://github.com/textbrowser/$isim/archive/v$surum.tar.gz)

derle() {
	cd "$isim-$surum/Version 1.x/"
	
	sed -i 's_-Werror__g' dooble.qt5.pro
    sed -i 's_-lspoton_-lspoton -lQt5PrintSupport_g' dooble.qt5.pro
    qmake-qt5 -o Makefile dooble.qt5.pro
    make distclean
    qmake-qt5 -o Makefile dooble.qt5.pro
    sed -i '/^INCPATH/s:=:= -I/usr/include/qt/QtWidgets:' Makefile
    sed -i '/^INCPATH/s:=:= -I/usr/include/qt/QtWebKitWidgets:' Makefile
    sed -i '/^INCPATH/s:=:= -I/usr/include/qt/QtPrintSupport:' Makefile
    sed -i '/#include/s:QtGui/\([^>]*\)QAction:\1:' Include/*.h
    make
	
	install -Dm755  Dooble         -- "${PKG}/usr/lib/${isim}/Dooble"
	install -Dm755  dooble.sh      -- "${PKG}/usr/bin/${isim}"
	install -d "${PKG}/usr/share/$isim" 
	install -Dm644  dooble.desktop -- "${PKG}/usr/share/applications/${isim}.desktop"
	install -Dm644  Icons/48x48/dooble.png -- "${PKG}/usr/share/icons/hicolor/48x48/$isim.png"
	
	sed -i s_"/usr/local/dooble/"_"/usr/lib/${isim}/"_g -- "${PKG}/usr/bin/${isim}"
	sed -i s_"/usr/local/dooble"_"/usr/share/dooble"_g     -- "${PKG}/usr/bin/${isim}"
	sed -i s_"\./Dooble"_"../../lib/${isim}/Dooble"_g   -- "${PKG}/usr/bin/${isim}"
	sed -i /LD_LIBRARY_PATH/d                              -- "${PKG}/usr/bin/${isim}"

	sed -i s_'/usr/local/dooble/Lib\x00'_'/usr/lib\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'_g  \
	-- "${PKG}/usr/lib/${isim}/Dooble" # The replacements's length must match the pattern's length

	sed -i s_'/usr/local/dooble/dooble.sh'_"/usr/bin/${isim}"_g  \
	-- "${PKG}/usr/share/applications/${isim}.desktop"
}
