From 97be57351f75fe52e3f52c627483449bef488fda Mon Sep 17 00:00:00 2001
From: Sascha Wildner <saw@online.de>
Date: Mon, 14 Jan 2019 07:47:09 +0100
Subject: [PATCH] lang/phantomjs

---
 lang/phantomjs/Makefile                       | 65 +++++++++++++++++++
 lang/phantomjs/distinfo                       |  9 +++
 .../dragonfly/patch-src_qt_qtbase_configure   | 12 ++++
 ..._qtbase_src_corelib_io_qlockfile__unix.cpp | 47 ++++++++++++++
 ...twork_ssl_qsslsocket__openssl__symbols.cpp | 21 ++++++
 ...work_ssl_qsslsocket__openssl__symbols__p.h | 21 ++++++
 lang/phantomjs/files/patch-build.py           | 16 +++++
 lang/phantomjs/files/patch-icu59              | 64 ++++++++++++++++++
 lang/phantomjs/files/patch-src-phantomjs.pro  | 10 +++
 .../phantomjs/files/patch-src-qt-preconfig.sh | 10 +++
 .../files/patch-src_qt_qtbase_configure       | 40 ++++++++++++
 ...qt_qtbase_mkspecs_freebsd-clang_qmake.conf | 13 ++++
 ...qt_qtbase_src_3rdparty_icu__dependency.pri | 10 +++
 ...base_src_corelib_io_qstorageinfo__unix.cpp | 18 +++++
 ...ce_JavaScriptCore_assembler_ARMAssembler.h | 17 +++++
 ...-src_qt_qtwebkit_Source_WTF_wtf_Platform.h | 19 ++++++
 ...raphics_cpu_arm_filters_FELightingNEON.cpp | 18 +++++
 lang/phantomjs/files/patch-src_webpage.cpp    | 20 ++++++
 lang/phantomjs/pkg-descr                      |  7 ++
 19 files changed, 437 insertions(+)
 create mode 100644 lang/phantomjs/Makefile
 create mode 100644 lang/phantomjs/distinfo
 create mode 100644 lang/phantomjs/dragonfly/patch-src_qt_qtbase_configure
 create mode 100644 lang/phantomjs/dragonfly/patch-src_qt_qtbase_src_corelib_io_qlockfile__unix.cpp
 create mode 100644 lang/phantomjs/dragonfly/patch-src_qt_qtbase_src_network_ssl_qsslsocket__openssl__symbols.cpp
 create mode 100644 lang/phantomjs/dragonfly/patch-src_qt_qtbase_src_network_ssl_qsslsocket__openssl__symbols__p.h
 create mode 100644 lang/phantomjs/files/patch-build.py
 create mode 100644 lang/phantomjs/files/patch-icu59
 create mode 100644 lang/phantomjs/files/patch-src-phantomjs.pro
 create mode 100644 lang/phantomjs/files/patch-src-qt-preconfig.sh
 create mode 100644 lang/phantomjs/files/patch-src_qt_qtbase_configure
 create mode 100644 lang/phantomjs/files/patch-src_qt_qtbase_mkspecs_freebsd-clang_qmake.conf
 create mode 100644 lang/phantomjs/files/patch-src_qt_qtbase_src_3rdparty_icu__dependency.pri
 create mode 100644 lang/phantomjs/files/patch-src_qt_qtbase_src_corelib_io_qstorageinfo__unix.cpp
 create mode 100644 lang/phantomjs/files/patch-src_qt_qtwebkit_Source_JavaScriptCore_assembler_ARMAssembler.h
 create mode 100644 lang/phantomjs/files/patch-src_qt_qtwebkit_Source_WTF_wtf_Platform.h
 create mode 100644 lang/phantomjs/files/patch-src_qt_qtwebkit_Source_WebCore_platform_graphics_cpu_arm_filters_FELightingNEON.cpp
 create mode 100644 lang/phantomjs/files/patch-src_webpage.cpp
 create mode 100644 lang/phantomjs/pkg-descr

diff --git a/lang/phantomjs/Makefile b/lang/phantomjs/Makefile
new file mode 100644
index 0000000000..759b09cda9
--- /dev/null
+++ b/lang/phantomjs/Makefile
@@ -0,0 +1,65 @@
+# $FreeBSD: head/lang/phantomjs/Makefile 487272 2018-12-12 01:35:33Z gerald $
+
+PORTNAME=	phantomjs
+PORTVERSION=	2.1.1
+PORTREVISION=	12
+CATEGORIES=	lang
+
+MAINTAINER=	feld@FreeBSD.org
+COMMENT=	Minimalistic, headless, WebKit-based, JavaScript-driven tool
+
+LICENSE=	BSD3CLAUSE
+
+BROKEN_powerpc64=	fails to build: g++48: not found
+BROKEN_sparc64=		does not link on sparc64
+BROKEN_SSL=	openssl111
+BROKEN_SSL_REASON_openssl111=	error: member access into incomplete type 'X509' (aka 'x509_st')
+
+BUILD_DEPENDS=	bash:shells/bash
+LIB_DEPENDS=	libfreetype.so:print/freetype2 \
+		libfontconfig.so:x11-fonts/fontconfig \
+		libicui18n.so:devel/icu \
+		libpng.so:graphics/png
+
+USES=		bison:build compiler:c++11-lang gmake gperf jpeg perl5 pkgconfig python:build ssl sqlite
+USE_GNOME+=	libxml2
+USE_PERL5=	build
+USE_RUBY=	yes
+USE_GITHUB=	yes
+GH_ACCOUNT=	ariya
+GH_TUPLE=	Vitallium:phantomjs-3rdparty-win:19051aa:msvc2013/src/qt/3rdparty \
+		Vitallium:qtbase:b5cc008:qtbase/src/qt/qtbase \
+		Vitallium:qtwebkit:e7b7433:qtwebkit/src/qt/qtwebkit
+RUBY_NO_RUN_DEPENDS=	yes
+PLIST_FILES=	bin/phantomjs
+NO_CCACHE=	yes
+BINARY_ALIAS=	python=${PYTHON_CMD}
+
+OPTIONS_DEFINE=	X11
+X11_USE=	XORG=x11
+
+.include <bsd.port.options.mk>
+
+# qmake.conf detection is in src/qt/qtbase/configure script.
+SPEC=	${WRKSRC}/src/qt/qtbase/mkspecs
+post-extract:
+	${MKDIR} ${SPEC}/freebsd-clang
+	cd ${SPEC} && ${SED} -e 's|\.\./\.\./|../|g' unsupported/freebsd-clang/qmake.conf > freebsd-clang/qmake.conf
+	cd ${SPEC} && ${SED} -e 's|\.\./\.\./|../|g' unsupported/freebsd-clang/qplatformdefs.h > freebsd-clang/qplatformdefs.h
+	${MKDIR} ${WRKSRC}/src/qt/qtbase/.git
+	${MKDIR} ${WRKSRC}/src/qt/qtwebkit/.git
+	${RM} ${WRKSRC}/src/qt/qtwebkit/Source/WebCore/DerivedSources.cpp
+
+_ENV=	CC=${CC} CXX=${CXX} GMAKE=${GMAKE} OSTYPE=freebsd MAKEFLAGS= LOCALBASE=${LOCALBASE}
+_BLD=	${PYTHON_CMD} build.py --jobs ${MAKE_JOBS_NUMBER} --confirm
+do-build:
+.if defined(_PHANTOMJS_USE_QT_SYSTEM)
+	cd ${WRKSRC} && ${SETENV} ${_ENV} PATH=${PATH}:${QT_BINDIR} ${_BLD} --qt=system --qtwebkit=system
+.else
+	cd ${WRKSRC} && ${SETENV} ${_ENV} PATH=${PATH} ${_BLD}
+.endif
+
+do-install:
+	cd ${WRKSRC} && ${INSTALL_PROGRAM} bin/phantomjs ${STAGEDIR}${PREFIX}/bin/
+
+.include <bsd.port.mk>
diff --git a/lang/phantomjs/distinfo b/lang/phantomjs/distinfo
new file mode 100644
index 0000000000..c0e55f5bf2
--- /dev/null
+++ b/lang/phantomjs/distinfo
@@ -0,0 +1,9 @@
+TIMESTAMP = 1484137497
+SHA256 (ariya-phantomjs-2.1.1_GH0.tar.gz) = bd1e63e9cd48d5a9c8ff1affc254eeae14704304437710729f133cb80cf98cf1
+SIZE (ariya-phantomjs-2.1.1_GH0.tar.gz) = 1880406
+SHA256 (Vitallium-phantomjs-3rdparty-win-19051aa_GH0.tar.gz) = cf097cf098c40f9b60255a5c369d968b0e3e3881e25374f00f0c74c265cfd37e
+SIZE (Vitallium-phantomjs-3rdparty-win-19051aa_GH0.tar.gz) = 24611974
+SHA256 (Vitallium-qtbase-b5cc008_GH0.tar.gz) = 9bf66dcaa1b522fe41d74574eae949b740a9bec3cd7f8a69e0555f3ffc2fe6a0
+SIZE (Vitallium-qtbase-b5cc008_GH0.tar.gz) = 46446806
+SHA256 (Vitallium-qtwebkit-e7b7433_GH0.tar.gz) = 76d0bc7430919d7f8c12cbc0cae6dd174543e40777d984a6c14af982a3a71fcc
+SIZE (Vitallium-qtwebkit-e7b7433_GH0.tar.gz) = 50630572
diff --git a/lang/phantomjs/dragonfly/patch-src_qt_qtbase_configure b/lang/phantomjs/dragonfly/patch-src_qt_qtbase_configure
new file mode 100644
index 0000000000..ea6472eb5b
--- /dev/null
+++ b/lang/phantomjs/dragonfly/patch-src_qt_qtbase_configure
@@ -0,0 +1,12 @@
+--- src/qt/qtbase/configure~	2019-01-14 02:03:41.521430000 +0100
++++ src/qt/qtbase/configure	2019-01-14 02:04:09.391581000 +0100
+@@ -2792,6 +2792,9 @@ if [ -z "$PLATFORM" ]; then
+      ULTRIX:*)
+         PLATFORM=ultrix-g++
+         ;;
++     DragonFly:*)
++        PLATFORM=freebsd-g++
++        ;;
+ #     FreeBSD:10.[0-9]*)
+ #        echo "=== ($UNAME_RELEASE) ==="
+ #        PLATFORM=freebsd-clang
diff --git a/lang/phantomjs/dragonfly/patch-src_qt_qtbase_src_corelib_io_qlockfile__unix.cpp b/lang/phantomjs/dragonfly/patch-src_qt_qtbase_src_corelib_io_qlockfile__unix.cpp
new file mode 100644
index 0000000000..73d7ed2032
--- /dev/null
+++ b/lang/phantomjs/dragonfly/patch-src_qt_qtbase_src_corelib_io_qlockfile__unix.cpp
@@ -0,0 +1,47 @@
+--- src/qt/qtbase/src/corelib/io/qlockfile_unix.cpp~	2015-12-12 13:58:05.000000000 +0100
++++ src/qt/qtbase/src/corelib/io/qlockfile_unix.cpp	2019-01-14 02:37:25.102364000 +0100
+@@ -56,13 +56,9 @@
+ #   include <cstdio>
+ #elif defined(Q_OS_BSD4) && !defined(Q_OS_IOS)
+ #   include <sys/user.h>
+-# if defined(__GLIBC__) && defined(__FreeBSD_kernel__)
+ #   include <sys/cdefs.h>
+ #   include <sys/param.h>
+ #   include <sys/sysctl.h>
+-# else
+-#   include <libutil.h>
+-# endif
+ #endif
+ 
+ QT_BEGIN_NAMESPACE
+@@ -240,28 +236,22 @@ QString QLockFilePrivate::processNameByP
+     buf[len] = 0;
+     return QFileInfo(QFile::decodeName(buf)).fileName();
+ #elif defined(Q_OS_BSD4) && !defined(Q_OS_IOS)
+-# if defined(__GLIBC__) && defined(__FreeBSD_kernel__)
+     int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, pid };
+     size_t len = 0;
+     if (sysctl(mib, 4, NULL, &len, NULL, 0) < 0)
+         return QString();
+     kinfo_proc *proc = static_cast<kinfo_proc *>(malloc(len));
+-# else
+-    kinfo_proc *proc = kinfo_getproc(pid);
+-# endif
+     if (!proc)
+         return QString();
+-# if defined(__GLIBC__) && defined(__FreeBSD_kernel__)
+     if (sysctl(mib, 4, proc, &len, NULL, 0) < 0) {
+         free(proc);
+         return QString();
+     }
+-    if (proc->ki_pid != pid) {
++    if (proc->kp_pid != pid) {
+         free(proc);
+         return QString();
+     }
+-# endif
+-    QString name = QFile::decodeName(proc->ki_comm);
++    QString name = QFile::decodeName(proc->kp_comm);
+     free(proc);
+     return name;
+ #else
diff --git a/lang/phantomjs/dragonfly/patch-src_qt_qtbase_src_network_ssl_qsslsocket__openssl__symbols.cpp b/lang/phantomjs/dragonfly/patch-src_qt_qtbase_src_network_ssl_qsslsocket__openssl__symbols.cpp
new file mode 100644
index 0000000000..9a7b23e3a4
--- /dev/null
+++ b/lang/phantomjs/dragonfly/patch-src_qt_qtbase_src_network_ssl_qsslsocket__openssl__symbols.cpp
@@ -0,0 +1,21 @@
+--- src/qt/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp~	2015-12-12 13:58:05.000000000 +0100
++++ src/qt/qtbase/src/network/ssl/qsslsocket_openssl_symbols.cpp	2019-01-14 03:55:12.607585000 +0100
+@@ -136,10 +136,18 @@ DEFINEFUNC(int, ASN1_STRING_length, ASN1
+ DEFINEFUNC2(int, ASN1_STRING_to_UTF8, unsigned char **a, a, ASN1_STRING *b, b, return 0, return);
+ DEFINEFUNC4(long, BIO_ctrl, BIO *a, a, int b, b, long c, c, void *d, d, return -1, return)
+ DEFINEFUNC(int, BIO_free, BIO *a, a, return 0, return)
++#if !defined(LIBRESSL_VERSION_NUMBER)
+ DEFINEFUNC(BIO *, BIO_new, BIO_METHOD *a, a, return 0, return)
++#else
++DEFINEFUNC(BIO *, BIO_new, const BIO_METHOD *a, a, return 0, return)
++#endif
+ DEFINEFUNC2(BIO *, BIO_new_mem_buf, void *a, a, int b, b, return 0, return)
+ DEFINEFUNC3(int, BIO_read, BIO *a, a, void *b, b, int c, c, return -1, return)
++#if !defined(LIBRESSL_VERSION_NUMBER)
+ DEFINEFUNC(BIO_METHOD *, BIO_s_mem, void, DUMMYARG, return 0, return)
++#else
++DEFINEFUNC(const BIO_METHOD *, BIO_s_mem, void, DUMMYARG, return 0, return)
++#endif
+ DEFINEFUNC3(int, BIO_write, BIO *a, a, const void *b, b, int c, c, return -1, return)
+ DEFINEFUNC(int, BN_num_bits, const BIGNUM *a, a, return 0, return)
+ #ifndef OPENSSL_NO_EC
diff --git a/lang/phantomjs/dragonfly/patch-src_qt_qtbase_src_network_ssl_qsslsocket__openssl__symbols__p.h b/lang/phantomjs/dragonfly/patch-src_qt_qtbase_src_network_ssl_qsslsocket__openssl__symbols__p.h
new file mode 100644
index 0000000000..c48230bf39
--- /dev/null
+++ b/lang/phantomjs/dragonfly/patch-src_qt_qtbase_src_network_ssl_qsslsocket__openssl__symbols__p.h
@@ -0,0 +1,21 @@
+--- src/qt/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h~	2015-12-12 13:58:05.000000000 +0100
++++ src/qt/qtbase/src/network/ssl/qsslsocket_openssl_symbols_p.h	2019-01-14 03:53:45.857116000 +0100
+@@ -215,10 +215,18 @@ int q_ASN1_STRING_length(ASN1_STRING *a)
+ int q_ASN1_STRING_to_UTF8(unsigned char **a, ASN1_STRING *b);
+ long q_BIO_ctrl(BIO *a, int b, long c, void *d);
+ int q_BIO_free(BIO *a);
++#if !defined(LIBRESSL_VERSION_NUMBER)
+ BIO *q_BIO_new(BIO_METHOD *a);
++#else
++BIO *q_BIO_new(const BIO_METHOD *a);
++#endif
+ BIO *q_BIO_new_mem_buf(void *a, int b);
+ int q_BIO_read(BIO *a, void *b, int c);
++#if !defined(LIBRESSL_VERSION_NUMBER)
+ BIO_METHOD *q_BIO_s_mem();
++#else
++const BIO_METHOD *q_BIO_s_mem();
++#endif
+ int q_BIO_write(BIO *a, const void *b, int c);
+ int q_BN_num_bits(const BIGNUM *a);
+ #ifndef OPENSSL_NO_EC
diff --git a/lang/phantomjs/files/patch-build.py b/lang/phantomjs/files/patch-build.py
new file mode 100644
index 0000000000..b6eb857a59
--- /dev/null
+++ b/lang/phantomjs/files/patch-build.py
@@ -0,0 +1,16 @@
+--- build.py.orig	2016-01-24 18:24:05 UTC
++++ build.py
+@@ -56,6 +56,13 @@ openssl_search_paths = [{
+     "-I/opt/local/include",
+     "-L/opt/local/lib"
+   ]
++}, {
++  "name": "freebsd",
++  "header": "/usr/local/include/openssl/opensslv.h",
++  "flags": [
++    "-I/usr/local/include",
++    "-L/usr/local/lib"
++  ]
+ }]
+ 
+ # check if path points to an executable
diff --git a/lang/phantomjs/files/patch-icu59 b/lang/phantomjs/files/patch-icu59
new file mode 100644
index 0000000000..2db4075f75
--- /dev/null
+++ b/lang/phantomjs/files/patch-icu59
@@ -0,0 +1,64 @@
+------------------------------------------------------------------------
+r216187 | annulen@yandex.ru | 2017-05-05 00:33:41 +0900 (Fri, 05 May 2017) | 28 lines
+
+Fix compilation with ICU 59.1
+https://bugs.webkit.org/show_bug.cgi?id=171612
+
+Reviewed by Mark Lam.
+
+ICU 59.1 has broken source compatibility. Now it defines UChar as
+char16_t, which does not allow automatic type conversion from unsigned
+short in C++ code.
+
+--- src/qt/qtwebkit/Source/JavaScriptCore/API/JSStringRef.cpp.orig	2016-01-08 10:07:46 UTC
++++ src/qt/qtwebkit/Source/JavaScriptCore/API/JSStringRef.cpp
+@@ -37,7 +37,7 @@ using namespace WTF::Unicode;
+ JSStringRef JSStringCreateWithCharacters(const JSChar* chars, size_t numChars)
+ {
+     initializeThreading();
+-    return OpaqueJSString::create(chars, numChars).leakRef();
++    return OpaqueJSString::create(reinterpret_cast<const UChar*>(chars), numChars).leakRef();
+ }
+ 
+ JSStringRef JSStringCreateWithUTF8CString(const char* string)
+@@ -62,7 +62,7 @@ JSStringRef JSStringCreateWithUTF8CString(const char* 
+ JSStringRef JSStringCreateWithCharactersNoCopy(const JSChar* chars, size_t numChars)
+ {
+     initializeThreading();
+-    return OpaqueJSString::create(StringImpl::createWithoutCopying(chars, numChars, WTF::DoesNotHaveTerminatingNullCharacter)).leakRef();
++    return OpaqueJSString::create(StringImpl::createWithoutCopying(reinterpret_cast<const UChar*>(chars), numChars, WTF::DoesNotHaveTerminatingNullCharacter)).leakRef();
+ }
+ 
+ JSStringRef JSStringRetain(JSStringRef string)
+@@ -83,7 +83,7 @@ size_t JSStringGetLength(JSStringRef string)
+ 
+ const JSChar* JSStringGetCharactersPtr(JSStringRef string)
+ {
+-    return string->characters();
++    return reinterpret_cast<const JSChar*>(string->characters());
+ }
+ 
+ size_t JSStringGetMaximumUTF8CStringSize(JSStringRef string)
+--- src/qt/qtwebkit/Source/JavaScriptCore/runtime/DateConversion.cpp.orig	2016-01-08 10:07:46 UTC
++++ src/qt/qtwebkit/Source/JavaScriptCore/runtime/DateConversion.cpp
+@@ -107,7 +107,8 @@ String formatDateTime(const GregorianDateTime& t, Date
+ #if OS(WINDOWS)
+             TIME_ZONE_INFORMATION timeZoneInformation;
+             GetTimeZoneInformation(&timeZoneInformation);
+-            const WCHAR* timeZoneName = t.isDST() ? timeZoneInformation.DaylightName : timeZoneInformation.StandardName;
++            const WCHAR* winTimeZoneName = t.isDST() ? timeZoneInformation.DaylightName : timeZoneInformation.StandardName;
++            String timeZoneName(reinterpret_cast<const UChar*>(winTimeZoneName));
+ #else
+             struct tm gtm = t;
+             char timeZoneName[70];
+--- src/qt/qtwebkit/Source/WebKit2/Shared/API/c/WKString.cpp.orig	2016-01-08 10:07:46 UTC
++++ src/qt/qtwebkit/Source/WebKit2/Shared/API/c/WKString.cpp
+@@ -55,7 +55,7 @@ size_t WKStringGetLength(WKStringRef stringRef)
+ size_t WKStringGetCharacters(WKStringRef stringRef, WKChar* buffer, size_t bufferLength)
+ {
+     COMPILE_ASSERT(sizeof(WKChar) == sizeof(UChar), WKStringGetCharacters_sizeof_WKChar_matches_UChar);
+-    return (toImpl(stringRef)->getCharacters(static_cast<UChar*>(buffer), bufferLength));
++    return (toImpl(stringRef)->getCharacters(reinterpret_cast<UChar*>(buffer), bufferLength));
+ }
+ 
+ size_t WKStringGetMaximumUTF8CStringSize(WKStringRef stringRef)
diff --git a/lang/phantomjs/files/patch-src-phantomjs.pro b/lang/phantomjs/files/patch-src-phantomjs.pro
new file mode 100644
index 0000000000..84f6225504
--- /dev/null
+++ b/lang/phantomjs/files/patch-src-phantomjs.pro
@@ -0,0 +1,10 @@
+--- src/phantomjs.pro.orig	2016-01-24 18:24:05 UTC
++++ src/phantomjs.pro
+@@ -97,3 +97,7 @@ win32-msvc* {
+ openbsd* {
+     LIBS += -L/usr/X11R6/lib
+ }
++
++freebsd* {
++    LIBS += -L/usr/local/lib
++}
diff --git a/lang/phantomjs/files/patch-src-qt-preconfig.sh b/lang/phantomjs/files/patch-src-qt-preconfig.sh
new file mode 100644
index 0000000000..369d362cfb
--- /dev/null
+++ b/lang/phantomjs/files/patch-src-qt-preconfig.sh
@@ -0,0 +1,10 @@
+--- src/qt/preconfig.sh.orig	2016-01-24 18:24:05 UTC
++++ src/qt/preconfig.sh
+@@ -187,5 +187,6 @@ if [[ -n "$SILENT" ]]; then
+     exec >& /dev/null
+ fi
+ 
++export CXX=${CXX}
+ cd qtbase
+-exec ./configure -prefix $PWD $QT_CFG "$@"
++exec bash -x ./configure -prefix $PWD $QT_CFG "$@"
diff --git a/lang/phantomjs/files/patch-src_qt_qtbase_configure b/lang/phantomjs/files/patch-src_qt_qtbase_configure
new file mode 100644
index 0000000000..17d185b1af
--- /dev/null
+++ b/lang/phantomjs/files/patch-src_qt_qtbase_configure
@@ -0,0 +1,40 @@
+--- src/qt/qtbase/configure.orig	2015-12-12 12:58:05 UTC
++++ src/qt/qtbase/configure
+@@ -51,6 +51,7 @@ mactests="$relpath/config.tests/mac"
+ WHICH="$unixtests/which.test"
+ 
+ PERL=`$WHICH perl 2>/dev/null`
++export CXX=${CXX}
+ 
+ # find out which awk we want to use, prefer gawk, then nawk, then regular awk
+ AWK=
+@@ -2791,11 +2792,19 @@ if [ -z "$PLATFORM" ]; then
+      ULTRIX:*)
+         PLATFORM=ultrix-g++
+         ;;
++#     FreeBSD:10.[0-9]*)
++#        echo "=== ($UNAME_RELEASE) ==="
++#        PLATFORM=freebsd-clang
++#        ;;
+      FreeBSD:*)
+-        PLATFORM=freebsd-g++
++        PLATFORM=freebsd-clang
+         PLATFORM_NOTES="
+             - Also available for FreeBSD: freebsd-icc
+         "
++        type g++   >/dev/null && PLATFORM=freebsd-g++
++        type g++46 >/dev/null && PLATFORM=freebsd-g++46
++        type g++48 >/dev/null && PLATFORM=freebsd-g++48
++        type g++49 >/dev/null && PLATFORM=freebsd-g++49
+         ;;
+      OpenBSD:*)
+         PLATFORM=openbsd-g++
+@@ -6359,7 +6368,7 @@ case "$XPLATFORM" in
+ 	;;
+     *-g++*)
+ 	# Check gcc's version
+-	case "$(${QMAKE_CONF_COMPILER} -dumpversion)" in
++	case "$(${TEST_COMPILER} -dumpversion)" in
+ 	    4*|3.4*)
+ 		;;
+             3.3*)
diff --git a/lang/phantomjs/files/patch-src_qt_qtbase_mkspecs_freebsd-clang_qmake.conf b/lang/phantomjs/files/patch-src_qt_qtbase_mkspecs_freebsd-clang_qmake.conf
new file mode 100644
index 0000000000..350e88d596
--- /dev/null
+++ b/lang/phantomjs/files/patch-src_qt_qtbase_mkspecs_freebsd-clang_qmake.conf
@@ -0,0 +1,13 @@
+--- src/qt/qtbase/mkspecs/freebsd-clang/qmake.conf.orig	2017-03-26 06:45:23 UTC
++++ src/qt/qtbase/mkspecs/freebsd-clang/qmake.conf
+@@ -10,8 +10,8 @@ QMAKE_CFLAGS_THREAD     = -pthread -D_TH
+ QMAKE_CXXFLAGS_THREAD   = $$QMAKE_CFLAGS_THREAD
+ 
+ # Addon software goes into /usr/local on the BSDs, by default we will look there
+-QMAKE_INCDIR            = /usr/local/include
+-QMAKE_LIBDIR            = /usr/local/lib
++QMAKE_INCDIR            = $$(LOCALBASE)/include
++QMAKE_LIBDIR            = $$(LOCALBASE)/lib
+ 
+ QMAKE_LFLAGS_NOUNDEF    = -Wl,--no-undefined
+ QMAKE_LFLAGS_THREAD     = -pthread
diff --git a/lang/phantomjs/files/patch-src_qt_qtbase_src_3rdparty_icu__dependency.pri b/lang/phantomjs/files/patch-src_qt_qtbase_src_3rdparty_icu__dependency.pri
new file mode 100644
index 0000000000..e52cc87819
--- /dev/null
+++ b/lang/phantomjs/files/patch-src_qt_qtbase_src_3rdparty_icu__dependency.pri
@@ -0,0 +1,10 @@
+--- src/qt/qtbase/src/3rdparty/icu_dependency.pri.orig	2015-12-12 12:58:05 UTC
++++ src/qt/qtbase/src/3rdparty/icu_dependency.pri
+@@ -10,7 +10,4 @@ win32 {
+     }
+ } else {
+     LIBS_PRIVATE += -licui18n -licuuc -licudata
+-    CONFIG(static) {
+-      LIBS_PRIVATE += -ldl
+-    }
+ }
diff --git a/lang/phantomjs/files/patch-src_qt_qtbase_src_corelib_io_qstorageinfo__unix.cpp b/lang/phantomjs/files/patch-src_qt_qtbase_src_corelib_io_qstorageinfo__unix.cpp
new file mode 100644
index 0000000000..33a01a40d1
--- /dev/null
+++ b/lang/phantomjs/files/patch-src_qt_qtbase_src_corelib_io_qstorageinfo__unix.cpp
@@ -0,0 +1,18 @@
+--- src/qt/qtbase/src/corelib/io/qstorageinfo_unix.cpp.orig	2015-12-12 12:58:05 UTC
++++ src/qt/qtbase/src/corelib/io/qstorageinfo_unix.cpp
+@@ -506,9 +506,15 @@ void QStorageInfoPrivate::retrieveVolume
+         valid = true;
+         ready = true;
+ 
++#if defined(Q_OS_FREEBSD)
++	bytesTotal = statfs_buf.f_blocks * statfs_buf.f_bsize;
++	bytesFree = statfs_buf.f_bfree * statfs_buf.f_bsize;
++	bytesAvailable = statfs_buf.f_bavail * statfs_buf.f_bsize;
++#else
+         bytesTotal = statfs_buf.f_blocks * statfs_buf.f_frsize;
+         bytesFree = statfs_buf.f_bfree * statfs_buf.f_frsize;
+         bytesAvailable = statfs_buf.f_bavail * statfs_buf.f_frsize;
++#endif
+ #if defined(Q_OS_ANDROID) || defined (Q_OS_BSD4)
+ #if defined(_STATFS_F_FLAGS)
+         readOnly = (statfs_buf.f_flags & ST_RDONLY) != 0;
diff --git a/lang/phantomjs/files/patch-src_qt_qtwebkit_Source_JavaScriptCore_assembler_ARMAssembler.h b/lang/phantomjs/files/patch-src_qt_qtwebkit_Source_JavaScriptCore_assembler_ARMAssembler.h
new file mode 100644
index 0000000000..24cd58695a
--- /dev/null
+++ b/lang/phantomjs/files/patch-src_qt_qtwebkit_Source_JavaScriptCore_assembler_ARMAssembler.h
@@ -0,0 +1,17 @@
+assembler/ARMAssembler.h:1073:2: error: "The cacheFlush support is missing on this platform."
+#error "The cacheFlush support is missing on this platform."
+ ^
+
+Obtained from: www/webkit-gtk3/files/patch-Source__JavaScriptCore__assembler__ARMAssembler.h
+
+--- src/qt/qtwebkit/Source/JavaScriptCore/assembler/ARMAssembler.h.orig	2016-01-08 10:07:46 UTC
++++ src/qt/qtwebkit/Source/JavaScriptCore/assembler/ARMAssembler.h
+@@ -1069,6 +1069,8 @@ namespace JSC {
+             UNUSED_PARAM(size);
+ #elif OS(QNX)
+             msync(code, size, MS_INVALIDATE_ICACHE);
++#elif CPU(ARM_TRADITIONAL) && OS(FREEBSD) && COMPILER(CLANG)
++            __clear_cache(code, reinterpret_cast<char*>(code) + size);
+ #else
+ #error "The cacheFlush support is missing on this platform."
+ #endif
diff --git a/lang/phantomjs/files/patch-src_qt_qtwebkit_Source_WTF_wtf_Platform.h b/lang/phantomjs/files/patch-src_qt_qtwebkit_Source_WTF_wtf_Platform.h
new file mode 100644
index 0000000000..9ddc03e3b9
--- /dev/null
+++ b/lang/phantomjs/files/patch-src_qt_qtwebkit_Source_WTF_wtf_Platform.h
@@ -0,0 +1,19 @@
+On armv6 platform:
+./wtf/Platform.h:323:6: error: "Not supported ARM architecture"
+#    error "Not supported ARM architecture"
+     ^
+
+Obtained from: www/webkit-gtk3/files/patch-Source_WTF_wtf_Platform.h
+
+This patch reportedly fixes build for ARM. See PR 208569
+
+--- src/qt/qtwebkit/Source/WTF/wtf/Platform.h.orig	2018-06-14 11:03:55 UTC
++++ src/qt/qtwebkit/Source/WTF/wtf/Platform.h
+@@ -232,6 +232,7 @@
+ #elif defined(__ARM_ARCH_6__) \
+     || defined(__ARM_ARCH_6J__) \
+     || defined(__ARM_ARCH_6K__) \
++    || defined(__ARM_ARCH_6KZ__) \
+     || defined(__ARM_ARCH_6Z__) \
+     || defined(__ARM_ARCH_6ZK__) \
+     || defined(__ARM_ARCH_6T2__) \
diff --git a/lang/phantomjs/files/patch-src_qt_qtwebkit_Source_WebCore_platform_graphics_cpu_arm_filters_FELightingNEON.cpp b/lang/phantomjs/files/patch-src_qt_qtwebkit_Source_WebCore_platform_graphics_cpu_arm_filters_FELightingNEON.cpp
new file mode 100644
index 0000000000..27b00b486e
--- /dev/null
+++ b/lang/phantomjs/files/patch-src_qt_qtwebkit_Source_WebCore_platform_graphics_cpu_arm_filters_FELightingNEON.cpp
@@ -0,0 +1,18 @@
+.obj/platform/graphics/cpu/arm/filters/FELightingNEON.o ---
+<inline asm>:149:1: error: invalid instruction
+vmov.u32 r2, r3, s8, s9
+^
+
+Obtained from: www/webkit-gtk3/files/patch-Source_WebCore_platform_graphics_cpu_arm_filters_FELightingNEON.cpp
+
+--- src/qt/qtwebkit/Source/WebCore/platform/graphics/cpu/arm/filters/FELightingNEON.cpp.orig	2018-06-12 14:38:27 UTC
++++ src/qt/qtwebkit/Source/WebCore/platform/graphics/cpu/arm/filters/FELightingNEON.cpp
+@@ -404,7 +404,7 @@ TOSTRING(neonDrawLighting) ":" NL
+     "vmin.f32 " TMP2_D0 ", " TMP2_D0 ", " CONST_ONE_HI_D NL
+     "vmul.f32 " TMP3_Q ", " COLOR_Q ", " TMP2_D0 "[1]" NL
+     "vcvt.u32.f32 " TMP3_Q ", " TMP3_Q NL
+-    "vmov.u32 r2, r3, " TMP3_S0 ", " TMP3_S1 NL
++    "vmov r2, r3, " TMP3_S0 ", " TMP3_S1 NL
+     // The color values are stored in-place.
+     "strb r2, [" PIXELS_R ", #-11]" NL
+     "strb r3, [" PIXELS_R ", #-10]" NL
diff --git a/lang/phantomjs/files/patch-src_webpage.cpp b/lang/phantomjs/files/patch-src_webpage.cpp
new file mode 100644
index 0000000000..2ef6b34951
--- /dev/null
+++ b/lang/phantomjs/files/patch-src_webpage.cpp
@@ -0,0 +1,20 @@
+webpage.cpp:80:89: error: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wreserved-user-defined-literal]
+#define CALLBACKS_OBJECT_INJECTION      INPAGE_CALL_NAME" = function() { return window."CALLBACKS_OBJECT_NAME".call.call(_phantom, Array.prototype.slice.call(arguments, 0)); };"
+                                                                                        ^
+webpage.cpp:81:57: error: invalid suffix on literal; C++11 requires a space between literal and identifier [-Wreserved-user-defined-literal]
+#define CALLBACKS_OBJECT_PRESENT        "typeof(window."CALLBACKS_OBJECT_NAME") !== \"undefined\";"
+                                                        ^
+
+--- src/webpage.cpp.orig	2018-01-26 07:17:31 UTC
++++ src/webpage.cpp
+@@ -77,8 +77,8 @@
+ #define BLANK_HTML                      "<html><head></head><body></body></html>"
+ #define CALLBACKS_OBJECT_NAME           "_phantom"
+ #define INPAGE_CALL_NAME                "window.callPhantom"
+-#define CALLBACKS_OBJECT_INJECTION      INPAGE_CALL_NAME" = function() { return window."CALLBACKS_OBJECT_NAME".call.call(_phantom, Array.prototype.slice.call(arguments, 0)); };"
+-#define CALLBACKS_OBJECT_PRESENT        "typeof(window."CALLBACKS_OBJECT_NAME") !== \"undefined\";"
++#define CALLBACKS_OBJECT_INJECTION      INPAGE_CALL_NAME" = function() { return window." CALLBACKS_OBJECT_NAME".call.call(_phantom, Array.prototype.slice.call(arguments, 0)); };"
++#define CALLBACKS_OBJECT_PRESENT        "typeof(window." CALLBACKS_OBJECT_NAME") !== \"undefined\";"
+ 
+ #define STDOUT_FILENAME "/dev/stdout"
+ #define STDERR_FILENAME "/dev/stderr"
diff --git a/lang/phantomjs/pkg-descr b/lang/phantomjs/pkg-descr
new file mode 100644
index 0000000000..9d23c59f26
--- /dev/null
+++ b/lang/phantomjs/pkg-descr
@@ -0,0 +1,7 @@
+PhantomJS is a minimalistic, headless, WebKit-based, JavaScript-driven
+tool.
+
+It has native support for different web technologies: DOM handling,
+CSS selector, JSON, Canvas, SVG, and of course JavaScript.
+
+WWW: http://www.phantomjs.org/
-- 
2.19.2

