icecat-115.18.0-r2.ebuild 57 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053
  1. # Copyright 1999-2024 Gentoo Authors
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=8
  4. # Using Gentoos firefox patches as system libraries and lto are quite nice
  5. FIREFOX_PATCHSET="firefox-${PV%%.*}esr-patches-13.tar.xz"
  6. LLVM_COMPAT=( 18 )
  7. PP="1"
  8. GV="2"
  9. PYTHON_COMPAT=( python3_{10..13} )
  10. PYTHON_REQ_USE="ncurses,sqlite,ssl"
  11. RUST_NEEDS_LLVM=1
  12. WANT_AUTOCONF="2.1"
  13. VIRTUALX_REQUIRED="manual"
  14. MOZ_ESR=yes
  15. inherit autotools check-reqs desktop flag-o-matic gnome2-utils linux-info llvm-r1 multiprocessing \
  16. multilib-minimal optfeature pax-utils python-any-r1 rust toolchain-funcs virtualx xdg
  17. PATCH_URIS=(
  18. https://dev.gentoo.org/~juippis/mozilla/patchsets/${FIREFOX_PATCHSET}
  19. )
  20. SRC_URI="
  21. !buildtarball? (
  22. icecat-${PV}-${PP}gnu${GV}.tar.bz2
  23. https://gitlab.com/api/v4/projects/37881342/packages/generic/${PN}/${PV}/${P}-${PP}gnu${GV}.tar.bz2
  24. )
  25. ${PATCH_URIS[@]}
  26. "
  27. DESCRIPTION="GNU IceCat Web Browser"
  28. HOMEPAGE="https://www.gnu.org/software/gnuzilla/"
  29. LICENSE="MPL-2.0 GPL-2 LGPL-2.1"
  30. SLOT="0"
  31. KEYWORDS="~amd64 ~arm64 ~ppc64 ~riscv ~x86"
  32. CODEC_IUSE="
  33. -aac
  34. +dav1d
  35. -h264
  36. +opus
  37. +vpx
  38. "
  39. IUSE+="
  40. ${CODEC_IUSE}
  41. alsa atk buildtarball clang cpu_flags_arm_neon cups +dbus debug ffvpx hardened hwaccel
  42. jack -jemalloc libcanberra libnotify libproxy libsecret lld lto mold +openh264 pgo
  43. pulseaudio sndio selinux speech +system-av1 +system-ffmpeg +system-harfbuzz
  44. +system-icu +system-jpeg +system-libevent +system-libvpx +system-png
  45. +system-python-libs +system-webp vaapi wayland +webrtc wifi webspeech X
  46. "
  47. # Firefox-only IUSE
  48. IUSE+=" geckodriver screencast"
  49. REQUIRED_USE="
  50. aac? (
  51. system-ffmpeg
  52. )
  53. dav1d? (
  54. || (
  55. ffvpx
  56. system-ffmpeg
  57. )
  58. )
  59. h264? (
  60. system-ffmpeg
  61. )
  62. libcanberra? (
  63. || (
  64. alsa
  65. pulseaudio
  66. )
  67. )
  68. opus? (
  69. || (
  70. ffvpx
  71. system-ffmpeg
  72. )
  73. )
  74. vpx? (
  75. || (
  76. ffvpx
  77. system-ffmpeg
  78. )
  79. )
  80. wifi? (
  81. dbus
  82. )
  83. || (
  84. alsa
  85. pulseaudio
  86. )
  87. || (
  88. lld
  89. mold
  90. )
  91. || (
  92. wayland
  93. X
  94. )
  95. debug? (
  96. !system-av1
  97. )
  98. wayland? (
  99. dbus
  100. )
  101. "
  102. # Firefox-only REQUIRED_USE flags
  103. REQUIRED_USE+=" screencast? ( wayland )"
  104. DBUS_PV="0.60"
  105. DBUS_GLIB_PV="0.60"
  106. FFMPEG_PV="4.4.1" # This corresponds to y in x.y.z from the subslot.
  107. GTK3_PV="3.14.5"
  108. NASM_PV="2.14.02"
  109. SPEECH_DISPATCHER_PV="0.11.4-r1"
  110. XKBCOMMON_PV="0.4.1"
  111. FF_ONLY_DEPEND="
  112. screencast? (
  113. >=media-video/pipewire-0.3.52:=[${MULTILIB_USEDEP}]
  114. )
  115. selinux? (
  116. sec-policy/selinux-mozilla
  117. )
  118. "
  119. GAMEPAD_BDEPEND="
  120. kernel_linux? (
  121. sys-kernel/linux-headers
  122. )
  123. "
  124. # Same as virtual/udev-217-r5 but with multilib changes.
  125. # Required for gamepad, or WebAuthn roaming authenticators (e.g. USB security key)
  126. UDEV_RDEPEND="
  127. kernel_linux? (
  128. || (
  129. >=sys-apps/systemd-217[${MULTILIB_USEDEP}]
  130. >=sys-fs/eudev-2.1.1[${MULTILIB_USEDEP}]
  131. sys-apps/systemd-utils[${MULTILIB_USEDEP},udev]
  132. sys-fs/udev[${MULTILIB_USEDEP}]
  133. )
  134. )
  135. "
  136. SYSTEM_PYTHON_LIBS="
  137. system-python-libs? (
  138. ${PYTHON_DEPS}
  139. $(python_gen_any_dep '
  140. dev-python/zstandard[${PYTHON_USEDEP}]
  141. dev-python/aiohttp[${PYTHON_USEDEP}]
  142. dev-python/appdirs[${PYTHON_USEDEP}]
  143. dev-python/attrs[${PYTHON_USEDEP}]
  144. dev-python/cbor2[${PYTHON_USEDEP}]
  145. dev-python/certifi[${PYTHON_USEDEP}]
  146. dev-python/chardet[${PYTHON_USEDEP}]
  147. dev-python/click[${PYTHON_USEDEP}]
  148. dev-python/colorama[${PYTHON_USEDEP}]
  149. dev-python/cookies[${PYTHON_USEDEP}]
  150. dev-python/diskcache[${PYTHON_USEDEP}]
  151. dev-python/distro[${PYTHON_USEDEP}]
  152. dev-python/ecdsa[${PYTHON_USEDEP}]
  153. dev-python/idna[${PYTHON_USEDEP}]
  154. dev-python/importlib-metadata[${PYTHON_USEDEP}]
  155. dev-python/iso8601[${PYTHON_USEDEP}]
  156. dev-python/jinja2[${PYTHON_USEDEP}]
  157. dev-python/jsmin[${PYTHON_USEDEP}]
  158. dev-python/jsonschema[${PYTHON_USEDEP}]
  159. dev-python/packaging[${PYTHON_USEDEP}]
  160. dev-python/pathspec[${PYTHON_USEDEP}]
  161. dev-python/pip[${PYTHON_USEDEP}]
  162. dev-python/ply[${PYTHON_USEDEP}]
  163. dev-python/pyasn1[${PYTHON_USEDEP}]
  164. dev-python/pylru[${PYTHON_USEDEP}]
  165. dev-python/pyparsing[${PYTHON_USEDEP}]
  166. dev-python/requests[${PYTHON_USEDEP}]
  167. dev-python/responses[${PYTHON_USEDEP}]
  168. dev-python/rsa[${PYTHON_USEDEP}]
  169. dev-python/setuptools[${PYTHON_USEDEP}]
  170. dev-python/six[${PYTHON_USEDEP}]
  171. dev-python/tomli[${PYTHON_USEDEP}]
  172. dev-python/tqdm[${PYTHON_USEDEP}]
  173. dev-python/typing-extensions[${PYTHON_USEDEP}]
  174. dev-python/urllib3[${PYTHON_USEDEP}]
  175. dev-python/voluptuous[${PYTHON_USEDEP}]
  176. dev-python/wcwidth[${PYTHON_USEDEP}]
  177. dev-python/wheel[${PYTHON_USEDEP}]
  178. dev-python/yarl[${PYTHON_USEDEP}]
  179. dev-python/zipp[${PYTHON_USEDEP}]
  180. ')
  181. )
  182. "
  183. CDEPEND="
  184. ${FF_ONLY_DEPEND}
  185. ${SYSTEM_PYTHON_LIBS}
  186. >=app-accessibility/at-spi2-core-2.46.0:2[${MULTILIB_USEDEP}]
  187. >=dev-libs/glib-2.42:2[${MULTILIB_USEDEP}]
  188. >=dev-libs/nss-3.90.0[${MULTILIB_USEDEP}]
  189. >=dev-libs/nspr-4.35[${MULTILIB_USEDEP}]
  190. >=media-libs/fontconfig-2.7.0[${MULTILIB_USEDEP}]
  191. >=media-libs/freetype-2.13.0[${MULTILIB_USEDEP}]
  192. >=sys-libs/zlib-1.2.13[${MULTILIB_USEDEP}]
  193. >=x11-libs/pango-1.22.0[${MULTILIB_USEDEP}]
  194. >=x11-libs/pixman-0.36.0[${MULTILIB_USEDEP}]
  195. dev-libs/expat[${MULTILIB_USEDEP}]
  196. dev-libs/libffi:=[${MULTILIB_USEDEP}]
  197. media-libs/alsa-lib[${MULTILIB_USEDEP}]
  198. virtual/freedesktop-icon-theme
  199. x11-libs/cairo
  200. x11-libs/gdk-pixbuf[${MULTILIB_USEDEP}]
  201. dbus? (
  202. >=dev-libs/dbus-glib-${DBUS_GLIB_PV}[${MULTILIB_USEDEP}]
  203. >=sys-apps/dbus-${DBUS_PV}[${MULTILIB_USEDEP}]
  204. )
  205. jack? (
  206. virtual/jack[${MULTILIB_USEDEP}]
  207. )
  208. libproxy? (
  209. net-libs/libproxy[${MULTILIB_USEDEP}]
  210. )
  211. pulseaudio? (
  212. || (
  213. media-libs/libpulse[${MULTILIB_USEDEP}]
  214. >=media-sound/apulse-0.1.12-r4[${MULTILIB_USEDEP},sdk]
  215. )
  216. )
  217. screencast? (
  218. media-video/pipewire:=
  219. )
  220. selinux? (
  221. sec-policy/selinux-mozilla
  222. )
  223. sndio? (
  224. >=media-sound/sndio-1.8.0-r1[${MULTILIB_USEDEP}]
  225. )
  226. system-av1? (
  227. >=media-libs/dav1d-1.1.0:=[${MULTILIB_USEDEP},8bit]
  228. >=media-libs/libaom-1.0.0:=[${MULTILIB_USEDEP}]
  229. )
  230. system-harfbuzz? (
  231. >=media-gfx/graphite2-1.3.14[${MULTILIB_USEDEP}]
  232. >=media-libs/harfbuzz-7.3.0:0=[${MULTILIB_USEDEP}]
  233. )
  234. system-icu? (
  235. >=dev-libs/icu-73.1:=[${MULTILIB_USEDEP}]
  236. )
  237. system-jpeg? (
  238. >=media-libs/libjpeg-turbo-2.1.5.1[${MULTILIB_USEDEP}]
  239. )
  240. system-ffmpeg? (
  241. >=media-video/ffmpeg-${FFMPEG_PV}[${MULTILIB_USEDEP},dav1d?,openh264?,opus?,vaapi?,vpx?]
  242. )
  243. system-libevent? (
  244. >=dev-libs/libevent-2.1.12:=[${MULTILIB_USEDEP},threads(+)]
  245. )
  246. system-libvpx? (
  247. >=media-libs/libvpx-1.13.0:=[${MULTILIB_USEDEP},postproc]
  248. )
  249. system-png? (
  250. >=media-libs/libpng-1.6.39:=[${MULTILIB_USEDEP},apng]
  251. )
  252. system-webp? (
  253. >=media-libs/libwebp-1.3.0:=[${MULTILIB_USEDEP}]
  254. )
  255. wayland? (
  256. >=media-libs/libepoxy-1.5.10-r1
  257. >=x11-libs/gtk+-${GTK3_PV}:3[${MULTILIB_USEDEP},wayland]
  258. >=x11-libs/libxkbcommon-${XKBCOMMON_PV}[${MULTILIB_USEDEP},wayland]
  259. )
  260. wifi? (
  261. kernel_linux? (
  262. >=dev-libs/dbus-glib-${DBUS_GLIB_PV}[${MULTILIB_USEDEP}]
  263. >=net-misc/networkmanager-0.7[${MULTILIB_USEDEP}]
  264. >=sys-apps/dbus-${DBUS_PV}[${MULTILIB_USEDEP}]
  265. )
  266. )
  267. X? (
  268. >=x11-libs/gtk+-${GTK3_PV}:3[${MULTILIB_USEDEP},X]
  269. >=x11-libs/libxkbcommon-${XKBCOMMON_PV}[${MULTILIB_USEDEP},X]
  270. >=x11-libs/libXrandr-1.4.0[${MULTILIB_USEDEP}]
  271. >=x11-libs/libXtst-1.2.3[${MULTILIB_USEDEP}]
  272. virtual/opengl[${MULTILIB_USEDEP}]
  273. x11-libs/cairo[${MULTILIB_USEDEP},X]
  274. x11-libs/libX11[${MULTILIB_USEDEP}]
  275. x11-libs/libXcomposite[${MULTILIB_USEDEP}]
  276. x11-libs/libXdamage[${MULTILIB_USEDEP}]
  277. x11-libs/libXext[${MULTILIB_USEDEP}]
  278. x11-libs/libXfixes[${MULTILIB_USEDEP}]
  279. x11-libs/libxcb:=[${MULTILIB_USEDEP}]
  280. )
  281. "
  282. # See also PR_LoadLibrary
  283. # speech-dispatcher-0.11.3 is bugged.
  284. RDEPEND+="
  285. ${CDEPEND}
  286. ${UDEV_RDEPEND}
  287. cups? (
  288. net-print/cups[${MULTILIB_USEDEP}]
  289. )
  290. jack? (
  291. virtual/jack[${MULTILIB_USEDEP}]
  292. )
  293. libcanberra? (
  294. !pulseaudio? (
  295. alsa? (
  296. media-libs/libcanberra[${MULTILIB_USEDEP},alsa]
  297. )
  298. )
  299. pulseaudio? (
  300. media-libs/libcanberra[${MULTILIB_USEDEP},pulseaudio]
  301. )
  302. )
  303. libnotify? (
  304. x11-libs/libnotify
  305. )
  306. libsecret? (
  307. app-crypt/libsecret[${MULTILIB_USEDEP}]
  308. )
  309. openh264? (
  310. media-libs/openh264:*[${MULTILIB_USEDEP},plugin]
  311. )
  312. pulseaudio? (
  313. || (
  314. media-sound/pulseaudio[${MULTILIB_USEDEP}]
  315. >=media-sound/apulse-0.1.12-r4[${MULTILIB_USEDEP}]
  316. )
  317. )
  318. speech? (
  319. !pulseaudio? (
  320. alsa? (
  321. || (
  322. >=app-accessibility/speech-dispatcher-${SPEECH_DISPATCHER_PV}[alsa,espeak]
  323. >=app-accessibility/speech-dispatcher-${SPEECH_DISPATCHER_PV}[alsa,espeak]
  324. >=app-accessibility/speech-dispatcher-${SPEECH_DISPATCHER_PV}[alsa,flite]
  325. )
  326. )
  327. )
  328. pulseaudio? (
  329. || (
  330. >=app-accessibility/speech-dispatcher-${SPEECH_DISPATCHER_PV}[espeak,pulseaudio]
  331. >=app-accessibility/speech-dispatcher-${SPEECH_DISPATCHER_PV}[espeak,pulseaudio]
  332. >=app-accessibility/speech-dispatcher-${SPEECH_DISPATCHER_PV}[flite,pulseaudio]
  333. )
  334. )
  335. )
  336. vaapi? (
  337. media-libs/libva[${MULTILIB_USEDEP},drm(+),X?,wayland?]
  338. )
  339. "
  340. DEPEND+="
  341. ${CDEPEND}
  342. pulseaudio? (
  343. || (
  344. >=media-sound/apulse-0.1.12-r4[${MULTILIB_USEDEP},sdk]
  345. media-sound/pulseaudio[${MULTILIB_USEDEP}]
  346. )
  347. )
  348. X? (
  349. x11-base/xorg-proto
  350. x11-libs/libICE[${MULTILIB_USEDEP}]
  351. x11-libs/libSM[${MULTILIB_USEDEP}]
  352. )
  353. "
  354. BDEPEND+="
  355. ${PYTHON_DEPS}
  356. ${GAMEPAD_BDEPEND}
  357. >=dev-lang/perl-5.006
  358. >=dev-util/cbindgen-0.24.3
  359. >=dev-util/pkgconf-1.8.0[${MULTILIB_USEDEP},pkg-config(+)]
  360. >=net-libs/nodejs-21
  361. || (
  362. >=dev-lang/rust-1.83.0[${MULTILIB_USEDEP}]
  363. >=dev-lang/rust-bin-1.83.0[${MULTILIB_USEDEP}]
  364. )
  365. app-alternatives/awk
  366. app-arch/unzip
  367. app-arch/zip
  368. buildtarball? (
  369. ~www-client/makeicecat-"${PV}"[buildtarball]
  370. )
  371. mold? (
  372. sys-devel/mold
  373. )
  374. lld? (
  375. llvm-core/lld
  376. )
  377. amd64? ( >=dev-lang/nasm-${NASM_PV} )
  378. x86? ( >=dev-lang/nasm-${NASM_PV} )
  379. pgo? (
  380. X? (
  381. sys-devel/gettext
  382. x11-base/xorg-server[xvfb]
  383. x11-apps/xhost
  384. )
  385. wayland? (
  386. || (
  387. gui-wm/tinywl
  388. <gui-libs/wlroots-0.17.3[tinywl(-)]
  389. )
  390. x11-misc/xkeyboard-config
  391. )
  392. )
  393. x86? (
  394. >=dev-lang/nasm-${NASM_PV}
  395. )
  396. "
  397. RESTRICT="mirror"
  398. S="${WORKDIR}/${PN}-${PV%_*}"
  399. llvm_check_deps() {
  400. if ! has_version -b "llvm-core/clang:${LLVM_SLOT}" ; then
  401. einfo "llvm-core/clang:${LLVM_SLOT} is missing! Cannot use LLVM slot ${LLVM_SLOT} ..." >&2
  402. return 1
  403. fi
  404. if use clang && ! use mold ; then
  405. if ! has_version -b "llvm-core/lld:${LLVM_SLOT}" ; then
  406. einfo "llvm-core/lld:${LLVM_SLOT} is missing! Cannot use LLVM slot ${LLVM_SLOT} ..." >&2
  407. return 1
  408. fi
  409. if ! has_version -b "dev-lang/rust:0/llvm-${LLVM_SLOT}" && ! has_version -b "dev-lang/rust-bin:0/llvm-${LLVM_SLOT}"; then
  410. einfo "dev-lang/rust:0/llvm-${LLVM_SLOT} is missing! Cannot use LLVM slot ${LLVM_SLOT} ..." >&2
  411. return 1
  412. fi
  413. if use pgo ; then
  414. if ! has_version -b "=llvm-runtimes/compiler-rt-sanitizers-${LLVM_SLOT}*[profile]" ; then
  415. einfo "=llvm-runtimes/compiler-rt-sanitizers-${LLVM_SLOT}*[profile] is missing!"
  416. einfo "Cannot use LLVM slot ${LLVM_SLOT} ..." >&2
  417. return 1
  418. fi
  419. fi
  420. fi
  421. einfo "Using LLVM slot ${LLVM_SLOT} to build" >&2
  422. }
  423. MOZ_LANGS=(
  424. af ar ast be bg br ca cak cs cy da de dsb
  425. el en-CA en-GB en-US es-AR es-ES et eu
  426. fi fr fy-NL ga-IE gd gl he hr hsb hu
  427. id is it ja ka kab kk ko lt lv ms nb-NO nl nn-NO
  428. pa-IN pl pt-BR pt-PT rm ro ru
  429. sk sl sq sr sv-SE th tr uk uz vi zh-CN zh-TW
  430. )
  431. # Firefox-only LANGS
  432. MOZ_LANGS+=( ach )
  433. MOZ_LANGS+=( an )
  434. MOZ_LANGS+=( az )
  435. MOZ_LANGS+=( bn )
  436. MOZ_LANGS+=( bs )
  437. MOZ_LANGS+=( ca-valencia )
  438. MOZ_LANGS+=( eo )
  439. MOZ_LANGS+=( es-CL )
  440. MOZ_LANGS+=( es-MX )
  441. MOZ_LANGS+=( fa )
  442. MOZ_LANGS+=( ff )
  443. MOZ_LANGS+=( fur )
  444. MOZ_LANGS+=( gn )
  445. MOZ_LANGS+=( gu-IN )
  446. MOZ_LANGS+=( hi-IN )
  447. MOZ_LANGS+=( hy-AM )
  448. MOZ_LANGS+=( ia )
  449. MOZ_LANGS+=( km )
  450. MOZ_LANGS+=( kn )
  451. MOZ_LANGS+=( lij )
  452. MOZ_LANGS+=( mk )
  453. MOZ_LANGS+=( mr )
  454. MOZ_LANGS+=( my )
  455. MOZ_LANGS+=( ne-NP )
  456. MOZ_LANGS+=( oc )
  457. MOZ_LANGS+=( sc )
  458. MOZ_LANGS+=( sco )
  459. MOZ_LANGS+=( si )
  460. MOZ_LANGS+=( son )
  461. MOZ_LANGS+=( szl )
  462. MOZ_LANGS+=( ta )
  463. MOZ_LANGS+=( te )
  464. MOZ_LANGS+=( tl )
  465. MOZ_LANGS+=( trs )
  466. MOZ_LANGS+=( ur )
  467. MOZ_LANGS+=( xh )
  468. mozilla_set_globals() {
  469. # https://bugs.gentoo.org/587334
  470. local MOZ_TOO_REGIONALIZED_FOR_L10N=(
  471. fy-NL ga-IE gu-IN hi-IN hy-AM nb-NO ne-NP nn-NO pa-IN sv-SE
  472. )
  473. local lang xflag
  474. for lang in "${MOZ_LANGS[@]}" ; do
  475. # en and en_US are handled internally
  476. if [[ ${lang} == en ]] || [[ ${lang} == en-US ]] ; then
  477. continue
  478. fi
  479. # strip region subtag if $lang is in the list
  480. if has ${lang} "${MOZ_TOO_REGIONALIZED_FOR_L10N[@]}" ; then
  481. xflag=${lang%%-*}
  482. else
  483. xflag=${lang}
  484. fi
  485. IUSE+=" l10n_${xflag/[_@]/-}"
  486. done
  487. }
  488. mozilla_set_globals
  489. moz_clear_vendor_checksums() {
  490. debug-print-function ${FUNCNAME} "$@"
  491. if [[ ${#} -ne 1 ]] ; then
  492. die "${FUNCNAME} requires exact one argument"
  493. fi
  494. einfo "Clearing cargo checksums for ${1} ..."
  495. sed -i \
  496. -e 's/\("files":{\)[^}]*/\1/' \
  497. "${S}"/third_party/rust/${1}/.cargo-checksum.json \
  498. || die
  499. }
  500. moz_build_xpi() {
  501. debug-print-function ${FUNCNAME} "$@"
  502. local MOZ_TOO_REGIONALIZED_FOR_L10N=(
  503. fy-NL ga-IE gu-IN hi-IN hy-AM nb-NO ne-NP nn-NO pa-IN sv-SE
  504. )
  505. cd "${BUILD_DIR}"/browser/locales || die
  506. local lang xflag
  507. for lang in "${MOZ_LANGS[@]}"; do
  508. # en and en_US are handled internally
  509. if [[ ${lang} == en ]] || [[ ${lang} == en-US ]] ; then
  510. continue
  511. fi
  512. # strip region subtag if $lang is in the list
  513. if has ${lang} "${MOZ_TOO_REGIONALIZED_FOR_L10N[@]}" ; then
  514. xflag=${lang%%-*}
  515. else
  516. xflag=${lang}
  517. fi
  518. if use l10n_"${xflag}"; then
  519. emake langpack-"${lang}" LOCALE_MERGEDIR=.
  520. fi
  521. done
  522. }
  523. moz_install_xpi() {
  524. debug-print-function ${FUNCNAME} "$@"
  525. if [[ ${#} -lt 2 ]] ; then
  526. die "${FUNCNAME} requires at least two arguments"
  527. fi
  528. local DESTDIR=${1}
  529. shift
  530. insinto "${DESTDIR}"
  531. local emid xpi_file xpi_tmp_dir
  532. for xpi_file in "${@}" ; do
  533. emid=
  534. xpi_tmp_dir=$(mktemp -d --tmpdir="${T}")
  535. # Unpack XPI
  536. unzip -qq "${xpi_file}" -d "${xpi_tmp_dir}" || die
  537. # Determine extension ID
  538. if [[ -f "${xpi_tmp_dir}/install.rdf" ]] ; then
  539. emid=$(sed -n -e '/install-manifest/,$ { /em:id/!d; s/.*[\">]\([^\"<>]*\)[\"<].*/\1/; p; q }' "${xpi_tmp_dir}/install.rdf")
  540. [[ -z "${emid}" ]] && die "failed to determine extension id from install.rdf"
  541. elif [[ -f "${xpi_tmp_dir}/manifest.json" ]] ; then
  542. emid=$(sed -n -e 's/.*"id": "\([^"]*\)".*/\1/p' "${xpi_tmp_dir}/manifest.json")
  543. [[ -z "${emid}" ]] && die "failed to determine extension id from manifest.json"
  544. else
  545. die "failed to determine extension id"
  546. fi
  547. einfo "Installing ${emid}.xpi into ${ED}${DESTDIR} ..."
  548. newins "${xpi_file}" "${emid}.xpi"
  549. done
  550. }
  551. mozconfig_add_options_ac() {
  552. debug-print-function ${FUNCNAME} "$@"
  553. if [[ ${#} -lt 2 ]] ; then
  554. die "${FUNCNAME} requires at least two arguments"
  555. fi
  556. local reason=${1}
  557. shift
  558. local option
  559. for option in ${@} ; do
  560. echo "ac_add_options ${option} # ${reason}" >>${MOZCONFIG}
  561. done
  562. }
  563. mozconfig_add_options_mk() {
  564. debug-print-function ${FUNCNAME} "$@"
  565. if [[ ${#} -lt 2 ]] ; then
  566. die "${FUNCNAME} requires at least two arguments"
  567. fi
  568. local reason=${1}
  569. shift
  570. local option
  571. for option in ${@} ; do
  572. echo "mk_add_options ${option} # ${reason}" >>${MOZCONFIG}
  573. done
  574. }
  575. mozconfig_use_enable() {
  576. debug-print-function ${FUNCNAME} "$@"
  577. if [[ ${#} -lt 1 ]] ; then
  578. die "${FUNCNAME} requires at least one arguments"
  579. fi
  580. local flag=$(use_enable "${@}")
  581. mozconfig_add_options_ac "$(use ${1} && echo +${1} || echo -${1})" "${flag}"
  582. }
  583. mozconfig_use_with() {
  584. debug-print-function ${FUNCNAME} "$@"
  585. if [[ ${#} -lt 1 ]] ; then
  586. die "${FUNCNAME} requires at least one arguments"
  587. fi
  588. local flag=$(use_with "${@}")
  589. mozconfig_add_options_ac "$(use ${1} && echo +${1} || echo -${1})" "${flag}"
  590. }
  591. virtwl() {
  592. debug-print-function ${FUNCNAME} "$@"
  593. [[ $# -lt 1 ]] && die "${FUNCNAME} needs at least one argument"
  594. [[ -n $XDG_RUNTIME_DIR ]] || die "${FUNCNAME} needs XDG_RUNTIME_DIR to be set; try xdg_environment_reset"
  595. tinywl -h >/dev/null || die 'tinywl -h failed'
  596. local VIRTWL VIRTWL_PID
  597. coproc VIRTWL { WLR_BACKENDS=headless exec tinywl -s 'echo $WAYLAND_DISPLAY; read _; kill $PPID'; }
  598. local -x WAYLAND_DISPLAY
  599. read WAYLAND_DISPLAY <&${VIRTWL[0]}
  600. debug-print "${FUNCNAME}: $@"
  601. "$@"
  602. local r=$?
  603. [[ -n $VIRTWL_PID ]] || die "tinywl exited unexpectedly"
  604. exec {VIRTWL[0]}<&- {VIRTWL[1]}>&-
  605. return $r
  606. }
  607. pkg_pretend() {
  608. if [[ ${MERGE_TYPE} != binary ]] ; then
  609. if use pgo ; then
  610. if ! has usersandbox $FEATURES ; then
  611. die "You must enable usersandbox as X server can not run as root!"
  612. fi
  613. fi
  614. # Ensure we have enough disk space to compile
  615. if use pgo || use lto || use debug ; then
  616. CHECKREQS_DISK_BUILD="13500M"
  617. else
  618. CHECKREQS_DISK_BUILD="6600M"
  619. fi
  620. check-reqs_pkg_pretend
  621. fi
  622. }
  623. pkg_setup() {
  624. if [[ ${MERGE_TYPE} != binary ]] ; then
  625. if use pgo ; then
  626. if ! has userpriv ${FEATURES} ; then
  627. eerror "Building ${PN} with USE=pgo and FEATURES=-userpriv is not supported!"
  628. fi
  629. fi
  630. # Ensure we have enough disk space to compile
  631. if use pgo || use lto || use debug ; then
  632. CHECKREQS_DISK_BUILD="13500M"
  633. else
  634. CHECKREQS_DISK_BUILD="6400M"
  635. fi
  636. check-reqs_pkg_setup
  637. llvm-r1_pkg_setup
  638. rust_pkg_setup
  639. if use clang && use lto && use lld ; then
  640. local version_lld=$(ld.lld --version 2>/dev/null | awk '{ print $2 }')
  641. [[ -n ${version_lld} ]] && version_lld=$(ver_cut 1 "${version_lld}")
  642. [[ -z ${version_lld} ]] && die "Failed to read ld.lld version!"
  643. local version_llvm_rust=$(rustc -Vv 2>/dev/null | grep -F -- 'LLVM version:' | awk '{ print $3 }')
  644. [[ -n ${version_llvm_rust} ]] && version_llvm_rust=$(ver_cut 1 "${version_llvm_rust}")
  645. [[ -z ${version_llvm_rust} ]] && die "Failed to read used LLVM version from rustc!"
  646. if ver_test "${version_lld}" -ne "${version_llvm_rust}" ; then
  647. eerror "Rust is using LLVM version ${version_llvm_rust} but ld.lld version belongs to LLVM version ${version_lld}."
  648. eerror "You will be unable to link ${CATEGORY}/${PN}. To proceed you have the following options:"
  649. eerror " - Manually switch rust version using 'eselect rust' to match used LLVM version"
  650. eerror " - Switch to dev-lang/rust[system-llvm] which will guarantee matching version"
  651. eerror " - Build ${CATEGORY}/${PN} without USE=lto"
  652. eerror " - Rebuild lld with llvm that was used to build rust (may need to rebuild the whole "
  653. eerror " llvm/clang/lld/rust chain depending on your @world updates)"
  654. die "LLVM version used by Rust (${version_llvm_rust}) does not match with ld.lld version (${version_lld})!"
  655. fi
  656. fi
  657. python-any-r1_pkg_setup
  658. # Avoid PGO profiling problems due to enviroment leakage
  659. # These should *always* be cleaned up anyway
  660. unset \
  661. DBUS_SESSION_BUS_ADDRESS \
  662. DISPLAY \
  663. ORBIT_SOCKETDIR \
  664. SESSION_MANAGER \
  665. XAUTHORITY \
  666. XDG_CACHE_HOME \
  667. XDG_SESSION_COOKIE
  668. # Build system is using /proc/self/oom_score_adj, bug #604394
  669. addpredict /proc/self/oom_score_adj
  670. if use pgo ; then
  671. # Update 105.0: "/proc/self/oom_score_adj" isn't enough anymore with pgo, but not sure
  672. # whether that's due to better OOM handling by Firefox (bmo#1771712), or portage
  673. # (PORTAGE_SCHEDULING_POLICY) update...
  674. addpredict "/proc"
  675. # Clear tons of conditions, since PGO is hardware-dependant.
  676. addpredict "/dev"
  677. # Allow access to GPU during PGO run
  678. local ati_cards mesa_cards nvidia_cards render_cards
  679. shopt -s nullglob
  680. ati_cards=$(echo -n /dev/ati/card* | sed 's/ /:/g')
  681. if [[ -n "${ati_cards}" ]] ; then
  682. addpredict "${ati_cards}"
  683. fi
  684. mesa_cards=$(echo -n /dev/dri/card* | sed 's/ /:/g')
  685. if [[ -n "${mesa_cards}" ]] ; then
  686. addpredict "${mesa_cards}"
  687. fi
  688. nvidia_cards=$(echo -n /dev/nvidia* | sed 's/ /:/g')
  689. if [[ -n "${nvidia_cards}" ]] ; then
  690. addpredict "${nvidia_cards}"
  691. fi
  692. render_cards=$(echo -n /dev/dri/renderD128* | sed 's/ /:/g')
  693. if [[ -n "${render_cards}" ]] ; then
  694. addpredict "${render_cards}"
  695. fi
  696. shopt -u nullglob
  697. fi
  698. if ! mountpoint -q /dev/shm ; then
  699. # If /dev/shm is not available, configure is known to fail with
  700. # a traceback report referencing /usr/lib/pythonN.N/multiprocessing/synchronize.py
  701. ewarn "/dev/shm is not mounted -- expect build failures!"
  702. fi
  703. # Google API keys (see http://www.chromium.org/developers/how-tos/api-keys)
  704. # Note: These are for Gentoo Linux use ONLY. For your own distribution, please
  705. # get your own set of keys.
  706. if [[ -z "${MOZ_API_KEY_GOOGLE+set}" ]] ; then
  707. MOZ_API_KEY_GOOGLE="AIzaSyDEAOvatFogGaPi0eTgsV_ZlEzx0ObmepsMzfAc"
  708. fi
  709. if [[ -z "${MOZ_API_KEY_LOCATION+set}" ]] ; then
  710. MOZ_API_KEY_LOCATION="AIzaSyB2h2OuRgGaPicUgy5N-5hsZqiPW6sH3n_rptiQ"
  711. fi
  712. # Mozilla API keys (see https://location.services.mozilla.com/api)
  713. # Note: These are for Gentoo Linux use ONLY. For your own distribution, please
  714. # get your own set of keys.
  715. if [[ -z "${MOZ_API_KEY_MOZILLA+set}" ]] ; then
  716. MOZ_API_KEY_MOZILLA="edb3d487-3a84-46m0ap1e3-9dfd-92b5efaaa005"
  717. fi
  718. # Ensure we use C locale when building, bug #746215
  719. export LC_ALL=C
  720. fi
  721. linux-info_pkg_setup
  722. if ! use pulseaudio ; then
  723. ewarn
  724. ewarn "Microphone support may be disabled when USE=-pulseaudio."
  725. ewarn
  726. fi
  727. local a
  728. for a in $(multilib_get_enabled_abis) ; do
  729. NABIS=$((${NABIS} + 1))
  730. done
  731. if [[ "${RUSTC_WRAPPER}" =~ "sccache" ]] ; then
  732. ewarn
  733. ewarn "Using sccache may randomly fail. Retry if it fails."
  734. ewarn
  735. fi
  736. if ! use wayland ; then
  737. ewarn
  738. ewarn "Disabling the wayland USE flag has the following consequences:"
  739. ewarn
  740. ewarn " (1) Degrade WebGL FPS by less than 25 FPS (15 FPS on average)"
  741. ewarn " (2) Always use software CPU based video decode for VP8, VP9, AV1."
  742. ewarn " If the wayland USE flag is enabled, it will use GPU accelerated"
  743. ewarn " decoding if supported."
  744. ewarn
  745. fi
  746. if use webspeech ; then
  747. ewarn
  748. ewarn "Speech recognition (USE=webspeech) has not been confirmed working."
  749. ewarn
  750. fi
  751. }
  752. src_unpack() {
  753. if use buildtarball; then
  754. unpack "/usr/src/makeicecat-${PV}/output/icecat-${PV}-${PP}gnu${GV}.tar.bz2" || eerror "Tarball is missing, check that www-client/makeicecat has use flag buildtarball enabled."
  755. else
  756. unpack "icecat-${PV}-${PP}gnu${GV}.tar.bz2"
  757. fi
  758. unpack "${FIREFOX_PATCHSET}"
  759. }
  760. _get_s() {
  761. if (( ${NABIS} == 1 )) ; then
  762. echo "${S}"
  763. else
  764. echo "${S}-${MULTILIB_ABI_FLAG}.${ABI}"
  765. fi
  766. }
  767. src_prepare() {
  768. use elibc_musl && eapply "${FILESDIR}/icecat-musl-sandbox.patch"
  769. use atk || eapply "${FILESDIR}/icecat-no-atk.patch"
  770. use dbus || eapply "${FILESDIR}/icecat-no-dbus.patch"
  771. eapply "${FILESDIR}/icecat-no-fribidi.patch"
  772. eapply "${FILESDIR}/icecat-fix-clang-as.patch"
  773. eapply "${FILESDIR}/icecat-system-gtests.patch"
  774. if use lto; then
  775. rm -v "${WORKDIR}"/firefox-patches/*-LTO-Only-enable-LTO-*.patch || die
  776. fi
  777. if ! use ppc64; then
  778. rm -v "${WORKDIR}"/firefox-patches/*ppc64*.patch || die
  779. fi
  780. if use x86 && use elibc_glibc ; then
  781. rm -v "${WORKDIR}"/firefox-patches/*-musl-non-lfs64-api-on-audio_thread_priority-crate.patch || die
  782. fi
  783. eapply "${FILESDIR}/extra-patches/firefox-106.0.2-disallow-store-data-races.patch"
  784. # Flicker prevention with -Ofast
  785. eapply "${FILESDIR}/extra-patches/firefox-106.0.2-disable-broken-flags-gfx-layers.patch"
  786. # Prevent YT stall prevention with clang with -Ofast.
  787. # Prevent audio perma mute with gcc with -Ofast.
  788. eapply "${FILESDIR}/extra-patches/firefox-106.0.2-disable-broken-flags-js.patch"
  789. # Only partial patching was done because the distro doesn't support
  790. # multilib Python. Only native ABI is supported. This means cbindgen
  791. # cannot load the 32-bit clang. It will build the cargo parts. When it
  792. # links it, it fails because of cbindings is 64-bit and the dependencies
  793. # use the build information for 64-bit linking, which should be 32-bit.
  794. #eapply "${DISTDIR}/${PN}-d4f5769.patch"
  795. # Allow to use system-ffmpeg completely.
  796. eapply "${FILESDIR}/extra-patches/firefox-115e-allow-ffmpeg-decode-av1.patch"
  797. eapply "${FILESDIR}/extra-patches/firefox-115e-disable-ffvpx.patch"
  798. # Prevent tab crash
  799. eapply "${FILESDIR}/extra-patches/firefox-106.0.2-disable-broken-flags-dom-bindings.patch"
  800. # Prevent video seek bug
  801. eapply "${FILESDIR}/extra-patches/firefox-106.0.2-disable-broken-flags-ipc-chromium-chromium-config.patch"
  802. # Workaround for bgo#917599
  803. if has_version ">=dev-libs/icu-74.1" && use system-icu ; then
  804. eapply "${WORKDIR}/firefox-patches/0029-bmo-1862601-system-icu-74.patch"
  805. fi
  806. rm -v "${WORKDIR}/firefox-patches/0029-bmo-1862601-system-icu-74.patch" || die
  807. # Workaround for bgo#915651 on musl
  808. if use elibc_glibc ; then
  809. rm -v "${WORKDIR}/firefox-patches/"*"bgo-748849-RUST_TARGET_override.patch" || die
  810. fi
  811. # Modify patch to apply correctly
  812. sed -i -e 's/firefox/icecat/' "${WORKDIR}"/firefox-patches/0033-bmo-1882209-update-crates-for-rust-1.78-stripped-patch-from-bugs.freebsd.org-bug278834.patch || die
  813. # sed -i -e 's/880c982df0843cbdff38b9f9c3829a2d863a224e4de2260c41c3ac69e9148ad4/239b3e4d20498f69ed5f94481ed932340bd58cb485b26c35b09517f249d20d11/' "${S}"/third_party/rust/bindgen/.cargo-checksum.json || die
  814. eapply "${WORKDIR}/firefox-patches"
  815. eapply "${FILESDIR}/icecat-115.18.0-python3.12-fix.patch"
  816. # Allow user to apply any additional patches without modifing ebuild
  817. eapply_user
  818. # Make cargo respect MAKEOPTS
  819. [[ -n ${CARGO_BUILD_JOBS} ]] || export CARGO_BUILD_JOBS="$(makeopts_jobs)"
  820. # Workaround for bgo#915651
  821. if ! use elibc_glibc ; then
  822. if use amd64 ; then
  823. export RUST_TARGET="x86_64-unknown-linux-musl"
  824. elif use x86 ; then
  825. export RUST_TARGET="i686-unknown-linux-musl"
  826. elif use arm64 ; then
  827. export RUST_TARGET="aarch64-unknown-linux-musl"
  828. else
  829. eerror
  830. eerror "Unknown musl chost, please post your rustc -vV along with"
  831. eerror "\`emerge --info\` on Gentoo's bug #915651"
  832. eerror
  833. die
  834. fi
  835. fi
  836. # Make LTO & ICU respect MAKEOPTS
  837. sed -i \
  838. -e "s/multiprocessing.cpu_count()/$(makeopts_jobs)/" \
  839. "${S}/build/moz.configure/lto-pgo.configure" \
  840. "${S}/intl/icu_sources_data.py" \
  841. || die "sed failed to set num_cores"
  842. # sed-in toolchain prefix
  843. sed -i \
  844. -e "s/objdump/${CHOST}-objdump/" \
  845. "${S}"/python/mozbuild/mozbuild/configure/check_debug_ranges.py \
  846. || die "sed failed to set toolchain prefix"
  847. sed -i \
  848. -e 's/ccache_stats = None/return None/' \
  849. "${S}"/python/mozbuild/mozbuild/controller/building.py \
  850. || die "sed failed to disable ccache stats call"
  851. einfo "Removing pre-built binaries ..."
  852. find "${S}"/third_party -type f \( -name '*.so' -o -name '*.o' \) -print -delete || die
  853. # Clear cargo checksums from crates we have patched
  854. # moz_clear_vendor_checksums crate
  855. moz_clear_vendor_checksums audio_thread_priority
  856. moz_clear_vendor_checksums bindgen
  857. moz_clear_vendor_checksums encoding_rs
  858. moz_clear_vendor_checksums any_all_workaround
  859. moz_clear_vendor_checksums packed_simd
  860. # Write API keys to disk
  861. echo -n "${MOZ_API_KEY_GOOGLE//gGaPi/}" > "${S}"/api-google.key || die
  862. echo -n "${MOZ_API_KEY_LOCATION//gGaPi/}" > "${S}"/api-location.key || die
  863. echo -n "${MOZ_API_KEY_MOZILLA//m0ap1/}" > "${S}"/api-mozilla.key || die
  864. xdg_environment_reset
  865. (( ${NABIS} > 1 )) && multilib_copy_sources
  866. _src_prepare() {
  867. cd $(_get_s) || die
  868. local CDEFAULT=$(get_abi_CHOST ${DEFAULT_ABI})
  869. # Only ${CDEFAULT}-objdump exists because in true multilib.
  870. # Logically speaking, there should be i686-pc-linux-gnu-objdump also.
  871. if [[ -e "${ESYSROOT}/usr/bin/${CHOST}-objdump" ]] ; then
  872. # Adds the toolchain prefix.
  873. sed -i \
  874. -e "s/\"objdump/\"${CHOST}-objdump/" \
  875. python/mozbuild/mozbuild/configure/check_debug_ranges.py \
  876. || die "sed failed to set toolchain prefix"
  877. einfo "Using ${CHOST}-objdump for CHOST"
  878. else
  879. [[ -e "${ESYSROOT}/usr/bin/${CDEFAULT}-objdump" ]] || die
  880. # Adds the toolchain prefix.
  881. sed -i \
  882. -e "s/\"objdump/\"${CDEFAULT}-objdump/" \
  883. python/mozbuild/mozbuild/configure/check_debug_ranges.py \
  884. || die "sed failed to set toolchain prefix"
  885. ewarn "Using ${CDEFAULT}-objdump for CDEFAULT"
  886. fi
  887. }
  888. }
  889. # Corrections based on the ABI being compiled
  890. # Preconditions:
  891. # CHOST must be defined
  892. # cwd is ABI's S
  893. _fix_paths() {
  894. # For proper rust cargo cross-compile for libloading and glslopt
  895. export PKG_CONFIG="${CHOST}-pkg-config"
  896. export CARGO_CFG_TARGET_ARCH=$(echo "${CHOST}" \
  897. | cut -f 1 -d "-")
  898. export MOZILLA_FIVE_HOME="/usr/$(get_libdir)/${PN}"
  899. export BUILD_OBJ_DIR="$(pwd)/ff"
  900. # Set MOZCONFIG
  901. export MOZCONFIG="$(pwd)/.mozconfig"
  902. # For rust crates libloading and glslopt
  903. if tc-is-clang ; then
  904. local version_clang=$(clang --version 2>/dev/null \
  905. | grep -F -- 'clang version' \
  906. | awk '{ print $3 }')
  907. if [[ -n "${version_clang}" ]] ; then
  908. version_clang=$(ver_cut 1 "${version_clang}")
  909. else
  910. eerror
  911. eerror "Failed to read clang version!"
  912. eerror
  913. die
  914. fi
  915. CC="${CHOST}-clang-${version_clang}"
  916. CXX="${CHOST}-clang++-${version_clang}"
  917. else
  918. CC="${CHOST}-gcc"
  919. CXX="${CHOST}-g++"
  920. fi
  921. tc-export CC CXX
  922. strip-unsupported-flags
  923. }
  924. append_all() {
  925. append-flags ${@}
  926. append-ldflags ${@}
  927. }
  928. is_flagq_last() {
  929. local flag="${1}"
  930. local olast=$(echo "${CFLAGS}" \
  931. | grep -o -E -e "-O(0|1|z|s|2|3|4|fast)" \
  932. | tr " " "\n" \
  933. | tail -n 1)
  934. einfo "CFLAGS:\t${CFLAGS}"
  935. einfo "olast:\t${olast}"
  936. [[ "${flag}" == "${olast}" ]] && return 0
  937. return 1
  938. }
  939. get_olast() {
  940. local olast=$(echo "${CFLAGS}" \
  941. | grep -o -E -e "-O(0|1|z|s|2|3|4|fast)" \
  942. | tr " " "\n" \
  943. | tail -n 1)
  944. if [[ -n "${olast}" ]] ; then
  945. echo "${olast}"
  946. else
  947. # Upstream default
  948. echo "-O3"
  949. fi
  950. }
  951. check_speech_dispatcher() {
  952. if use speech ; then
  953. if [[ ! -f "${ESYSROOT}/etc/speech-dispatcher/speechd.conf" ]] ; then
  954. eerror
  955. eerror "Missing ${ESYSROOT}/etc/speech-dispatcher/speechd.conf"
  956. eerror
  957. die
  958. fi
  959. if has_version "app-accessibility/speech-dispatcher[pulseaudio]" ; then
  960. if ! grep -q -e "^AudioOutputMethod.*\"pulse\"" \
  961. "${ESYSROOT}/etc/speech-dispatcher/speechd.conf" ; then
  962. eerror
  963. eerror "The following changes are required to"
  964. eerror "${ESYSROOT}/etc/speech-dispatcher/speechd.conf"
  965. eerror
  966. eerror "AudioOutputMethod \"pulse\""
  967. eerror
  968. eerror "The ~/.config/speech-dispatcher/speechd.conf should be removed or have"
  969. eerror "the same settings."
  970. eerror
  971. die
  972. fi
  973. elif has_version "app-accessibility/speech-dispatcher[alsa]" ; then
  974. if ! grep -q -e "^AudioOutputMethod.*\"alsa\"" \
  975. "${ESYSROOT}/etc/speech-dispatcher/speechd.conf" ; then
  976. eerror
  977. eerror "The following changes are required to"
  978. eerror "${ESYSROOT}/etc/speech-dispatcher/speechd.conf:"
  979. eerror
  980. eerror "AudioOutputMethod \"alsa\""
  981. eerror
  982. eerror "The ~/.config/speech-dispatcher/speechd.conf should be removed or have"
  983. eerror "the same settings."
  984. eerror
  985. die
  986. fi
  987. fi
  988. if has_version "app-accessibility/speech-dispatcher[espeak]" ; then
  989. if ! grep -q -e "^AddModule.*\"espeak-ng\"" \
  990. "${ESYSROOT}/etc/speech-dispatcher/speechd.conf" ; then
  991. eerror
  992. eerror "The following changes are required to"
  993. eerror "${ESYSROOT}/etc/speech-dispatcher/speechd.conf:"
  994. eerror
  995. eerror "AddModule \"espeak-ng\" \"sd_espeak-ng\" \"espeak-ng.conf\""
  996. eerror "DefaultModule espeak-ng"
  997. eerror
  998. eerror "The ~/.config/speech-dispatcher/speechd.conf should be removed or have"
  999. eerror "the same settings."
  1000. eerror
  1001. die
  1002. fi
  1003. if ! grep -q -e "^DefaultModule.*espeak-ng" \
  1004. "${ESYSROOT}/etc/speech-dispatcher/speechd.conf" ; then
  1005. eerror
  1006. eerror "The following changes are required to"
  1007. eerror "${ESYSROOT}/etc/speech-dispatcher/speechd.conf:"
  1008. eerror
  1009. eerror "DefaultModule espeak-ng"
  1010. eerror
  1011. eerror "The ~/.config/speech-dispatcher/speechd.conf should be removed or have"
  1012. eerror "the same settings."
  1013. eerror
  1014. die
  1015. fi
  1016. elif has_version "app-accessibility/speech-dispatcher[espeak]" ; then
  1017. if ! grep -q -e "^AddModule.*\"espeak\"" \
  1018. "${ESYSROOT}/etc/speech-dispatcher/speechd.conf" ; then
  1019. eerror
  1020. eerror "The following changes are required to"
  1021. eerror "${ESYSROOT}/etc/speech-dispatcher/speechd.conf:"
  1022. eerror
  1023. eerror "AddModule \"espeak\" \"sd_espeak\" \"espeak.conf\""
  1024. eerror "DefaultModule espeak"
  1025. eerror
  1026. eerror "The ~/.config/speech-dispatcher/speechd.conf should be removed or have"
  1027. eerror "the same settings."
  1028. eerror
  1029. die
  1030. fi
  1031. if ! grep -q -e "^DefaultModule.*espeak" \
  1032. "${ESYSROOT}/etc/speech-dispatcher/speechd.conf" ; then
  1033. eerror
  1034. eerror "The following changes are required to"
  1035. eerror "${ESYSROOT}/etc/speech-dispatcher/speechd.conf:"
  1036. eerror
  1037. eerror "DefaultModule espeak"
  1038. eerror
  1039. eerror "The ~/.config/speech-dispatcher/speechd.conf should be removed or have"
  1040. eerror "the same settings."
  1041. eerror
  1042. die
  1043. fi
  1044. elif has_version "app-accessibility/speech-dispatcher[flite]" ; then
  1045. if ! grep -q -e "^AddModule.*\"flite\"" \
  1046. "${ESYSROOT}/etc/speech-dispatcher/speechd.conf" ; then
  1047. eerror
  1048. eerror "The following changes are required to"
  1049. eerror "${ESYSROOT}/etc/speech-dispatcher/speechd.conf:"
  1050. eerror
  1051. eerror "#AddModule \"flite\" \"sd_flite\" \"flite.conf\""
  1052. eerror "DefaultModule flite"
  1053. eerror
  1054. eerror "The ~/.config/speech-dispatcher/speechd.conf should be removed or have"
  1055. eerror "the same settings."
  1056. eerror
  1057. die
  1058. fi
  1059. if ! grep -q -e "^DefaultModule.*flite" \
  1060. "${ESYSROOT}/etc/speech-dispatcher/speechd.conf" ; then
  1061. eerror
  1062. eerror "The following changes are required to"
  1063. eerror "${ESYSROOT}/etc/speech-dispatcher/speechd.conf:"
  1064. eerror
  1065. eerror "DefaultModule flite"
  1066. eerror
  1067. eerror "The ~/.config/speech-dispatcher/speechd.conf should be removed or have"
  1068. eerror "the same settings."
  1069. eerror
  1070. die
  1071. fi
  1072. fi
  1073. fi
  1074. }
  1075. OFLAG=""
  1076. LTO_TYPE=""
  1077. _src_configure() {
  1078. local s=$(_get_s)
  1079. cd "${s}" || die
  1080. local CDEFAULT=$(get_abi_CHOST ${DEFAULT_ABI})
  1081. # Show flags set at the beginning
  1082. einfo
  1083. einfo "Current BINDGEN_CFLAGS:\t${BINDGEN_CFLAGS:-no value set}"
  1084. einfo "Current CFLAGS:\t\t${CFLAGS:-no value set}"
  1085. einfo "Current CXXFLAGS:\t\t${CXXFLAGS:-no value set}"
  1086. einfo "Current LDFLAGS:\t\t${LDFLAGS:-no value set}"
  1087. einfo "Current RUSTFLAGS:\t\t${RUSTFLAGS:-no value set}"
  1088. einfo "Current CHOST:\t\t${CHOST:-no value set}"
  1089. einfo
  1090. local have_switched_compiler=
  1091. if use clang; then
  1092. # Force clang
  1093. einfo "Enforcing the use of clang due to USE=clang ..."
  1094. local version_clang=$(clang --version 2>/dev/null | grep -F -- 'clang version' | awk '{ print $3 }')
  1095. [[ -n ${version_clang} ]] && version_clang=$(ver_cut 1 "${version_clang}")
  1096. [[ -z ${version_clang} ]] && die "Failed to read clang version!"
  1097. if tc-is-gcc; then
  1098. have_switched_compiler=yes
  1099. fi
  1100. AR=llvm-ar
  1101. CC=${CHOST}-clang-${version_clang}
  1102. CXX=${CHOST}-clang++-${version_clang}
  1103. NM=llvm-nm
  1104. RANLIB=llvm-ranlib
  1105. elif ! use clang && ! tc-is-gcc ; then
  1106. # Force gcc
  1107. have_switched_compiler=yes
  1108. einfo "Enforcing the use of gcc due to USE=-clang ..."
  1109. AR=gcc-ar
  1110. CC=${CHOST}-gcc
  1111. CXX=${CHOST}-g++
  1112. NM=gcc-nm
  1113. RANLIB=gcc-ranlib
  1114. fi
  1115. if [[ -n "${have_switched_compiler}" ]] ; then
  1116. # Because we switched active compiler, we have to ensure
  1117. # that no unsupported flags are set
  1118. strip-unsupported-flags
  1119. fi
  1120. check_speech_dispatcher
  1121. # Ensure we use correct toolchain,
  1122. # AS is used in a non-standard way by upstream, #bmo1654031
  1123. export HOST_CC="$(tc-getBUILD_CC)"
  1124. export HOST_CXX="$(tc-getBUILD_CXX)"
  1125. export AS="$(tc-getCC) -c"
  1126. tc-export CC CXX LD AR AS NM OBJDUMP RANLIB PKG_CONFIG
  1127. _fix_paths
  1128. # Pass the correct toolchain paths through cbindgen
  1129. if tc-is-cross-compiler ; then
  1130. export BINDGEN_CFLAGS="
  1131. ${SYSROOT:+--sysroot=${ESYSROOT}}
  1132. --host=${CDEFAULT}
  1133. --target=${CHOST}
  1134. ${BINDGEN_CFLAGS-}
  1135. "
  1136. fi
  1137. # Set MOZILLA_FIVE_HOME
  1138. # MOZILLA_FIVE_HOME is dynamically generated per ABI in _fix_paths().
  1139. #export MOZILLA_FIVE_HOME="/usr/$(get_libdir)/${PN}"
  1140. # python/mach/mach/mixin/process.py fails to detect SHELL
  1141. export SHELL="${EPREFIX}/bin/bash"
  1142. # Set state path
  1143. export MOZBUILD_STATE_PATH="${BUILD_DIR}"
  1144. # MOZCONFIG is dynamically generated per ABI in _fix_paths().
  1145. #export MOZCONFIG="${s}/.mozconfig"
  1146. # Set Gentoo defaults
  1147. export MOZILLA_OFFICIAL=1
  1148. # Initialize MOZCONFIG
  1149. mozconfig_add_options_ac '' --enable-application="browser"
  1150. mozconfig_add_options_ac '' --enable-project="browser"
  1151. mozconfig_add_options_ac \
  1152. 'Gentoo default' \
  1153. --allow-addon-sideload \
  1154. --disable-cargo-incremental \
  1155. --disable-crashreporter \
  1156. --disable-eme \
  1157. --disable-gpsd \
  1158. --disable-install-strip \
  1159. --disable-parental-controls \
  1160. --disable-strip \
  1161. --disable-tests \
  1162. --disable-updater \
  1163. --disable-wmf \
  1164. --enable-legacy-profile-creation \
  1165. --enable-negotiateauth \
  1166. --enable-new-pass-manager \
  1167. --enable-official-branding \
  1168. --enable-release \
  1169. --enable-system-ffi \
  1170. --enable-system-pixman \
  1171. --enable-system-policies \
  1172. --host="${CDEFAULT}" \
  1173. --libdir="${EPREFIX}/usr/$(get_libdir)" \
  1174. --prefix="${EPREFIX}/usr" \
  1175. --target="${CHOST}" \
  1176. --without-ccache \
  1177. --without-wasm-sandboxed-libraries \
  1178. --with-intl-api \
  1179. --with-l10n-base="${s}/l10n" \
  1180. --with-system-nspr \
  1181. --with-system-nss \
  1182. --with-system-zlib \
  1183. --with-toolchain-prefix="${CHOST}-" \
  1184. --with-unsigned-addon-scopes="app,system" \
  1185. --x-includes="${ESYSROOT}/usr/include" \
  1186. --x-libraries="${ESYSROOT}/usr/$(get_libdir)"
  1187. if use system-ffmpeg ; then
  1188. mozconfig_add_options_ac \
  1189. '+system-ffmpeg' \
  1190. --enable-ffmpeg
  1191. else
  1192. mozconfig_add_options_ac \
  1193. '-system-ffmpeg' \
  1194. --disable-ffmpeg
  1195. fi
  1196. if use ffvpx ; then
  1197. mozconfig_add_options_ac \
  1198. 'ffvpx=default' \
  1199. --with-ffvpx="default"
  1200. else
  1201. mozconfig_add_options_ac \
  1202. 'ffvpx=no' \
  1203. --with-ffvpx="no"
  1204. fi
  1205. # mozconfig_add_options_ac \
  1206. # '' \
  1207. # --with-libclang-path="$(${CHOST}-llvm-config --libdir)"
  1208. # Disabled the lines above because the distro doesn't support multilib
  1209. # python, so full cross-compile is not supported.
  1210. # The commented lines above are mutually exclusive with this line below.
  1211. mozconfig_add_options_ac \
  1212. '' \
  1213. --with-libclang-path="$(llvm-config --libdir)"
  1214. # Set update channel
  1215. mozconfig_add_options_ac '' --update-channel="esr"
  1216. #if ! use x86 && [[ ${CHOST} != armv*h* ]] ; then
  1217. # mozconfig_add_options_ac '' --enable-rust-simd
  1218. #fi
  1219. # For future keywording: This is currently (97.0) only supported on:
  1220. # amd64, arm, arm64, and x86.
  1221. # You might want to flip the logic around if Firefox is to support more
  1222. # arches.
  1223. # bug 833001, bug 903411#c8
  1224. if use ppc64 || use riscv ; then
  1225. mozconfig_add_options_ac '' --disable-sandbox
  1226. else
  1227. mozconfig_add_options_ac '' --enable-sandbox
  1228. fi
  1229. # Enable JIT on riscv64 explicitly
  1230. # Can be removed once upstream enable it by default in the future.
  1231. use riscv && mozconfig_add_options_ac 'Enable JIT for RISC-V 64' --enable-jit
  1232. if [[ -s "${s}/api-google.key" ]] ; then
  1233. local key_origin="Gentoo default"
  1234. if [[ $(cat "${s}/api-google.key" | md5sum | awk '{ print $1 }') != 709560c02f94b41f9ad2c49207be6c54 ]] ; then
  1235. key_origin="User value"
  1236. fi
  1237. mozconfig_add_options_ac "${key_origin}" \
  1238. --with-google-safebrowsing-api-keyfile="${s}/api-google.key"
  1239. else
  1240. einfo "Building without Google API key ..."
  1241. fi
  1242. if [[ -s "${s}/api-location.key" ]] ; then
  1243. local key_origin="Gentoo default"
  1244. if [[ $(cat "${s}/api-location.key" | md5sum | awk '{ print $1 }') != ffb7895e35dedf832eb1c5d420ac7420 ]] ; then
  1245. key_origin="User value"
  1246. fi
  1247. mozconfig_add_options_ac "${key_origin}" \
  1248. --with-google-location-service-api-keyfile="${s}/api-location.key"
  1249. else
  1250. einfo "Building without Location API key ..."
  1251. fi
  1252. if [[ -s "${s}/api-mozilla.key" ]] ; then
  1253. local key_origin="Gentoo default"
  1254. if [[ $(cat "${s}/api-mozilla.key" | md5sum | awk '{ print $1 }') != 3927726e9442a8e8fa0e46ccc39caa27 ]] ; then
  1255. key_origin="User value"
  1256. fi
  1257. mozconfig_add_options_ac "${key_origin}" \
  1258. --with-mozilla-api-keyfile="${s}/api-mozilla.key"
  1259. else
  1260. einfo "Building without Mozilla API key ..."
  1261. fi
  1262. mozconfig_use_with system-av1
  1263. mozconfig_use_with system-harfbuzz
  1264. mozconfig_use_with system-harfbuzz system-graphite2
  1265. mozconfig_use_with system-icu
  1266. mozconfig_use_with system-jpeg
  1267. mozconfig_use_with system-libevent
  1268. mozconfig_use_with system-libvpx
  1269. mozconfig_use_with system-png
  1270. mozconfig_use_with system-webp
  1271. mozconfig_use_enable atk accessibility
  1272. mozconfig_use_enable dbus
  1273. mozconfig_use_enable libproxy
  1274. mozconfig_use_enable cups printing
  1275. multilib_is_native_abi && mozconfig_use_enable speech synth-speechd
  1276. mozconfig_use_enable webrtc
  1277. mozconfig_use_enable webspeech
  1278. mozconfig_use_enable geckodriver
  1279. # The upstream default is hardening on even if unset.
  1280. if use hardened ; then
  1281. mozconfig_add_options_ac "+hardened" --enable-hardening
  1282. append-ldflags "-Wl,-z,relro -Wl,-z,now" # Full Relro
  1283. else
  1284. mozconfig_add_options_ac "-hardened" --disable-hardening
  1285. fi
  1286. local myaudiobackends=""
  1287. use jack && myaudiobackends+="jack,"
  1288. use sndio && myaudiobackends+="sndio,"
  1289. use pulseaudio && myaudiobackends+="pulseaudio,"
  1290. ! use pulseaudio && myaudiobackends+="alsa,"
  1291. mozconfig_add_options_ac \
  1292. '--enable-audio-backends' \
  1293. --enable-audio-backends=$(echo "${myaudiobackends}" \
  1294. | sed -e "s|,$||g") # Cannot be empty
  1295. mozconfig_use_enable wifi necko-wifi
  1296. if use X && use wayland ; then
  1297. mozconfig_add_options_ac '+x11+wayland' --enable-default-toolkit="cairo-gtk3-x11-wayland"
  1298. elif ! use X && use wayland ; then
  1299. mozconfig_add_options_ac '+wayland' --enable-default-toolkit="cairo-gtk3-wayland-only"
  1300. else
  1301. mozconfig_add_options_ac '+x11' --enable-default-toolkit="cairo-gtk3"
  1302. fi
  1303. if use lto; then
  1304. if tc-is-cross-compiler; then
  1305. mozconfig_add_options_ac '+lto' --enable-lto="cross"
  1306. elif use clang; then
  1307. mozconfig_add_options_ac '+lto' --enable-lto="thin"
  1308. else
  1309. mozconfig_add_options_ac '+lto' --enable-lto="full"
  1310. fi
  1311. if use pgo ; then
  1312. mozconfig_add_options_ac '+pgo' MOZ_PGO=1
  1313. if use clang ; then
  1314. # Used in build/pgo/profileserver.py
  1315. export LLVM_PROFDATA="llvm-profdata"
  1316. mozconfig_add_options_ac '+pgo-rust' MOZ_PGO_RUST=1
  1317. fi
  1318. fi
  1319. fi
  1320. # Avoid auto-magic on linker
  1321. if use mold ; then
  1322. mozconfig_add_options_ac "using ld=mold due to system selection" --enable-linker="mold"
  1323. elif use lld ; then
  1324. mozconfig_add_options_ac "using ld=lld due to system selection" --enable-linker="lld"
  1325. else
  1326. mozconfig_add_options_ac "linker is set to bfd" --enable-linker="bfd"
  1327. fi
  1328. # Linker flags are set from above.
  1329. filter-ldflags '-fuse-ld=*' '-Wl,-fuse-ld=*'
  1330. filter-flags '-fuse-ld=*' '-Wl,-fuse-ld=*'
  1331. export RUSTFLAGS="${RUSTFLAGS/-C link-arg=-fuse-ld=lld/}"
  1332. export RUSTFLAGS="${RUSTFLAGS/-C link-arg=-fuse-ld=mold/}"
  1333. export RUSTFLAGS="${RUSTFLAGS/-C linker-plugin-lto/}"
  1334. export RUSTFLAGS="${RUSTFLAGS/-C link-arg=-flto/}"
  1335. # LTO flag was handled via configure
  1336. filter-lto
  1337. # Filter ldflags after linker switch
  1338. strip-unsupported-flags
  1339. mozconfig_use_enable debug
  1340. if use debug ; then
  1341. mozconfig_add_options_ac \
  1342. '+debug' \
  1343. --disable-optimize
  1344. mozconfig_add_options_ac \
  1345. '+debug' \
  1346. --enable-real-time-tracing
  1347. else
  1348. mozconfig_add_options_ac \
  1349. 'Gentoo defaults' \
  1350. --disable-real-time-tracing
  1351. mozconfig_add_options_ac \
  1352. 'Gentoo default' \
  1353. --disable-debug-symbols
  1354. # Fork ebuild or set USE=debug if you want -Og
  1355. if is_flagq_last '-Ofast' || [[ "${OFLAG}" == "-Ofast" ]] ; then
  1356. einfo "Using -Ofast"
  1357. OFLAG="-Ofast"
  1358. mozconfig_add_options_ac \
  1359. "from CFLAGS" \
  1360. --enable-optimize="-Ofast"
  1361. elif is_flagq_last '-O4' || [[ "${OFLAG}" == "-O4" ]] ; then
  1362. # O4 is the same as O3.
  1363. OFLAG="-O4"
  1364. mozconfig_add_options_ac \
  1365. "from CFLAGS" \
  1366. --enable-optimize="-O4"
  1367. elif is_flagq_last '-O3' || [[ "${OFLAG}" == "-O3" ]] ; then
  1368. # Repeated for multiple Oflags
  1369. OFLAG="-O3"
  1370. mozconfig_add_options_ac \
  1371. "from CFLAGS" \
  1372. --enable-optimize="-O3"
  1373. elif is_flagq_last '-O2' || [[ "${OFLAG}" == "-O2" ]] ; then
  1374. OFLAG="-O2"
  1375. mozconfig_add_options_ac \
  1376. "from CFLAGS" \
  1377. --enable-optimize="-O2"
  1378. else
  1379. OFLAG="-O3"
  1380. mozconfig_add_options_ac \
  1381. "Upstream default" \
  1382. --enable-optimize="-O3"
  1383. fi
  1384. fi
  1385. local oflag_safe
  1386. if [[ -z "${OFLAG}" ]] ; then
  1387. oflag_safe=$(get_olast)
  1388. else
  1389. oflag_safe="${OFLAG}"
  1390. fi
  1391. [[ "${oflag_safe}" == "-Ofast" ]] && oflag_safe="-O3"
  1392. einfo "oflag_safe:\t${oflag_safe}"
  1393. local L=(
  1394. "dom/bindings/moz.build"
  1395. "ipc/chromium/chromium-config.mozbuild"
  1396. "gfx/layers/moz.build"
  1397. "js/src/js-cxxflags.mozbuild"
  1398. )
  1399. local f
  1400. for f in ${L[@]} ; do
  1401. einfo "Editing ${f}: __OFLAG_SAFE__ -> ${oflag_safe}"
  1402. sed -i -e "s|__OFLAG_SAFE__|${oflag_safe}|g" \
  1403. "${f}" \
  1404. || die
  1405. done
  1406. # Debug flag was handled via configure
  1407. filter-flags '-g*'
  1408. # Optimization flag was handled via configure
  1409. filter-flags '-O*'
  1410. if is-flagq '-ffast-math' || [[ "${OFLAG}" == "-Ofast" ]] ; then
  1411. local pos=$(grep -n "#define OPUS_DEFINES_H" \
  1412. "${s}/media/libopus/include/opus_defines.h" \
  1413. | cut -f 1 -d ":")
  1414. sed -i -e "${pos}a#define FLOAT_APPROX 1" \
  1415. "${s}/media/libopus/include/opus_defines.h" || die
  1416. fi
  1417. # Modifications to better support ARM, bug #553364
  1418. if use cpu_flags_arm_neon ; then
  1419. mozconfig_add_options_ac '+cpu_flags_arm_neon' --with-fpu="neon"
  1420. if tc-is-gcc ; then
  1421. # Thumb options aren't supported when using clang, bug 666966
  1422. mozconfig_add_options_ac \
  1423. '+cpu_flags_arm_neon' \
  1424. --with-thumb=yes \
  1425. --with-thumb-interwork=no
  1426. fi
  1427. fi
  1428. if [[ ${CHOST} == armv*h* ]] ; then
  1429. mozconfig_add_options_ac 'CHOST=armv*h*' --with-float-abi="hard"
  1430. if ! use system-libvpx ; then
  1431. sed -i \
  1432. -e "s|softfp|hard|" \
  1433. "${s}/media/libvpx/moz.build" \
  1434. || die
  1435. fi
  1436. fi
  1437. # With profile 23.0 elf-hack=legacy is broken with gcc.
  1438. # With Firefox-115esr elf-hack=relr isn't available (only in rapid).
  1439. # Solution: Disable build system's elf-hack completely, and add "-z,pack-relative-relocs"
  1440. # manually with gcc.
  1441. #
  1442. # elf-hack configure option isn't available on ppc64/riscv, #916259, #929244, #930046.
  1443. if use ppc64 || use riscv ; then
  1444. :;
  1445. else
  1446. mozconfig_add_options_ac 'elf-hack disabled' --disable-elf-hack
  1447. fi
  1448. if (is_flagq_last "-O3" || is_flagq_last "-Ofast") \
  1449. && tc-is-gcc \
  1450. && ver_test $(gcc-fullversion) -lt 11.3.0 ; then
  1451. ewarn
  1452. ewarn "GCC version detected:\t$(gcc-fullversion)"
  1453. ewarn "Expected version:\t>= 11.3"
  1454. ewarn
  1455. ewarn "The detected version is untested and may result in userscript failure."
  1456. ewarn "Use GCC >= 11.3 or Clang to prevent this bug."
  1457. ewarn
  1458. fi
  1459. # Additional ARCH support
  1460. case "${ARCH}" in
  1461. arm)
  1462. # Reduce the memory requirements for linking
  1463. if use clang ; then
  1464. # Nothing to do
  1465. :;
  1466. elif use lto ; then
  1467. append-ldflags -Wl,--no-keep-memory
  1468. else
  1469. append-ldflags -Wl,--no-keep-memory -Wl,--reduce-memory-overheads
  1470. fi
  1471. ;;
  1472. esac
  1473. # Use the O(1) algorithm linker algorithm and add more swap instead.
  1474. ewarn
  1475. ewarn "Add more swap space if linker causes an out of memory (OOM) condition."
  1476. ewarn
  1477. if ! use elibc_glibc ; then
  1478. mozconfig_add_options_ac '!elibc_glibc' --disable-jemalloc
  1479. elif ! use jemalloc ; then
  1480. mozconfig_add_options_ac '-jemalloc' --disable-jemalloc
  1481. else
  1482. mozconfig_add_options_ac '+jemalloc' --enable-jemalloc
  1483. fi
  1484. # System-av1 fix
  1485. use system-av1 && append-ldflags "-Wl,--undefined-version"
  1486. # Allow elfhack to work in combination with unstripped binaries
  1487. # when they would normally be larger than 2GiB.
  1488. append-ldflags "-Wl,--compress-debug-sections=zlib"
  1489. # Make revdep-rebuild.sh happy; Also required for musl
  1490. append-ldflags -Wl,-rpath="${MOZILLA_FIVE_HOME}",--enable-new-dtags
  1491. # Pass $MAKEOPTS to build system
  1492. export MOZ_MAKE_FLAGS="${MAKEOPTS}"
  1493. # Use system's Python environment
  1494. export PIP_NETWORK_INSTALL_RESTRICTED_VIRTUALENVS="mach"
  1495. if use system-python-libs; then
  1496. export MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE="system"
  1497. export MACH_SYSTEM_ASSERTED_COMPATIBLE_WITH_BUILD_SITE=1
  1498. export MACH_SYSTEM_ASSERTED_COMPATIBLE_WITH_MACH_SITE=1
  1499. else
  1500. export MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE="none"
  1501. fi
  1502. # Disable notification when build system has finished
  1503. export MOZ_NOSPAM=1
  1504. # Portage sets XARGS environment variable to "xargs -r" by default which
  1505. # breaks build system's check_prog() function which doesn't support arguments
  1506. mozconfig_add_options_ac 'Gentoo default' "XARGS=${EPREFIX}/usr/bin/xargs"
  1507. # Set build dir
  1508. mozconfig_add_options_mk 'Gentoo default' "MOZ_OBJDIR=${BUILD_DIR}"
  1509. einfo "Cross-compile ABI:\t\t${ABI}"
  1510. einfo "Cross-compile CFLAGS:\t${CFLAGS}"
  1511. einfo "Cross-compile CC:\t\t${CC}"
  1512. einfo "Cross-compile CXX:\t\t${CXX}"
  1513. echo "export PKG_CONFIG=${CHOST}-pkg-config" \
  1514. >>"${MOZCONFIG}"
  1515. echo "export PKG_CONFIG_PATH=/usr/$(get_libdir)/pkgconfig:/usr/share/pkgconfig" \
  1516. >>"${MOZCONFIG}"
  1517. # Show flags we will use
  1518. einfo "Build BINDGEN_CFLAGS:\t${BINDGEN_CFLAGS:-no value set}"
  1519. einfo "Build CFLAGS:\t\t${CFLAGS:-no value set}"
  1520. einfo "Build CXXFLAGS:\t\t${CXXFLAGS:-no value set}"
  1521. einfo "Build LDFLAGS:\t\t${LDFLAGS:-no value set}"
  1522. einfo "Build RUSTFLAGS:\t\t${RUSTFLAGS:-no value set}"
  1523. # Handle EXTRA_CONF and show summary
  1524. local ac opt hash reason
  1525. # Apply EXTRA_ECONF entries to $MOZCONFIG
  1526. if [[ -n "${EXTRA_ECONF}" ]] ; then
  1527. IFS=\! read -a ac <<<${EXTRA_ECONF// --/\!}
  1528. for opt in "${ac[@]}"; do
  1529. mozconfig_add_options_ac "EXTRA_ECONF" --${opt#--}
  1530. done
  1531. fi
  1532. echo
  1533. echo "=========================================================="
  1534. echo "Building ${PF} with the following configuration"
  1535. grep ^ac_add_options "${MOZCONFIG}" | \
  1536. while read ac opt hash reason; do
  1537. [[ -z "${hash}" || "${hash}" == \# ]] \
  1538. || die "error reading mozconfig: ${ac} ${opt} ${hash} ${reason}"
  1539. printf " %-30s %s\n" "${opt}" "${reason:-mozilla.org default}"
  1540. done
  1541. echo "=========================================================="
  1542. echo
  1543. ./mach configure || die
  1544. }
  1545. src_configure() {
  1546. multilib_foreach_abi _src_configure
  1547. }
  1548. _src_compile() {
  1549. local s=$(_get_s)
  1550. cd "${s}" || die
  1551. if use mold && use lto; then
  1552. # increase ulimit with mold+lto, bugs #892641, #907485
  1553. if ! ulimit -n 16384 1>/dev/null 2>&1 ; then
  1554. ewarn "Unable to modify ulimits - building with mold+lto might fail due to low"
  1555. ewarn "ulimit -n resources."
  1556. #ewarn "Please see bugs #892641 & #907485."
  1557. else
  1558. ulimit -n 16384
  1559. fi
  1560. fi
  1561. local CDEFAULT=$(get_abi_CHOST "${DEFAULT_ABI}")
  1562. _fix_paths
  1563. local virtx_cmd=
  1564. if use pgo; then
  1565. # Reset and cleanup environment variables used by GNOME/XDG
  1566. gnome2_environment_reset
  1567. addpredict "/root"
  1568. if ! use X; then
  1569. virtx_cmd="virtwl"
  1570. else
  1571. virtx_cmd="virtx"
  1572. fi
  1573. fi
  1574. if ! use X; then
  1575. local -x GDK_BACKEND="wayland"
  1576. else
  1577. local -x GDK_BACKEND="x11"
  1578. fi
  1579. ${virtx_cmd} ./mach build --verbose || die
  1580. # Build language packs
  1581. moz_build_xpi
  1582. }
  1583. src_compile() {
  1584. multilib_foreach_abi _src_compile
  1585. }
  1586. _src_install() {
  1587. local s=$(_get_s)
  1588. cd "${s}" || die
  1589. local CDEFAULT=$(get_abi_CHOST "${DEFAULT_ABI}")
  1590. _fix_paths
  1591. # xpcshell is getting called during install
  1592. pax-mark m \
  1593. "${BUILD_DIR}/dist/bin/xpcshell" \
  1594. "${BUILD_DIR}/dist/bin/${PN}" \
  1595. "${BUILD_DIR}/dist/bin/plugin-container"
  1596. DESTDIR="${D}" ./mach install || die
  1597. # Upstream cannot ship symlink but we can (bmo#658850)
  1598. rm "${ED}${MOZILLA_FIVE_HOME}/${PN}-bin" || die
  1599. dosym "${PN}" "${MOZILLA_FIVE_HOME}/${PN}-bin"
  1600. # Don't install llvm-symbolizer from llvm-core/llvm package
  1601. if [[ -f "${ED}${MOZILLA_FIVE_HOME}/llvm-symbolizer" ]] ; then
  1602. rm -v "${ED}${MOZILLA_FIVE_HOME}/llvm-symbolizer" || die
  1603. fi
  1604. # Install policy (currently only used to disable application updates)
  1605. insinto "${MOZILLA_FIVE_HOME}/distribution"
  1606. newins "${FILESDIR}/distribution.ini" "distribution.ini"
  1607. newins "${FILESDIR}/disable-auto-update.policy.json" "policies.json"
  1608. # Install system-wide preferences
  1609. local PREFS_DIR="${MOZILLA_FIVE_HOME}/browser/defaults/preferences"
  1610. insinto "${PREFS_DIR}"
  1611. newins "${FILESDIR}/gentoo-default-prefs.js" "gentoo-prefs.js"
  1612. local GENTOO_PREFS="${ED}${PREFS_DIR}/gentoo-prefs.js"
  1613. # Set dictionary path to use system hunspell
  1614. cat >>"${GENTOO_PREFS}" <<-EOF || die "failed to set spellchecker.dictionary_path pref"
  1615. pref("spellchecker.dictionary_path", "${EPREFIX}/usr/share/myspell");
  1616. EOF
  1617. # Set installDistroAddons to true so that language packs work
  1618. cat >>"${GENTOO_PREFS}" <<-EOF || die "failed to set extensions.installDistroAddons pref"
  1619. pref("extensions.installDistroAddons", true);
  1620. pref("extensions.langpacks.signatures.required", false);
  1621. EOF
  1622. # Disable signatures for language packs so that unsigned just built language packs work
  1623. cat >>"${GENTOO_PREFS}" <<-EOF || die "failed to disable langpacks signatures"
  1624. pref("extensions.langpacks.signatures.required", false);
  1625. EOF
  1626. # Force hwaccel prefs if USE=hwaccel is enabled
  1627. if use hwaccel ; then
  1628. cat "${FILESDIR}/gentoo-hwaccel-prefs.js-r2" \
  1629. >>"${GENTOO_PREFS}" \
  1630. || die "failed to add prefs to force hardware-accelerated rendering to all-gentoo.js"
  1631. if use wayland; then
  1632. cat >>"${GENTOO_PREFS}" <<-EOF || die "failed to set hwaccel wayland prefs"
  1633. pref("gfx.x11-egl.force-enabled", false);
  1634. EOF
  1635. else
  1636. cat >>"${GENTOO_PREFS}" <<-EOF || die "failed to set hwaccel x11 prefs"
  1637. pref("gfx.x11-egl.force-enabled", true);
  1638. EOF
  1639. fi
  1640. fi
  1641. # Force the graphite pref if USE=system-harfbuzz is enabled, since the pref cannot disable it
  1642. if use system-harfbuzz ; then
  1643. cat >>"${GENTOO_PREFS}" <<-EOF || die "failed to set gfx.font_rendering.graphite.enabled pref"
  1644. sticky_pref("gfx.font_rendering.graphite.enabled", true);
  1645. EOF
  1646. fi
  1647. # Install language packs
  1648. local langpacks=( $(find "${BUILD_DIR}/dist/linux-x86_64/xpi" -type f -name '*.xpi') )
  1649. if [[ -n "${langpacks}" ]] ; then
  1650. moz_install_xpi "${MOZILLA_FIVE_HOME}/distribution/extensions" "${langpacks[@]}"
  1651. fi
  1652. # Install geckodriver
  1653. if use geckodriver ; then
  1654. einfo "Installing geckodriver into ${ED}${MOZILLA_FIVE_HOME} ..."
  1655. pax-mark m "${BUILD_DIR}/dist/bin/geckodriver"
  1656. exeinto "${MOZILLA_FIVE_HOME}"
  1657. doexe "${BUILD_DIR}/dist/bin/geckodriver"
  1658. dosym "${MOZILLA_FIVE_HOME}/geckodriver" "/usr/bin/geckodriver"
  1659. fi
  1660. # Install icons
  1661. local icon_srcdir="${s}/browser/branding/official"
  1662. local icon_symbolic_file="${FILESDIR}/icon/${PN}-symbolic.svg"
  1663. insinto /usr/share/icons/hicolor/symbolic/apps
  1664. newins "${icon_symbolic_file}" "${PN}-symbolic.svg"
  1665. local icon size
  1666. for icon in "${icon_srcdir}/default"*".png" ; do
  1667. size=${icon%.png}
  1668. size=${size##*/default}
  1669. if [[ ${size} -eq 48 ]] ; then
  1670. newicon "${icon}" "${PN}.png"
  1671. fi
  1672. newicon -s ${size} "${icon}" "${PN}.png"
  1673. done
  1674. # Install menu
  1675. local app_name="GNU IceCat"
  1676. local desktop_file="${FILESDIR}/icon/${PN}-r3.desktop"
  1677. local desktop_filename="${PN}-esr-${ABI}.desktop"
  1678. local exec_command="${PN}-${ABI}"
  1679. local icon="${PN}"
  1680. local use_wayland="false"
  1681. if use wayland ; then
  1682. use_wayland="true"
  1683. fi
  1684. cp "${desktop_file}" "${WORKDIR}/${PN}.desktop-template" || die
  1685. sed -i \
  1686. -e "s:@NAME@:${app_name}:" \
  1687. -e "s:@EXEC@:${exec_command}:" \
  1688. -e "s:@ICON@:${icon}:" \
  1689. "${WORKDIR}/${PN}.desktop-template" \
  1690. || die
  1691. newmenu "${WORKDIR}/${PN}.desktop-template" "${desktop_filename}"
  1692. rm "${WORKDIR}/${PN}.desktop-template" || die
  1693. # Install wrapper script
  1694. [[ -f "${ED}/usr/bin/${PN}" ]] && rm "${ED}/usr/bin/${PN}"
  1695. newbin "${FILESDIR}/${PN}-r1.sh" "${PN}-${ABI}"
  1696. dosym "/usr/bin/${PN}-${ABI}" "/usr/bin/${PN}"
  1697. # Update wrapper
  1698. sed -i \
  1699. -e "s:@PREFIX@:${EPREFIX}/usr:" \
  1700. -e "s:@LIBDIR@:$(get_libdir):" \
  1701. -e "s:@MOZ_FIVE_HOME@:${MOZILLA_FIVE_HOME}:" \
  1702. -e "s:@APULSELIB_DIR@:${apulselib}:" \
  1703. -e "s:@DEFAULT_WAYLAND@:${use_wayland}:" \
  1704. "${ED}/usr/bin/${PN}-${ABI}" \
  1705. || die
  1706. }
  1707. src_install() {
  1708. install_abi() {
  1709. _src_install
  1710. multilib_check_headers
  1711. }
  1712. multilib_foreach_abi install_abi
  1713. }
  1714. pkg_preinst() {
  1715. xdg_pkg_preinst
  1716. # If the apulse libs are available in MOZILLA_FIVE_HOME then apulse
  1717. # does not need to be forced into the LD_LIBRARY_PATH
  1718. if use pulseaudio && has_version ">=media-sound/apulse-0.1.12-r4" ; then
  1719. einfo "APULSE found; Generating library symlinks for sound support ..."
  1720. local lib
  1721. pushd "${ED}${MOZILLA_FIVE_HOME}" &>/dev/null || die
  1722. for lib in "../apulse/libpulse"{".so"{"",".0"},"-simple.so"{"",".0"}} ; do
  1723. # A quickpkg rolled by hand will grab symlinks as part of the package,
  1724. # so we need to avoid creating them if they already exist.
  1725. if [[ ! -L "${lib##*/}" ]] ; then
  1726. ln -s "${lib}" "${lib##*/}" || die
  1727. fi
  1728. done
  1729. popd &>/dev/null || die
  1730. fi
  1731. }
  1732. pkg_postinst() {
  1733. xdg_pkg_postinst
  1734. elog "Cloudflare browser checks are broken with GNU IceCats anti fingerprinting measures."
  1735. elog "You can fix cloudflare browser checks by undoing them in about:config like below:"
  1736. # Specifying (X11) is necessary for it to work, even in a Wayland session
  1737. elog " general.appversion.override: ${PV%.[0-9]*} (X11)"
  1738. elog " general.oscpu.override: Linux x86_64"
  1739. elog " general.platform.override: Linux x86_64"
  1740. if use pulseaudio && has_version ">=media-sound/apulse-0.1.12-r4" ; then
  1741. elog "Apulse was detected at merge time on this system and so it will always be"
  1742. elog "used for sound. If you wish to use pulseaudio instead please unmerge"
  1743. elog "media-sound/apulse."
  1744. elog
  1745. fi
  1746. if ! use hwaccel ; then
  1747. ewarn
  1748. ewarn "You must manually enable \"Use hardware acceleration when available\""
  1749. ewarn "for smoother scrolling and >= 25 FPS video playback."
  1750. ewarn
  1751. ewarn "For details, see https://support.mozilla.org/en-US/kb/performance-settings"
  1752. ewarn
  1753. fi
  1754. if use libcanberra ; then
  1755. if has_version "media-libs/libcanberra[-sound]" ; then
  1756. ewarn
  1757. ewarn "You need a sound theme to hear notifications."
  1758. ewarn "The default one can be installed with media-libs/libcanberra[sound]"
  1759. ewarn
  1760. fi
  1761. fi
  1762. # bug 835078
  1763. if use hwaccel && has_version "x11-drivers/xf86-video-nouveau"; then
  1764. ewarn "You have nouveau drivers installed in your system and 'hwaccel' "
  1765. ewarn "enabled for IceCat. Nouveau / your GPU might not support the "
  1766. ewarn "required EGL, so either disable 'hwaccel' or try the workaround "
  1767. ewarn "explained in https://bugs.gentoo.org/835078#c5 if Firefox crashes."
  1768. fi
  1769. optfeature_header "Optional programs for extra features:"
  1770. optfeature "desktop notifications" x11-libs/libnotify
  1771. optfeature "fallback mouse cursor theme e.g. on WMs" gnome-base/gsettings-desktop-schemas
  1772. optfeature "screencasting with pipewire" sys-apps/xdg-desktop-portal
  1773. if use hwaccel && has_version "x11-drivers/nvidia-drivers"; then
  1774. optfeature "hardware acceleration with NVIDIA cards" media-libs/nvidia-vaapi-driver
  1775. fi
  1776. if ! has_version "sys-libs/glibc"; then
  1777. elog
  1778. elog "glibc not found! You won't be able to play DRM content."
  1779. elog "See Gentoo bug #910309 or upstream bug #1843683."
  1780. elog
  1781. fi
  1782. if use geckodriver ; then
  1783. ewarn "You have enabled the 'geckodriver' USE flag. Geckodriver is now"
  1784. ewarn "packaged separately as net-misc/geckodriver and the use flag will be"
  1785. ewarn "dropped from main Firefox package by Firefox 128.0 release."
  1786. fi
  1787. }