bsd.gecko.mk 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. #-*- tab-width: 4; -*-
  2. # ex:ts=4
  3. #
  4. # Date created: 12 Nov 2005
  5. # Whom: Michael Johnson <ahze@FreeBSD.org>
  6. #
  7. # 4 column tabs prevent hair loss and tooth decay!
  8. # bsd.gecko.mk abstracts the selection of gecko-based backends. It allows users
  9. # and porters to support any available gecko backend without needing to build
  10. # many conditional tests. ${USE_GECKO} is the list of backends that your port
  11. # can handle, and ${GECKO} is set by bsd.gecko.mk to be the chosen backend.
  12. # Users set ${WITH_GECKO} to the list of gecko backends they want on their
  13. # system.
  14. .if defined(USE_GECKO)
  15. . if !defined(_POSTMKINCLUDED) && !defined(Gecko_Pre_Include)
  16. Gecko_Pre_Include= bsd.gecko.mk
  17. # This file contains some reusable components for mozilla ports. It's of
  18. # use primarily to apps from the mozilla project itself (such as Firefox,
  19. # Thunderbird, etc.), and probably won't be of use for gecko-based ports
  20. # like epiphany, galeon, etc.
  21. #
  22. # You need to make sure to add USE_GECKO=gecko to for your port can uses
  23. # one of these options below.
  24. #
  25. # Ports can use the following:
  26. #
  27. # USE_MOZILLA By default, it enables every system dependency
  28. # listed in '_ALL_DEPENDS'. If your port doesn't
  29. # need one of those then you can use '-' like
  30. # 'USE_MOZILLA= -png -vpx' to subtract the
  31. # dependencies. Experimental deps use '+' like
  32. # 'USE_MOZILLA= +speex +theora'.
  33. #
  34. # MOZILLA_PLIST_DIRS List of directories to descend into when installing
  35. # and creating the plist
  36. #
  37. # MOZ_OPTIONS configure arguments (added to .mozconfig). If
  38. # NOMOZCONFIG is defined, you probably want to set
  39. # CONFIGURE_ARGS+=${MOZ_OPTIONS}
  40. #
  41. # MOZ_MK_OPTIONS The make(1) arguments (added to .mozconfig). If
  42. # NOMOZCONFIG is defined, you probably want to set
  43. # MAKE_ARGS+=${MOZ_MK_OPTIONS}
  44. #
  45. # MOZ_EXPORT Environment variables for the build process (added
  46. # to .mozconfig). If NOMOZCONFIG is defined, you
  47. # probably want to set MAKE_ENV+=${MOZ_EXPORT}
  48. #
  49. # NOMOZCONFIG Don't drop a customized .mozconfig into the build
  50. # directory. Options will have to be specified in
  51. # CONFIGURE_ARGS instead
  52. #
  53. MAINTAINER?= gecko@FreeBSD.org
  54. MOZILLA?= ${PORTNAME}
  55. MOZILLA_VER?= ${PORTVERSION}
  56. MOZILLA_BIN?= ${PORTNAME}-bin
  57. MOZILLA_EXEC_NAME?=${MOZILLA}
  58. USES+= compiler:c++17-lang cpe gl gmake gnome iconv llvm:min=17,noexport localbase \
  59. pkgconfig python:build desktop-file-utils
  60. CPE_VENDOR?=mozilla
  61. USE_GL= gl
  62. USE_GNOME= cairo gdkpixbuf2 gtk30
  63. USE_XORG= x11 xcb xcomposite xdamage xext xfixes xrandr xrender xt xtst
  64. HAS_CONFIGURE= yes
  65. CONFIGURE_OUTSOURCE= yes
  66. LDFLAGS+= -Wl,--as-needed -Wl,--undefined-version
  67. BINARY_ALIAS+= python3=${PYTHON_CMD}
  68. BUNDLE_LIBS= yes
  69. BUILD_DEPENDS+= rust-cbindgen>=0.26.0:devel/rust-cbindgen \
  70. ${RUST_DEFAULT}>=1.78.0:lang/${RUST_DEFAULT} \
  71. node:www/node
  72. LIB_DEPENDS+= libdrm.so:graphics/libdrm
  73. RUN_DEPENDS+= ${LOCALBASE}/lib/libpci.so:devel/libpci
  74. LIB_DEPENDS+= libepoll-shim.so:devel/libepoll-shim
  75. MOZ_EXPORT+= ${CONFIGURE_ENV} \
  76. PYTHON3="${PYTHON_CMD}" \
  77. RUSTFLAGS="${RUSTFLAGS}"
  78. MOZ_OPTIONS+= --prefix="${PREFIX}"
  79. MOZ_MK_OPTIONS+=MOZ_OBJDIR="${BUILD_WRKSRC}"
  80. MOZ_OPTIONS+= --with-libclang-path="${LLVM_PREFIX:S/${PREFIX}/${LOCALBASE}/}/lib"
  81. . if !exists(/usr/bin/llvm-objdump)
  82. MOZ_EXPORT+= LLVM_OBJDUMP="${LOCALBASE}/bin/llvm-objdump${LLVM_VERSION}"
  83. . endif
  84. # Require newer Clang than what's in base system unless user opted out
  85. . if ${CC} == cc && ${CXX} == c++ && exists(/usr/lib/libc++.so)
  86. CPP= ${LOCALBASE}/bin/clang-cpp${LLVM_VERSION}
  87. CC= ${LOCALBASE}/bin/clang${LLVM_VERSION}
  88. CXX= ${LOCALBASE}/bin/clang++${LLVM_VERSION}
  89. USES:= ${USES:Ncompiler\:*} # XXX avoid warnings
  90. . endif
  91. MOZSRC?= ${WRKSRC}
  92. PLISTF?= ${WRKDIR}/plist_files
  93. MOZCONFIG?= ${WRKSRC}/.mozconfig
  94. MOZILLA_PLIST_DIRS?= bin lib share/pixmaps share/applications
  95. # Adjust -C target-cpu if -march/-mcpu is set by bsd.cpu.mk
  96. . if ${ARCH} == amd64 || ${ARCH} == i386
  97. RUSTFLAGS+= ${CFLAGS:M-march=*:S/-march=/-C target-cpu=/}
  98. . elif ${ARCH:Mpowerpc*}
  99. RUSTFLAGS+= ${CFLAGS:M-mcpu=*:S/-mcpu=/-C target-cpu=/:S/power/pwr/}
  100. . else
  101. RUSTFLAGS+= ${CFLAGS:M-mcpu=*:S/-mcpu=/-C target-cpu=/}
  102. . endif
  103. # Standard depends
  104. _ALL_DEPENDS= av1 event ffi graphite harfbuzz icu jpeg nspr nss png pixman sqlite vpx webp
  105. . if exists(${FILESDIR}/patch-bug1559213)
  106. av1_LIB_DEPENDS= libaom.so:multimedia/aom libdav1d.so:multimedia/dav1d
  107. av1_MOZ_OPTIONS= --with-system-av1
  108. . endif
  109. event_LIB_DEPENDS= libevent.so:devel/libevent
  110. event_MOZ_OPTIONS= --with-system-libevent
  111. ffi_LIB_DEPENDS= libffi.so:devel/libffi
  112. ffi_MOZ_OPTIONS= --enable-system-ffi
  113. . if exists(${FILESDIR}/patch-bug847568)
  114. graphite_LIB_DEPENDS= libgraphite2.so:graphics/graphite2
  115. graphite_MOZ_OPTIONS= --with-system-graphite2
  116. harfbuzz_LIB_DEPENDS= libharfbuzz.so:print/harfbuzz
  117. harfbuzz_MOZ_OPTIONS= --with-system-harfbuzz
  118. . endif
  119. icu_LIB_DEPENDS= libicui18n.so:devel/icu
  120. icu_MOZ_OPTIONS= --with-system-icu --with-intl-api
  121. -jpeg_BUILD_DEPENDS=yasm:devel/yasm
  122. jpeg_USES= jpeg
  123. jpeg_MOZ_OPTIONS= --with-system-jpeg=${LOCALBASE}
  124. nspr_LIB_DEPENDS= libnspr4.so:devel/nspr
  125. nspr_MOZ_OPTIONS= --with-system-nspr
  126. nss_LIB_DEPENDS= libnss3.so:security/nss
  127. nss_MOZ_OPTIONS= --with-system-nss
  128. pixman_LIB_DEPENDS= libpixman-1.so:x11/pixman
  129. pixman_MOZ_OPTIONS= --enable-system-pixman
  130. png_LIB_DEPENDS= libpng.so:graphics/png
  131. png_MOZ_OPTIONS= --with-system-png
  132. sqlite_LIB_DEPENDS= libsqlite3.so:databases/sqlite3
  133. sqlite_MOZ_OPTIONS= --enable-system-sqlite
  134. -vpx_BUILD_DEPENDS= yasm:devel/yasm
  135. vpx_LIB_DEPENDS= libvpx.so:multimedia/libvpx
  136. vpx_MOZ_OPTIONS= --with-system-libvpx
  137. webp_LIB_DEPENDS= libwebp.so:graphics/webp
  138. webp_MOZ_OPTIONS= --with-system-webp
  139. . for use in ${USE_MOZILLA}
  140. ${use:S/-/_WITHOUT_/}= ${TRUE}
  141. . endfor
  142. LIB_DEPENDS+= libfontconfig.so:x11-fonts/fontconfig \
  143. libfreetype.so:print/freetype2
  144. . for dep in ${_ALL_DEPENDS} ${USE_MOZILLA:M+*:S/+//}
  145. . if !defined(_WITHOUT_${dep})
  146. BUILD_DEPENDS+= ${${dep}_BUILD_DEPENDS}
  147. LIB_DEPENDS+= ${${dep}_LIB_DEPENDS}
  148. RUN_DEPENDS+= ${${dep}_RUN_DEPENDS}
  149. USES+= ${${dep}_USES}
  150. MOZ_OPTIONS+= ${${dep}_MOZ_OPTIONS}
  151. . else
  152. BUILD_DEPENDS+= ${-${dep}_BUILD_DEPENDS}
  153. . endif
  154. . endfor
  155. # Standard options
  156. MOZ_OPTIONS+= \
  157. --enable-update-channel=${PKGNAMESUFFIX:Urelease:S/^-//} \
  158. --disable-updater \
  159. --with-system-zlib
  160. # API keys from www/chromium
  161. # http://www.chromium.org/developers/how-tos/api-keys
  162. # Note: these are for FreeBSD use ONLY. For your own distribution,
  163. # please get your own set of keys.
  164. MOZ_EXPORT+= MOZ_GOOGLE_LOCATION_SERVICE_API_KEY=AIzaSyBsp9n41JLW8jCokwn7vhoaMejDFRd1mp8
  165. MOZ_EXPORT+= MOZ_GOOGLE_SAFEBROWSING_API_KEY=AIzaSyBsp9n41JLW8jCokwn7vhoaMejDFRd1mp8
  166. . if ${PORT_OPTIONS:MOPTIMIZED_CFLAGS}
  167. CFLAGS+= -O3
  168. MOZ_EXPORT+= MOZ_OPTIMIZE_FLAGS="${CFLAGS:M-O*}"
  169. MOZ_OPTIONS+= --enable-optimize
  170. . else
  171. MOZ_OPTIONS+= --disable-optimize
  172. . if ${/usr/bin/ld:L:tA} != /usr/bin/ld.lld
  173. # ld 2.17 barfs on Stylo built with -C opt-level=0
  174. USE_BINUTILS= yes
  175. LDFLAGS+= -B${LOCALBASE}/bin
  176. . endif
  177. . endif
  178. . if ${PORT_OPTIONS:MCANBERRA}
  179. RUN_DEPENDS+= libcanberra>0:audio/libcanberra
  180. . endif
  181. . if ${PORT_OPTIONS:MDBUS}
  182. BUILD_DEPENDS+= libnotify>0:devel/libnotify
  183. LIB_DEPENDS+= libdbus-1.so:devel/dbus \
  184. libdbus-glib-1.so:devel/dbus-glib
  185. . else
  186. MOZ_OPTIONS+= --disable-dbus
  187. . endif
  188. . if ${PORT_OPTIONS:MFFMPEG}
  189. # dom/media/platforms/ffmpeg/FFmpegRuntimeLinker.cpp
  190. RUN_DEPENDS+= ffmpeg>=6.0,1:multimedia/ffmpeg
  191. . endif
  192. . if ${PORT_OPTIONS:MLIBPROXY}
  193. LIB_DEPENDS+= libproxy.so:net/libproxy
  194. MOZ_OPTIONS+= --enable-libproxy
  195. . else
  196. MOZ_OPTIONS+= --disable-libproxy
  197. . endif
  198. . if ${PORT_OPTIONS:MLTO}
  199. MOZ_OPTIONS+= --enable-lto=cross
  200. . endif
  201. . if ${PORT_OPTIONS:MALSA}
  202. BUILD_DEPENDS+= ${LOCALBASE}/include/alsa/asoundlib.h:audio/alsa-lib
  203. MOZ_OPTIONS+= --enable-alsa
  204. . endif
  205. . if ${PORT_OPTIONS:MJACK}
  206. BUILD_DEPENDS+= ${LOCALBASE}/include/jack/jack.h:audio/jack
  207. MOZ_OPTIONS+= --enable-jack
  208. . endif
  209. . if ${PORT_OPTIONS:MPULSEAUDIO}
  210. BUILD_DEPENDS+= ${LOCALBASE}/include/pulse/pulseaudio.h:audio/pulseaudio
  211. MOZ_OPTIONS+= --enable-pulseaudio
  212. . else
  213. MOZ_OPTIONS+= --disable-pulseaudio
  214. . endif
  215. . if ${PORT_OPTIONS:MSNDIO}
  216. BUILD_DEPENDS+= ${LOCALBASE}/include/sndio.h:audio/sndio
  217. MOZ_OPTIONS+= --enable-sndio
  218. . else
  219. MOZ_OPTIONS+= --disable-sndio
  220. . endif
  221. . if ${PORT_OPTIONS:MDEBUG}
  222. MOZ_OPTIONS+= --enable-debug --disable-release
  223. STRIP= # ports/184285
  224. . else
  225. MOZ_OPTIONS+= --disable-debug --disable-debug-symbols --enable-release
  226. . if ${ARCH:Maarch64} || (defined(MACHINE_CPU) && ${MACHINE_CPU:Msse2})
  227. MOZ_OPTIONS+= --enable-rust-simd
  228. . endif
  229. . endif
  230. . if ${PORT_OPTIONS:MPROFILE}
  231. MOZ_OPTIONS+= --enable-profiling
  232. STRIP=
  233. . else
  234. MOZ_OPTIONS+= --disable-profiling
  235. . endif
  236. . if ${PORT_OPTIONS:MTEST}
  237. USE_XORG+= xscrnsaver
  238. MOZ_OPTIONS+= --enable-tests
  239. . else
  240. MOZ_OPTIONS+= --disable-tests
  241. . endif
  242. . if !defined(STRIP) || ${STRIP} == ""
  243. MOZ_OPTIONS+= --disable-strip --disable-install-strip
  244. . else
  245. MOZ_OPTIONS+= --enable-strip --enable-install-strip
  246. . endif
  247. # _MAKE_JOBS is only available after bsd.port.post.mk, thus cannot be
  248. # used in .mozconfig. And client.mk automatically uses -jN where N
  249. # is what multiprocessing.cpu_count() returns.
  250. . if defined(DISABLE_MAKE_JOBS) || defined(MAKE_JOBS_UNSAFE)
  251. MAKE_JOBS_NUMBER= 1
  252. . endif
  253. . if defined(MAKE_JOBS_NUMBER)
  254. MOZ_MAKE_FLAGS+=-j${MAKE_JOBS_NUMBER}
  255. . endif
  256. . if defined(MOZ_MAKE_FLAGS)
  257. MOZ_MK_OPTIONS+=MOZ_MAKE_FLAGS="${MOZ_MAKE_FLAGS}"
  258. . endif
  259. . if ${ARCH} == amd64
  260. . if ${USE_MOZILLA:M-nss}
  261. USE_BINUTILS= # intel-gcm.s
  262. CFLAGS+= -B${LOCALBASE}/bin
  263. LDFLAGS+= -B${LOCALBASE}/bin
  264. . endif
  265. . elif ${ARCH:Mpowerpc*}
  266. BUILD_DEPENDS+= as:devel/binutils
  267. . endif
  268. . else # bsd.port.post.mk
  269. post-patch: gecko-post-patch
  270. gecko-post-patch:
  271. @${RM} ${MOZCONFIG}
  272. . if !defined(NOMOZCONFIG)
  273. . for arg in ${MOZ_OPTIONS}
  274. @${ECHO_CMD} ac_add_options ${arg:Q} >> ${MOZCONFIG}
  275. . endfor
  276. . for arg in ${MOZ_MK_OPTIONS}
  277. @${ECHO_CMD} mk_add_options ${arg:Q} >> ${MOZCONFIG}
  278. . endfor
  279. . for var in ${MOZ_EXPORT}
  280. @${ECHO_CMD} export ${var:Q} >> ${MOZCONFIG}
  281. . endfor
  282. . endif # .if !defined(NOMOZCONFIG)
  283. . if ${USE_MOZILLA:M-nspr}
  284. @${ECHO_MSG} "===> Applying NSPR patches"
  285. @for i in ${.CURDIR}/../../devel/nspr/files/patch-*; do \
  286. ${PATCH} ${PATCH_ARGS} -d ${MOZSRC}/nsprpub < $$i; \
  287. done
  288. . endif
  289. . if ${USE_MOZILLA:M-nss}
  290. @${ECHO_MSG} "===> Applying NSS patches"
  291. @for i in ${.CURDIR}/../../security/nss/files/patch-*; do \
  292. ${PATCH} ${PATCH_ARGS} -d ${MOZSRC}/security/nss < $$i; \
  293. done
  294. . endif
  295. @if [ -f ${WRKSRC}/config/baseconfig.mk ] ; then \
  296. ${REINPLACE_CMD} -e 's|%%MOZILLA%%|${MOZILLA}|g' \
  297. ${WRKSRC}/config/baseconfig.mk; \
  298. fi
  299. @${REINPLACE_CMD} -e 's|%%MOZILLA%%|${MOZILLA}|g' \
  300. ${MOZSRC}/config/baseconfig.mk
  301. @${REINPLACE_CMD} -e 's|/usr/local/netscape|${LOCALBASE}|g ; \
  302. s|/usr/local/lib/netscape|${LOCALBASE}/lib|g' \
  303. ${MOZSRC}/xpcom/io/SpecialSystemDirectory.cpp
  304. @${REINPLACE_CMD} -e 's|/etc|${PREFIX}&|g' \
  305. ${MOZSRC}/xpcom/build/nsXPCOMPrivate.h
  306. @${REINPLACE_CMD} -e 's|/usr/local|${LOCALBASE}|g' \
  307. -e 's|mozilla/plugins|browser_plugins|g' \
  308. -e 's|share/mozilla/extensions|lib/xpi|g' \
  309. ${MOZSRC}/xpcom/io/nsAppFileLocationProvider.cpp \
  310. ${MOZSRC}/toolkit/xre/nsXREDirProvider.cpp
  311. # Disable vendor checksums like lang/rust
  312. @${REINPLACE_CMD} 's,"files":{[^}]*},"files":{},' \
  313. ${MOZSRC}/third_party/rust/*/.cargo-checksum.json
  314. pre-configure-script:
  315. # Check that the running kernel has COMPAT_FREEBSD11 required by lang/rust post-ino64
  316. @${SETENV} CC="${CC}" OPSYS="${OPSYS}" OSVERSION="${OSVERSION}" WRKDIR="${WRKDIR}" \
  317. ${SH} ${SCRIPTSDIR}/rust-compat11-canary.sh
  318. post-install-script: gecko-create-plist
  319. gecko-create-plist:
  320. # Create the plist
  321. ${RM} ${PLISTF}
  322. . for dir in ${MOZILLA_PLIST_DIRS}
  323. @cd ${STAGEDIR}${PREFIX}/${dir} && ${FIND} -H -s * ! -type d | \
  324. ${SED} -e 's|^|${dir}/|' >> ${PLISTF}
  325. . endfor
  326. ${CAT} ${PLISTF} | ${SORT} >> ${TMPPLIST}
  327. . endif
  328. .endif
  329. # HERE THERE BE TACOS -- adamw