pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

firefox140: Import firefox140-140.3.1 as wip/firefox140



Module Name:	pkgsrc-wip
Committed By:	Leonardo Taccari <leot%NetBSD.org@localhost>
Pushed By:	leot
Date:		Wed Oct 15 12:32:54 2025 +0200
Changeset:	897d72f8a49f7949c5d3d80d988868ba188a11d3

Added Files:
	firefox140/DESCR
	firefox140/Makefile
	firefox140/PLIST
	firefox140/PLIST.Linux
	firefox140/TODO
	firefox140/distinfo
	firefox140/files/desktop.in
	firefox140/files/firefox.sh
	firefox140/files/node-wrapper.sh
	firefox140/files/replace-moz.build.awk
	firefox140/mozilla-common.mk
	firefox140/options.mk
	firefox140/patches/patch-browser_app_profile_firefox.js
	firefox140/patches/patch-build_moz.configure_init.configure
	firefox140/patches/patch-build_moz.configure_rust.configure
	firefox140/patches/patch-config_gcc-stl-wrapper.template.h
	firefox140/patches/patch-config_makefiles_rust.mk
	firefox140/patches/patch-dom_base_nsAttrName.h
	firefox140/patches/patch-dom_webtransport_api_WebTransportDatagramDuplexStream.cpp
	firefox140/patches/patch-gfx_angle_checkout_src_common_third__party_smhasher_src_PMurHash.cpp
	firefox140/patches/patch-gfx_angle_checkout_src_compiler_translator_InfoSink.h
	firefox140/patches/patch-gfx_ots_src_name.cc
	firefox140/patches/patch-gfx_skia_skia_src_sksl_codegen_SkSLSPIRVCodeGenerator.cpp
	firefox140/patches/patch-ipc_chromium_src_base_message__pump__libevent.cc
	firefox140/patches/patch-ipc_chromium_src_base_platform__thread__posix.cc
	firefox140/patches/patch-ipc_glue_GeckoChildProcessHost.cpp
	firefox140/patches/patch-js-src-jit-arm64-vixl-MozCpu-vixl.cpp
	firefox140/patches/patch-js_public_Utility.h
	firefox140/patches/patch-js_src_jit_FlushICache.cpp
	firefox140/patches/patch-js_src_util_NativeStack.cpp
	firefox140/patches/patch-js_src_vm_TypedArrayObject-inl.h
	firefox140/patches/patch-media_ffvpx_libavutil_arm_bswap.h
	firefox140/patches/patch-media_libpng_pngpriv.h
	firefox140/patches/patch-modules_fdlibm_src_math__private.h
	firefox140/patches/patch-netwerk_protocol_http_nsHttpHandler.cpp
	firefox140/patches/patch-nsprpub_pr_src_pthreads_ptsynch.c
	firefox140/patches/patch-python_mozbuild_mozbuild_backend_recursivemake.py
	firefox140/patches/patch-python_mozbuild_mozbuild_frontend_reader.py
	firefox140/patches/patch-third__party_abseil-cpp_absl_debugging_internal_elf__mem__image.cc
	firefox140/patches/patch-third__party_abseil-cpp_absl_debugging_internal_vdso__support.cc
	firefox140/patches/patch-third__party_js_cfworker_build.sh
	firefox140/patches/patch-third__party_libwebrtc_modules_audio__device_audio__device__impl.cc
	firefox140/patches/patch-third__party_libwebrtc_modules_desktop__capture_desktop__capture__gn_moz.build
	firefox140/patches/patch-third__party_libwebrtc_modules_desktop__capture_linux_wayland_egl__dmabuf.cc
	firefox140/patches/patch-third__party_libwebrtc_modules_video__capture_linux_device__info__v4l2.cc
	firefox140/patches/patch-third__party_libwebrtc_modules_video__capture_linux_video__capture__v4l2.cc
	firefox140/patches/patch-third__party_libwebrtc_modules_video__capture_video__capture__options.cc
	firefox140/patches/patch-third__party_libwebrtc_rtc__base_memory__usage.cc
	firefox140/patches/patch-third__party_libwebrtc_rtc__base_physical__socket__server.cc
	firefox140/patches/patch-third__party_libwebrtc_rtc__base_platform__thread__types.cc
	firefox140/patches/patch-third__party_libwebrtc_system__wrappers_source_cpu__features__linux.cc
	firefox140/patches/patch-third__party_python_dlmanager_check.py
	firefox140/patches/patch-third__party_sqlite3_ext_moz.build
	firefox140/patches/patch-third__party_sqlite3_src_moz.build
	firefox140/patches/patch-third__party_wasm2c_src_c-writer.cc
	firefox140/patches/patch-third__party_wasm2c_src_prebuilt_wasm2c__source__includes.cc
	firefox140/patches/patch-toolkit_components_terminator_nsTerminator.cpp
	firefox140/patches/patch-toolkit_moz.configure
	firefox140/patches/patch-toolkit_mozapps_installer_packager.mk
	firefox140/patches/patch-xpcom_base_nscore.h
	firefox140/patches/patch-xpcom_reflect_xptcall_md_unix_moz.build

Log Message:
firefox140: Import firefox140-140.3.1 as wip/firefox140

Mozilla Firefox is a free, open-source and cross-platform web browser
for Windows, Linux, MacOS X and many other operating systems.

It is fast and easy to use, and offers many advantages over other web
browsers, such as tabbed browsing and the ability to block pop-up
windows.

Firefox also offers excellent bookmark and history management, and it
can be extended by developers using industry standards such as XML,
CSS, JavaScript, C++, etc. Many extensions are available.

Note: Due to upstream's trademark policies, this package identifies as
"Nightly" rather than "Firefox" by default.

This package provides Firefox 140 Extended Support Release.

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=897d72f8a49f7949c5d3d80d988868ba188a11d3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 firefox140/DESCR                                   |  15 ++
 firefox140/Makefile                                | 200 ++++++++++++++
 firefox140/PLIST                                   |  40 +++
 firefox140/PLIST.Linux                             |   2 +
 firefox140/TODO                                    |  18 ++
 firefox140/distinfo                                |  57 ++++
 firefox140/files/desktop.in                        | 191 +++++++++++++
 firefox140/files/firefox.sh                        |  14 +
 firefox140/files/node-wrapper.sh                   |   9 +
 firefox140/files/replace-moz.build.awk             | 106 ++++++++
 firefox140/mozilla-common.mk                       | 296 +++++++++++++++++++++
 firefox140/options.mk                              | 104 ++++++++
 .../patches/patch-browser_app_profile_firefox.js   |  47 ++++
 .../patch-build_moz.configure_init.configure       |  15 ++
 .../patch-build_moz.configure_rust.configure       |  15 ++
 .../patch-config_gcc-stl-wrapper.template.h        |  31 +++
 firefox140/patches/patch-config_makefiles_rust.mk  |  29 ++
 firefox140/patches/patch-dom_base_nsAttrName.h     |  18 ++
 ...nsport_api_WebTransportDatagramDuplexStream.cpp |  40 +++
 ...c_common_third__party_smhasher_src_PMurHash.cpp |  17 ++
 ...gle_checkout_src_compiler_translator_InfoSink.h |  16 ++
 firefox140/patches/patch-gfx_ots_src_name.cc       |  13 +
 ...kia_src_sksl_codegen_SkSLSPIRVCodeGenerator.cpp |  13 +
 ...pc_chromium_src_base_message__pump__libevent.cc |  22 ++
 ...pc_chromium_src_base_platform__thread__posix.cc |  17 ++
 .../patch-ipc_glue_GeckoChildProcessHost.cpp       |  21 ++
 .../patch-js-src-jit-arm64-vixl-MozCpu-vixl.cpp    |  15 ++
 firefox140/patches/patch-js_public_Utility.h       |  27 ++
 .../patches/patch-js_src_jit_FlushICache.cpp       |  34 +++
 .../patches/patch-js_src_util_NativeStack.cpp      |  32 +++
 .../patches/patch-js_src_vm_TypedArrayObject-inl.h |  17 ++
 .../patch-media_ffvpx_libavutil_arm_bswap.h        |  22 ++
 firefox140/patches/patch-media_libpng_pngpriv.h    |  17 ++
 .../patch-modules_fdlibm_src_math__private.h       |  20 ++
 .../patch-netwerk_protocol_http_nsHttpHandler.cpp  |  15 ++
 .../patch-nsprpub_pr_src_pthreads_ptsynch.c        | 112 ++++++++
 ...thon_mozbuild_mozbuild_backend_recursivemake.py |  27 ++
 ...tch-python_mozbuild_mozbuild_frontend_reader.py |  15 ++
 ...-cpp_absl_debugging_internal_elf__mem__image.cc |  17 ++
 ...il-cpp_absl_debugging_internal_vdso__support.cc |  18 ++
 .../patch-third__party_js_cfworker_build.sh        |  20 ++
 ...tc_modules_audio__device_audio__device__impl.cc |  34 +++
 ...desktop__capture_desktop__capture__gn_moz.build |  45 ++++
 ...s_desktop__capture_linux_wayland_egl__dmabuf.cc |  21 ++
 ...ules_video__capture_linux_device__info__v4l2.cc | 107 ++++++++
 ...es_video__capture_linux_video__capture__v4l2.cc |  23 ++
 ...dules_video__capture_video__capture__options.cc |  13 +
 ...ird__party_libwebrtc_rtc__base_memory__usage.cc |  22 ++
 ...libwebrtc_rtc__base_physical__socket__server.cc |  13 +
 ..._libwebrtc_rtc__base_platform__thread__types.cc |  29 ++
 ...system__wrappers_source_cpu__features__linux.cc |  25 ++
 .../patch-third__party_python_dlmanager_check.py   |  24 ++
 .../patch-third__party_sqlite3_ext_moz.build       |  13 +
 .../patch-third__party_sqlite3_src_moz.build       |  15 ++
 .../patch-third__party_wasm2c_src_c-writer.cc      |  13 +
 ...wasm2c_src_prebuilt_wasm2c__source__includes.cc |  13 +
 ...-toolkit_components_terminator_nsTerminator.cpp |  27 ++
 firefox140/patches/patch-toolkit_moz.configure     |  31 +++
 .../patch-toolkit_mozapps_installer_packager.mk    |  15 ++
 firefox140/patches/patch-xpcom_base_nscore.h       |  15 ++
 .../patch-xpcom_reflect_xptcall_md_unix_moz.build  |  17 ++
 61 files changed, 2289 insertions(+)

diffs:
diff --git a/firefox140/DESCR b/firefox140/DESCR
new file mode 100644
index 0000000000..20e6c60d1f
--- /dev/null
+++ b/firefox140/DESCR
@@ -0,0 +1,15 @@
+Mozilla Firefox is a free, open-source and cross-platform web browser
+for Windows, Linux, MacOS X and many other operating systems.
+
+It is fast and easy to use, and offers many advantages over other web
+browsers, such as tabbed browsing and the ability to block pop-up
+windows.
+
+Firefox also offers excellent bookmark and history management, and it
+can be extended by developers using industry standards such as XML,
+CSS, JavaScript, C++, etc. Many extensions are available.
+
+Note: Due to upstream's trademark policies, this package identifies as
+"Nightly" rather than "Firefox" by default.
+
+This package provides Firefox 140 Extended Support Release.
diff --git a/firefox140/Makefile b/firefox140/Makefile
new file mode 100644
index 0000000000..f8acb56323
--- /dev/null
+++ b/firefox140/Makefile
@@ -0,0 +1,200 @@
+# $NetBSD: Makefile,v 1.637 2025/07/23 13:57:34 ryoon Exp $
+
+FIREFOX_VER=		${MOZ_BRANCH}${MOZ_BRANCH_MINOR}
+MOZ_BRANCH=		140.3
+MOZ_BRANCH_MINOR=	.1esr
+
+DISTNAME=	firefox-${FIREFOX_VER}.source
+PKGNAME=	${DISTNAME:S/.source//:S/b/beta/:S/esr//:S/firefox-/firefox140-/}
+CATEGORIES=	www
+MASTER_SITES+=	${MASTER_SITE_MOZILLA:=firefox/releases/${FIREFOX_VER}/source/}
+MASTER_SITES+=	${MASTER_SITE_MOZILLA_ALL:=firefox/releases/${FIREFOX_VER}/source/}
+EXTRACT_SUFX=	.tar.xz
+
+NODEJSKIT=		nodejs-output-140.0.4.tgz
+DISTFILES=		${DEFAULT_DISTFILES} ${NODEJSKIT}
+SITES.${NODEJSKIT}=	${MASTER_SITE_LOCAL}
+
+MAINTAINER=	ryoon%NetBSD.org@localhost
+HOMEPAGE=	https://www.mozilla.org/en-US/firefox/
+COMMENT=	Web browser with support for extensions (version ${FIREFOX_VER:tu:C/\\.[[:digit:]\.]*//})
+LICENSE=	mpl-1.1
+
+# -------- BEFORE UPDATING THIS PACKAGE PLEASE READ & UNDERSTAND: -------
+#
+# This package works around a (stupid) build time dependency on nodejs
+# (which is not available for all architectures and unnecessary for the
+# real build). To do this, it places some additional burden on the
+# maintainer.
+#
+# While working on the package, please make sure you have
+#
+#	FIREFOX_MAINTAINER=yes
+#
+# set in your build environment.
+# When the package is ready for commit (but before commit), do:
+#
+#	make maintainer-files
+#
+# This will do another round (depending on state of your work dir at this
+# moment) of one or two builds and generate a cache of all output that
+# nodejs generates during a build.
+#
+# When this is done, just commit the results (they will be in the files/
+# directory).
+#
+# -----------------------------------------------------------------------
+
+WRKSRC=		${WRKDIR}/firefox-${PKGVERSION_NOREV}
+
+MOZILLA_DIR=	# empty
+
+# Note: In --enable-chrome-format=flat case,
+#       when updating remember to conditionalise about-background.png in PLIST
+CONFIGURE_ARGS+=	--enable-application=browser
+
+#CFLAGS+=	-I${PREFIX}/include/nspr
+# for lang/gcc6
+CFLAGS+=	-D_GLIBCXX_INCLUDE_NEXT_C_HEADERS
+CFLAGS.SunOS+=	-D_POSIX_PTHREAD_SEMANTICS
+# Do not use uselocale() in third_party/pipewire.
+CFLAGS.NetBSD+=	-D__LOCALE_C_ONLY
+
+LDFLAGS+=		${COMPILER_RPATH_FLAG}${PREFIX}/lib/${PKGBASE}
+LDFLAGS+=		${COMPILER_RPATH_FLAG}${PREFIX}/lib
+LDFLAGS.DragonFly+=	-lplc4 -lnspr4
+LDFLAGS.FreeBSD+=	-lplc4 -lnspr4
+LDFLAGS.Linux+=		-lnspr4
+LDFLAGS.SunOS+=		-lm
+
+# Should revisit to complete mprotect support.
+NOT_PAX_MPROTECT_SAFE+=	lib/${PKGBASE}/${MOZILLA}
+NOT_PAX_MPROTECT_SAFE+=	lib/${PKGBASE}/${MOZILLA}-bin
+
+# Avoid ld "invalid section index" errors.
+BUILDLINK_TRANSFORM.SunOS+=	rm:-fdata-sections
+BUILDLINK_TRANSFORM.SunOS+=	rm:-ffunction-sections
+BUILDLINK_TRANSFORM.SunOS+=	rm:-pie
+
+BUILDLINK_TRANSFORM.SunOS+=	rm:-Wl,-rpath-link,${WRKDIR}/build/dist/bin
+BUILDLINK_TRANSFORM.SunOS+=	rm:-Wl,-rpath-link,${PREFIX}/lib
+
+# Workaround for https://bugs.llvm.org/show_bug.cgi?id=46366
+BUILDLINK_TRANSFORM.NetBSD+=	rm:-fexperimental-new-pass-manager
+
+SUBST_CLASSES+=			dfly_malloc_h
+SUBST_STAGE.dfly_malloc_h=	pre-configure
+SUBST_MESSAGE.dfly_malloc_h=	Dont include malloc.h on dragonflybsd
+SUBST_SED.dfly_malloc_h=	-e 's,HAVE_MALLOC_H,HAVE_MALLOC_H \&\& !defined(__DragonFly__),g'
+SUBST_FILES.dfly_malloc_h+=	media/ffvpx/libavutil/mem.c
+
+SUBST_CLASSES+=			paths
+SUBST_STAGE.paths=		pre-configure
+SUBST_FILES.paths=		../firefox.sh
+SUBST_VARS.paths=		PREFIX MOZILLA
+
+.include "mozilla-common.mk"
+.include "options.mk"
+
+CHECK_INTERPRETER_SKIP+=	lib/firefox-sdk/sdk/bin/header.py
+CHECK_INTERPRETER_SKIP+=	lib/firefox-sdk/sdk/bin/typelib.py
+CHECK_INTERPRETER_SKIP+=	lib/firefox-sdk/sdk/bin/xpidl.py
+CHECK_INTERPRETER_SKIP+=	lib/firefox-sdk/sdk/bin/xpt.py
+
+CHECK_WRKREF_SKIP+=	lib/${MOZILLA}/omni.ja
+
+MOZILLA=	${PKGBASE}
+
+.if !empty(PKG_OPTIONS:Mofficial-mozilla-branding)
+MOZILLA_NAME=		Firefox
+MOZILLA_BRANDING=	official
+.else
+MOZILLA_NAME=		Browser
+MOZILLA_BRANDING=	unofficial
+.endif
+
+pre-configure:
+# As of 106.0, .in template files are not patched.
+#	cd ${WRKSRC} && autoconf
+#	cd ${WRKSRC}/js/src && autoconf
+	cd ${WRKSRC} && mkdir ${OBJDIR}
+	cd ${WRKSRC}/${OBJDIR} && touch old-configure.vars
+#	Do not fetch Rust Cargo file via network during build
+.if !defined(FIREFOX_MAINTAINER)
+	mv ${WRKDIR}/dist ${WRKSRC}/${OBJDIR}
+.endif
+
+.if defined(FIREFOX_MAINTAINER)
+# Create files needed only by the firefox maintainer when updating
+# the package
+# XXX - manually removing the .*_done files is wrong!
+.PHONY: build-list
+build-list:
+	cd ${WRKSRC}/${OBJDIR}/dist/bin/browser/chrome && \
+		find . -type f | sort > ${OUT:Q}
+
+NODE_LIST=	"${WRKDIR}/node.list"
+NO_NODE_LIST=	"${WRKDIR}/no-node.list"
+NODE_FILES=	"${WRKDIR}/node.flist"
+
+.PHONY: maintainer-files
+maintainer-files:
+	rm -f ${FILESDIR}/node-wrapper.sh
+	V=$$( node -v ) && \
+	    printf '#! /bin/sh\n\nVERS=%s\n\nif [ "$$1" = "-v" ] || [ "$$1" = "--version" ]; then\n\tprintf "$${VERS}\\n"\nfi\n\nexit 0\n' $$V \
+	    > ${FILESDIR}/node-wrapper.sh && \
+	    chmod 0755 ${FILESDIR}/node-wrapper.sh
+	rm -f ${WRKDIR}/.build_done ${WRKDIR}/.configure_done
+	${MAKE} MAINTAINER_INTERNAL=yes build
+	${MAKE} MAINTAINER_INTERNAL=yes OUT="${NO_NODE_LIST}" build-list
+	${MAKE} OUT="${NODE_LIST}" build-list
+	${DIFF} -u "${NO_NODE_LIST}" "${NODE_LIST}" | \
+	    ${AWK} \
+	    '/^\+\.\//{ printf("dist/bin/browser/chrome/%s\n", gensub(/^\+\.\//, "", "")) }' \
+	    > "${NODE_FILES}"
+	cd ${WRKSRC}/${OBJDIR} && tar -c -T "${NODE_FILES}" -z \
+	    -f ${FILESDIR}/nodejs-output-${PKGVERSION_NOREV}.tgz
+.endif
+
+pre-patch:
+	for f in $$(find ${WRKSRC}/third_party/libwebrtc -name moz.build -type f) ; \
+	do \
+		${AWK} -f ${FILESDIR}/replace-moz.build.awk $$f > $$f.new; mv $$f.new $$f ; \
+	done
+	for f in $$(find ${WRKSRC}/third_party/abseil-cpp -name moz.build -type f) ; \
+	do \
+		${AWK} -f ${FILESDIR}/replace-moz.build.awk $$f > $$f.new; mv $$f.new $$f ; \
+	done
+
+post-build:
+	${SED} -e 's|@MOZILLA@|${MOZILLA}|g'				\
+	  -e 's|@MOZILLA_NAME@|${MOZILLA_NAME}|g'			\
+	  -e 's|@FIREFOX_ICON@|${MOZILLA}|g'				\
+	  < ${FILESDIR}/desktop.in					\
+	  > ${WRKDIR}/desktop
+
+INSTALLATION_DIRS+=	share/applications
+
+post-extract:
+	${CP} ${FILESDIR}/firefox.sh ${WRKDIR}/firefox.sh
+
+post-install:
+.if ${OPSYS} == "NetBSD" && ${X11_TYPE} == "native"
+	${INSTALL_SCRIPT} ${WRKDIR}/firefox.sh ${DESTDIR}${PREFIX}/bin/${MOZILLA}
+.else
+	${ECHO} '#! /bin/sh' > ${DESTDIR}${PREFIX}/bin/${MOZILLA}
+	${ECHO} '${PREFIX}/lib/${MOZILLA}/${MOZILLA} "$$@"' >> \
+		${DESTDIR}${PREFIX}/bin/${MOZILLA}
+	${CHMOD} 755 ${DESTDIR}${PREFIX}/bin/${MOZILLA}
+.endif
+	${INSTALL_DATA} ${WRKDIR}/desktop				\
+	  ${DESTDIR}${PREFIX}/share/applications/${MOZILLA}.desktop
+.for i in 16 22 24 32 48 64 128 256
+	${INSTALL_DATA_DIR} ${DESTDIR}${PREFIX}/share/icons/hicolor/${i}x${i}/apps
+	${INSTALL_DATA} ${WRKSRC}/browser/branding/${MOZILLA_BRANDING}/default${i}.png \
+	  ${DESTDIR}${PREFIX}/share/icons/hicolor/${i}x${i}/apps/${MOZILLA}.png
+.endfor
+
+.include "../../graphics/hicolor-icon-theme/buildlink3.mk"
+.include "../../sysutils/desktop-file-utils/desktopdb.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/firefox140/PLIST b/firefox140/PLIST
new file mode 100644
index 0000000000..5db2865ef4
--- /dev/null
+++ b/firefox140/PLIST
@@ -0,0 +1,40 @@
+@comment $NetBSD: PLIST,v 1.190 2025/05/13 20:56:25 ryoon Exp $
+bin/firefox140
+lib/firefox140/application.ini
+lib/firefox140/browser/chrome/icons/default/default128.png
+lib/firefox140/browser/chrome/icons/default/default16.png
+lib/firefox140/browser/chrome/icons/default/default32.png
+lib/firefox140/browser/chrome/icons/default/default48.png
+lib/firefox140/browser/chrome/icons/default/default64.png
+lib/firefox140/browser/omni.ja
+lib/firefox140/defaults/pref/channel-prefs.js
+lib/firefox140/dependentlibs.list
+lib/firefox140/firefox140
+lib/firefox140/firefox140-bin
+lib/firefox140/fonts/TwemojiMozilla.ttf
+lib/firefox140/glxtest
+lib/firefox140/gmp-clearkey/0.1/libclearkey.so
+lib/firefox140/gmp-clearkey/0.1/manifest.json
+lib/firefox140/libgkcodecs.so
+lib/firefox140/liblgpllibs.so
+${PLIST.ffvpx}lib/firefox140/libmozavcodec.so
+${PLIST.ffvpx}lib/firefox140/libmozavutil.so
+lib/firefox140/libmozgtk.so
+lib/firefox140/libmozsqlite3.so
+${PLIST.wayland}lib/firefox140/libmozwayland.so
+lib/firefox140/libxul.so
+lib/firefox140/omni.ja
+lib/firefox140/pingsender
+lib/firefox140/platform.ini
+lib/firefox140/removed-files
+${PLIST.v4l2_decode}lib/firefox140/v4l2test
+lib/firefox140/vaapitest
+share/applications/firefox140.desktop
+share/icons/hicolor/128x128/apps/firefox140.png
+share/icons/hicolor/16x16/apps/firefox140.png
+share/icons/hicolor/22x22/apps/firefox140.png
+share/icons/hicolor/24x24/apps/firefox140.png
+share/icons/hicolor/256x256/apps/firefox140.png
+share/icons/hicolor/32x32/apps/firefox140.png
+share/icons/hicolor/48x48/apps/firefox140.png
+share/icons/hicolor/64x64/apps/firefox140.png
diff --git a/firefox140/PLIST.Linux b/firefox140/PLIST.Linux
new file mode 100644
index 0000000000..5bf6fb813c
--- /dev/null
+++ b/firefox140/PLIST.Linux
@@ -0,0 +1,2 @@
+@comment $NetBSD: PLIST.Linux,v 1.4 2021/08/21 22:53:00 mcf Exp $
+lib/firefox/libmozsandbox.so
diff --git a/firefox140/TODO b/firefox140/TODO
new file mode 100644
index 0000000000..7186924386
--- /dev/null
+++ b/firefox140/TODO
@@ -0,0 +1,18 @@
+Running maintainers-file target as required fails with:
+
+[...]
+gmake[3]: Leaving directory '.../pkgsrc/www/firefox140/work/no-node-build/browser/app'
+gmake[2]: Leaving directory '.../pkgsrc/www/firefox140/work/no-node-build'
+gmake[1]: Leaving directory '.../pkgsrc/www/firefox140/work/no-node-build'
+*** Please use pkgtools/verifypc to sanity check dependencies.
+/usr/bin/sed -e 's|@MOZILLA@|firefox140|g'                               -e 's|@MOZILLA_NAME@|Browser|g'                         -e 's|@FIREFOX_ICON@|firefox140|g'                            < .../pkgsrc/www/firefox140/files/desktop.in                                         > .../pkgsrc/www/firefox140/work/desktop
+/usr/bin/make MAINTAINER_INTERNAL=yes OUT="".../pkgsrc/www/firefox140/work/no-node.list"" build-list
+cd .../pkgsrc/www/firefox140/work/firefox-140.3.1/../no-node-build/dist/bin/browser/chrome &&  find . -type f | sort > .../pkgsrc/www/firefox140/work/no-node.list
+/usr/bin/make OUT="".../pkgsrc/www/firefox140/work/node.list"" build-list
+cd .../pkgsrc/www/firefox140/work/firefox-140.3.1/../build/dist/bin/browser/chrome &&  find . -type f | sort > .../pkgsrc/www/firefox140/work/node.list
+cd: Can't cd to ".../pkgsrc/www/firefox140/work/firefox-140.3.1/../build/dist/bin/browser/chrome": No such file or directory
+*** Error code 2
+
+Stop.
+make[1]: stopped making "build-list" in .../pkgsrc/www/firefox140
+[...]
diff --git a/firefox140/distinfo b/firefox140/distinfo
new file mode 100644
index 0000000000..12fe7fbc96
--- /dev/null
+++ b/firefox140/distinfo
@@ -0,0 +1,57 @@
+$NetBSD: distinfo,v 1.559 2025/07/23 13:57:35 ryoon Exp $
+
+BLAKE2s (firefox-140.3.1esr.source.tar.xz) = e5b13d827e7079863017d8c97eea397eb158a1ef877d313660058d676be5fb44
+SHA512 (firefox-140.3.1esr.source.tar.xz) = a9302d99d7f07f4b250aa214635814964dd083204268e05fe877a3d8330b9c0caa6c29ed19da71bd88979b7cf39ed52f17698968b0da5b0d7430b6764b43b6cc
+Size (firefox-140.3.1esr.source.tar.xz) = 634713368 bytes
+BLAKE2s (nodejs-output-140.0.4.tgz) = 7ebb5993c8c9d7d5492afdb9fa7fef74fec7753fb0b14673817f24faf4a7fca4
+SHA512 (nodejs-output-140.0.4.tgz) = e421b0b6be8b5b8dfda705eefcf4573a1270df9012dca5eac9ba0ac2af2bcc47dd66b1057106f8c2336a10bdcc39b9f852041dd33da9e7a8929d981dbb4e1fb4
+Size (nodejs-output-140.0.4.tgz) = 245385 bytes
+SHA1 (patch-browser_app_profile_firefox.js) = bc719edef37d18655ba79b030270438ee166fdaf
+SHA1 (patch-build_moz.configure_init.configure) = 65deb3c233df0aab81eb1fca05d708e5a4ed169a
+SHA1 (patch-build_moz.configure_rust.configure) = 25ddfacd29cebbc6db005dbe61a2a7446d480678
+SHA1 (patch-config_gcc-stl-wrapper.template.h) = 9d1f15ff487efa9202114d19ed5668b4e7aa032a
+SHA1 (patch-config_makefiles_rust.mk) = 3366ab089a23e66230e7e23749c10db38018fdd4
+SHA1 (patch-dom_base_nsAttrName.h) = ac7ba441a3b27df2855cf2673eea36b1cb44ad49
+SHA1 (patch-dom_webtransport_api_WebTransportDatagramDuplexStream.cpp) = b93b4c6367bd2fb3d1868ab7d97ca56c100be414
+SHA1 (patch-gfx_angle_checkout_src_common_third__party_smhasher_src_PMurHash.cpp) = e458c9c8dc66edc69c1874734af28a77fc5e3993
+SHA1 (patch-gfx_angle_checkout_src_compiler_translator_InfoSink.h) = b2adce9e65662283a11b6dcff40e95523e940045
+SHA1 (patch-gfx_ots_src_name.cc) = 35ae5b2689eae8fab1ea351612f3628c14001f9e
+SHA1 (patch-gfx_skia_skia_src_sksl_codegen_SkSLSPIRVCodeGenerator.cpp) = 3eb9855e20fe8b7784a9620fce4ffb96f4736f82
+SHA1 (patch-ipc_chromium_src_base_message__pump__libevent.cc) = 298642a3527804115b398fb7904a3596962932e3
+SHA1 (patch-ipc_chromium_src_base_platform__thread__posix.cc) = 753bb4e90758f5b42a51bbc073b328de673988cf
+SHA1 (patch-ipc_glue_GeckoChildProcessHost.cpp) = 63fbee04321f7ade20db4ccc1a1218b848344ce1
+SHA1 (patch-js-src-jit-arm64-vixl-MozCpu-vixl.cpp) = d90fca47d79551fd74214d47f8184670b901b792
+SHA1 (patch-js_public_Utility.h) = bb5464a0398b91693ab362e6b9b06d48429b9e7d
+SHA1 (patch-js_src_jit_FlushICache.cpp) = f5d1fcb391c36a29fb71a78dbf731ee6a1cb17b6
+SHA1 (patch-js_src_util_NativeStack.cpp) = a0a16d8d8d78d3cc3f4d2a508586f1a7821f7dba
+SHA1 (patch-js_src_vm_TypedArrayObject-inl.h) = e7913c8d4b2b05b67040baa64dae62d6ba40390e
+SHA1 (patch-media_ffvpx_libavutil_arm_bswap.h) = 019677e249e744baea857ca17ef69d977f43b3a4
+SHA1 (patch-media_libpng_pngpriv.h) = 8320a1f7534ed5c4914b597bb3d6117d0060318f
+SHA1 (patch-modules_fdlibm_src_math__private.h) = e20b6c23011d7123cbbd64a500eb8ce8c426620e
+SHA1 (patch-netwerk_protocol_http_nsHttpHandler.cpp) = 67493b4635041d21ff9fbfda80b3197fed542a26
+SHA1 (patch-nsprpub_pr_src_pthreads_ptsynch.c) = 753fd4d62088c870aefe7c4b739286259848446e
+SHA1 (patch-python_mozbuild_mozbuild_backend_recursivemake.py) = 5be4183d9075f5a3a3c6b3e0338473af185fb50e
+SHA1 (patch-python_mozbuild_mozbuild_frontend_reader.py) = 57cad432ccc18e790e2cf00732f499116c79f4c1
+SHA1 (patch-third__party_abseil-cpp_absl_debugging_internal_elf__mem__image.cc) = 2b5955027add79d1b8709667b0433b2d19fbd1bc
+SHA1 (patch-third__party_abseil-cpp_absl_debugging_internal_vdso__support.cc) = f9c44d0d6fd952296f23c24f56053958b30d8e5c
+SHA1 (patch-third__party_js_cfworker_build.sh) = 46cdf97b99cf01080f290ae8d9a33b5f869fc3e4
+SHA1 (patch-third__party_libwebrtc_modules_audio__device_audio__device__impl.cc) = 47ba1a2b88b3fdfd16cd29da3eb1e4a218ecada8
+SHA1 (patch-third__party_libwebrtc_modules_desktop__capture_desktop__capture__gn_moz.build) = d0454784eb72be49162f619579e060a0de3c480f
+SHA1 (patch-third__party_libwebrtc_modules_desktop__capture_linux_wayland_egl__dmabuf.cc) = 455be625b5de2f6f1f4b2dbb6c8cb33ca16c2583
+SHA1 (patch-third__party_libwebrtc_modules_video__capture_linux_device__info__v4l2.cc) = 8831d477f14fd4f8f735ff0c1a322cba8c70e277
+SHA1 (patch-third__party_libwebrtc_modules_video__capture_linux_video__capture__v4l2.cc) = 8111952a107eb2cd665525ddd0e27c79eee3c1cd
+SHA1 (patch-third__party_libwebrtc_modules_video__capture_video__capture__options.cc) = e15f7e365ef6d57cd262f920f49c4d73f3a13305
+SHA1 (patch-third__party_libwebrtc_rtc__base_memory__usage.cc) = f8d926d400bf3df107127823eac27816f4b85644
+SHA1 (patch-third__party_libwebrtc_rtc__base_physical__socket__server.cc) = 6909c4da9e7b3785252e5bce9be0ff47ebb87e01
+SHA1 (patch-third__party_libwebrtc_rtc__base_platform__thread__types.cc) = 8ae75100775037347008d168eedc151e0e993b0f
+SHA1 (patch-third__party_libwebrtc_system__wrappers_source_cpu__features__linux.cc) = b90e22b50879f7adcc1da3a993f52c0701b720f8
+SHA1 (patch-third__party_python_dlmanager_check.py) = 69054522d8ced8cb47e65e5a8b1a87ed5ce6708e
+SHA1 (patch-third__party_sqlite3_ext_moz.build) = 026483e9cdc61eda80b699978b1677e1b6d3ff6d
+SHA1 (patch-third__party_sqlite3_src_moz.build) = b26856a4b87aa12211575d9982f62dc899474b52
+SHA1 (patch-third__party_wasm2c_src_c-writer.cc) = 38eb2ee0e00722aa1380540b83648b43723719aa
+SHA1 (patch-third__party_wasm2c_src_prebuilt_wasm2c__source__includes.cc) = 99d0db944f0c2d0c623460991efd423d9127c988
+SHA1 (patch-toolkit_components_terminator_nsTerminator.cpp) = e905e38ef1b88d764c695c019f15609350c1c43b
+SHA1 (patch-toolkit_moz.configure) = 1306e7ac3c3939886aff38a58dd3162e6517409b
+SHA1 (patch-toolkit_mozapps_installer_packager.mk) = 706635b76a7b525794aba95e95544f09e18bb662
+SHA1 (patch-xpcom_base_nscore.h) = 1ac4d34d3c9e80bc1ac966c6c84cb320bc0fa1ec
+SHA1 (patch-xpcom_reflect_xptcall_md_unix_moz.build) = 8980398051fa16c7283acb6d323419993cce1420
diff --git a/firefox140/files/desktop.in b/firefox140/files/desktop.in
new file mode 100644
index 0000000000..d72090e1aa
--- /dev/null
+++ b/firefox140/files/desktop.in
@@ -0,0 +1,191 @@
+[Desktop Entry]
+Encoding=UTF-8
+Name=@MOZILLA_NAME@ Web Browser
+Name[am]=
+Name[ar]=
+Name[az]=@MOZILLA_NAME@ Veb Səyyahı
+Name[be]=
+Name[bg]=Интернет браузър @MOZILLA_NAME@
+Name[bn]=
+Name[bs]=@MOZILLA_NAME@ web preglednik
+Name[ca]=Navegador web @MOZILLA_NAME@
+Name[cs]=Prohlížeč WWW @MOZILLA_NAME@
+Name[cy]=Y Porwr Gwe @MOZILLA_NAME@
+Name[da]=@MOZILLA_NAME@ - internetsurfning
+Name[de]=@MOZILLA_NAME@ Webbrowser
+Name[el]=Περιηγητής Διαδικτύου @MOZILLA_NAME@
+Name[en_CA]=@MOZILLA_NAME@ Web Browser
+Name[en_GB]=@MOZILLA_NAME@ Web Browser
+Name[es]=Navegador Web @MOZILLA_NAME@
+Name[et]=@MOZILLA_NAME@ veebibrauser
+Name[eu]=@MOZILLA_NAME@ web arakatzailea
+Name[fi]=@MOZILLA_NAME@, WWW-selain
+Name[fr]=Navigateur Web @MOZILLA_NAME@
+Name[ga]=Brabhsálaí Lín @MOZILLA_NAME@
+Name[gu]=એપીફની વૅબ બ્રાઉઝર
+Name[he]=דפדפן @MOZILLA_NAME@
+Name[hi]=
+Name[hr]=@MOZILLA_NAME@ Web preglednik
+Name[hu]=@MOZILLA_NAME@ webböngésző
+Name[id]=Web Browser @MOZILLA_NAME@
+Name[it]=Browser web @MOZILLA_NAME@
+Name[ja]=@MOZILLA_NAME@ ウェブ・ブラウザ
+Name[ko]=@MOZILLA_NAME@ 웹 브라우저
+Name[li]=@MOZILLA_NAME@ Web Browser
+Name[lt]=@MOZILLA_NAME@ web naršyklė
+Name[mk]=@MOZILLA_NAME@ веб прелистувач
+Name[ml]=എപ്പിഫാനി വെബ്ബ് ബ്രൌസ‌ര്
+Name[mn]=@MOZILLA_NAME@ веб хөтөч
+Name[ms]=Pelungsur Web @MOZILLA_NAME@
+Name[nb]=@MOZILLA_NAME@ nettleser
+Name[nl]=@MOZILLA_NAME@ Webbrowser
+Name[nn]=@MOZILLA_NAME@ nettlesar
+Name[no]=@MOZILLA_NAME@ nettleser
+Name[pa]=ਏਪੀਫਾਨੀ ਵੈੱਬ ਬਰਾਊਜ਼ਰ
+Name[pl]=Przeglądarka WWW @MOZILLA_NAME@
+Name[pt]=Navegador Web @MOZILLA_NAME@
+Name[pt_BR]=Navegador Web @MOZILLA_NAME@
+Name[ro]=Navigatorul @MOZILLA_NAME@
+Name[ru]=Веб-браузер @MOZILLA_NAME@
+Name[sk]=
+Name[sl]=Spletni brskalnik @MOZILLA_NAME@
+Name[sq]=@MOZILLA_NAME@ - Shfletuesi Web
+Name[sr]=
+Name[sr@Latn]=Veb čitač Spoznaja
+Name[sv]=Webbläsaren @MOZILLA_NAME@
+Name[ta]=எபிபனி வலை உலாவி
+Name[tk]=@MOZILLA_NAME@ Web Ahtarçisi
+Name[tr]=@MOZILLA_NAME@ Web Tarayıcı
+Name[uk]=Переглядач web @MOZILLA_NAME@
+Name[vi]=Trình Duyệt Web @MOZILLA_NAME@
+Name[wa]=Betchteu waibe epiphany
+Name[zh_CN]=@MOZILLA_NAME@ Web 浏览器
+Name[zh_TW]=@MOZILLA_NAME@ 網頁瀏覽器
+GenericName=Web Browser
+GenericName[ar]=متصفّح الانترنت
+GenericName[az]=Veb Səyyahı
+GenericName[be]=Вандроўнік па павуціньню
+GenericName[bg]=Браузър
+GenericName[bn]=ওয়েব ব্রাউজার
+GenericName[bs]=Web preglednik
+GenericName[ca]=Navegador web
+GenericName[cs]=Prohlížeč WWW
+GenericName[cy]=Porwr Gwe
+GenericName[da]=Internetsurfning
+GenericName[de]=Webbrowser
+GenericName[el]=Περιηγητής Ιστοσελίδων
+GenericName[en_CA]=Web Browser
+GenericName[en_GB]=Web Browser
+GenericName[es]=Navegador web
+GenericName[et]=Veebilehitseja
+GenericName[eu]=Web arakatzailea
+GenericName[fi]=WWW-selain
+GenericName[fr]=Navigateur Web @MOZILLA_NAME@
+GenericName[ga]=Brabhsálaí Lín
+GenericName[gu]=વેબ બ્રાઉઝર
+GenericName[he]=דפדפן אינטרנט
+GenericName[hi]=वेब ब्राउज़र
+GenericName[hr]=Web preglednik
+GenericName[hu]=Webböngésző
+GenericName[id]=Browser Web
+GenericName[it]=Browser web
+GenericName[ja]=GNOME ウェブ・ブラウザ
+GenericName[ko]=웹 브라우저
+GenericName[li]=Wèb Browser
+GenericName[lt]=Web naršyklė
+GenericName[mk]=Веб прелистувач
+GenericName[mn]=Веб хөтөч
+GenericName[ms]=Pelungsur Web
+GenericName[nb]=Nettleser
+GenericName[nl]=Web-browser
+GenericName[nn]=Nettlesar
+GenericName[no]=Nettleser
+GenericName[pa]=ਵੈਬ ਬਰਾਊਜ਼
+GenericName[pl]=Przeglądarka WWW
+GenericName[pt]=Navegador Web
+GenericName[pt_BR]=Navegador Web
+GenericName[ro]=Navigator Internet
+GenericName[ru]=Веб-браузер
+GenericName[sk]=WWW prehliadač
+GenericName[sl]=Spletni brskalnik
+GenericName[sq]=Shfletuesi Web
+GenericName[sr]=Веб читач
+GenericName[sr@Latn]=Veb čitač
+GenericName[sv]=Webbläsare
+GenericName[ta]=வலை உலாவி
+GenericName[th]=เว็บบราวเซอร์
+GenericName[tk]=Web Ahtarçysy
+GenericName[tr]=Web Tarayıcı
+GenericName[uk]=Переглядач web-сторінок
+GenericName[vi]=Trình duyệt Web
+GenericName[wa]=Betchteu waibe
+GenericName[zh_CN]=Web 浏览器
+GenericName[zh_TW]=網頁瀏覽器
+Comment=Browse the web
+Comment[ar]=تصفح الانترنت
+Comment[az]=Vebi gəzin
+Comment[be]=Вандраваць па павуціньню
+Comment[bg]=Сърфиране в интернет
+Comment[bn]=ওয়েব ব্রাউজ করুন
+Comment[bs]=Pregledaj na internetu
+Comment[ca]=Navegueu per la web
+Comment[cs]=Prohlížet WWW
+Comment[cy]=Pori'r we
+Comment[da]=Surf på internettet
+Comment[de]=Im Web surfen
+Comment[el]=Περιήγηση στον παγκόσμιο ιστό
+Comment[en_CA]=Browse the web
+Comment[en_GB]=Browse the web
+Comment[es]=Navegar por la web
+Comment[et]=Sirvi veebi
+Comment[eu]=Arakatu web-a
+Comment[fi]=Selaa WWW:tä
+Comment[fr]=Naviguer sur Internet
+Comment[ga]=Brabhsáil an Líon
+Comment[gu]=વેબમાં શોધો
+Comment[he]=גלוש ברשת
+Comment[hi]=वेब ब्राउज़ करें
+Comment[hr]=Pregledaj Web
+Comment[hu]=A világháló böngészése
+Comment[id]=Jelajah web
+Comment[it]=Esplora il web
+Comment[ja]=ウェブを閲覧します
+Comment[ko]=웹을 돌아 다닙니다
+Comment[li]=Blajere op internet
+Comment[lt]=Naršyti internete
+Comment[mk]=Прелистувајте на веб
+Comment[ml]=വലക്കെട്ട് തിരയുക
+Comment[mn]=Веб броузе хийх
+Comment[ms]=Layari web
+Comment[nb]=Surf på nettet
+Comment[nl]=Websurfen
+Comment[nn]=Surf på nettet
+Comment[no]=Surf på nettet
+Comment[pa]=ਵੈਬ ਬਰਾਊਜ਼
+Comment[pl]=Przeglądanie stron WWW
+Comment[pt]=Navegar na web
+Comment[pt_BR]=Navegar na web
+Comment[ro]=Navigare Internet
+Comment[ru]=Веб-браузер
+Comment[sk]=Prehliadať internet
+Comment[sl]=Brskaj po spletu
+Comment[sq]=Eksploro web-in
+Comment[sr]=Прегледај веб
+Comment[sr@Latn]=Pregledaj veb
+Comment[sv]=Surfa på nätet
+Comment[ta]=வலையில் உலாவு
+Comment[th]=ใช้งานเว็บบราวเซอร์ @MOZILLA_NAME@
+Comment[tk]=Webi Ahtar
+Comment[tr]=Web'e Gözat
+Comment[uk]=Програма перегляду web-сторінок
+Comment[vi]=Duyệt web
+Comment[wa]=Naivyî avå les waibes
+Comment[zh_CN]=浏览 Web
+Comment[zh_TW]=瀏覽網頁
+Exec=@MOZILLA@ %u
+Icon=@FIREFOX_ICON@
+StartupNotify=false
+Terminal=false
+Type=Application
+Categories=Application;Network;
+MimeType=text/html;text/xml;application/xhtml+xml;application/vnd.mozilla.xul+xml;text/mml;
diff --git a/firefox140/files/firefox.sh b/firefox140/files/firefox.sh
new file mode 100755
index 0000000000..b2b1ab5655
--- /dev/null
+++ b/firefox140/files/firefox.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+if [ -f /usr/X11R7/lib/libEGL.so ] && [ -z "$LD_PRELOAD" ] && \
+  nm /usr/X11R7/lib/libGL.so | grep -Fq "B _glapi_tls_Dispatch"; then
+    # Workaround for PR#57445/50277 for netbsd-9 & netbsd-10 pre 2023-08-05
+    # This may not avoid a crash 100% of the time, but changes at least some
+    # cases of 100% crash on startup to "have not yet seen crash on startup"
+    echo "Applying libEGL LD_PRELOAD workaround for NetBSD" >&2
+    export LD_PRELOAD=/usr/X11R7/lib/libEGL.so
+    # Note that there is an _additional_ issue with firefox >= 111 that
+    # needs to be addressed, and that is worked around by disabling webgl
+    # by default, but it's not even worth looking at that on a system without
+    # the fixed libGL
+fi
+exec @PREFIX@/lib/@MOZILLA@/@MOZILLA@ "$@"
diff --git a/firefox140/files/node-wrapper.sh b/firefox140/files/node-wrapper.sh
new file mode 100755
index 0000000000..9d1b215a65
--- /dev/null
+++ b/firefox140/files/node-wrapper.sh
@@ -0,0 +1,9 @@
+#! /bin/sh
+
+VERS=v24.10.0
+
+if [ "$1" = "-v" ] || [ "$1" = "--version" ]; then
+	printf "${VERS}\n"
+fi
+
+exit 0
diff --git a/firefox140/files/replace-moz.build.awk b/firefox140/files/replace-moz.build.awk
new file mode 100644
index 0000000000..4de20ea8a0
--- /dev/null
+++ b/firefox140/files/replace-moz.build.awk
@@ -0,0 +1,106 @@
+/^if CONFIG\[\"OS_TARGET\"\] == \"Android\":/{
+	flag = 1;
+	print $0;
+	next;
+}
+/^if CONFIG\[\"OS_TARGET\"\] == \"Linux\":/{
+	flag = 0;
+	sub(/^if CONFIG\[\"OS_TARGET\"\] == \"Linux\":/, "if CONFIG[\"OS_TARGET\"] == \"Linux\" or CONFIG[\"OS_TARGET\"] == \"NetBSD\" or CONFIG[\"OS_TARGET\"] == \"OpenBSD\" or CONFIG[\"OS_TARGET\"] == \"FreeBSD\":");
+	print $0;
+	next;
+}
+/^if CONFIG\[\"TARGET_CPU\"\] == \"arm\" and CONFIG\[\"OS_TARGET\"\] == \"Linux\":/{
+	flag = 0;
+	sub(/^if CONFIG\[\"TARGET_CPU\"\] == \"arm\" and CONFIG\[\"OS_TARGET\"\] == \"Linux\":/, "if CONFIG\[\"TARGET_CPU\"\] == \"arm\" and (CONFIG[\"OS_TARGET\"] == \"Linux\" or CONFIG[\"OS_TARGET\"] == \"NetBSD\" or CONFIG[\"OS_TARGET\"] == \"OpenBSD\" or CONFIG[\"OS_TARGET\"] == \"FreeBSD\"):");
+	print $0;
+	next;
+}
+/^if CONFIG\[\"OS_TARGET\"\] == \"Linux\" and CONFIG\[\"TARGET_CPU\"\] == \"arm\":/{
+	flag = 0;
+	sub(/^if CONFIG\[\"OS_TARGET\"\] == \"Linux\" and CONFIG\[\"TARGET_CPU\"\] == \"arm\":/, "if CONFIG\[\"TARGET_CPU\"\] == \"arm\" and (CONFIG[\"OS_TARGET\"] == \"Linux\" or CONFIG[\"OS_TARGET\"] == \"NetBSD\" or CONFIG[\"OS_TARGET\"] == \"OpenBSD\" or CONFIG[\"OS_TARGET\"] == \"FreeBSD\"):");
+	print $0;
+	next;
+}
+/^if CONFIG\[\"TARGET_CPU\"\] == \"aarch64\" and CONFIG\[\"OS_TARGET\"\] == \"Linux\":/{
+	flag = 0;
+	sub(/^if CONFIG\[\"TARGET_CPU\"\] == \"aarch64\" and CONFIG\[\"OS_TARGET\"\] == \"Linux\":/, "if CONFIG\[\"TARGET_CPU\"\] == \"aarch64\" and (CONFIG[\"OS_TARGET\"] == \"Linux\" or CONFIG[\"OS_TARGET\"] == \"NetBSD\" or CONFIG[\"OS_TARGET\"] == \"OpenBSD\" or CONFIG[\"OS_TARGET\"] == \"FreeBSD\"):");
+	print $0;
+	next;
+}
+/^if CONFIG\[\"OS_TARGET\"\] == \"Linux\" and CONFIG\[\"TARGET_CPU\"\] == \"aarch64\":/{
+	flag = 0;
+	sub(/^if CONFIG\[\"OS_TARGET\"\] == \"Linux\" and CONFIG\[\"TARGET_CPU\"\] == \"aarch64\":/, "if CONFIG\[\"TARGET_CPU\"\] == \"aarch64\" and (CONFIG[\"OS_TARGET\"] == \"Linux\" or CONFIG[\"OS_TARGET\"] == \"NetBSD\" or CONFIG[\"OS_TARGET\"] == \"OpenBSD\" or CONFIG[\"OS_TARGET\"] == \"FreeBSD\"):");
+	print $0;
+	next;
+}
+/^if CONFIG\[\"TARGET_CPU\"\] == \"x86\" and CONFIG\[\"OS_TARGET\"\] == \"Linux\":/{
+	flag = 0;
+	sub(/^if CONFIG\[\"TARGET_CPU\"\] == \"x86\" and CONFIG\[\"OS_TARGET\"\] == \"Linux\":/, "if CONFIG\[\"TARGET_CPU\"\] == \"x86\" and (CONFIG[\"OS_TARGET\"] == \"Linux\" or CONFIG[\"OS_TARGET\"] == \"NetBSD\" or CONFIG[\"OS_TARGET\"] == \"OpenBSD\" or CONFIG[\"OS_TARGET\"] == \"FreeBSD\"):");
+	print $0;
+	next;
+}
+/^if CONFIG\[\"OS_TARGET\"\] == \"Linux\" and CONFIG\[\"TARGET_CPU\"\] == \"x86\":/{
+	flag = 0;
+	sub(/^if CONFIG\[\"OS_TARGET\"\] == \"Linux\" and CONFIG\[\"TARGET_CPU\"\] == \"x86\":/, "if CONFIG\[\"TARGET_CPU\"\] == \"x86\" and (CONFIG[\"OS_TARGET\"] == \"Linux\" or CONFIG[\"OS_TARGET\"] == \"NetBSD\" or CONFIG[\"OS_TARGET\"] == \"OpenBSD\" or CONFIG[\"OS_TARGET\"] == \"FreeBSD\"):");
+	print $0;
+	next;
+}
+/^if CONFIG\[\"TARGET_CPU\"\] == \"x86_64\" and CONFIG\[\"OS_TARGET\"\] == \"Linux\":/{
+	flag = 0;
+	sub(/^if CONFIG\[\"TARGET_CPU\"\] == \"x86_64\" and CONFIG\[\"OS_TARGET\"\] == \"Linux\":/, "if CONFIG\[\"TARGET_CPU\"\] == \"x86_64\" and (CONFIG[\"OS_TARGET\"] == \"Linux\" or CONFIG[\"OS_TARGET\"] == \"NetBSD\" or CONFIG[\"OS_TARGET\"] == \"OpenBSD\" or CONFIG[\"OS_TARGET\"] == \"FreeBSD\"):");
+	print $0;
+	next;
+}
+/^if CONFIG\[\"OS_TARGET\"\] == \"Linux\" and CONFIG\[\"TARGET_CPU\"\] == \"x86_64\":/{
+	flag = 0;
+	sub(/^if CONFIG\[\"OS_TARGET\"\] == \"Linux\" and CONFIG\[\"TARGET_CPU\"\] == \"x86_64\":/, "if CONFIG\[\"TARGET_CPU\"\] == \"x86_64\" and (CONFIG[\"OS_TARGET\"] == \"Linux\" or CONFIG[\"OS_TARGET\"] == \"NetBSD\" or CONFIG[\"OS_TARGET\"] == \"OpenBSD\" or CONFIG[\"OS_TARGET\"] == \"FreeBSD\"):");
+	print $0;
+	next;
+}
+/^if CONFIG\[\"MOZ_X11\"\] == \"1\" and CONFIG\[\"OS_TARGET\"\] == \"Linux\" and CONFIG\[\"TARGET_CPU\"\] == \"aarch64\":/{
+	flag = 0;
+	sub(/^if CONFIG\[\"MOZ_X11\"\] == \"1\" and CONFIG\[\"OS_TARGET\"\] == \"Linux\" and CONFIG\[\"TARGET_CPU\"\] == \"aarch64\":/, "if CONFIG\[\"TARGET_CPU\"\] == \"aarch64\" and CONFIG\[\"MOZ_X11\"\] == \"1\" and (CONFIG[\"OS_TARGET\"] == \"Linux\" or CONFIG[\"OS_TARGET\"] == \"NetBSD\" or CONFIG[\"OS_TARGET\"] == \"OpenBSD\" or CONFIG[\"OS_TARGET\"] == \"FreeBSD\"):");
+}
+/^if CONFIG\[\"TARGET_CPU\"\] == \"aarch64\" and CONFIG\[\"MOZ_X11\"\] == \"1\" and CONFIG\[\"OS_TARGET\"\] == \"Linux\":/{
+	flag = 0;
+	sub(/^if CONFIG\[\"TARGET_CPU\"\] == \"aarch64\" and CONFIG\[\"MOZ_X11\"\] == \"1\" and CONFIG\[\"OS_TARGET\"\] == \"Linux\":/, "if CONFIG\[\"TARGET_CPU\"\] == \"aarch64\" and CONFIG\[\"MOZ_X11\"\] == \"1\" and (CONFIG[\"OS_TARGET\"] == \"Linux\" or CONFIG[\"OS_TARGET\"] == \"NetBSD\" or CONFIG[\"OS_TARGET\"] == \"OpenBSD\" or CONFIG[\"OS_TARGET\"] == \"FreeBSD\"):");
+}
+/^if CONFIG\[\"MOZ_X11\"\] == \"1\" and CONFIG\[\"OS_TARGET\"\] == \"Linux\" and CONFIG\[\"TARGET_CPU\"\] == \"arm\":/{
+	flag = 0;
+	sub(/^if CONFIG\[\"MOZ_X11\"\] == \"1\" and CONFIG\[\"OS_TARGET\"\] == \"Linux\" and CONFIG\[\"TARGET_CPU\"\] == \"arm\":/, "if CONFIG\[\"TARGET_CPU\"\] == \"arm\" and CONFIG\[\"MOZ_X11\"\] == \"1\" and (CONFIG[\"OS_TARGET\"] == \"Linux\" or CONFIG[\"OS_TARGET\"] == \"NetBSD\" or CONFIG[\"OS_TARGET\"] == \"OpenBSD\" or CONFIG[\"OS_TARGET\"] == \"FreeBSD\"):");
+}
+/^if CONFIG\[\"TARGET_CPU\"\] == \"arm\" and CONFIG\[\"MOZ_X11\"\] == \"1\" and CONFIG\[\"OS_TARGET\"\] == \"Linux\":/{
+	flag = 0;
+	sub(/^if CONFIG\[\"TARGET_CPU\"\] == \"arm\" and CONFIG\[\"MOZ_X11\"\] == \"1\" and CONFIG\[\"OS_TARGET\"\] == \"Linux\":/, "if CONFIG\[\"TARGET_CPU\"\] == \"arm\" and CONFIG\[\"MOZ_X11\"\] == \"1\" and (CONFIG[\"OS_TARGET\"] == \"Linux\" or CONFIG[\"OS_TARGET\"] == \"NetBSD\" or CONFIG[\"OS_TARGET\"] == \"OpenBSD\" or CONFIG[\"OS_TARGET\"] == \"FreeBSD\"):");
+}
+/^if CONFIG\[\"MOZ_X11\"\] == \"1\" and CONFIG\[\"OS_TARGET\"\] == \"Linux\" and CONFIG\[\"TARGET_CPU\"\] == \"x86\":/{
+	flag = 0;
+	sub(/^if CONFIG\[\"MOZ_X11\"\] == \"1\" and CONFIG\[\"OS_TARGET\"\] == \"Linux\" and CONFIG\[\"TARGET_CPU\"\] == \"x86\":/, "if CONFIG\[\"TARGET_CPU\"\] == \"x86\" and CONFIG\[\"MOZ_X11\"\] == \"1\" and (CONFIG[\"OS_TARGET\"] == \"Linux\" or CONFIG[\"OS_TARGET\"] == \"NetBSD\" or CONFIG[\"OS_TARGET\"] == \"OpenBSD\" or CONFIG[\"OS_TARGET\"] == \"FreeBSD\"):");
+}
+/^if CONFIG\[\"TARGET_CPU\"\] == \"x86\" and CONFIG\[\"MOZ_X11\"\] == \"1\" and CONFIG\[\"OS_TARGET\"\] == \"Linux\":/{
+	flag = 0;
+	sub(/^if CONFIG\[\"TARGET_CPU\"\] == \"x86\" and CONFIG\[\"MOZ_X11\"\] == \"1\" and CONFIG\[\"OS_TARGET\"\] == \"Linux\":/, "if CONFIG\[\"TARGET_CPU\"\] == \"x86\" and CONFIG\[\"MOZ_X11\"\] == \"1\" and (CONFIG[\"OS_TARGET\"] == \"Linux\" or CONFIG[\"OS_TARGET\"] == \"NetBSD\" or CONFIG[\"OS_TARGET\"] == \"OpenBSD\" or CONFIG[\"OS_TARGET\"] == \"FreeBSD\"):");
+}
+/^if CONFIG\[\"MOZ_X11\"\] == \"1\" and CONFIG\[\"OS_TARGET\"\] == \"Linux\" and CONFIG\[\"TARGET_CPU\"\] == \"x86_64\":/{
+	flag = 0;
+	sub(/^if CONFIG\[\"MOZ_X11\"\] == \"1\" and CONFIG\[\"OS_TARGET\"\] == \"Linux\" and CONFIG\[\"TARGET_CPU\"\] == \"x86_64\":/, "if CONFIG\[\"TARGET_CPU\"\] == \"x86_64\" and CONFIG\[\"MOZ_X11\"\] == \"1\" and (CONFIG[\"OS_TARGET\"] == \"Linux\" or CONFIG[\"OS_TARGET\"] == \"NetBSD\" or CONFIG[\"OS_TARGET\"] == \"OpenBSD\" or CONFIG[\"OS_TARGET\"] == \"FreeBSD\"):");
+}
+/^if CONFIG\[\"TARGET_CPU\"\] == \"x86_64\" and CONFIG\[\"MOZ_X11\"\] == \"1\" and CONFIG\[\"OS_TARGET\"\] == \"Linux\":/{
+	flag = 0;
+	sub(/^if CONFIG\[\"TARGET_CPU\"\] == \"x86_64\" and CONFIG\[\"MOZ_X11\"\] == \"1\" and CONFIG\[\"OS_TARGET\"\] == \"Linux\":/, "if CONFIG\[\"TARGET_CPU\"\] == \"x86_64\" and CONFIG\[\"MOZ_X11\"\] == \"1\" and (CONFIG[\"OS_TARGET\"] == \"Linux\" or CONFIG[\"OS_TARGET\"] == \"NetBSD\" or CONFIG[\"OS_TARGET\"] == \"OpenBSD\" or CONFIG[\"OS_TARGET\"] == \"FreeBSD\"):");
+}
+/^if CONFIG\[\"MOZ_X11\"\] == \"1\" and CONFIG\[\"OS_TARGET\"\] == \"Linux\":/{
+	flag = 0;
+	sub(/^if CONFIG\[\"MOZ_X11\"\] == \"1\" and CONFIG\[\"OS_TARGET\"\] == \"Linux\":/, "if CONFIG\[\"MOZ_X11\"\] == \"1\" and (CONFIG[\"OS_TARGET\"] == \"Linux\" or CONFIG[\"OS_TARGET\"] == \"NetBSD\" or CONFIG[\"OS_TARGET\"] == \"OpenBSD\" or CONFIG[\"OS_TARGET\"] == \"FreeBSD\"):");
+}
+{
+	if (flag != 1) {
+		sub(/^    DEFINES\[\"WEBRTC_LINUX\"\] = True/, "    if CONFIG\[\"OS_TARGET\"\] == \"Linux\":\n        DEFINES\[\"WEBRTC_LINUX\"\] = True\n    else:\n        DEFINES\[\"WEBRTC_BSD\"\] = True");
+		sub(/^if not CONFIG\[\"MOZ_DEBUG\"\] and CONFIG\[\"OS_TARGET\"\] == \"Linux\":/, "if not CONFIG[\"MOZ_DEBUG\"] and (CONFIG[\"OS_TARGET\"] == \"Linux\" or CONFIG[\"OS_TARGET\"] == \"NetBSD\" or CONFIG[\"OS_TARGET\"] == \"OpenBSD\" or CONFIG[\"OS_TARGET\"] == \"FreeBSD\"):");
+		sub(/^if CONFIG\[\"MOZ_DEBUG\"\] == \"1\" and CONFIG\[\"OS_TARGET\"\] == \"Linux\":/, "if CONFIG[\"MOZ_DEBUG\"] == \"1\" and (CONFIG[\"OS_TARGET\"] == \"Linux\" or CONFIG[\"OS_TARGET\"] == \"NetBSD\" or CONFIG[\"OS_TARGET\"] == \"OpenBSD\" or CONFIG[\"OS_TARGET\"] == \"FreeBSD\"):");
+		sub(/^if CONFIG\[\"TARGET_CPU\"\] == \"aarch64\" and CONFIG\[\"OS_TARGET\"\] == \"Linux\":/, "if CONFIG[\"TARGET_CPU\"] == \"aarch64\" and (CONFIG[\"OS_TARGET\"] == \"Linux\" or CONFIG[\"OS_TARGET\"] == \"NetBSD\" or CONFIG[\"OS_TARGET\"] == \"OpenBSD\" or CONFIG[\"OS_TARGET\"] == \"FreeBSD\"):");
+		sub(/^if CONFIG\[\"TARGET_CPU\"\] == \"x86\" and CONFIG\[\"OS_TARGET\"\] == \"Linux\":/, "if CONFIG[\"TARGET_CPU\"] == \"x86\" and (CONFIG[\"OS_TARGET\"] == \"Linux\" or CONFIG[\"OS_TARGET\"] == \"NetBSD\" or CONFIG[\"OS_TARGET\"] == \"OpenBSD\" or CONFIG[\"OS_TARGET\"] == \"FreeBSD\"):");
+		sub(/^if CONFIG\[\"TARGET_CPU\"\] == \"x86_64\" and CONFIG\[\"OS_TARGET\"\] == \"Linux\":/, "if CONFIG[\"TARGET_CPU\"] == \"x86_64\" and (CONFIG[\"OS_TARGET\"] == \"Linux\" or CONFIG[\"OS_TARGET\"] == \"NetBSD\" or CONFIG[\"OS_TARGET\"] == \"OpenBSD\" or CONFIG[\"OS_TARGET\"] == \"FreeBSD\"):");
+	}
+	print $0;
+}
diff --git a/firefox140/mozilla-common.mk b/firefox140/mozilla-common.mk
new file mode 100644
index 0000000000..449e541bb7
--- /dev/null
+++ b/firefox140/mozilla-common.mk
@@ -0,0 +1,296 @@
+# $NetBSD: mozilla-common.mk,v 1.296 2025/05/25 12:42:05 manu Exp $
+#
+# common Makefile fragment for mozilla packages based on gecko 2.0.
+#
+# used by www/firefox140/Makefile
+
+.include "../../mk/bsd.prefs.mk"
+
+PYTHON_VERSIONS_INCOMPATIBLE=	27
+PYTHON_FOR_BUILD_ONLY=		tool
+ALL_ENV+=			PYTHON3=${PYTHONBIN}
+
+REPLACE_PYTHON=		build/cargo-linker
+
+HAS_CONFIGURE=		yes
+CONFIGURE_ARGS+=	--prefix=${PREFIX}
+USE_TOOLS+=		pkg-config perl gmake gm4 unzip zip # autoconf213
+UNLIMIT_RESOURCES+=	datasize stacksize virtualsize
+
+OVERRIDE_GNU_CONFIG_SCRIPTS=	yes
+OVERRIDE_DIRDEPTH=		4
+
+USE_LANGUAGES+=		c c++
+
+# XXX: As of 114.0.2
+# For nested constant initializer support in rlbox, requires 8.
+GCC_REQD+=		8
+
+TOOL_DEPENDS+=		cbindgen>=0.28.0:../../devel/cbindgen
+
+.if defined(FIREFOX_MAINTAINER) && !defined(MAINTAINER_INTERNAL)
+TOOL_DEPENDS+=		nodejs-[0-9]*:../../lang/nodejs
+USE_TOOLS+=		diff
+.else
+CONFIGURE_ENV+=		NODEJS="${FILESDIR}/node-wrapper.sh"
+.endif
+
+.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64"
+TOOL_DEPENDS+=		nasm>=2.14:../../devel/nasm
+TOOL_DEPENDS+=		yasm>=1.1:../../devel/yasm
+CFLAGS+=		-msse2
+.endif
+
+#CKSUM_CRATES+=	third_party/rust/quinn-udp
+#
+#CKSUMS+=	b8e595499055115d15bfb95259c0c585934adf55f61e365bcc9fc47ab8fa9cdd
+#CKSUMS+=	7be04be65b1606fd2560d572ba5a6238a645075555085d5e9cef15d10b0b8024
+#
+#SUBST_CLASSES+=		cksum
+#SUBST_STAGE.cksum=	pre-configure
+#.for crate in ${CKSUM_CRATES}
+#SUBST_FILES.cksum+=	${crate}/.cargo-checksum.json
+#.endfor
+#.for from to in ${CKSUMS}
+#SUBST_SED.cksum+=	-e 's,${from},${to},g'
+#.endfor
+
+# This is to work around build failures where an upstream configuration script
+# is confused by having more than one approximate match to MACHINE_GNU_PLATFORM
+# "i486" when attempting to select the Rust compiler target.
+.if ${MACHINE_PLATFORM:MNetBSD-*-i386}
+CONFIGURE_ARGS+=	--target=i586-unknown-netbsd
+CONFIGURE_ARGS+=	--host=i586-unknown-netbsd
+.elif ${MACHINE_PLATFORM:MSunOS-*-x86_64}
+CONFIGURE_ARGS+=	--host=x86_64-unknown-illumos
+CONFIGURE_ARGS+=	--target=x86_64-unknown-illumos
+.else
+CONFIGURE_ARGS+=	--target=${MACHINE_GNU_PLATFORM}
+CONFIGURE_ARGS+=	--host=${MACHINE_GNU_PLATFORM}
+.endif
+
+CONFIGURE_ENV+=		BINDGEN_CFLAGS="-isystem${PREFIX}/include/nspr \
+			-isystem${X11BASE}/include/pixman-1"
+
+do-test:
+	cd ${WRKSRC}/${OBJDIR}/dist/bin &&	\
+	     ./run-mozilla.sh ${WRKSRC}/mach check-spidermonkey
+
+# tar(1) of OpenBSD 5.5 has no --exclude command line option.
+.if ${OPSYS} == "OpenBSD"
+TOOLS_PLATFORM.tar=	${TOOLS_PATH.bsdtar}
+USE_TOOLS+=		bsdtar
+.else
+USE_TOOLS+=		tar
+.endif
+
+.if ${MACHINE_ARCH} == "i386"
+# This is required for SSE2 code under i386.
+CFLAGS+=	-mstackrealign
+.endif
+
+CHECK_PORTABILITY_SKIP+=	${MOZILLA_DIR}security/nss/tests/*/*.sh
+CHECK_PORTABILITY_SKIP+=	${MOZILLA_DIR}js/src/tests/update-test262.sh
+CHECK_PORTABILITY_SKIP+=	${MOZILLA_DIR}intl/icu/source/configure
+CHECK_PORTABILITY_SKIP+=	${MOZILLA_DIR}browser/components/loop/run-all-loop-tests.sh
+CHECK_PORTABILITY_SKIP+=	${MOZILLA_DIR}browser/extensions/loop/run-all-loop-tests.sh
+CHECK_PORTABILITY_SKIP+=	${MOZILLA_DIR}third_party/libwebrtc/tools_webrtc/iwyu/apply-iwyu
+
+CONFIGURE_ARGS+=	--enable-release
+# Disable Rust SIMD option to fix build with lang/rust-1.33.0
+# This should be enabled later again.
+#CONFIGURE_ARGS+=	--enable-rust-simd
+CONFIGURE_ARGS+=	--disable-tests
+# Mozilla Bug 1432751
+#CONFIGURE_ARGS+=	--enable-system-cairo
+CONFIGURE_ARGS+=	--enable-system-pixman
+CONFIGURE_ARGS+=	--with-system-libvpx
+CONFIGURE_ARGS+=	--enable-system-ffi
+CONFIGURE_ARGS+=	--with-system-icu
+CONFIGURE_ARGS+=	--with-intl-api
+CONFIGURE_ARGS+=	--with-system-nss
+CONFIGURE_ARGS+=	--with-system-nspr
+#CONFIGURE_ARGS+=	--with-system-jpeg
+CONFIGURE_ARGS+=	--with-system-zlib
+CONFIGURE_ARGS+=	--with-system-libevent
+CONFIGURE_ARGS+=	--disable-crashreporter
+CONFIGURE_ARGS+=	--enable-chrome-format=omni
+CONFIGURE_ARGS+=	--with-system-webp
+CONFIGURE_ARGS+=	--enable-forkserver
+
+#CONFIGURE_ARGS+=	--enable-readline
+CONFIGURE_ARGS+=	--disable-icf
+CONFIGURE_ARGS+=	--disable-updater
+
+.include "../../mk/compiler.mk"
+
+.if empty(PKGSRC_COMPILER:Mclang)
+# Set path to "clang for cbindgen" when target compiler is not clang.
+CONFIGURE_ARGS+=	--with-clang-path=${PREFIX}/bin/clang
+.endif
+CONFIGURE_ARGS+=	--with-libclang-path=${PREFIX}/lib
+
+# RLBox WASM sandbox
+.if ${MACHINE_ARCH} == "x86_64" || ${MACHINE_ARCH} == "i386"
+# For wasm-ld command
+TOOL_DEPENDS+=		lld-[0-9]*:../../devel/lld
+.include "../../lang/wasi-libc/buildlink3.mk"
+.include "../../lang/wasi-libcxx/buildlink3.mk"
+.include "../../lang/wasi-compiler-rt/buildlink3.mk"
+CONFIGURE_ARGS+=	--with-wasi-sysroot=${PREFIX}/wasi
+CONFIGURE_ENV+=		WASM_CC=${PREFIX}/bin/clang
+CONFIGURE_ENV+=		WASM_CXX=${PREFIX}/bin/clang++
+.else
+CONFIGURE_ARGS+=	--without-wasm-sandboxed-libraries
+.endif
+
+.include "../../sysutils/pciutils/libname.mk"
+SUBST_CLASSES+=				fix-libpci-soname
+SUBST_STAGE.fix-libpci-soname=		pre-configure
+SUBST_MESSAGE.fix-libpci-soname=	Fixing libpci soname
+SUBST_FILES.fix-libpci-soname+=		${MOZILLA_DIR}toolkit/xre/glxtest/glxtest.cpp
+SUBST_SED.fix-libpci-soname+=		-e 's,"libpci.so, "lib${PCIUTILS_LIBNAME}.so,'
+
+.if ${MACHINE_PLATFORM:MNetBSD-*-i386}
+SQLITE3OPTFLAG=			'-O0',
+.else
+SQLITE3OPTFLAG=			# empty
+.endif
+SUBST_CLASSES+=			sqlite3-opt
+SUBST_STAGE.sqlite3-opt=	pre-configure
+SUBST_MESSAGE.sqlite3-opt=	Fixing segfault in libmozsqlite3.so
+SUBST_FILES.sqlite3-opt+=	${MOZILLA_DIR}third_party/sqlite3/src/moz.build
+SUBST_VARS.sqlite3-opt+=	SQLITE3OPTFLAG
+
+.if ${OPSYS} == "NetBSD" && ${MACHINE_ARCH} == "aarch64"
+SUBST_CLASSES+=                 sve2
+SUBST_STAGE.sve2=               pre-configure
+SUBST_FILES.sve2=               media/libyuv/libyuv/source/convert.cc
+SUBST_FILES.sve2+=              media/libyuv/libyuv/source/scale_argb.cc
+SUBST_FILES.sve2+=              media/libyuv/libyuv/source/convert_argb.cc
+SUBST_SED.sve2=                 -e 's/_SVE2/_NEON/g'
+.endif
+
+# Do not pass '-j1 -j1' for MAKE_JOBS=1 for NetBSD 9.3 or earlier.
+RUST_MAKE_JOBS=		# empty by default
+.if ${OPSYS} == "NetBSD" && ${OPSYS_VERSION} < 090400
+.  if defined(MAKE_JOBS) && !empty(MAKE_JOBS) && !(defined(MAKE_JOBS_SAFE) && ${MAKE_JOBS_SAFE:U:tl} == no)
+.    if ${MAKE_JOBS} > 1
+RUST_MAKE_JOBS=		-j1 # for MAKE_JOBS=1, RUST_MAKE_JOBS should be empty.
+.    endif
+.  endif
+.endif
+
+SUBST_CLASSES+=		njobs
+SUBST_STAGE.njobs=	pre-configure
+SUBST_MESSAGE.njobs=	Setting MAKE_JOBS for cairo
+SUBST_FILES.njobs+=	${MOZILLA_DIR}config/makefiles/rust.mk
+SUBST_VARS.njobs+=	RUST_MAKE_JOBS
+
+# Workaround for link of libxul.so as of 96.0.
+# There are too many -ldl under third_paty/libwebrtc.
+.include "../../mk/dlopen.buildlink3.mk"
+BUILDLINK_TRANSFORM+=	opt:-ldl:${BUILDLINK_LDADD.dl:Q}
+
+CONFIG_GUESS_OVERRIDE+=		${MOZILLA_DIR}build/autoconf/config.guess
+CONFIG_GUESS_OVERRIDE+=		${MOZILLA_DIR}js/src/build/autoconf/config.guess
+CONFIG_GUESS_OVERRIDE+=		${MOZILLA_DIR}nsprpub/build/autoconf/config.guess
+CONFIG_GUESS_OVERRIDE+=		${MOZILLA_DIR}/js/ctypes/libffi/config.guess
+CONFIG_SUB_OVERRIDE+=		${MOZILLA_DIR}build/autoconf/config.sub
+CONFIG_SUB_OVERRIDE+=		${MOZILLA_DIR}js/src/build/autoconf/config.sub
+CONFIG_SUB_OVERRIDE+=		${MOZILLA_DIR}nsprpub/build/autoconf/config.sub
+CONFIG_SUB_OVERRIDE+=		${MOZILLA_DIR}/js/ctypes/libffi/config.sub
+
+CONFIGURE_ENV+=		CPP=${CPP:Q}
+ALL_ENV+=		SHELL=${CONFIG_SHELL:Q}
+ALL_ENV+=		MOZ_APP_NAME=${MOZILLA}
+
+# Build outside ${WRKSRC}
+# Try to avoid conflict with config/makefiles/xpidl/Makefile.in
+.if ${MAINTAINER_INTERNAL:Uno} == "yes"
+OBJDIR=			../no-node-build
+.else
+OBJDIR=			../build
+.endif
+CONFIGURE_DIRS=		${OBJDIR}
+CONFIGURE_SCRIPT=	${WRKSRC}/configure
+
+PLIST_VARS+=	v4l2_decode ffvpx
+
+PLIST_VARS+=		v4l2_decode
+.if ${MACHINE_ARCH} == "aarch64" || \
+    ${MACHINE_ARCH:M*arm*} || \
+    ${MACHINE_ARCH} == riscv64
+PLIST.v4l2_decode=	yes	# see toolkit/moz.configure
+.endif
+
+.if ${MACHINE_ARCH} == "aarch64" || \
+    ${MACHINE_ARCH:M*arm*} || \
+    ${MACHINE_ARCH} == "i386" || \
+    ${MACHINE_ARCH} == "x86_64"
+PLIST.ffvpx=	yes	# see media/ffvpx/ffvpxcommon.mozbuild
+.endif
+
+# See ${WRKSRC}/security/sandbox/mac/Sandbox.mm: On Darwin, sandboxing
+# support is only available when the toolkit is cairo-cocoa.
+CONFIGURE_ARGS.Darwin+=	--disable-sandbox
+CONFIGURE_ARGS.NetBSD+=	--disable-sandbox
+
+# Makefiles sometimes call "rm -f" without more arguments. Kludge around ...
+.PHONY: create-rm-wrapper
+pre-configure: create-rm-wrapper
+create-rm-wrapper:
+	printf '#!/bin/sh\n[ "$$*" = "-f" ] && exit 0\nexec /bin/rm $$@\n' > \
+	  ${WRAPPER_DIR}/bin/rm
+	chmod +x ${WRAPPER_DIR}/bin/rm
+
+# The configure test for __thread succeeds, but later we end up with:
+# dist/bin/libxul.so: undefined reference to `__tls_get_addr'
+CONFIGURE_ENV.NetBSD+=	ac_cv_thread_keyword=no
+# In unspecified case, clock_gettime(CLOCK_MONOTONIC, ...) fails.
+CONFIGURE_ENV.NetBSD+=	ac_cv_clock_monotonic=
+
+.include "../../sysutils/pciutils/buildlink3.mk"
+.include "../../mk/atomic64.mk"
+BUILDLINK_API_DEPENDS.libevent+=	libevent>=1.1
+.include "../../devel/libevent/buildlink3.mk"
+.include "../../devel/libffi/buildlink3.mk"
+# See build/moz.configure/nspr.configure
+BUILDLINK_API_DEPENDS.nspr+=	nspr>=4.34
+.include "../../devel/nspr/buildlink3.mk"
+BUILDLINK_API_DEPENDS.icu+=	icu>=76.1
+.include "../../textproc/icu/buildlink3.mk"
+# See build/moz.configure/nss.configure
+BUILDLINK_API_DEPENDS.nss+=	nss>=3.109
+.include "../../devel/nss/buildlink3.mk"
+.include "../../devel/zlib/buildlink3.mk"
+#.include "../../mk/jpeg.buildlink3.mk"
+.include "../../graphics/MesaLib/buildlink3.mk"
+#BUILDLINK_API_DEPENDS.cairo+=	cairo>=1.10.2nb4
+#.include "../../graphics/cairo/buildlink3.mk"
+BUILDLINK_API_DEPENDS.libwebp+=	libwebp>=1.0.2
+.include "../../graphics/libwebp/buildlink3.mk"
+BUILDLINK_DEPMETHOD.clang=	build
+.include "../../lang/clang/buildlink3.mk"
+RUST_REQ=	1.76.0
+.include "../../lang/rust/rust.mk"
+.include "../../multimedia/libvpx/buildlink3.mk"
+.include "../../net/libIDL/buildlink3.mk"
+# TODO: check again, pkgsrc has hunspell 1.7
+# was: textproc/hunspell 1.3 is too old
+#.include "../../textproc/hunspell/buildlink3.mk"
+.include "../../multimedia/ffmpeg7/buildlink3.mk"
+.include "../../x11/libXt/buildlink3.mk"
+.include "../../x11/libXtst/buildlink3.mk"
+BUILDLINK_API_DEPENDS.pixman+= pixman>=0.40
+.include "../../x11/pixman/buildlink3.mk"
+.include "../../x11/gtk3/buildlink3.mk"
+PLIST_VARS+=		wayland
+.if ${PKG_BUILD_OPTIONS.gtk3:Mwayland}
+CONFIGURE_ARGS+=	--enable-default-toolkit=cairo-gtk3-x11-wayland
+PLIST.wayland=		yes
+.else
+CONFIGURE_ARGS+=	--enable-default-toolkit=cairo-gtk3
+.endif
+.include "../../lang/python/batteries-included.mk"
+.include "../../lang/python/application.mk"
diff --git a/firefox140/options.mk b/firefox140/options.mk
new file mode 100644
index 0000000000..04963e8dc7
--- /dev/null
+++ b/firefox140/options.mk
@@ -0,0 +1,104 @@
+# $NetBSD: options.mk,v 1.76 2024/10/01 12:47:18 ryoon Exp $
+
+PKG_OPTIONS_VAR=	PKG_OPTIONS.firefox140
+
+PKG_SUPPORTED_OPTIONS=	official-mozilla-branding
+PKG_SUPPORTED_OPTIONS+=	debug debug-info mozilla-jemalloc webrtc
+PKG_SUPPORTED_OPTIONS+=	dbus speechd
+PKG_SUPPORTED_OPTIONS+=	alsa pulseaudio sunaudio jack
+
+.if ${OPSYS} == "Linux"
+PKG_SUGGESTED_OPTIONS+=	dbus
+PKG_SUGGESTED_OPTIONS+=	alsa pulseaudio mozilla-jemalloc webrtc
+.endif
+
+.if ${OPSYS} == "NetBSD" || ${OPSYS} == "SunOS"
+PKG_SUGGESTED_OPTIONS+=	sunaudio
+.endif
+
+.if ${OPSYS} == "NetBSD" && ${OPSYS_VERSION} >= 090000
+PKG_SUGGESTED_OPTIONS+=	webrtc
+.endif
+
+.include "../../mk/bsd.options.mk"
+
+.if !empty(PKG_OPTIONS:Malsa)
+AUDIO_BACKENDS+=	alsa
+.include "../../audio/alsa-lib/buildlink3.mk"
+.endif
+
+.if !empty(PKG_OPTIONS:Mmozilla-jemalloc)
+CONFIGURE_ARGS+=	--enable-jemalloc
+CONFIGURE_ARGS+=	--enable-replace-malloc
+.else
+CONFIGURE_ARGS+=	--disable-jemalloc
+#.include "../../devel/jemalloc/buildlink3.mk"
+.endif
+
+.if !empty(PKG_OPTIONS:Mdebug)
+CONFIGURE_ARGS+=	--enable-debug="-g -Og"
+CONFIGURE_ARGS+=	--disable-optimize
+CONFIGURE_ARGS+=	--enable-debug-js-modules
+CONFIGURE_ARGS+=	--disable-install-strip
+.else
+.  if !empty(PKG_OPTIONS:Mdebug-info)
+CONFIGURE_ARGS+=	--enable-debug-symbols
+CONFIGURE_ARGS+=	--enable-optimize=-O2
+CONFIGURE_ARGS+=	--disable-install-strip
+.  else
+CONFIGURE_ARGS+=	--disable-debug-symbols
+CONFIGURE_ARGS+=	--enable-optimize=-O2
+CONFIGURE_ARGS+=	--enable-install-strip
+.  endif
+CONFIGURE_ARGS+=	--disable-debug
+.endif
+
+.if !empty(PKG_OPTIONS:Mpulseaudio)
+AUDIO_BACKENDS+=	pulseaudio
+.include "../../audio/pulseaudio/buildlink3.mk"
+.endif
+
+.if !empty(PKG_OPTIONS:Mdbus)
+.include "../../sysutils/dbus-glib/buildlink3.mk"
+CONFIGURE_ARGS+=	--enable-dbus
+.else
+CONFIGURE_ARGS+=	--disable-dbus
+.  if ${OPSYS} == "Linux"
+CONFIGURE_ARGS+=	--disable-necko-wifi
+.  endif
+.endif
+
+.if !empty(PKG_OPTIONS:Mofficial-mozilla-branding)
+CONFIGURE_ARGS+=	--enable-official-branding
+LICENSE+=		AND mozilla-trademark-license
+RESTRICTED=		Trademark holder prohibits distribution of modified versions.
+NO_BIN_ON_CDROM=	${RESTRICTED}
+NO_BIN_ON_FTP=		${RESTRICTED}
+.else
+CONFIGURE_ARGS+=	--with-branding=browser/branding/unofficial
+.endif
+
+.if !empty(PKG_OPTIONS:Msunaudio)
+AUDIO_BACKENDS+=	sunaudio
+.endif
+
+.if !empty(PKG_OPTIONS:Mjack)
+AUDIO_BACKENDS+=	jack
+.include "../../audio/jack/buildlink3.mk"
+.endif
+
+.if !empty(PKG_OPTIONS:Mwebrtc)
+.include "../../graphics/libv4l/buildlink3.mk"
+CONFIGURE_ARGS+=	--enable-webrtc
+.else
+CONFIGURE_ARGS+=	--disable-webrtc
+.endif
+
+.if !empty(PKG_OPTIONS:Mspeechd)
+.include "../../audio/speech-dispatcher/buildlink3.mk"
+CONFIGURE_ARGS+=	--enable-synth-speechd
+.else
+CONFIGURE_ARGS+=	--disable-synth-speechd
+.endif
+
+CONFIGURE_ARGS+=	--audio-backends=${AUDIO_BACKENDS:ts,}
diff --git a/firefox140/patches/patch-browser_app_profile_firefox.js b/firefox140/patches/patch-browser_app_profile_firefox.js
new file mode 100644
index 0000000000..7801828de6
--- /dev/null
+++ b/firefox140/patches/patch-browser_app_profile_firefox.js
@@ -0,0 +1,47 @@
+$NetBSD: patch-browser_app_profile_firefox.js,v 1.23 2024/04/06 08:53:35 ryoon Exp $
+
+This patch modifies default Firefox settings - see the comments above
+each one.
+
+--- browser/app/profile/firefox.js.orig	2024-03-08 13:19:26.000000000 +0000
++++ browser/app/profile/firefox.js
+@@ -2461,6 +2461,39 @@ pref("app.normandy.onsync_skew_sec", 600
+ pref("toolkit.coverage.enabled", false);
+ pref("toolkit.coverage.endpoint.base", "https://coverage.mozilla.org";);
+ 
++// Select UI locale from LANG/LC_MESSAGE environmental variables
++pref("intl.locale.requested", "");
++
++// Enable system addons, for example langpacks from www/firefox-l10n
++pref("extensions.autoDisableScopes", 11);
++
++// Firefox includes a complex mechanism for "blacklisting" GPUs that
++// appears to fail on a NetBSD system where the only available OpenGL
++// implementations are all from Mesa.  WebRender was supposed to be
++// enabled by default from Firefox 91 onwards and appears to greatly
++// improve performance even with acceleration disabled at the kernel
++// level.
++pref("gfx.webrender.all", true);
++
++// Disable Web MIDI support
++// NetBSD gets immediate SIGSEGV when Web MIDI is enabled.
++pref("midi.testing", true);
++pref("dom.webmidi.enabled", true);
++pref("midi.prompt.testing", true);
++pref("media.navigator.permission.disabled", true);
++
++// Avoid runtime error from WebGL for NetBSD systems
++pref("webgl.out-of-process", false);
++
++// Avoid unfunctional video and audio codecs
++pref("media.allow-audio-non-utility", true);
++
++// On NetBSD, many web applications (e.g. Telegram, Mastodon, Twitter)
++// will freeze until the service worker is restarted in about:serviceworkers.
++// This is a workaround that makes most of these sites function.
++// The root cause of this should be investigated.
++pref("dom.serviceWorkers.enabled", false);
++
+ // Discovery prefs
+ pref("browser.discovery.enabled", true);
+ pref("browser.discovery.containers.enabled", true);
diff --git a/firefox140/patches/patch-build_moz.configure_init.configure b/firefox140/patches/patch-build_moz.configure_init.configure
new file mode 100644
index 0000000000..93c053da51
--- /dev/null
+++ b/firefox140/patches/patch-build_moz.configure_init.configure
@@ -0,0 +1,15 @@
+$NetBSD: patch-build_moz.configure_init.configure,v 1.5 2024/05/10 09:14:07 jperkin Exp $
+
+Support illumos triple.
+
+--- build/moz.configure/init.configure.orig	2024-05-09 17:11:33.720650056 +0000
++++ build/moz.configure/init.configure
+@@ -535,6 +535,8 @@ def split_triplet(triplet, allow_wasi=Fa
+         canonical_os = canonical_kernel = "OpenBSD"
+     elif os.startswith("solaris"):
+         canonical_os = canonical_kernel = "SunOS"
++    elif os.startswith("illumos"):
++        canonical_os = canonical_kernel = "SunOS"
+     elif os.startswith("wasi") and allow_wasi:
+         canonical_os = canonical_kernel = "WASI"
+     else:
diff --git a/firefox140/patches/patch-build_moz.configure_rust.configure b/firefox140/patches/patch-build_moz.configure_rust.configure
new file mode 100644
index 0000000000..413b542641
--- /dev/null
+++ b/firefox140/patches/patch-build_moz.configure_rust.configure
@@ -0,0 +1,15 @@
+$NetBSD: patch-build_moz.configure_rust.configure,v 1.8 2020/12/17 09:53:15 ryoon Exp $
+
+* Do not match rumprun toolchain for NetBSD,
+  narrowed should be one not two.
+
+--- build/moz.configure/rust.configure.orig	2020-12-03 23:12:39.000000000 +0000
++++ build/moz.configure/rust.configure
+@@ -371,6 +371,7 @@ def detect_rustc_target(
+             for c in candidates
+             if c.target.raw_os == host_or_target.raw_os
+             and c.target.raw_cpu == host_or_target.raw_cpu
++            and not c.rust_target.endswith("-rumprun-netbsd")
+         ]
+         if len(narrowed) == 1:
+             return narrowed[0].rust_target
diff --git a/firefox140/patches/patch-config_gcc-stl-wrapper.template.h b/firefox140/patches/patch-config_gcc-stl-wrapper.template.h
new file mode 100644
index 0000000000..42cf75a664
--- /dev/null
+++ b/firefox140/patches/patch-config_gcc-stl-wrapper.template.h
@@ -0,0 +1,31 @@
+$NetBSD: patch-config_gcc-stl-wrapper.template.h,v 1.4 2021/09/30 14:18:28 ryoon Exp $
+
+--- config/gcc-stl-wrapper.template.h.orig	2021-09-04 13:24:51.000000000 +0000
++++ config/gcc-stl-wrapper.template.h
+@@ -32,8 +32,8 @@
+ // limits) and bug 1694575 (iosfwd).
+ // Please be careful when adding more exceptions, especially regarding
+ // the header not directly or indirectly including <new>.
+-#ifndef moz_dont_include_mozalloc_for_cstdlib
+-#  define moz_dont_include_mozalloc_for_cstdlib
++#ifndef moz_dont_include_mozalloc_for_${HEADER}
++#  define moz_dont_include_mozalloc_for_${HEADER}
+ #endif
+ 
+ #ifndef moz_dont_include_mozalloc_for_cmath
+@@ -55,7 +55,7 @@
+ // Include mozalloc after the STL header and all other headers it includes
+ // have been preprocessed.
+ #if !defined(MOZ_INCLUDE_MOZALLOC_H) && \
+-    !defined(moz_dont_include_mozalloc_for_${HEADER})
++    !defined(moz_dont_include_mozalloc_for_cstdlib)
+ #  define MOZ_INCLUDE_MOZALLOC_H
+ #  define MOZ_INCLUDE_MOZALLOC_H_FROM_${HEADER}
+ #endif
+@@ -84,4 +84,6 @@
+ #  include "mozilla/throw_gcc.h"
+ #endif
+ 
++#undef moz_dont_include_mzalloc_for_${HEADER}
++
+ #endif  // if mozilla_${HEADER}_h
diff --git a/firefox140/patches/patch-config_makefiles_rust.mk b/firefox140/patches/patch-config_makefiles_rust.mk
new file mode 100644
index 0000000000..3272199469
--- /dev/null
+++ b/firefox140/patches/patch-config_makefiles_rust.mk
@@ -0,0 +1,29 @@
+$NetBSD: patch-config_makefiles_rust.mk,v 1.14 2025/04/30 03:10:40 ryoon Exp $
+
+NetBSD doesn't get along with parallel rust builds (it causes issues
+with ld.so) which are the default. Force -j1.
+
+Use less memory to fix build under NetBSD/i386.
+From: https://bugzilla.mozilla.org/show_bug.cgi?id=1644409
+
+--- config/makefiles/rust.mk.orig	2025-02-21 13:24:16.000000000 +0000
++++ config/makefiles/rust.mk
+@@ -60,6 +60,9 @@ ifdef MOZ_TSAN
+ cargo_build_flags += -Zbuild-std=std,panic_abort
+ RUSTFLAGS += -Zsanitizer=thread
+ endif
++ifeq ($(OS_ARCH),NetBSD)
++cargo_build_flags += @RUST_MAKE_JOBS@
++endif
+ 
+ rustflags_sancov =
+ ifndef MOZ_TSAN
+@@ -101,7 +104,7 @@ ifndef rustflags_sancov
+ # Never enable when coverage is enabled to work around https://github.com/rust-lang/rust/issues/90045.
+ ifndef MOZ_CODE_COVERAGE
+ ifeq (,$(findstring gkrust_gtest,$(RUST_LIBRARY_FILE)))
+-cargo_rustc_flags += -Clto$(if $(filter full,$(MOZ_LTO_RUST_CROSS)),=fat)
++cargo_rustc_flags += -Clto=thin
+ endif
+ # We need -Cembed-bitcode=yes for all crates when using -Clto.
+ RUSTFLAGS += -Cembed-bitcode=yes
diff --git a/firefox140/patches/patch-dom_base_nsAttrName.h b/firefox140/patches/patch-dom_base_nsAttrName.h
new file mode 100644
index 0000000000..3eddb89fa0
--- /dev/null
+++ b/firefox140/patches/patch-dom_base_nsAttrName.h
@@ -0,0 +1,18 @@
+$NetBSD: patch-dom_base_nsAttrName.h,v 1.2 2019/01/29 16:28:22 ryoon Exp $
+
+cbindgen gets confused by NetBSD's types being macros too
+https://mail-index.netbsd.org/tech-pkg/2018/10/25/msg020395.html
+
+--- dom/base/nsAttrName.h.orig	2019-01-18 00:20:23.000000000 +0000
++++ dom/base/nsAttrName.h
+@@ -16,6 +16,10 @@
+ #include "mozilla/dom/NodeInfo.h"
+ #include "nsAtom.h"
+ #include "nsDOMString.h"
++#ifdef __NetBSD__
++/* This is also a macro which causes problems with cbindgen */
++#undef uintptr_t
++#endif
+ 
+ #define NS_ATTRNAME_NODEINFO_BIT 1
+ class nsAttrName {
diff --git a/firefox140/patches/patch-dom_webtransport_api_WebTransportDatagramDuplexStream.cpp b/firefox140/patches/patch-dom_webtransport_api_WebTransportDatagramDuplexStream.cpp
new file mode 100644
index 0000000000..947c3f8e23
--- /dev/null
+++ b/firefox140/patches/patch-dom_webtransport_api_WebTransportDatagramDuplexStream.cpp
@@ -0,0 +1,40 @@
+$NetBSD: patch-dom_webtransport_api_WebTransportDatagramDuplexStream.cpp,v 1.1 2023/06/04 09:26:35 ryoon Exp $
+
+--- dom/webtransport/api/WebTransportDatagramDuplexStream.cpp.orig	2023-04-23 21:17:18.000000000 +0000
++++ dom/webtransport/api/WebTransportDatagramDuplexStream.cpp
+@@ -62,7 +62,7 @@ void WebTransportDatagramDuplexStream::S
+                                                          ErrorResult& aRv) {
+   // https://w3c.github.io/webtransport/#dom-webtransportdatagramduplexstream-incomingmaxage
+   // Step 1
+-  if (isnan(aMaxAge) || aMaxAge < 0.) {
++  if (std::isnan(aMaxAge) || aMaxAge < 0.) {
+     aRv.ThrowRangeError("Invalid IncomingMaxAge");
+     return;
+   }
+@@ -78,7 +78,7 @@ void WebTransportDatagramDuplexStream::S
+                                                          ErrorResult& aRv) {
+   // https://w3c.github.io/webtransport/#dom-webtransportdatagramduplexstream-outgoingmaxage
+   // Step 1
+-  if (isnan(aMaxAge) || aMaxAge < 0.) {
++  if (std::isnan(aMaxAge) || aMaxAge < 0.) {
+     aRv.ThrowRangeError("Invalid OutgoingMaxAge");
+     return;
+   }
+@@ -94,7 +94,7 @@ void WebTransportDatagramDuplexStream::S
+     double aWaterMark, ErrorResult& aRv) {
+   // https://w3c.github.io/webtransport/#dom-webtransportdatagramduplexstream-incominghighwatermark
+   // Step 1
+-  if (isnan(aWaterMark) || aWaterMark < 0.) {
++  if (std::isnan(aWaterMark) || aWaterMark < 0.) {
+     aRv.ThrowRangeError("Invalid OutgoingMaxAge");
+     return;
+   }
+@@ -110,7 +110,7 @@ void WebTransportDatagramDuplexStream::S
+     double aWaterMark, ErrorResult& aRv) {
+   // https://w3c.github.io/webtransport/#dom-webtransportdatagramduplexstream-outgoinghighwatermark
+   // Step 1
+-  if (isnan(aWaterMark) || aWaterMark < 0.) {
++  if (std::isnan(aWaterMark) || aWaterMark < 0.) {
+     aRv.ThrowRangeError("Invalid OutgoingHighWaterMark");
+     return;
+   }
diff --git a/firefox140/patches/patch-gfx_angle_checkout_src_common_third__party_smhasher_src_PMurHash.cpp b/firefox140/patches/patch-gfx_angle_checkout_src_common_third__party_smhasher_src_PMurHash.cpp
new file mode 100644
index 0000000000..ecc30d6251
--- /dev/null
+++ b/firefox140/patches/patch-gfx_angle_checkout_src_common_third__party_smhasher_src_PMurHash.cpp
@@ -0,0 +1,17 @@
+$NetBSD: patch-gfx_angle_checkout_src_common_third__party_smhasher_src_PMurHash.cpp,v 1.4 2019/07/11 11:32:40 ryoon Exp $
+
+Fix build where _LITTLE_ENDIAN is not an integer.
+
+--- gfx/angle/checkout/src/common/third_party/smhasher/src/PMurHash.cpp.orig	2019-07-06 01:48:31.000000000 +0000
++++ gfx/angle/checkout/src/common/third_party/smhasher/src/PMurHash.cpp
+@@ -91,8 +91,8 @@ on big endian machines, or a byte-by-byt
+ /* gcc 'may' define __LITTLE_ENDIAN__ or __BIG_ENDIAN__ to 1 (Note the trailing __),
+  * or even _LITTLE_ENDIAN or _BIG_ENDIAN (Note the single _ prefix) */
+ #if !defined(__BYTE_ORDER)
+-#    if defined(__LITTLE_ENDIAN__) && __LITTLE_ENDIAN__ == 1 || \
+-        defined(_LITTLE_ENDIAN) && _LITTLE_ENDIAN == 1
++#    if defined(__LITTLE_ENDIAN__) && __LITTLE_ENDIAN__-0 == 1 || \
++        defined(_LITTLE_ENDIAN) && _LITTLE_ENDIAN-0 == 1
+ #        define __BYTE_ORDER __LITTLE_ENDIAN
+ #    elif defined(__BIG_ENDIAN__) && __BIG_ENDIAN__ == 1 || defined(_BIG_ENDIAN) && _BIG_ENDIAN == 1
+ #        define __BYTE_ORDER __BIG_ENDIAN
diff --git a/firefox140/patches/patch-gfx_angle_checkout_src_compiler_translator_InfoSink.h b/firefox140/patches/patch-gfx_angle_checkout_src_compiler_translator_InfoSink.h
new file mode 100644
index 0000000000..25cc3ee4f9
--- /dev/null
+++ b/firefox140/patches/patch-gfx_angle_checkout_src_compiler_translator_InfoSink.h
@@ -0,0 +1,16 @@
+$NetBSD: patch-gfx_angle_checkout_src_compiler_translator_InfoSink.h,v 1.3 2021/11/11 16:48:04 ryoon Exp $
+
+* isinf/isnan in make.h is defined as macro. Use non-macro version
+  to fix build.
+
+--- gfx/angle/checkout/src/compiler/translator/InfoSink.h.orig	2021-10-28 18:03:11.000000000 +0000
++++ gfx/angle/checkout/src/compiler/translator/InfoSink.h
+@@ -7,7 +7,7 @@
+ #ifndef COMPILER_TRANSLATOR_INFOSINK_H_
+ #define COMPILER_TRANSLATOR_INFOSINK_H_
+ 
+-#include <math.h>
++#include <cmath>
+ #include <stdlib.h>
+ #include "GLSLANG/ShaderLang.h"
+ #include "compiler/translator/Common.h"
diff --git a/firefox140/patches/patch-gfx_ots_src_name.cc b/firefox140/patches/patch-gfx_ots_src_name.cc
new file mode 100644
index 0000000000..4c4f650798
--- /dev/null
+++ b/firefox140/patches/patch-gfx_ots_src_name.cc
@@ -0,0 +1,13 @@
+$NetBSD: patch-gfx_ots_src_name.cc,v 1.1 2025/07/26 14:12:54 ryoon Exp $
+
+--- gfx/ots/src/name.cc.orig	2025-07-26 13:25:22.747360576 +0000
++++ gfx/ots/src/name.cc
+@@ -16,7 +16,7 @@ namespace {
+ // We disallow characters outside the URI spec "unreserved characters"
+ // set; any chars outside this set will be replaced by underscore.
+ bool AllowedInPsName(char c) {
+-  return isalnum(c) || std::strchr("-._~", c);
++  return isalnum((unsigned char)c) || std::strchr("-._~", c);
+ }
+ 
+ bool SanitizePsNameAscii(std::string& name) {
diff --git a/firefox140/patches/patch-gfx_skia_skia_src_sksl_codegen_SkSLSPIRVCodeGenerator.cpp b/firefox140/patches/patch-gfx_skia_skia_src_sksl_codegen_SkSLSPIRVCodeGenerator.cpp
new file mode 100644
index 0000000000..a48e5579ef
--- /dev/null
+++ b/firefox140/patches/patch-gfx_skia_skia_src_sksl_codegen_SkSLSPIRVCodeGenerator.cpp
@@ -0,0 +1,13 @@
+$NetBSD: patch-gfx_skia_skia_src_sksl_codegen_SkSLSPIRVCodeGenerator.cpp,v 1.1 2025/07/26 14:12:54 ryoon Exp $
+
+--- gfx/skia/skia/src/sksl/codegen/SkSLSPIRVCodeGenerator.cpp.orig	2025-07-26 13:25:51.000473818 +0000
++++ gfx/skia/skia/src/sksl/codegen/SkSLSPIRVCodeGenerator.cpp
+@@ -4405,7 +4405,7 @@ void SPIRVCodeGenerator::writeFunctionSt
+             f, fSpecializationInfo, fActiveSpecializationIndex,
+             [&](int, const Variable*, const Expression* expr) {
+                 std::string name = expr->description();
+-                std::replace_if(name.begin(), name.end(), [](char c) { return !isalnum(c); }, '_');
++                std::replace_if(name.begin(), name.end(), [](char c) { return !isalnum(i(unsigned char)c); }, '_');
+ 
+                 mangledName += "_" + name;
+             });
diff --git a/firefox140/patches/patch-ipc_chromium_src_base_message__pump__libevent.cc b/firefox140/patches/patch-ipc_chromium_src_base_message__pump__libevent.cc
new file mode 100644
index 0000000000..44121f6b76
--- /dev/null
+++ b/firefox140/patches/patch-ipc_chromium_src_base_message__pump__libevent.cc
@@ -0,0 +1,22 @@
+$NetBSD: patch-ipc_chromium_src_base_message__pump__libevent.cc,v 1.12 2022/07/04 14:34:08 ryoon Exp $
+
+Allow older libevent
+
+--- ipc/chromium/src/base/message_pump_libevent.cc.orig	2022-06-16 21:32:07.000000000 +0000
++++ ipc/chromium/src/base/message_pump_libevent.cc
+@@ -24,6 +24,7 @@
+ 
+ // This macro checks that the _EVENT_SIZEOF_* constants defined in
+ // ipc/chromiume/src/third_party/<platform>/event2/event-config.h are correct.
++#if 0
+ #if defined(_EVENT_SIZEOF_SHORT)
+ #  define CHECK_EVENT_SIZEOF(TYPE, type)                \
+     static_assert(_EVENT_SIZEOF_##TYPE == sizeof(type), \
+@@ -44,6 +45,7 @@ CHECK_EVENT_SIZEOF(SHORT, short);
+ CHECK_EVENT_SIZEOF(SIZE_T, size_t);
+ CHECK_EVENT_SIZEOF(TIME_T, time_t);
+ CHECK_EVENT_SIZEOF(VOID_P, void*);
++#endif
+ 
+ // Lifecycle of struct event
+ // Libevent uses two main data structures:
diff --git a/firefox140/patches/patch-ipc_chromium_src_base_platform__thread__posix.cc b/firefox140/patches/patch-ipc_chromium_src_base_platform__thread__posix.cc
new file mode 100644
index 0000000000..c6824ec9a4
--- /dev/null
+++ b/firefox140/patches/patch-ipc_chromium_src_base_platform__thread__posix.cc
@@ -0,0 +1,17 @@
+$NetBSD: patch-ipc_chromium_src_base_platform__thread__posix.cc,v 1.13 2023/08/03 22:02:33 ryoon Exp $
+
+* Support NetBSD
+* Support Solaris (we can't rely on pthread_setname_np so ignore it).
+
+--- ipc/chromium/src/base/platform_thread_posix.cc.orig	2023-07-20 18:06:23.000000000 +0000
++++ ipc/chromium/src/base/platform_thread_posix.cc
+@@ -12,7 +12,9 @@
+ #if defined(XP_DARWIN)
+ #  include <mach/mach.h>
+ #elif defined(XP_NETBSD)
++_Pragma("GCC visibility push(default)")
+ #  include <lwp.h>
++_Pragma("GCC visibility pop")
+ #elif defined(XP_LINUX)
+ #  include <sys/syscall.h>
+ #  include <sys/prctl.h>
diff --git a/firefox140/patches/patch-ipc_glue_GeckoChildProcessHost.cpp b/firefox140/patches/patch-ipc_glue_GeckoChildProcessHost.cpp
new file mode 100644
index 0000000000..dc76a80e0b
--- /dev/null
+++ b/firefox140/patches/patch-ipc_glue_GeckoChildProcessHost.cpp
@@ -0,0 +1,21 @@
+$NetBSD: patch-ipc_glue_GeckoChildProcessHost.cpp,v 1.15 2023/09/05 14:08:39 ryoon Exp $
+
+* Support Solaris
+* Fix NetBSD linking
+
+--- ipc/glue/GeckoChildProcessHost.cpp.orig	2023-08-17 21:21:29.000000000 +0000
++++ ipc/glue/GeckoChildProcessHost.cpp
+@@ -4,7 +4,13 @@
+  * License, v. 2.0. If a copy of the MPL was not distributed with this
+  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+ 
++#if defined(__NetBSD__)
++_Pragma("GCC visibility push(default)")
++#endif
+ #include "GeckoChildProcessHost.h"
++#if defined(__NetBSD__)
++_Pragma("GCC visibility pop")
++#endif
+ 
+ #include "base/command_line.h"
+ #include "base/process.h"
diff --git a/firefox140/patches/patch-js-src-jit-arm64-vixl-MozCpu-vixl.cpp b/firefox140/patches/patch-js-src-jit-arm64-vixl-MozCpu-vixl.cpp
new file mode 100644
index 0000000000..58f337b4e0
--- /dev/null
+++ b/firefox140/patches/patch-js-src-jit-arm64-vixl-MozCpu-vixl.cpp
@@ -0,0 +1,15 @@
+$NetBSD: patch-js-src-jit-arm64-vixl-MozCpu-vixl.cpp,v 1.2 2024/02/22 15:12:50 ryoon Exp $
+
+Add NetBSD support.
+
+--- js/src/jit/arm64/vixl/MozCpu-vixl.cpp.orig	2024-02-13 14:50:57.324257195 +0000
++++ js/src/jit/arm64/vixl/MozCpu-vixl.cpp
+@@ -110,7 +110,7 @@ void CPU::EnsureIAndDCacheCoherency(void
+   FlushInstructionCache(GetCurrentProcess(), address, length);
+ #elif defined(XP_DARWIN)
+   sys_icache_invalidate(address, length);
+-#elif defined(__aarch64__) && (defined(__linux__) || defined(__android__) || defined(__FreeBSD__))
++#elif defined(__aarch64__) && (defined(__linux__) || defined(__android__) || defined(__FreeBSD__) || defined(__NetBSD__))
+   // Implement the cache synchronisation for all targets where AArch64 is the
+   // host, even if we're building the simulator for an AAarch64 host. This
+   // allows for cases where the user wants to simulate code as well as run it
diff --git a/firefox140/patches/patch-js_public_Utility.h b/firefox140/patches/patch-js_public_Utility.h
new file mode 100644
index 0000000000..4d6e780aed
--- /dev/null
+++ b/firefox140/patches/patch-js_public_Utility.h
@@ -0,0 +1,27 @@
+$NetBSD: patch-js_public_Utility.h,v 1.2 2024/08/03 02:06:31 tsutsui Exp $
+
+- kludge to build on NetBSD/i386 10.0
+  https://mail-index.netbsd.org/pkgsrc-users/2024/07/16/msg039900.html
+
+--- js/public/Utility.h.orig	2024-07-04 17:04:15.000000000 +0000
++++ js/public/Utility.h
+@@ -482,9 +482,6 @@ static inline void js_free(void* p) {
+ #define JS_DECLARE_NEW_METHODS(NEWNAME, ALLOCATOR, QUALIFIERS)              \
+   template <class T, typename... Args>                                      \
+   QUALIFIERS T* MOZ_HEAP_ALLOCATOR NEWNAME(Args&&... args) {                \
+-    static_assert(                                                          \
+-        alignof(T) <= alignof(max_align_t),                                 \
+-        "over-aligned type is not supported by JS_DECLARE_NEW_METHODS");    \
+     void* memory = ALLOCATOR(sizeof(T));                                    \
+     return MOZ_LIKELY(memory) ? new (memory) T(std::forward<Args>(args)...) \
+                               : nullptr;                                    \
+@@ -501,9 +498,6 @@ static inline void js_free(void* p) {
+ #define JS_DECLARE_NEW_ARENA_METHODS(NEWNAME, ALLOCATOR, QUALIFIERS)           \
+   template <class T, typename... Args>                                         \
+   QUALIFIERS T* MOZ_HEAP_ALLOCATOR NEWNAME(arena_id_t arena, Args&&... args) { \
+-    static_assert(                                                             \
+-        alignof(T) <= alignof(max_align_t),                                    \
+-        "over-aligned type is not supported by JS_DECLARE_NEW_ARENA_METHODS"); \
+     void* memory = ALLOCATOR(arena, sizeof(T));                                \
+     return MOZ_LIKELY(memory) ? new (memory) T(std::forward<Args>(args)...)    \
+                               : nullptr;                                       \
diff --git a/firefox140/patches/patch-js_src_jit_FlushICache.cpp b/firefox140/patches/patch-js_src_jit_FlushICache.cpp
new file mode 100644
index 0000000000..35b52513f4
--- /dev/null
+++ b/firefox140/patches/patch-js_src_jit_FlushICache.cpp
@@ -0,0 +1,34 @@
+$NetBSD: patch-js_src_jit_FlushICache.cpp,v 1.3 2025/07/23 13:57:35 ryoon Exp $
+
+NetBSD does not have the Linux-specific membarrier(2) syscall.
+
+--- js/src/jit/FlushICache.cpp.orig	2025-06-13 17:08:49.000000000 +0000
++++ js/src/jit/FlushICache.cpp
+@@ -31,12 +31,18 @@
+ #    elif defined(__android__)
+ #      include <sys/syscall.h>
+ #      include <unistd.h>
++#    elif defined(__NetBSD__)
++       // nothing
+ #    else
+ #      error "Missing platform-specific declarations for membarrier syscall!"
+ #    endif  // __linux__ / ANDROID
+ 
+ static int membarrier(int cmd, int flags) {
++#if defined(__NetBSD__)
++  return ENOSYS;
++#else
+   return syscall(__NR_membarrier, cmd, flags);
++#endif
+ }
+ 
+ // These definitions come from the Linux kernel source, for kernels before 4.16
+@@ -112,6 +118,8 @@ bool CanFlushExecutionContextForAllThrea
+   MOZ_ASSERT(state != MemBarrierAvailable::Unset);
+   return state == MemBarrierAvailable::Yes;
+ 
++#  elif defined(__NetBSD__)
++  return false;
+ #  else
+   // On other platforms, we assume that the syscall for flushing the icache
+   // will flush the execution context for other cores.
diff --git a/firefox140/patches/patch-js_src_util_NativeStack.cpp b/firefox140/patches/patch-js_src_util_NativeStack.cpp
new file mode 100644
index 0000000000..b4d587e1a4
--- /dev/null
+++ b/firefox140/patches/patch-js_src_util_NativeStack.cpp
@@ -0,0 +1,32 @@
+$NetBSD: patch-js_src_util_NativeStack.cpp,v 1.6 2020/04/09 14:01:26 ryoon Exp $
+
+Support SunOS.
+
+--- js/src/util/NativeStack.cpp.orig	2020-04-03 19:34:51.000000000 +0000
++++ js/src/util/NativeStack.cpp
+@@ -13,7 +13,7 @@
+ #  if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
+ #    include <pthread_np.h>
+ #  endif
+-#  if defined(SOLARIS) || defined(AIX)
++#  if defined(__sun) || defined(AIX)
+ #    include <ucontext.h>
+ #  endif
+ #  if defined(ANDROID) && !defined(__aarch64__)
+@@ -40,7 +40,7 @@ void* js::GetNativeStackBaseImpl() {
+   return static_cast<void*>(pTib->StackBase);
+ }
+ 
+-#elif defined(SOLARIS)
++#elif defined(__sun)
+ 
+ static_assert(JS_STACK_GROWTH_DIRECTION < 0);
+ 
+@@ -128,6 +128,7 @@ void* js::GetNativeStackBaseImpl() {
+ #    elif defined(PTHREAD_NP_H) || defined(_PTHREAD_NP_H_) || defined(NETBSD)
+   /* e.g. on FreeBSD 4.8 or newer, neundorf%kde.org@localhost */
+   pthread_attr_get_np(thread, &sattr);
++#    elif defined(__sun)
+ #    else
+   /*
+    * FIXME: this function is non-portable;
diff --git a/firefox140/patches/patch-js_src_vm_TypedArrayObject-inl.h b/firefox140/patches/patch-js_src_vm_TypedArrayObject-inl.h
new file mode 100644
index 0000000000..6e434b4ceb
--- /dev/null
+++ b/firefox140/patches/patch-js_src_vm_TypedArrayObject-inl.h
@@ -0,0 +1,17 @@
+$NetBSD: patch-js_src_vm_TypedArrayObject-inl.h,v 1.2 2024/10/01 12:47:19 ryoon Exp $
+
+- kludge to build on NetBSD/i386 10.0
+  https://mail-index.netbsd.org/pkgsrc-users/2024/07/16/msg039900.html
+
+--- js/src/vm/TypedArrayObject-inl.h.orig	2024-08-23 12:51:13.000000000 +0000
++++ js/src/vm/TypedArrayObject-inl.h
+@@ -435,7 +435,9 @@ class ElementSpecific {
+     // `malloc` returns memory at least as strictly aligned as for max_align_t
+     // and the alignment of max_align_t is a multiple of the size of `T`,
+     // so `SharedMem::cast` will be called with properly aligned memory.
++#if !defined(__i386__)
+     static_assert(alignof(std::max_align_t) % sizeof(T) == 0);
++#endif
+ 
+     SharedMem<T*> dest = Ops::extract(target).template cast<T*>() + offset;
+     SharedMem<void*> data = Ops::extract(source);
diff --git a/firefox140/patches/patch-media_ffvpx_libavutil_arm_bswap.h b/firefox140/patches/patch-media_ffvpx_libavutil_arm_bswap.h
new file mode 100644
index 0000000000..2b1d9ba488
--- /dev/null
+++ b/firefox140/patches/patch-media_ffvpx_libavutil_arm_bswap.h
@@ -0,0 +1,22 @@
+$NetBSD: patch-media_ffvpx_libavutil_arm_bswap.h,v 1.2 2025/04/30 03:10:40 ryoon Exp $
+
+Fix NetBSD aarch64 build.
+
+--- media/ffvpx/libavutil/arm/bswap.h.orig	2025-02-21 13:24:25.000000000 +0000
++++ media/ffvpx/libavutil/arm/bswap.h
+@@ -23,6 +23,8 @@
+ #include "config.h"
+ #include "libavutil/attributes.h"
+ 
++#ifndef __aarch64__
++
+ #ifdef __ARMCC_VERSION
+ 
+ #if HAVE_ARMV6
+@@ -47,4 +49,6 @@ static av_always_inline av_const unsigne
+ #endif
+ #endif /* __ARMCC_VERSION */
+ 
++#endif /* __aarch64__ */
++
+ #endif /* AVUTIL_ARM_BSWAP_H */
diff --git a/firefox140/patches/patch-media_libpng_pngpriv.h b/firefox140/patches/patch-media_libpng_pngpriv.h
new file mode 100644
index 0000000000..fa64fe119d
--- /dev/null
+++ b/firefox140/patches/patch-media_libpng_pngpriv.h
@@ -0,0 +1,17 @@
+$NetBSD: patch-media_libpng_pngpriv.h,v 1.7 2024/04/16 20:10:33 ryoon Exp $
+
+Fix _POSIX_SOURCE on SunOS.
+
+--- media/libpng/pngpriv.h.orig	2024-04-05 19:49:16.000000000 +0000
++++ media/libpng/pngpriv.h
+@@ -36,8 +36,10 @@
+  * still required (as of 2011-05-02.)
+  */
+ #ifndef _POSIX_SOURCE
++#if !defined(__sun) || (__STDC_VERSION__-0 < 199901L)
+ #  define _POSIX_SOURCE 1 /* Just the POSIX 1003.1 and C89 APIs */
+ #endif
++#endif
+ 
+ #ifndef PNG_VERSION_INFO_ONLY
+ /* Standard library headers not required by png.h: */
diff --git a/firefox140/patches/patch-modules_fdlibm_src_math__private.h b/firefox140/patches/patch-modules_fdlibm_src_math__private.h
new file mode 100644
index 0000000000..06fcc7bbf3
--- /dev/null
+++ b/firefox140/patches/patch-modules_fdlibm_src_math__private.h
@@ -0,0 +1,20 @@
+$NetBSD: patch-modules_fdlibm_src_math__private.h,v 1.3 2022/12/11 13:49:09 ryoon Exp $
+
+* Fix PR pkg/56457, build failure on NetBSD/i386.
+  Do not use FreeBSD-specific definition.
+
+--- modules/fdlibm/src/math_private.h.orig	2022-11-03 21:19:39.000000000 +0000
++++ modules/fdlibm/src/math_private.h
+@@ -30,9 +30,9 @@
+  * Adapted from https://github.com/freebsd/freebsd-src/search?q=__double_t
+  */
+ 
+-typedef double      __double_t;
+-typedef __double_t  double_t;
+-typedef float       __float_t;
++#include <math.h>
++typedef double_t __double_t;
++typedef float_t __float_t;
+ 
+ /*
+  * The original fdlibm code used statements like:
diff --git a/firefox140/patches/patch-netwerk_protocol_http_nsHttpHandler.cpp b/firefox140/patches/patch-netwerk_protocol_http_nsHttpHandler.cpp
new file mode 100644
index 0000000000..b7c452a7b5
--- /dev/null
+++ b/firefox140/patches/patch-netwerk_protocol_http_nsHttpHandler.cpp
@@ -0,0 +1,15 @@
+$NetBSD: patch-netwerk_protocol_http_nsHttpHandler.cpp,v 1.5 2025/01/14 13:36:15 ryoon Exp $
+
+* Do not freeze user-agent string as Linux under NetBSD.
+
+--- netwerk/protocol/http/nsHttpHandler.cpp.orig	2024-12-26 14:27:48.719857849 +0000
++++ netwerk/protocol/http/nsHttpHandler.cpp
+@@ -1063,6 +1063,8 @@ void nsHttpHandler::InitUserAgentCompone
+   mOscpu.AssignLiteral("Linux armv81");
+ #elif defined(XP_IOS)
+   mOscpu.AssignLiteral("iPhone");
++#elif defined(__NetBSD__)
++  mOscpu.AssignLiteral("NetBSD x86_64");
+ #else
+   mOscpu.AssignLiteral("Linux x86_64");
+ #endif
diff --git a/firefox140/patches/patch-nsprpub_pr_src_pthreads_ptsynch.c b/firefox140/patches/patch-nsprpub_pr_src_pthreads_ptsynch.c
new file mode 100644
index 0000000000..37e3d6c39a
--- /dev/null
+++ b/firefox140/patches/patch-nsprpub_pr_src_pthreads_ptsynch.c
@@ -0,0 +1,112 @@
+$NetBSD: patch-nsprpub_pr_src_pthreads_ptsynch.c,v 1.3 2024/12/25 13:30:11 ryoon Exp $
+
+firefox: Workaround broken pthread_equal() usage
+
+Switch to an internal version of pthread_equal() without sanity checks.
+
+Problems detected on NetBSD 9.99.46.
+
+https://bugzilla.mozilla.org/show_bug.cgi?id=1718838
+
+--- nsprpub/pr/src/pthreads/ptsynch.c.orig	2024-11-25 14:49:12.865195781 +0000
++++ nsprpub/pr/src/pthreads/ptsynch.c
+@@ -25,6 +25,13 @@ static pthread_condattr_t _pt_cvar_attr;
+ extern PTDebug pt_debug; /* this is shared between several modules */
+ #  endif                 /* defined(DEBUG) */
+ 
++/* XXX, pthread_equal() is misused to compare non-valid thread pointers */
++static int
++pt_pthread_equal(pthread_t t1, pthread_t t2)
++{
++	return t1 == t2;
++}
++
+ #  if defined(FREEBSD)
+ /*
+  * On older versions of FreeBSD, pthread_mutex_trylock returns EDEADLK.
+@@ -181,9 +188,9 @@ PR_IMPLEMENT(PRStatus) PR_Unlock(PRLock*
+   PR_ASSERT(lock != NULL);
+   PR_ASSERT(_PT_PTHREAD_MUTEX_IS_LOCKED(lock->mutex));
+   PR_ASSERT(PR_TRUE == lock->locked);
+-  PR_ASSERT(pthread_equal(lock->owner, self));
++  PR_ASSERT(pt_pthread_equal(lock->owner, self));
+ 
+-  if (!lock->locked || !pthread_equal(lock->owner, self)) {
++  if (!lock->locked || !pt_pthread_equal(lock->owner, self)) {
+     return PR_FAILURE;
+   }
+ 
+@@ -207,7 +214,7 @@ PR_IMPLEMENT(void) PR_AssertCurrentThrea
+    * to the correctness of PR_AssertCurrentThreadOwnsLock(), but
+    * this particular order makes the assertion more likely to
+    * catch errors. */
+-  PR_ASSERT(lock->locked && pthread_equal(lock->owner, pthread_self()));
++  PR_ASSERT(lock->locked && pt_pthread_equal(lock->owner, pthread_self()));
+ }
+ 
+ /**************************************************************/
+@@ -260,7 +267,7 @@ static void pt_PostNotifyToCvar(PRCondVa
+   _PT_Notified* notified = &cvar->lock->notified;
+ 
+   PR_ASSERT(PR_TRUE == cvar->lock->locked);
+-  PR_ASSERT(pthread_equal(cvar->lock->owner, pthread_self()));
++  PR_ASSERT(pt_pthread_equal(cvar->lock->owner, pthread_self()));
+   PR_ASSERT(_PT_PTHREAD_MUTEX_IS_LOCKED(cvar->lock->mutex));
+ 
+   while (1) {
+@@ -336,7 +343,7 @@ PR_IMPLEMENT(PRStatus) PR_WaitCondVar(PR
+   PR_ASSERT(_PT_PTHREAD_MUTEX_IS_LOCKED(cvar->lock->mutex));
+   PR_ASSERT(PR_TRUE == cvar->lock->locked);
+   /* and it better be by us */
+-  PR_ASSERT(pthread_equal(cvar->lock->owner, pthread_self()));
++  PR_ASSERT(pt_pthread_equal(cvar->lock->owner, pthread_self()));
+ 
+   if (_PT_THREAD_INTERRUPTED(thred)) {
+     goto aborted;
+@@ -535,7 +542,7 @@ PR_IMPLEMENT(PRIntn) PR_GetMonitorEntryC
+ 
+   rv = pthread_mutex_lock(&mon->lock);
+   PR_ASSERT(0 == rv);
+-  if (pthread_equal(mon->owner, self)) {
++  if (pt_pthread_equal(mon->owner, self)) {
+     count = mon->entryCount;
+   }
+   rv = pthread_mutex_unlock(&mon->lock);
+@@ -549,7 +556,7 @@ PR_IMPLEMENT(void) PR_AssertCurrentThrea
+ 
+   rv = pthread_mutex_lock(&mon->lock);
+   PR_ASSERT(0 == rv);
+-  PR_ASSERT(mon->entryCount != 0 && pthread_equal(mon->owner, pthread_self()));
++  PR_ASSERT(mon->entryCount != 0 && pt_pthread_equal(mon->owner, pthread_self()));
+   rv = pthread_mutex_unlock(&mon->lock);
+   PR_ASSERT(0 == rv);
+ #  endif
+@@ -563,7 +570,7 @@ PR_IMPLEMENT(void) PR_EnterMonitor(PRMon
+   rv = pthread_mutex_lock(&mon->lock);
+   PR_ASSERT(0 == rv);
+   if (mon->entryCount != 0) {
+-    if (pthread_equal(mon->owner, self)) {
++    if (pt_pthread_equal(mon->owner, self)) {
+       goto done;
+     }
+     while (mon->entryCount != 0) {
+@@ -593,8 +600,8 @@ PR_IMPLEMENT(PRStatus) PR_ExitMonitor(PR
+   PR_ASSERT(0 == rv);
+   /* the entries should be > 0 and we'd better be the owner */
+   PR_ASSERT(mon->entryCount > 0);
+-  PR_ASSERT(pthread_equal(mon->owner, self));
+-  if (mon->entryCount == 0 || !pthread_equal(mon->owner, self)) {
++  PR_ASSERT(pt_pthread_equal(mon->owner, self));
++  if (mon->entryCount == 0 || !pt_pthread_equal(mon->owner, self)) {
+     rv = pthread_mutex_unlock(&mon->lock);
+     PR_ASSERT(0 == rv);
+     return PR_FAILURE;
+@@ -638,7 +645,7 @@ PR_IMPLEMENT(PRStatus) PR_Wait(PRMonitor
+   /* the entries better be positive */
+   PR_ASSERT(mon->entryCount > 0);
+   /* and it better be owned by us */
+-  PR_ASSERT(pthread_equal(mon->owner, pthread_self()));
++  PR_ASSERT(pt_pthread_equal(mon->owner, pthread_self()));
+ 
+   /* tuck these away 'till later */
+   saved_entries = mon->entryCount;
diff --git a/firefox140/patches/patch-python_mozbuild_mozbuild_backend_recursivemake.py b/firefox140/patches/patch-python_mozbuild_mozbuild_backend_recursivemake.py
new file mode 100644
index 0000000000..62f7822f79
--- /dev/null
+++ b/firefox140/patches/patch-python_mozbuild_mozbuild_backend_recursivemake.py
@@ -0,0 +1,27 @@
+$NetBSD: patch-python_mozbuild_mozbuild_backend_recursivemake.py,v 1.2 2024/10/01 12:47:19 ryoon Exp $
+
+* As of 129.0, libxul.so is built with -Wl,-z,defs (no undefined references).
+  Supply memalign() from fallback.cpp (Unified_cpp_memory_build0) for NetBSD.
+  This approach is completely incorrect, however I do not find the correct
+  way to include Unified_cpp_memory_build0.o to objs yet.
+
+--- python/mozbuild/mozbuild/backend/recursivemake.py.orig	2024-08-23 12:51:15.000000000 +0000
++++ python/mozbuild/mozbuild/backend/recursivemake.py
+@@ -73,6 +73,8 @@ from ..util import FileAvoidWrite, ensur
+ from .common import CommonBackend
+ from .make import MakeBackend
+ 
++import buildconfig
++
+ # To protect against accidentally adding logic to Makefiles that belong in moz.build,
+ # we check if moz.build-like variables are defined in Makefiles. If they are, we throw
+ # an error to encourage the usage of moz.build instead.
+@@ -1426,6 +1428,8 @@ class RecursiveMakeBackend(MakeBackend):
+ 
+     def _process_linked_libraries(self, obj, backend_file):
+         objs, shared_libs, os_libs, static_libs = self._expand_libs(obj)
++        if buildconfig.substs["OS_ARCH"] == "NetBSD" and obj.name == "libxul.so":
++            objs.append("memory/build/Unified_cpp_memory_build0.o")
+ 
+         obj_target = obj.name
+         if isinstance(obj, (Program, SharedLibrary)):
diff --git a/firefox140/patches/patch-python_mozbuild_mozbuild_frontend_reader.py b/firefox140/patches/patch-python_mozbuild_mozbuild_frontend_reader.py
new file mode 100644
index 0000000000..2638269d85
--- /dev/null
+++ b/firefox140/patches/patch-python_mozbuild_mozbuild_frontend_reader.py
@@ -0,0 +1,15 @@
+$NetBSD: patch-python_mozbuild_mozbuild_frontend_reader.py,v 1.1 2025/10/09 14:48:03 ryoon Exp $
+
+* For Python 3.14 too.
+
+--- python/mozbuild/mozbuild/frontend/reader.py.orig	2025-10-08 15:23:09.699830974 +0000
++++ python/mozbuild/mozbuild/frontend/reader.py
+@@ -470,7 +470,7 @@ class TemplateFunction:
+             return c(
+                 ast.Subscript(
+                     value=c(ast.Name(id=self._global_name, ctx=ast.Load())),
+-                    slice=c(ast.Index(value=c(ast.Str(s=node.id)))),
++                    slice=c(ast.Index(value=c(ast.Constant(value=node.id)))),
+                     ctx=node.ctx,
+                 )
+             )
diff --git a/firefox140/patches/patch-third__party_abseil-cpp_absl_debugging_internal_elf__mem__image.cc b/firefox140/patches/patch-third__party_abseil-cpp_absl_debugging_internal_elf__mem__image.cc
new file mode 100644
index 0000000000..eba67085ac
--- /dev/null
+++ b/firefox140/patches/patch-third__party_abseil-cpp_absl_debugging_internal_elf__mem__image.cc
@@ -0,0 +1,17 @@
+$NetBSD: patch-third__party_abseil-cpp_absl_debugging_internal_elf__mem__image.cc,v 1.1 2025/04/30 03:10:40 ryoon Exp $
+
+* NetBSD has no DT_GNU_HASH definition.
+
+--- third_party/abseil-cpp/absl/debugging/internal/elf_mem_image.cc.orig	2025-03-05 13:29:06.318414617 +0000
++++ third_party/abseil-cpp/absl/debugging/internal/elf_mem_image.cc
+@@ -221,6 +221,10 @@ void ElfMemImage::Init(const void *base)
+   for (; dynamic_entry->d_tag != DT_NULL; ++dynamic_entry) {
+     const auto value =
+         static_cast<intptr_t>(dynamic_entry->d_un.d_val) + relocation;
++/* For NetBSD 9 */
++#if !defined(DT_GNU_HASH)
++#define DT_GNU_HASH 0x6ffffef5
++#endif
+     switch (dynamic_entry->d_tag) {
+       case DT_HASH:
+         sysv_hash = reinterpret_cast<uint32_t *>(value);
diff --git a/firefox140/patches/patch-third__party_abseil-cpp_absl_debugging_internal_vdso__support.cc b/firefox140/patches/patch-third__party_abseil-cpp_absl_debugging_internal_vdso__support.cc
new file mode 100644
index 0000000000..5ec542894a
--- /dev/null
+++ b/firefox140/patches/patch-third__party_abseil-cpp_absl_debugging_internal_vdso__support.cc
@@ -0,0 +1,18 @@
+$NetBSD: patch-third__party_abseil-cpp_absl_debugging_internal_vdso__support.cc,v 1.1 2025/04/30 03:10:40 ryoon Exp $
+
+* Do not find system_wrappers/syscall.h generated by Firefox.
+
+--- third_party/abseil-cpp/absl/debugging/internal/vdso_support.cc.orig	2025-03-01 04:07:45.625009806 +0000
++++ third_party/abseil-cpp/absl/debugging/internal/vdso_support.cc
+@@ -26,9 +26,9 @@
+ 
+ #include <errno.h>
+ #include <fcntl.h>
+-#if __has_include(<syscall.h>)
++#if defined(__linux__)
+ #include <syscall.h>
+-#elif __has_include(<sys/syscall.h>)
++#elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__)
+ #include <sys/syscall.h>
+ #endif
+ #include <unistd.h>
diff --git a/firefox140/patches/patch-third__party_js_cfworker_build.sh b/firefox140/patches/patch-third__party_js_cfworker_build.sh
new file mode 100644
index 0000000000..98e308661a
--- /dev/null
+++ b/firefox140/patches/patch-third__party_js_cfworker_build.sh
@@ -0,0 +1,20 @@
+$NetBSD: patch-third__party_js_cfworker_build.sh,v 1.1 2022/05/14 10:30:26 tnn Exp $
+
+shell portability
+
+--- third_party/js/cfworker/build.sh.orig	2022-04-28 22:03:47.000000000 +0000
++++ third_party/js/cfworker/build.sh
+@@ -4,9 +4,10 @@ set -euo pipefail
+ # Path to mach relative to /third_party/js/cfworker
+ MACH=$(realpath "../../../mach")
+ 
+-if [[ $(uname -a) == *MSYS* ]]; then
+-  MACH="python ${MACH}"
+-fi
++# uname -a is not a good idea here. Someone could have MSYS in the hostname.
++#if uname -a | grep MSYS > /dev/null; then
++#  MACH="python ${MACH}"
++#fi
+ 
+ NODE="${MACH} node"
+ NPM="${MACH} npm"
diff --git a/firefox140/patches/patch-third__party_libwebrtc_modules_audio__device_audio__device__impl.cc b/firefox140/patches/patch-third__party_libwebrtc_modules_audio__device_audio__device__impl.cc
new file mode 100644
index 0000000000..f7c8b351f8
--- /dev/null
+++ b/firefox140/patches/patch-third__party_libwebrtc_modules_audio__device_audio__device__impl.cc
@@ -0,0 +1,34 @@
+$NetBSD: patch-third__party_libwebrtc_modules_audio__device_audio__device__impl.cc,v 1.2 2025/07/23 13:57:35 ryoon Exp $
+
+--- third_party/libwebrtc/modules/audio_device/audio_device_impl.cc.orig	2025-05-21 12:45:39.616635762 +0000
++++ third_party/libwebrtc/modules/audio_device/audio_device_impl.cc
+@@ -28,7 +28,7 @@
+ #include <stdlib.h>
+ 
+ #include "sdk/android/native_api/audio_device_module/audio_device_android.h"
+-#elif defined(WEBRTC_LINUX)
++#elif defined(WEBRTC_LINUX) || defined(WEBRTC_BSD)
+ #if defined(WEBRTC_ENABLE_LINUX_ALSA)
+ #include "modules/audio_device/linux/audio_device_alsa_linux.h"
+ #endif
+@@ -155,6 +155,11 @@ int32_t AudioDeviceModuleImpl::CheckPlat
+ #elif defined(WEBRTC_FUCHSIA)
+   platform = kPlatformFuchsia;
+   RTC_LOG(LS_INFO) << "current platform is Fuchsia";
++#elif defined(WEBRTC_BSD)
++#  if defined(__NetBSD__)
++  platform = kPlatformNetBSD;
++  RTC_LOG(LS_INFO) << "current platform is NetBSD";
++#  endif
+ #endif
+   if (platform == kPlatformNotSupported) {
+     RTC_LOG(LS_ERROR)
+@@ -207,7 +212,7 @@ int32_t AudioDeviceModuleImpl::CreatePla
+ // 'rtc_include_pulse_audio' build flag.
+ // TODO(bugs.webrtc.org/9127): improve support and make it more clear that
+ // PulseAudio is the default selection.
+-#if !defined(WEBRTC_ANDROID) && defined(WEBRTC_LINUX)
++#if !defined(WEBRTC_ANDROID) && (defined(WEBRTC_LINUX) || defined(WEBRTC_BSD))
+ #if !defined(WEBRTC_ENABLE_LINUX_PULSE)
+   // Build flag 'rtc_include_pulse_audio' is set to false. In this mode:
+   // - kPlatformDefaultAudio => ALSA, and
diff --git a/firefox140/patches/patch-third__party_libwebrtc_modules_desktop__capture_desktop__capture__gn_moz.build b/firefox140/patches/patch-third__party_libwebrtc_modules_desktop__capture_desktop__capture__gn_moz.build
new file mode 100644
index 0000000000..e57a37c1b0
--- /dev/null
+++ b/firefox140/patches/patch-third__party_libwebrtc_modules_desktop__capture_desktop__capture__gn_moz.build
@@ -0,0 +1,45 @@
+$NetBSD: patch-third__party_libwebrtc_modules_desktop__capture_desktop__capture__gn_moz.build,v 1.4 2024/04/06 08:53:35 ryoon Exp $
+
+* Disable Wayland desktop capture for non-Linux platforms.
+  Fix segfault under X11.
+
+--- third_party/libwebrtc/modules/desktop_capture/desktop_capture_gn/moz.build.orig	2024-03-11 10:11:56.287869888 +0000
++++ third_party/libwebrtc/modules/desktop_capture/desktop_capture_gn/moz.build
+@@ -392,7 +392,7 @@ if CONFIG["MOZ_DEBUG"] == "1" and CONFIG
+ 
+     DEFINES["_HAS_ITERATOR_DEBUGGING"] = "0"
+ 
+-if CONFIG["TARGET_CPU"] == "aarch64" and (CONFIG["OS_TARGET"] == "Linux" or CONFIG["OS_TARGET"] == "NetBSD" or CONFIG["OS_TARGET"] == "OpenBSD" or CONFIG["OS_TARGET"] == "FreeBSD"):
++if CONFIG["TARGET_CPU"] == "aarch64" and CONFIG["OS_TARGET"] == "Linux":
+ 
+     DEFINES["WEBRTC_USE_PIPEWIRE"] = True
+     DEFINES["_GNU_SOURCE"] = True
+@@ -449,7 +449,7 @@ if CONFIG["OS_TARGET"] == "Linux" and CO
+         "/third_party/libwebrtc/modules/desktop_capture/linux/x11/x_window_property.cc"
+     ]
+ 
+-if CONFIG["TARGET_CPU"] == "x86" and (CONFIG["OS_TARGET"] == "Linux" or CONFIG["OS_TARGET"] == "NetBSD" or CONFIG["OS_TARGET"] == "OpenBSD" or CONFIG["OS_TARGET"] == "FreeBSD"):
++if CONFIG["TARGET_CPU"] == "x86" and CONFIG["OS_TARGET"] == "Linux":
+ 
+     CXXFLAGS += [
+         "-msse2"
+@@ -482,7 +482,7 @@ if CONFIG["TARGET_CPU"] == "x86" and (CO
+         "/third_party/libwebrtc/modules/desktop_capture/linux/wayland/shared_screencast_stream.cc"
+     ]
+ 
+-if CONFIG["TARGET_CPU"] == "x86_64" and (CONFIG["OS_TARGET"] == "Linux" or CONFIG["OS_TARGET"] == "NetBSD" or CONFIG["OS_TARGET"] == "OpenBSD" or CONFIG["OS_TARGET"] == "FreeBSD"):
++if CONFIG["TARGET_CPU"] == "x86_64" and CONFIG["OS_TARGET"] == "Linux":
+ 
+     DEFINES["WEBRTC_USE_PIPEWIRE"] = True
+     DEFINES["_GNU_SOURCE"] = True
+@@ -628,6 +628,10 @@ if CONFIG["TARGET_CPU"] == "x86" and CON
+     DEFINES["USE_X11"] = "1"
+     DEFINES["WEBRTC_USE_X11"] = True
+ 
++    CXXFLAGS += [
++        "-msse2"
++    ]
++
+     OS_LIBS += [
+         "X11",
+         "Xcomposite",
diff --git a/firefox140/patches/patch-third__party_libwebrtc_modules_desktop__capture_linux_wayland_egl__dmabuf.cc b/firefox140/patches/patch-third__party_libwebrtc_modules_desktop__capture_linux_wayland_egl__dmabuf.cc
new file mode 100644
index 0000000000..c1a71424c0
--- /dev/null
+++ b/firefox140/patches/patch-third__party_libwebrtc_modules_desktop__capture_linux_wayland_egl__dmabuf.cc
@@ -0,0 +1,21 @@
+$NetBSD: patch-third__party_libwebrtc_modules_desktop__capture_linux_wayland_egl__dmabuf.cc,v 1.2 2023/04/18 14:00:11 ryoon Exp $
+
+--- third_party/libwebrtc/modules/desktop_capture/linux/wayland/egl_dmabuf.cc.orig	2023-03-30 21:16:09.000000000 +0000
++++ third_party/libwebrtc/modules/desktop_capture/linux/wayland/egl_dmabuf.cc
+@@ -10,12 +10,16 @@
+ 
+ #include "modules/desktop_capture/linux/wayland/egl_dmabuf.h"
+ 
++#if defined(__linux__)
+ #include <asm/ioctl.h>
++#endif
+ #include <dlfcn.h>
+ #include <fcntl.h>
+ #include <gdk/gdk.h>
+ #include <libdrm/drm_fourcc.h>
++#if defined(__linux__)
+ #include <linux/types.h>
++#endif
+ #include <spa/param/video/format-utils.h>
+ #include <unistd.h>
+ #include <xf86drm.h>
diff --git a/firefox140/patches/patch-third__party_libwebrtc_modules_video__capture_linux_device__info__v4l2.cc b/firefox140/patches/patch-third__party_libwebrtc_modules_video__capture_linux_device__info__v4l2.cc
new file mode 100644
index 0000000000..a796819dc7
--- /dev/null
+++ b/firefox140/patches/patch-third__party_libwebrtc_modules_video__capture_linux_device__info__v4l2.cc
@@ -0,0 +1,107 @@
+$NetBSD: patch-third__party_libwebrtc_modules_video__capture_linux_device__info__v4l2.cc,v 1.4 2025/07/15 13:58:05 ryoon Exp $
+
+* Fix build under NetBSD 9 and older.
+  The older NetBSD's sys/videoio.h does not have v4l2_capability.device_caps.
+
+--- third_party/libwebrtc/modules/video_capture/linux/device_info_v4l2.cc.orig	2025-05-17 19:55:48.000000000 +0000
++++ third_party/libwebrtc/modules/video_capture/linux/device_info_v4l2.cc
+@@ -52,14 +52,14 @@
+ #define V4L2_PIX_FMT_RGBA32 v4l2_fourcc('A', 'B', '2', '4')
+ #endif
+ 
+-#ifdef WEBRTC_LINUX
++#ifdef WEBRTC_LINUX || WEBRTC_BSD
+ #define EVENT_SIZE  ( sizeof (struct inotify_event) )
+ #define BUF_LEN     ( 1024 * ( EVENT_SIZE + 16 ) )
+ #endif
+ 
+ namespace webrtc {
+ namespace videocapturemodule {
+-#ifdef WEBRTC_LINUX
++#ifdef WEBRTC_LINUX || WEBRTC_BSD
+ void DeviceInfoV4l2::HandleEvent(inotify_event* event, int fd)
+ {
+     if (event->mask & IN_CREATE) {
+@@ -175,11 +175,11 @@ void DeviceInfoV4l2::InotifyProcess()
+ #endif
+ 
+ DeviceInfoV4l2::DeviceInfoV4l2() : DeviceInfoImpl()
+-#ifdef WEBRTC_LINUX
++#ifdef WEBRTC_LINUX || WEBRTC_BSD
+     , _isShutdown(false)
+ #endif
+ {
+-#ifdef WEBRTC_LINUX
++#ifdef WEBRTC_LINUX || WEBRTC_BSD
+   _inotifyEventThread = rtc::PlatformThread::SpawnJoinable(
+       [this] {
+         InotifyProcess();
+@@ -192,7 +192,7 @@ int32_t DeviceInfoV4l2::Init() {
+ }
+ 
+ DeviceInfoV4l2::~DeviceInfoV4l2() {
+-#ifdef WEBRTC_LINUX
++#ifdef WEBRTC_LINUX || WEBRTC_BSD
+     _isShutdown = true;
+ 
+     if (!_inotifyEventThread.empty()) {
+@@ -211,11 +211,13 @@ uint32_t DeviceInfoV4l2::NumberOfDevices
+   for (int n = 0; n < 64; n++) {
+     snprintf(device, sizeof(device), "/dev/video%d", n);
+     if ((fd = open(device, O_RDONLY)) != -1) {
++#if defined(VIDIOC_QUERYCAP)
+       // query device capabilities and make sure this is a video capture device
+       if (ioctl(fd, VIDIOC_QUERYCAP, &cap) < 0 || !IsVideoCaptureDevice(&cap)) {
+         close(fd);
+         continue;
+       }
++#endif
+ 
+       close(fd);
+       count++;
+@@ -243,11 +245,13 @@ int32_t DeviceInfoV4l2::GetDeviceName(ui
+   for (int n = 0; n < 64; n++) {
+     snprintf(device, sizeof(device), "/dev/video%d", n);
+     if ((fd = open(device, O_RDONLY)) != -1) {
++#if defined(VIDIOC_QUERYCAP)
+       // query device capabilities and make sure this is a video capture device
+       if (ioctl(fd, VIDIOC_QUERYCAP, &cap) < 0 || !IsVideoCaptureDevice(&cap)) {
+         close(fd);
+         continue;
+       }
++#endif
+       if (count == deviceNumber) {
+         // Found the device
+         found = true;
+@@ -318,6 +322,7 @@ int32_t DeviceInfoV4l2::CreateCapability
+     if (fd == -1)
+       continue;
+ 
++#if defined(VIDIOC_QUERYCAP)
+     // query device capabilities
+     struct v4l2_capability cap;
+     if (ioctl(fd, VIDIOC_QUERYCAP, &cap) == 0) {
+@@ -342,6 +347,7 @@ int32_t DeviceInfoV4l2::CreateCapability
+         }
+       }
+     }
++#endif
+     close(fd);  // close since this is not the matching device
+   }
+ 
+@@ -387,11 +393,15 @@ bool DeviceInfoV4l2::IsDeviceNameMatches
+ 
+ bool DeviceInfoV4l2::IsVideoCaptureDevice(struct v4l2_capability* cap)
+ {
++#if defined(V4L2_CAP_DEVICE_CAPS)
+   if (cap->capabilities & V4L2_CAP_DEVICE_CAPS) {
+     return cap->device_caps & V4L2_CAP_VIDEO_CAPTURE;
+   } else {
+     return cap->capabilities & V4L2_CAP_VIDEO_CAPTURE;
+   }
++#else
++    return cap->capabilities & V4L2_CAP_VIDEO_CAPTURE;
++#endif
+ }
+ 
+ int32_t DeviceInfoV4l2::FillCapabilities(int fd) {
diff --git a/firefox140/patches/patch-third__party_libwebrtc_modules_video__capture_linux_video__capture__v4l2.cc b/firefox140/patches/patch-third__party_libwebrtc_modules_video__capture_linux_video__capture__v4l2.cc
new file mode 100644
index 0000000000..70dcb7b66d
--- /dev/null
+++ b/firefox140/patches/patch-third__party_libwebrtc_modules_video__capture_linux_video__capture__v4l2.cc
@@ -0,0 +1,23 @@
+$NetBSD: patch-third__party_libwebrtc_modules_video__capture_linux_video__capture__v4l2.cc,v 1.2 2023/01/24 17:57:09 nia Exp $
+
+* Fix build under NetBSD 9 and older.
+  The older NetBSD's sys/videoio.h does not have v4l2_capability.device_caps.
+
+--- third_party/libwebrtc/modules/video_capture/linux/video_capture_v4l2.cc.orig	2022-10-06 21:19:29.000000000 +0000
++++ third_party/libwebrtc/modules/video_capture/linux/video_capture_v4l2.cc
+@@ -77,6 +77,7 @@ int32_t VideoCaptureModuleV4L2::Init(con
+     if ((fd = open(device, O_RDONLY)) != -1) {
+       // query device capabilities
+       struct v4l2_capability cap;
++#if defined(VIDIOC_QUERYCAP)
+       if (ioctl(fd, VIDIOC_QUERYCAP, &cap) == 0) {
+         if (cap.bus_info[0] != 0) {
+           if (strncmp((const char*)cap.bus_info,
+@@ -89,6 +90,7 @@ int32_t VideoCaptureModuleV4L2::Init(con
+           }
+         }
+       }
++#endif
+       close(fd);  // close since this is not the matching device
+     }
+   }
diff --git a/firefox140/patches/patch-third__party_libwebrtc_modules_video__capture_video__capture__options.cc b/firefox140/patches/patch-third__party_libwebrtc_modules_video__capture_video__capture__options.cc
new file mode 100644
index 0000000000..f51cacdc54
--- /dev/null
+++ b/firefox140/patches/patch-third__party_libwebrtc_modules_video__capture_video__capture__options.cc
@@ -0,0 +1,13 @@
+$NetBSD: patch-third__party_libwebrtc_modules_video__capture_video__capture__options.cc,v 1.2 2025/07/23 13:57:35 ryoon Exp $
+
+--- third_party/libwebrtc/modules/video_capture/video_capture_options.cc.orig	2025-05-21 12:41:53.782245708 +0000
++++ third_party/libwebrtc/modules/video_capture/video_capture_options.cc
+@@ -37,7 +37,7 @@ void VideoCaptureOptions::Init(Callback*
+     return;
+   }
+ #endif
+-#if defined(WEBRTC_LINUX)
++#if defined(WEBRTC_LINUX) || defined(WEBRTC_BSD)
+   if (!allow_v4l2_)
+     callback->OnInitialized(Status::UNAVAILABLE);
+   else
diff --git a/firefox140/patches/patch-third__party_libwebrtc_rtc__base_memory__usage.cc b/firefox140/patches/patch-third__party_libwebrtc_rtc__base_memory__usage.cc
new file mode 100644
index 0000000000..d5a06a5d15
--- /dev/null
+++ b/firefox140/patches/patch-third__party_libwebrtc_rtc__base_memory__usage.cc
@@ -0,0 +1,22 @@
+$NetBSD: patch-third__party_libwebrtc_rtc__base_memory__usage.cc,v 1.2 2025/07/23 13:57:35 ryoon Exp $
+
+--- third_party/libwebrtc/rtc_base/memory_usage.cc.orig	2025-05-21 12:27:20.023110519 +0000
++++ third_party/libwebrtc/rtc_base/memory_usage.cc
+@@ -10,7 +10,7 @@
+ 
+ #include "rtc_base/memory_usage.h"
+ 
+-#if defined(WEBRTC_LINUX)
++#if defined(WEBRTC_LINUX) || defined(WEBRTC_BSD)
+ #include <unistd.h>
+ 
+ #include <cstdio>
+@@ -32,7 +32,7 @@
+ namespace rtc {
+ 
+ int64_t GetProcessResidentSizeBytes() {
+-#if defined(WEBRTC_LINUX)
++#if defined(WEBRTC_LINUX) || defined(WEBRTC_BSD)
+   FILE* file = fopen("/proc/self/statm", "r");
+   if (file == nullptr) {
+     RTC_LOG(LS_ERROR) << "Failed to open /proc/self/statm";
diff --git a/firefox140/patches/patch-third__party_libwebrtc_rtc__base_physical__socket__server.cc b/firefox140/patches/patch-third__party_libwebrtc_rtc__base_physical__socket__server.cc
new file mode 100644
index 0000000000..bb0f288ce6
--- /dev/null
+++ b/firefox140/patches/patch-third__party_libwebrtc_rtc__base_physical__socket__server.cc
@@ -0,0 +1,13 @@
+$NetBSD: patch-third__party_libwebrtc_rtc__base_physical__socket__server.cc,v 1.1 2024/07/13 22:10:30 ryoon Exp $
+
+--- third_party/libwebrtc/rtc_base/physical_socket_server.cc.orig	2024-07-03 20:25:45.412396416 +0000
++++ third_party/libwebrtc/rtc_base/physical_socket_server.cc
+@@ -770,7 +770,7 @@ int PhysicalSocket::TranslateOption(Opti
+       return -1;
+ #endif
+     case OPT_RECV_ECN:
+-#if defined(WEBRTC_POSIX)
++#if defined(WEBRTC_POSIX) && defined(IP_RECVTOS)
+       if (family_ == AF_INET6) {
+         *slevel = IPPROTO_IPV6;
+         *sopt = IPV6_RECVTCLASS;
diff --git a/firefox140/patches/patch-third__party_libwebrtc_rtc__base_platform__thread__types.cc b/firefox140/patches/patch-third__party_libwebrtc_rtc__base_platform__thread__types.cc
new file mode 100644
index 0000000000..f169c571e1
--- /dev/null
+++ b/firefox140/patches/patch-third__party_libwebrtc_rtc__base_platform__thread__types.cc
@@ -0,0 +1,29 @@
+$NetBSD: patch-third__party_libwebrtc_rtc__base_platform__thread__types.cc,v 1.2 2025/07/23 13:57:35 ryoon Exp $
+
+--- third_party/libwebrtc/rtc_base/platform_thread_types.cc.orig	2025-05-21 12:30:11.564823191 +0000
++++ third_party/libwebrtc/rtc_base/platform_thread_types.cc
+@@ -71,7 +71,11 @@ bool IsThreadRefEqual(const PlatformThre
+ #if defined(WEBRTC_WIN) || defined(WEBRTC_FUCHSIA)
+   return a == b;
+ #elif defined(WEBRTC_POSIX)
++#  if defined(__NetBSD__)
++  return a == b;
++#  else
+   return pthread_equal(a, b);
++#  endif
+ #endif
+ }
+ 
+@@ -118,6 +122,12 @@ void SetCurrentThreadName(const char* na
+   prctl(PR_SET_NAME, reinterpret_cast<unsigned long>(name));  // NOLINT
+ #elif defined(WEBRTC_MAC) || defined(WEBRTC_IOS)
+   pthread_setname_np(name);
++#elif defined(WEBRTC_BSD)
++#  if defined(__NetBSD__)
++  pthread_setname_np(pthread_self(), "%s", const_cast<char *>(name));
++#  else
++  pthread_setname_np(pthread_self(), name);
++#  endif
+ #elif defined(WEBRTC_FUCHSIA)
+   zx_status_t status = zx_object_set_property(zx_thread_self(), ZX_PROP_NAME,
+                                               name, strlen(name));
diff --git a/firefox140/patches/patch-third__party_libwebrtc_system__wrappers_source_cpu__features__linux.cc b/firefox140/patches/patch-third__party_libwebrtc_system__wrappers_source_cpu__features__linux.cc
new file mode 100644
index 0000000000..5ebcd61054
--- /dev/null
+++ b/firefox140/patches/patch-third__party_libwebrtc_system__wrappers_source_cpu__features__linux.cc
@@ -0,0 +1,25 @@
+$NetBSD: patch-third__party_libwebrtc_system__wrappers_source_cpu__features__linux.cc,v 1.2 2022/01/17 10:22:54 tnn Exp $
+
+* Fix build under NetBSD at least.
+
+--- third_party/libwebrtc/system_wrappers/source/cpu_features_linux.cc.orig	2022-01-13 19:26:15.000000000 +0000
++++ third_party/libwebrtc/system_wrappers/source/cpu_features_linux.cc
+@@ -8,7 +8,9 @@
+  *  be found in the AUTHORS file in the root of the source tree.
+  */
+ 
++#if !defined(__NetBSD__)
+ #include <features.h>
++#endif
+ #include <stdlib.h>
+ #include <string.h>
+ 
+@@ -30,7 +32,7 @@
+ #include "rtc_base/system/arch.h"
+ #include "system_wrappers/include/cpu_features_wrapper.h"
+ 
+-#if defined(WEBRTC_ARCH_ARM_FAMILY)
++#if defined(WEBRTC_ARCH_ARM_FAMILY) && defined(__linux__)
+ #include <asm/hwcap.h>
+ 
+ namespace webrtc {
diff --git a/firefox140/patches/patch-third__party_python_dlmanager_check.py b/firefox140/patches/patch-third__party_python_dlmanager_check.py
new file mode 100644
index 0000000000..bcbfcc8abc
--- /dev/null
+++ b/firefox140/patches/patch-third__party_python_dlmanager_check.py
@@ -0,0 +1,24 @@
+$NetBSD: patch-third__party_python_dlmanager_check.py,v 1.1 2024/10/11 13:55:48 wiz Exp $
+
+Fix build with Python 3.13.
+
+--- third_party/python/dlmanager/check.py.orig	2024-10-11 13:43:43.746252969 +0000
++++ third_party/python/dlmanager/check.py
+@@ -5,7 +5,7 @@ Run flake8 checks and tests.
+ 
+ import os
+ import argparse
+-import pipes
++import shlex
+ import shutil
+ import tempfile
+ 
+@@ -23,7 +23,7 @@ def parse_args():
+ 
+ 
+ def run(cmd, **kwargs):
+-    msg = 'Running: |%s|' % ' '.join(pipes.quote(c) for c in cmd)
++    msg = 'Running: |%s|' % ' '.join(shlex.quote(c) for c in cmd)
+     if kwargs.get('cwd'):
+         msg += ' in %s' % kwargs['cwd']
+     print(msg)
diff --git a/firefox140/patches/patch-third__party_sqlite3_ext_moz.build b/firefox140/patches/patch-third__party_sqlite3_ext_moz.build
new file mode 100644
index 0000000000..c1f2ffbe24
--- /dev/null
+++ b/firefox140/patches/patch-third__party_sqlite3_ext_moz.build
@@ -0,0 +1,13 @@
+$NetBSD: patch-third__party_sqlite3_ext_moz.build,v 1.2 2025/07/15 13:58:05 ryoon Exp $
+
+--- third_party/sqlite3/ext/moz.build.orig	2025-05-20 17:57:17.576392093 +0000
++++ third_party/sqlite3/ext/moz.build
+@@ -21,7 +21,7 @@ SOURCES += [
+     "sqlite-vec/sqlite-vec.c",
+ ]
+ 
+-if CONFIG["OS_TARGET"] == "Linux" or CONFIG["OS_TARGET"] == "Android":
++if CONFIG["OS_TARGET"] == "Linux" or CONFIG["OS_TARGET"] == "Android" or CONFIG["OS_TARGET"] == "FreeBSD" or CONFIG["OS_TARGET"] == "NetBSD" or CONFIG["OS_TARGET"] == "OpenBSD":
+     OS_LIBS += [
+         "m",
+     ]
diff --git a/firefox140/patches/patch-third__party_sqlite3_src_moz.build b/firefox140/patches/patch-third__party_sqlite3_src_moz.build
new file mode 100644
index 0000000000..695047fc60
--- /dev/null
+++ b/firefox140/patches/patch-third__party_sqlite3_src_moz.build
@@ -0,0 +1,15 @@
+$NetBSD: patch-third__party_sqlite3_src_moz.build,v 1.2 2023/07/07 13:47:10 ryoon Exp $
+
+* Fix segfault under NetBSD/i386 9 and pkgsrc/lang/gcc8-8.5.0
+  For NetBSD/i386 9, @SQLITE3OPTFLAG@ will be replaced with "'-O0',".
+
+--- third_party/sqlite3/src/moz.build.orig	2023-06-22 21:19:22.000000000 +0000
++++ third_party/sqlite3/src/moz.build
+@@ -108,6 +108,7 @@ if CONFIG['CC_TYPE'] in ('clang', 'gcc')
+     CFLAGS += [
+         '-Wno-sign-compare',
+         '-Wno-type-limits',
++        @SQLITE3OPTFLAG@
+     ]
+ 
+ # Set a default journal size limit. Note an hot journal can grow over this
diff --git a/firefox140/patches/patch-third__party_wasm2c_src_c-writer.cc b/firefox140/patches/patch-third__party_wasm2c_src_c-writer.cc
new file mode 100644
index 0000000000..55ccbf010f
--- /dev/null
+++ b/firefox140/patches/patch-third__party_wasm2c_src_c-writer.cc
@@ -0,0 +1,13 @@
+$NetBSD: patch-third__party_wasm2c_src_c-writer.cc,v 1.1 2025/07/26 14:12:54 ryoon Exp $
+
+--- third_party/wasm2c/src/c-writer.cc.orig	2025-07-26 13:24:19.226278807 +0000
++++ third_party/wasm2c/src/c-writer.cc
+@@ -1490,7 +1490,7 @@ void CWriter::WriteInitExprTerminal(cons
+ std::string CWriter::GenerateHeaderGuard() const {
+   std::string result;
+   for (char c : header_name_) {
+-    if (isalnum(c) || c == '_') {
++    if (isalnum((unsigned char)c) || c == '_') {
+       result += toupper(c);
+     } else {
+       result += '_';
diff --git a/firefox140/patches/patch-third__party_wasm2c_src_prebuilt_wasm2c__source__includes.cc b/firefox140/patches/patch-third__party_wasm2c_src_prebuilt_wasm2c__source__includes.cc
new file mode 100644
index 0000000000..bfaa06a031
--- /dev/null
+++ b/firefox140/patches/patch-third__party_wasm2c_src_prebuilt_wasm2c__source__includes.cc
@@ -0,0 +1,13 @@
+$NetBSD: patch-third__party_wasm2c_src_prebuilt_wasm2c__source__includes.cc,v 1.1 2023/06/14 16:22:18 ryoon Exp $
+
+--- third_party/wasm2c/src/prebuilt/wasm2c_source_includes.cc.orig	2023-05-25 21:19:41.000000000 +0000
++++ third_party/wasm2c/src/prebuilt/wasm2c_source_includes.cc
+@@ -20,7 +20,7 @@ R"w2c_template(#include <malloc.h>
+ )w2c_template"
+ R"w2c_template(#define alloca _alloca
+ )w2c_template"
+-R"w2c_template(#elif defined(__FreeBSD__) || defined(__OpenBSD__)
++R"w2c_template(#elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
+ )w2c_template"
+ R"w2c_template(#include <stdlib.h>
+ )w2c_template"
diff --git a/firefox140/patches/patch-toolkit_components_terminator_nsTerminator.cpp b/firefox140/patches/patch-toolkit_components_terminator_nsTerminator.cpp
new file mode 100644
index 0000000000..6eb631a296
--- /dev/null
+++ b/firefox140/patches/patch-toolkit_components_terminator_nsTerminator.cpp
@@ -0,0 +1,27 @@
+$NetBSD: patch-toolkit_components_terminator_nsTerminator.cpp,v 1.8 2023/01/07 23:36:39 ryoon Exp $
+
+* Fix segfault on exit under NetBSD
+
+--- toolkit/components/terminator/nsTerminator.cpp.orig	2022-06-16 21:35:58.000000000 +0000
++++ toolkit/components/terminator/nsTerminator.cpp
+@@ -34,7 +34,7 @@
+ #if defined(XP_WIN)
+ #  include <windows.h>
+ #else
+-#  include <unistd.h>
++#  include <time.h>
+ #endif
+ 
+ #include "mozilla/AppShutdown.h"
+@@ -184,7 +184,10 @@ void RunWatchdog(void* arg) {
+ #if defined(XP_WIN)
+     Sleep(HEARTBEAT_INTERVAL_MS /* ms */);
+ #else
+-    usleep(HEARTBEAT_INTERVAL_MS * 1000 /* usec */);
++    struct timespec tickd;
++    tickd.tv_sec = 0;
++    tickd.tv_nsec = HEARTBEAT_INTERVAL_MS * 1000 * 1000;
++    nanosleep(&tickd, NULL);
+ #endif
+ 
+     if (gHeartbeat++ < timeToLive) {
diff --git a/firefox140/patches/patch-toolkit_moz.configure b/firefox140/patches/patch-toolkit_moz.configure
new file mode 100644
index 0000000000..7bafdf5614
--- /dev/null
+++ b/firefox140/patches/patch-toolkit_moz.configure
@@ -0,0 +1,31 @@
+$NetBSD: patch-toolkit_moz.configure,v 1.17 2023/08/22 13:48:17 tnn Exp $
+
+* Enable ALSA for NetBSD too.
+* Support --enable-forkserver on NetBSD.
+
+--- toolkit/moz.configure.orig	2023-08-15 21:10:03.000000000 +0000
++++ toolkit/moz.configure
+@@ -242,6 +242,7 @@ def imply_alsa(values, target):
+         any("alsa" in value for value in values)
+         and target.kernel != "Linux"
+         and target.os != "FreeBSD"
++        and target.os != "NetBSD"
+     ):
+         die("Cannot enable ALSA on %s", target.os)
+     return any("alsa" in value for value in values) or None
+@@ -2816,6 +2817,7 @@ def forkserver_default(target, build_pro
+         (target.os == "GNU" and target.kernel == "Linux")
+         or target.os == "FreeBSD"
+         or target.os == "OpenBSD"
++        or target.os == "NetBSD"
+     )
+ 
+ 
+@@ -2834,6 +2836,7 @@ def forkserver_flag(value, target):
+         or (target.os == "GNU" and target.kernel == "Linux")
+         or target.os == "FreeBSD"
+         or target.os == "OpenBSD"
++        or target.os == "NetBSD"
+     ):
+         return bool(value)
+     pass
diff --git a/firefox140/patches/patch-toolkit_mozapps_installer_packager.mk b/firefox140/patches/patch-toolkit_mozapps_installer_packager.mk
new file mode 100644
index 0000000000..06a25f04c8
--- /dev/null
+++ b/firefox140/patches/patch-toolkit_mozapps_installer_packager.mk
@@ -0,0 +1,15 @@
+$NetBSD: patch-toolkit_mozapps_installer_packager.mk,v 1.3 2020/02/12 16:36:50 ryoon Exp $
+
+* Symbolic link to lib/firefox/firefox causes 'Couldn't load XPCOM.' error.
+
+--- toolkit/mozapps/installer/packager.mk.orig	2020-01-29 07:05:13.000000000 +0000
++++ toolkit/mozapps/installer/packager.mk
+@@ -145,7 +145,7 @@ endif
+ 	  (cd $(DESTDIR)$(installdir) && tar -xf -)
+ 	$(NSINSTALL) -D $(DESTDIR)$(bindir)
+ 	$(RM) -f $(DESTDIR)$(bindir)/$(MOZ_APP_NAME)
+-	ln -s $(installdir)/$(MOZ_APP_NAME) $(DESTDIR)$(bindir)
++	#ln -s $(installdir)/$(MOZ_APP_NAME) $(DESTDIR)$(bindir)
+ 
+ upload:
+ 	$(PYTHON3) -u $(MOZILLA_DIR)/build/upload.py --base-path $(DIST) $(UPLOAD_FILES)
diff --git a/firefox140/patches/patch-xpcom_base_nscore.h b/firefox140/patches/patch-xpcom_base_nscore.h
new file mode 100644
index 0000000000..da83809add
--- /dev/null
+++ b/firefox140/patches/patch-xpcom_base_nscore.h
@@ -0,0 +1,15 @@
+$NetBSD: patch-xpcom_base_nscore.h,v 1.5 2019/03/19 16:11:28 ryoon Exp $
+
+* Support llvm/clang
+
+--- xpcom/base/nscore.h.orig	2019-03-07 16:53:44.000000000 +0000
++++ xpcom/base/nscore.h
+@@ -76,7 +76,7 @@
+  *           NS_HIDDEN_(int) NS_FASTCALL func2(char *foo);
+  */
+ 
+-#if defined(__i386__) && defined(__GNUC__)
++#if defined(__i386__) && defined(__GNUC__) && !(defined(__clang__) && __clang_major__ == 3 && __clang_minor__ == 4 && __clang_patchlevel__ == 0)
+ #  define NS_FASTCALL __attribute__((regparm(3), stdcall))
+ #  define NS_CONSTRUCTOR_FASTCALL __attribute__((regparm(3), stdcall))
+ #elif defined(XP_WIN) && !defined(_WIN64)
diff --git a/firefox140/patches/patch-xpcom_reflect_xptcall_md_unix_moz.build b/firefox140/patches/patch-xpcom_reflect_xptcall_md_unix_moz.build
new file mode 100644
index 0000000000..c90a2d181f
--- /dev/null
+++ b/firefox140/patches/patch-xpcom_reflect_xptcall_md_unix_moz.build
@@ -0,0 +1,17 @@
+$NetBSD: patch-xpcom_reflect_xptcall_md_unix_moz.build,v 1.15 2024/01/31 15:54:52 ryoon Exp $
+
+Make NetBSD/sparc64 use the same xptcall bindings as all other sparc64 ports
+
+https://bugzilla.mozilla.org/show_bug.cgi?id=1505360
+
+--- xpcom/reflect/xptcall/md/unix/moz.build.orig	2024-01-12 13:20:20.000000000 +0000
++++ xpcom/reflect/xptcall/md/unix/moz.build
+@@ -221,7 +221,7 @@ if CONFIG["OS_ARCH"] == "OpenBSD" and CO
+     ]
+ 
+ if (
+-    CONFIG["OS_ARCH"] in ("OpenBSD", "FreeBSD", "Linux", "SunOS")
++    CONFIG["OS_ARCH"] in ("OpenBSD", "FreeBSD", "Linux", "SunOS", "NetBSD")
+     and CONFIG["TARGET_CPU"] == "sparc64"
+ ):
+     SOURCES += [


Home | Main Index | Thread Index | Old Index