1PORTNAME=     firefox
2DISTVERSION=  146.0.1
3PORTREVISION=	1
4PORTEPOCH=    2
5CATEGORIES=   www wayland
6MASTER_SITES= MOZILLA/${PORTNAME}/releases/${DISTVERSION}${DISTVERSIONSUFFIX}/source \
7              MOZILLA/${PORTNAME}/candidates/${DISTVERSION}${DISTVERSIONSUFFIX}-candidates/build1/source
8DISTFILES=    ${DISTNAME}.source${EXTRACT_SUFX}
9
10MAINTAINER=	ports@MidnightBSD.org
11COMMENT=	Web browser based on the browser portion of Mozilla
12WWW=		https://www.mozilla.com/firefox
13
14LICENSE=	MPL20 gpl2
15LICENSE_COMB=	dual
16
17BUILD_DEPENDS=	nspr>=4.32:devel/nspr \
18		nss>=3.108:security/nss \
19		libevent>=2.1.8:devel/libevent \
20		harfbuzz>=10.1.0:print/harfbuzz \
21		graphite2>=1.3.14:graphics/graphite2 \
22		png>=1.6.45:graphics/png \
23		dav1d>=1.0.0:multimedia/dav1d \
24		libvpx>=1.15.0:multimedia/libvpx \
25		${PYTHON_PKGNAMEPREFIX}sqlite3>0:databases/py-sqlite3@${PY_FLAVOR} \
26		v4l_compat>0:multimedia/v4l_compat \
27		autoconf2.13:devel/autoconf2.13 \
28		nasm:devel/nasm \
29		yasm:devel/yasm \
30		zip:archivers/zip \
31		clang19:devel/llvm19 \
32		cargo:lang/rust \
33		cbindgen:devel/rust-cbindgen
34
35LIB_DEPENDS+=   libvpx.so:multimedia/libvpx \
36                libevent.so:devel/libevent \
37                libstartup-notification-1.so:x11/startup-notification \
38                libnspr4.so:devel/nspr \
39                libnss3.so:security/nss \
40                libicui18n.so:devel/icu \
41                libharfbuzz.so:print/harfbuzz \
42                libgraphite2.so.3:graphics/graphite2 \
43                libpng16.so:graphics/png \
44                libavcodec.so:multimedia/ffmpeg \
45                libffi.so:devel/libffi \
46                libpixman-1.so:x11/pixman \
47                libwebp.so:graphics/webp \
48                libfontconfig.so:x11-fonts/fontconfig \
49                libfreetype.so:print/freetype2 \
50                libpci.so:devel/libpci \
51                libdbus-1.so:devel/dbus \
52                libdbus-glib-1.so:devel/dbus-glib \
53                libatk-1.0.so:accessibility/at-spi2-core \
54                libaom.so:multimedia/aom \
55                libdav1d.so:multimedia/dav1d \
56		libproxy.so:net/libproxy
57
58USES=           compiler:c++17-lang cpe gl gettext gmake gnome iconv jpeg localbase nodejs:24,build,env \
59		perl5 pkgconfig python desktop-file-utils tar:xz
60CPE_VENDOR=     mozilla
61USE_GL=         gl
62USE_GNOME=      cairo gdkpixbuf gtk30
63USE_XORG=       x11 xcb xcomposite xdamage xext xfixes xrandr xrender xt ice sm
64
65QMAKE_ARGS=		--enable-application=browser \
66			--enable-chrome-format=omni \
67			--enable-default-toolkit=cairo-gtk3 \
68			--enable-install-strip \
69			--enable-official-branding \
70			--enable-optimize \
71			--enable-release \
72			--enable-strip \
73			--enable-libproxy \
74			--enable-system-ffi \
75			--enable-system-pixman \
76			--disable-alsa \
77			--disable-debug \
78			--disable-debug-symbols \
79			--disable-jack \
80			--disable-profiling \
81			--disable-pulseaudio \
82			--disable-tests \
83			--disable-necko-wifi \
84			--disable-updater \
85			--disable-webrtc \
86			--disable-hardening \
87			--prefix=${PREFIX} \
88			--with-intl-api \
89			--with-system-icu \
90			--with-system-libevent \
91			--with-system-nspr \
92			--with-system-nss \
93			--with-system-png \
94			--with-system-zlib \
95			--without-wasm-sandboxed-libraries
96
97# --with-system-jpeg
98
99LLVM_VERSION=	19
100MBSD64_TARGET=	x86_64-mports-freebsd13.4
101CONFIGURE_TARGET=	${MBSD64_TARGET}
102HAS_CONFIGURE=	yes
103CONFIGURE_ENV+= BINDGEN_CFLAGS="-I${LOCALBASE}/include" CBINDGEN=${LOCALBASE}/bin/cbindgen
104CONFIGURE_OUTSOURCE=    yes
105MAKE_ENV+=		__FreeBSD__=13 __FreeBSD__version=1303501
106LDFLAGS+=               -Wl,--as-needed -Wl,--undefined-version -L/usr/local/lib
107BINARY_ALIAS+=  python3=${PYTHON_CMD}
108
109MOZ_OPTIONS+=   --with-libclang-path="${LLVM_PREFIX:S/${PREFIX}/${LOCALBASE}/}/lib"
110.    if !exists(/usr/bin/llvm-objdump)
111MOZ_EXPORT+=    LLVM_OBJDUMP="${LOCALBASE}/bin/llvm-objdump${LLVM_VERSION}"
112.    endif
113# Require newer Clang than what's in base system unless user opted out
114.    if ${CC} == cc && ${CXX} == c++ && exists(/usr/lib/libc++.so)
115CPP=                    ${LOCALBASE}/bin/clang-cpp${LLVM_VERSION}
116CC=                             ${LOCALBASE}/bin/clang${LLVM_VERSION}
117CXX=                    ${LOCALBASE}/bin/clang++${LLVM_VERSION}
118USES:=                  ${USES:Ncompiler\:*} # XXX avoid warnings
119.    endif
120
121
122post-extract:
123	${SED} -e 's|@FIREFOX_ICON@|firefox|;s|@MOZILLA@|firefox|' \
124		< ${FILESDIR}/firefox.desktop.in \
125		> ${WRKDIR}/firefox.desktop
126
127post-patch:
128	${REINPLACE_CMD} -e 's|%%LOCALBASE%%|${LOCALBASE}|g' \
129		${WRKSRC}/browser/app/nsBrowserApp.cpp
130	(cd ${WRKSRC}/gfx/angle/checkout/src/compiler/translator && \
131		${REINPLACE_CMD} -e 's|<math.h>|<cmath>|' \
132		InfoSink.h IntermNode.cpp)
133	# disable SCTP
134	${REINPLACE_CMD} -e 's|MOZ_SCTP|MOZ_DISABLE_SCTP|' \
135		${WRKSRC}/netwerk/moz.build
136	# disable rust checksums
137	${REINPLACE_CMD} -e 's/"files":{[^}]*}/"files":{}/' \
138		${WRKSRC}/third_party/rust/libc/.cargo-checksum.json \
139		${WRKSRC}/third_party/rust/quinn-udp/.cargo-checksum.json
140	# Fix midnight
141	${REINPLACE_CMD} -e "s|%%MBSD64_TGT%%|${MBSD64_TARGET}|" \
142		${WRKSRC}/build/autoconf/config.guess
143	# Set mozilla options
144	@${ECHO_CMD} "--=> Setting configuration <=--"
145	@for arg in ${QMAKE_ARGS}; do \
146		${ECHO_CMD} ".mozconfig <<  $$arg" ;\
147		${ECHO_CMD} ac_add_options $$arg >> ${WRKSRC}/.mozconfig ;\
148	done
149	@${ECHO_CMD} LDFLAGS=\"-lm ${MOZLDFLAGS} -Wl,-rpath,${PREFIX}/lib/firefox\" \
150		>> ${WRKSRC}/.mozconfig
151
152post-install:
153	${MKDIR} ${PREFIX}/share/pixmaps \
154		${PREFIX}/share/applications
155	${INSTALL_DATA} ${WRKDIR}/firefox.desktop \
156		${PREFIX}/share/applications/
157	(cd ${PREFIX}/share/pixmaps &&\
158	${LN} -sf ../../lib/firefox/browser/chrome/icons/default/default48.png firefox.png)
159	# Rewrite symlink to make it relative instead of absolute
160	(cd ${PREFIX}/bin &&\
161	${LN} -sf ../lib/firefox/firefox firefox)
162
163.include <bsd.port.mk>
164