Index: head/Mk/bsd.gecko.mk =================================================================== --- head/Mk/bsd.gecko.mk (revision 454669) +++ head/Mk/bsd.gecko.mk (revision 454670) @@ -1,599 +1,589 @@ #-*- tab-width: 4; -*- # ex:ts=4 # # Date created: 12 Nov 2005 # Whom: Michael Johnson # # $FreeBSD$ # # 4 column tabs prevent hair loss and tooth decay! # bsd.gecko.mk abstracts the selection of gecko-based backends. It allows users # and porters to support any available gecko backend without needing to build # many conditional tests. ${USE_GECKO} is the list of backends that your port # can handle, and ${GECKO} is set by bsd.gecko.mk to be the chosen backend. # Users set ${WITH_GECKO} to the list of gecko backends they want on their # system. .if defined(USE_GECKO) .if !defined(_POSTMKINCLUDED) && !defined(Gecko_Pre_Include) Gecko_Pre_Include= bsd.gecko.mk # This file contains some reusable components for mozilla ports. It's of # use primarily to apps from the mozilla project itself (such as Firefox, # Thunderbird, etc.), and probably won't be of use for gecko-based ports # like epiphany, galeon, etc. # # You need to make sure to add USE_GECKO=gecko to for your port can uses # one of these options below. # # Ports can use the following: # # USE_MOZILLA By default, it enables every system dependency # listed in '_ALL_DEPENDS'. If your port doesn't # need one of those then you can use '-' like # 'USE_MOZILLA= -png -vpx' to subtract the # dependencies. Experimental deps use '+' like # 'USE_MOZILLA= +speex +theora'. # # MOZILLA_PLIST_DIRS List of directories to descend into when installing # and creating the plist # # MOZ_PIS_SCRIPTS List of scripts residing in ${FILESDIR} to be # filtered through MOZCONFIG_SED and installed along # with our Pluggable Init Scripts (PIS) # # MOZ_SED_ARGS sed(1) commands through which MOZ_PIS_SCRIPTS are # filtered. There is a default set defined here, so # you probably want to add to MOZ_SED_ARGS rather # than clobber it # # MOZ_OPTIONS configure arguments (added to .mozconfig). If # NOMOZCONFIG is defined, you probably want to set # CONFIGURE_ARGS+=${MOZ_OPTIONS} # # MOZ_MK_OPTIONS The make(1) arguments (added to .mozconfig). If # NOMOZCONFIG is defined, you probably want to set # MAKE_ARGS+=${MOZ_MK_OPTIONS} # # MOZ_EXPORT Environment variables for the build process (added # to .mozconfig). If NOMOZCONFIG is defined, you # probably want to set MAKE_ENV+=${MOZ_EXPORT} # # MOZ_CHROME A variable for the --enable-chrome-format= in # CONFIGURE_ARGS. The default is omni. # # MOZ_TOOLKIT A variable for the --enable-default-toolkit= in # CONFIGURE_ARGS. The default is cairo-gtk2. # # MOZ_EXTENSIONS A list of extensions to build # # PORT_MOZCONFIG Defaults to ${FILESDIR}/mozconfig.in, but can be # set to a generic mozconfig included with the port # # NOMOZCONFIG Don't drop a customized .mozconfig into the build # directory. Options will have to be specified in # CONFIGURE_ARGS instead # MAINTAINER?= gecko@FreeBSD.org MOZILLA?= ${PORTNAME} MOZILLA_VER?= ${PORTVERSION} MOZILLA_BIN?= ${PORTNAME}-bin MOZILLA_EXEC_NAME?=${MOZILLA} MOZ_RPATH?= ${MOZILLA} USES+= cpe gmake iconv localbase perl5 pkgconfig \ python:2.7,build desktop-file-utils CPE_VENDOR?=mozilla USE_PERL5= build USE_XORG= x11 xcomposite xdamage xext xfixes xrender xt .if ${MOZILLA_VER:R:R} >= 49 USES+= compiler:c++14-lang CPPFLAGS+= -D_GLIBCXX_USE_C99 -D_GLIBCXX_USE_C99_MATH_TR1 \ -D_DECLARE_C99_LDBL_MATH # XXX ports/193528 .else USES+= compiler:c++11-lang .endif .if ${MOZILLA_VER:R:R} >= 50 USE_XORG+= xcb .endif .if ${MOZILLA_VER:R:R} >= 56 MESA_LLVM_VER?= 40 BUILD_DEPENDS+= llvm${MESA_LLVM_VER}>0:devel/llvm${MESA_LLVM_VER} MOZ_EXPORT+= LLVM_CONFIG=llvm-config${MESA_LLVM_VER} MOZ_EXPORT+= BINDGEN_CFLAGS="${BINDGEN_CFLAGS}" # XXX bug 1341234 . if ! ${USE_MOZILLA:M-nspr} BINDGEN_CFLAGS+=-isystem${LOCALBASE}/include/nspr . endif . if ! ${USE_MOZILLA:M-pixman} BINDGEN_CFLAGS+=-isystem${LOCALBASE}/include/pixman-1 . endif .endif .if ${OPSYS} == FreeBSD && ${OSREL} == 11.1 LLD_UNSAFE= yes .endif MOZILLA_SUFX?= none MOZSRC?= ${WRKSRC} WRKSRC?= ${WRKDIR}/mozilla PLISTF?= ${WRKDIR}/plist_files MOZ_OBJDIR?= ${WRKSRC}/obj-${ARCH:C/amd64/x86_64/}-unknown-${OPSYS:tl}${OSREL} MOZ_PIS_DIR?= lib/${MOZILLA}/init.d PORT_MOZCONFIG?= ${FILESDIR}/mozconfig.in MOZCONFIG?= ${WRKSRC}/.mozconfig # XXX Not ?= because fmake uses MAKEFILE internally MAKEFILE= ${WRKSRC}/client.mk MOZILLA_PLIST_DIRS?= bin lib share/pixmaps share/applications PKGINSTALL?= ${WRKDIR}/pkg-install PKGDEINSTALL?= ${WRKDIR}/pkg-deinstall PKGINSTALL_INC?= ${.CURDIR}/../../www/firefox/files/pkg-install.in PKGDEINSTALL_INC?= ${.CURDIR}/../../www/firefox/files/pkg-deinstall.in MOZ_PKGCONFIG_FILES?= ${MOZILLA}-gtkmozembed ${MOZILLA}-js \ ${MOZILLA}-xpcom ${MOZILLA}-plugin ALL_TARGET?= build MOZ_EXPORT+= ${CONFIGURE_ENV} \ PERL="${PERL}" MOZ_OPTIONS+= --prefix="${PREFIX}" MOZ_MK_OPTIONS+=MOZ_OBJDIR="${MOZ_OBJDIR}" LDFLAGS+= -Wl,--as-needed .if ${MOZILLA_VER:R:R} < 55 && ${OPSYS} == FreeBSD && ${OSVERSION} < 1200032 # use jemalloc 3.0.0 (4.0 for firefox 43+) API for stats/tuning MOZ_EXPORT+= MOZ_JEMALLOC4=1 .if ${MOZILLA_VER:R:R} >= 48 MOZ_OPTIONS+= --enable-jemalloc=4 .elif ${OSVERSION} < 1100079 MOZ_OPTIONS+= --enable-jemalloc .endif # Mozilla >= 48 .endif # Mozilla < 55 # Standard depends _ALL_DEPENDS= cairo event ffi graphite harfbuzz hunspell icu jpeg nspr nss png pixman soundtouch sqlite vpx .if ${PORT_OPTIONS:MINTEGER_SAMPLES} MOZ_EXPORT+= MOZ_INTEGER_SAMPLES=1 _ALL_DEPENDS+= tremor .else _ALL_DEPENDS+= vorbis .endif .if ! ${PORT_OPTIONS:MBUNDLED_CAIRO} cairo_BUILD_DEPENDS=cairo>=1.12.16_1,2:graphics/cairo cairo_LIB_DEPENDS= libcairo.so:graphics/cairo cairo_MOZ_OPTIONS= --enable-system-cairo .endif event_LIB_DEPENDS= libevent.so:devel/libevent event_MOZ_OPTIONS= --with-system-libevent ffi_LIB_DEPENDS= libffi.so:devel/libffi ffi_MOZ_OPTIONS= --enable-system-ffi .if exists(${FILESDIR}/patch-bug847568) graphite_LIB_DEPENDS= libgraphite2.so:graphics/graphite2 graphite_MOZ_OPTIONS= --with-system-graphite2 harfbuzz_LIB_DEPENDS= libharfbuzz.so:print/harfbuzz harfbuzz_MOZ_OPTIONS= --with-system-harfbuzz .endif hunspell_LIB_DEPENDS= libhunspell-1.6.so:textproc/hunspell hunspell_MOZ_OPTIONS= --enable-system-hunspell icu_LIB_DEPENDS= libicui18n.so:devel/icu icu_MOZ_OPTIONS= --with-system-icu --with-intl-api -jpeg_BUILD_DEPENDS=yasm:devel/yasm # XXX Remove files/patch-ijg-libjpeg once -turbo is default jpeg_USES= jpeg jpeg_MOZ_OPTIONS= --with-system-jpeg=${LOCALBASE} nspr_LIB_DEPENDS= libnspr4.so:devel/nspr nspr_MOZ_OPTIONS= --with-system-nspr nss_LIB_DEPENDS= libnss3.so:security/nss nss_MOZ_OPTIONS= --with-system-nss pixman_LIB_DEPENDS= libpixman-1.so:x11/pixman pixman_MOZ_OPTIONS= --enable-system-pixman png_LIB_DEPENDS= libpng.so:graphics/png png_MOZ_OPTIONS= --with-system-png=${LOCALBASE} .if exists(${FILESDIR}/patch-z-bug517422) soundtouch_LIB_DEPENDS= libSoundTouch.so:audio/soundtouch soundtouch_MOZ_OPTIONS= --with-system-soundtouch .endif sqlite_LIB_DEPENDS= libsqlite3.so:databases/sqlite3 sqlite_MOZ_OPTIONS= --enable-system-sqlite .if exists(${FILESDIR}/patch-z-bug517422) # XXX disabled: update to 1.2.x or review backported fixes theora_LIB_DEPENDS= libtheora.so:multimedia/libtheora theora_MOZ_OPTIONS= --with-system-theora tremor_LIB_DEPENDS= libogg.so:audio/libogg libvorbisidec.so:audio/libtremor tremor_MOZ_OPTIONS= --with-system-tremor --with-system-ogg vorbis_LIB_DEPENDS= libogg.so:audio/libogg libvorbis.so:audio/libvorbis vorbis_MOZ_OPTIONS= --with-system-vorbis --with-system-ogg .endif -vpx_BUILD_DEPENDS= yasm:devel/yasm vpx_LIB_DEPENDS= libvpx.so:multimedia/libvpx vpx_MOZ_OPTIONS= --with-system-libvpx .for use in ${USE_MOZILLA} ${use:S/-/_WITHOUT_/}= ${TRUE} .endfor LIB_DEPENDS+= libfontconfig.so:x11-fonts/fontconfig \ libfreetype.so:print/freetype2 .for dep in ${_ALL_DEPENDS} ${USE_MOZILLA:M+*:S/+//} .if !defined(_WITHOUT_${dep}) BUILD_DEPENDS+= ${${dep}_BUILD_DEPENDS} LIB_DEPENDS+= ${${dep}_LIB_DEPENDS} RUN_DEPENDS+= ${${dep}_RUN_DEPENDS} USES+= ${${dep}_USES} MOZ_OPTIONS+= ${${dep}_MOZ_OPTIONS} .else BUILD_DEPENDS+= ${-${dep}_BUILD_DEPENDS} .endif .endfor # Standard options MOZ_CHROME?= omni MOZ_TOOLKIT?= cairo-gtk3 MOZ_CHANNEL?= ${PKGNAMESUFFIX:Urelease:S/^-//} MOZ_OPTIONS+= \ --enable-chrome-format=${MOZ_CHROME} \ --enable-default-toolkit=${MOZ_TOOLKIT} \ --enable-update-channel=${MOZ_CHANNEL} \ --disable-updater \ --enable-pie \ --with-pthreads # Configure options for install .if !defined(MOZ_EXTENSIONS) MOZ_OPTIONS+= --enable-extensions=default .else MOZ_OPTIONS+= --enable-extensions=${MOZ_EXTENSIONS} .endif # others MOZ_OPTIONS+= --with-system-zlib \ --with-system-bz2 # API keys from www/chromium # http://www.chromium.org/developers/how-tos/api-keys # Note: these are for FreeBSD use ONLY. For your own distribution, # please get your own set of keys. MOZ_EXPORT+= MOZ_GOOGLE_API_KEY=AIzaSyBsp9n41JLW8jCokwn7vhoaMejDFRd1mp8 .if ${PORT_OPTIONS:MGTK2} MOZ_TOOLKIT= cairo-gtk2 .endif .if ${MOZ_TOOLKIT:Mcairo-gtk3} BUILD_DEPENDS+= gtk3>=3.14.6:x11-toolkits/gtk30 USE_GNOME+= gdkpixbuf2 gtk20 gtk30 .else # gtk2, cairo-gtk2 USE_GNOME+= gdkpixbuf2 gtk20 .endif .if ${PORT_OPTIONS:MOPTIMIZED_CFLAGS} CFLAGS+= -O3 MOZ_EXPORT+= MOZ_OPTIMIZE_FLAGS="${CFLAGS:M-O*}" MOZ_OPTIONS+= --enable-optimize .else MOZ_OPTIONS+= --disable-optimize .endif .if ${PORT_OPTIONS:MCANBERRA} RUN_DEPENDS+= libcanberra>0:audio/libcanberra .endif .if ${PORT_OPTIONS:MDBUS} BUILD_DEPENDS+= libnotify>0:devel/libnotify LIB_DEPENDS+= libdbus-1.so:devel/dbus \ libdbus-glib-1.so:devel/dbus-glib \ libstartup-notification-1.so:x11/startup-notification MOZ_OPTIONS+= --enable-startup-notification .else MOZ_OPTIONS+= --disable-dbus .endif .if ${PORT_OPTIONS:MFFMPEG} # dom/media/platforms/ffmpeg/FFmpegRuntimeLinker.cpp RUN_DEPENDS+= ffmpeg>=0.8,1:multimedia/ffmpeg .endif .if ${MOZILLA_VER:R:R} < 46 MOZ_OPTIONS+= --disable-gstreamer .endif .if ${PORT_OPTIONS:MGCONF} BUILD_DEPENDS+= ${gconf2_DETECT}:${gconf2_LIB_DEPENDS:C/.*://} USE_GNOME+= gconf2:build MOZ_OPTIONS+= --enable-gconf .else MOZ_OPTIONS+= --disable-gconf .endif -.if ${MOZILLA_VER:R:R} < 55 -.if ${PORT_OPTIONS:MGNOMEUI} -BUILD_DEPENDS+= ${libgnomeui_DETECT}:${libgnomeui_LIB_DEPENDS:C/.*://} -USE_GNOME+= libgnomeui:build -MOZ_OPTIONS+= --enable-gnomeui -.else -MOZ_OPTIONS+= --disable-gnomeui -.endif -.endif # Mozilla < 55 - .if ${PORT_OPTIONS:MLIBPROXY} LIB_DEPENDS+= libproxy.so:net/libproxy MOZ_OPTIONS+= --enable-libproxy .else MOZ_OPTIONS+= --disable-libproxy .endif .if ${PORT_OPTIONS:MALSA} LIB_DEPENDS+= libasound.so:audio/alsa-lib RUN_DEPENDS+= ${LOCALBASE}/lib/alsa-lib/libasound_module_pcm_oss.so:audio/alsa-plugins RUN_DEPENDS+= alsa-lib>=1.1.1_1:audio/alsa-lib MOZ_OPTIONS+= --enable-alsa .endif .if ${PORT_OPTIONS:MJACK} BUILD_DEPENDS+= ${LOCALBASE}/include/jack/jack.h:audio/jack MOZ_OPTIONS+= --enable-jack .endif .if ${PORT_OPTIONS:MPULSEAUDIO} BUILD_DEPENDS+= ${LOCALBASE}/include/pulse/pulseaudio.h:audio/pulseaudio MOZ_OPTIONS+= --enable-pulseaudio .else MOZ_OPTIONS+= --disable-pulseaudio .endif .if ${PORT_OPTIONS:MSNDIO} LIB_DEPENDS+= libsndio.so:audio/sndio post-patch-SNDIO-on: @${REINPLACE_CMD} -e 's|OpenBSD|${OPSYS}|g' \ ${MOZSRC}/media/libcubeb/src/moz.build \ ${MOZSRC}/toolkit/library/moz.build . for tests in tests gtest @if [ -f "${MOZSRC}/media/libcubeb/${tests}/moz.build" ]; then \ ${REINPLACE_CMD} -e 's|OpenBSD|${OPSYS}|g' \ ${MOZSRC}/media/libcubeb/${tests}/moz.build \ ; fi . endfor @${REINPLACE_CMD} -e 's|OS==\"openbsd\"|OS==\"${OPSYS:tl}\"|g' \ ${MOZSRC}/media/webrtc/trunk/webrtc/build/common.gypi @${ECHO} "OS_LIBS += ['sndio']" >> \ ${MOZSRC}/media/webrtc/signaling/test/common.build .endif .if ${PORT_OPTIONS:MRUST} || ${MOZILLA_VER:R:R} >= 54 BUILD_DEPENDS+= ${RUST_PORT:T}>=1.19.0_2:${RUST_PORT} RUST_PORT?= lang/rust . if ${MOZILLA_VER:R:R} < 54 MOZ_OPTIONS+= --enable-rust . endif .else MOZ_OPTIONS+= --disable-rust .endif .if ${PORT_OPTIONS:MDEBUG} MOZ_OPTIONS+= --enable-debug --disable-release STRIP= # ports/184285 .else MOZ_OPTIONS+= --disable-debug --disable-debug-symbols --enable-release . if ${MOZILLA_VER:R:R} >= 56 MOZ_OPTIONS+= --enable-rust-simd . endif .endif .if ${PORT_OPTIONS:MDTRACE} MOZ_OPTIONS+= --enable-dtrace \ --disable-gold . if ${OPSYS} == FreeBSD && ${OSVERSION} < 1100061 LIBS+= -lelf . endif STRIP= .else MOZ_OPTIONS+= --disable-dtrace .endif .if ${PORT_OPTIONS:MPROFILE} MOZ_OPTIONS+= --enable-profiling STRIP= .else MOZ_OPTIONS+= --disable-profiling .endif .if ${PORT_OPTIONS:MTEST} USE_XORG+= xscrnsaver MOZ_OPTIONS+= --enable-tests .else MOZ_OPTIONS+= --disable-tests .endif .if !defined(STRIP) || ${STRIP} == "" MOZ_OPTIONS+= --disable-strip --disable-install-strip .else MOZ_OPTIONS+= --enable-strip --enable-install-strip .endif # _MAKE_JOBS is only available after bsd.port.post.mk, thus cannot be # used in .mozconfig. And client.mk automatically uses -jN where N # is what multiprocessing.cpu_count() returns. .if defined(DISABLE_MAKE_JOBS) || defined(MAKE_JOBS_UNSAFE) MAKE_JOBS_NUMBER= 1 .endif .if defined(MAKE_JOBS_NUMBER) MOZ_MAKE_FLAGS+=-j${MAKE_JOBS_NUMBER} .endif .if defined(MOZ_MAKE_FLAGS) MOZ_MK_OPTIONS+=MOZ_MAKE_FLAGS="${MOZ_MAKE_FLAGS}" .endif MOZ_SED_ARGS+= -e's|@CPPFLAGS@|${CPPFLAGS}|g' \ -e 's|@CFLAGS@|${CFLAGS}|g' \ -e 's|@LDFLAGS@|${LDFLAGS}|g' \ -e 's|@LIBS@|${LIBS}|g' \ -e 's|@LOCALBASE@|${LOCALBASE}|g' \ -e 's|@PERL@|${PERL}|g' \ -e 's|@MOZDIR@|${PREFIX}/lib/${MOZILLA}|g' \ -e 's|%%PREFIX%%|${PREFIX}|g' \ -e 's|%%CFLAGS%%|${CFLAGS}|g' \ -e 's|%%LDFLAGS%%|${LDFLAGS}|g' \ -e 's|%%LIBS%%|${LIBS}|g' \ -e 's|%%LOCALBASE%%|${LOCALBASE}|g' \ -e 's|%%PERL%%|${PERL}|g' \ -e 's|%%MOZILLA%%|${MOZILLA}|g' \ -e 's|%%MOZILLA_BIN%%|${MOZILLA_BIN}|g' \ -e 's|%%MOZDIR%%|${PREFIX}/lib/${MOZILLA}|g' MOZCONFIG_SED?= ${SED} ${MOZ_SED_ARGS} .if ${ARCH} == amd64 . if ${USE_MOZILLA:M-nss} USE_BINUTILS= # intel-gcm.s CFLAGS+= -B${LOCALBASE}/bin LDFLAGS+= -B${LOCALBASE}/bin . endif .elif ${ARCH:Mpowerpc*} . if ${ARCH} == "powerpc64" MOZ_EXPORT+= UNAME_m="${ARCH}" CFLAGS+= -mminimal-toc . endif .elif ${ARCH} == "sparc64" # Work around miscompilation/mislinkage of the sCanonicalVTable hacks. MOZ_OPTIONS+= --disable-v1-string-abi .endif .else # bsd.port.post.mk post-patch: gecko-post-patch gecko-moz-pis-patch gecko-post-patch: .if exists(${PKGINSTALL_INC}) @${MOZCONFIG_SED} < ${PKGINSTALL_INC} > ${PKGINSTALL} .endif .if exists(${PKGDEINSTALL_INC}) @${MOZCONFIG_SED} < ${PKGDEINSTALL_INC} > ${PKGDEINSTALL} .endif @${RM} ${MOZCONFIG} .if !defined(NOMOZCONFIG) @if [ -e ${PORT_MOZCONFIG} ] ; then \ ${MOZCONFIG_SED} < ${PORT_MOZCONFIG} >> ${MOZCONFIG} ; \ fi .for arg in ${MOZ_OPTIONS} @${ECHO_CMD} ac_add_options ${arg:Q} >> ${MOZCONFIG} .endfor .for arg in ${MOZ_MK_OPTIONS} @${ECHO_CMD} mk_add_options ${arg:Q} >> ${MOZCONFIG} .endfor .for var in ${MOZ_EXPORT} @${ECHO_CMD} export ${var:Q} >> ${MOZCONFIG} .endfor .endif # .if !defined(NOMOZCONFIG) .if exists(${MOZSRC}/build/unix/mozilla-config.in) @${REINPLACE_CMD} -e 's/%{idldir}/%idldir%/g ; \ s|"%FULL_NSPR_CFLAGS%"|`nspr-config --cflags`|g ; \ s|"%FULL_NSPR_LIBS%"|`nspr-config --libs`|g' \ ${MOZSRC}/build/unix/mozilla-config.in .endif .if ${USE_MOZILLA:M-nspr} @${ECHO_MSG} "===> Applying NSPR patches" @for i in ${.CURDIR}/../../devel/nspr/files/patch-*; do \ ${PATCH} ${PATCH_ARGS} -d ${MOZSRC}/nsprpub < $$i; \ done .endif .if ${USE_MOZILLA:M-nss} @${ECHO_MSG} "===> Applying NSS patches" @for i in ${.CURDIR}/../../security/nss/files/patch-*; do \ ${PATCH} ${PATCH_ARGS} -d ${MOZSRC}/security/nss < $$i; \ done .endif @for f in \ ${WRKSRC}/directory/c-sdk/config/FreeBSD.mk \ ${WRKSRC}/directory/c-sdk/configure \ ${MOZSRC}/security/coreconf/FreeBSD.mk \ ${MOZSRC}/js/src/Makefile.in \ ${MOZSRC}/js/src/configure \ ${MOZSRC}/configure \ ${WRKSRC}/configure; do \ if [ -f $$f ] ; then \ ${REINPLACE_CMD} -Ee 's|-lc_r|-pthread|g ; \ s|-l?pthread|-pthread|g ; \ s|echo aout|echo elf|g ; \ s|/usr/X11R6|${LOCALBASE}|g' \ $$f; \ fi; \ done @if [ -f ${WRKSRC}/config/baseconfig.mk ] ; then \ ${REINPLACE_CMD} -e 's|%%MOZILLA%%|${MOZILLA}|g' \ ${WRKSRC}/config/baseconfig.mk; \ fi @${REINPLACE_CMD} -e 's|%%MOZILLA%%|${MOZILLA}|g' \ ${MOZSRC}/config/baseconfig.mk @${REINPLACE_CMD} -e 's|%%PREFIX%%|${PREFIX}|g ; \ s|%%LOCALBASE%%|${LOCALBASE}|g' \ ${MOZSRC}/build/unix/run-mozilla.sh @${REINPLACE_CMD} -e 's|/usr/local/netscape|${LOCALBASE}|g ; \ s|/usr/local/lib/netscape|${LOCALBASE}/lib|g' \ ${MOZSRC}/xpcom/io/SpecialSystemDirectory.cpp @${REINPLACE_CMD} -e 's|/etc|${PREFIX}&|g' \ ${MOZSRC}/xpcom/build/nsXPCOMPrivate.h @${REINPLACE_CMD} -e 's|/usr/local|${LOCALBASE}|g' \ -e 's|mozilla/plugins|browser_plugins|g' \ -e 's|share/mozilla/extensions|lib/xpi|g' \ ${MOZSRC}/xpcom/io/nsAppFileLocationProvider.cpp \ ${MOZSRC}/toolkit/xre/nsXREDirProvider.cpp @${REINPLACE_CMD} -e 's|%%LOCALBASE%%|${LOCALBASE}|g' \ ${MOZSRC}/extensions/spellcheck/hunspell/*/mozHunspell.cpp # handles mozilla pis scripts. gecko-moz-pis-patch: .for moz in ${MOZ_PIS_SCRIPTS} @${MOZCONFIG_SED} < ${FILESDIR}/${moz} > ${WRKDIR}/${moz} .endfor pre-install: gecko-moz-pis-pre-install post-install-script: gecko-create-plist gecko-create-plist: # Create the plist ${RM} ${PLISTF} .for dir in ${MOZILLA_PLIST_DIRS} @cd ${STAGEDIR}${PREFIX}/${dir} && ${FIND} -H -s * ! -type d | \ ${SED} -e 's|^|${dir}/|' >> ${PLISTF} .endfor ${CAT} ${PLISTF} | ${SORT} >> ${TMPPLIST} gecko-moz-pis-pre-install: .if defined(MOZ_PIS_SCRIPTS) ${MKDIR} ${STAGEDIR}${PREFIX}/${MOZ_PIS_DIR} .for moz in ${MOZ_PIS_SCRIPTS} ${INSTALL_SCRIPT} ${WRKDIR}/${moz} ${STAGEDIR}${PREFIX}/${MOZ_PIS_DIR} .endfor .endif .endif .endif # HERE THERE BE TACOS -- adamw Index: head/www/firefox/Makefile =================================================================== --- head/www/firefox/Makefile (revision 454669) +++ head/www/firefox/Makefile (revision 454670) @@ -1,73 +1,72 @@ # Created by: Alan Eldridge # $FreeBSD$ PORTNAME= firefox DISTVERSION= 57.0 DISTVERSIONSUFFIX=.source PORTEPOCH= 1 CATEGORIES= www ipv6 MASTER_SITES= MOZILLA/${PORTNAME}/releases/${DISTVERSION}/source \ MOZILLA/${PORTNAME}/candidates/${DISTVERSION}-candidates/build4/source MAINTAINER= gecko@FreeBSD.org COMMENT= Web browser based on the browser portion of Mozilla BUILD_DEPENDS= nspr>=4.17:devel/nspr \ nss>=3.33:security/nss \ icu>=59.1,1:devel/icu \ libevent>=2.1.8:devel/libevent \ harfbuzz>=1.5.1:print/harfbuzz \ graphite2>=1.3.10:graphics/graphite2 \ png>=1.6.31:graphics/png \ libvorbis>=1.3.5,3:audio/libvorbis \ libvpx>=1.5.0:multimedia/libvpx \ sqlite3>=3.20.1:databases/sqlite3 \ ${PYTHON_PKGNAMEPREFIX}sqlite3>0:databases/py-sqlite3 \ v4l_compat>0:multimedia/v4l_compat \ autoconf-2.13:devel/autoconf213 \ yasm:devel/yasm \ zip:archivers/zip # soundtouch>=1.9.0:audio/soundtouch \ LIB_DEPENDS= libv4l2.so:multimedia/libv4l USE_GECKO= gecko CONFLICTS_INSTALL= firefox-esr MOZ_PKGCONFIG_FILES= # empty USE_MOZILLA= -soundtouch MOZILLA_NAME= Firefox USE_GL= gl USES= tar:xz FIREFOX_ICON= ${MOZILLA}.png FIREFOX_ICON_SRC= ${PREFIX}/lib/${MOZILLA}/browser/chrome/icons/default/default48.png MOZ_OPTIONS= --enable-application=browser \ --enable-official-branding OPTIONS_DEFAULT= BUNDLED_CAIRO -OPTIONS_EXCLUDE= GNOMEUI .include "${.CURDIR}/../../www/firefox/Makefile.options" WRKSRC:= ${WRKDIR}/${PORTNAME}-${DISTVERSION} post-extract: @${SED} -e 's|@FIREFOX_ICON@|${FIREFOX_ICON}|' -e 's|@MOZILLA@|${MOZILLA}|' \ -e 's|@MOZILLA_NAME@|${MOZILLA_NAME}|' \ <${FILESDIR}/firefox.desktop.in >${WRKDIR}/${MOZILLA}.desktop post-patch: @${REINPLACE_CMD} -e 's|%%LOCALBASE%%|${LOCALBASE}|g' \ ${WRKSRC}/browser/app/nsBrowserApp.cpp pre-configure: (cd ${WRKSRC} && ${LOCALBASE}/bin/autoconf-2.13) (cd ${WRKSRC}/js/src/ && ${LOCALBASE}/bin/autoconf-2.13) post-install: ${MKDIR} ${STAGEDIR}${PREFIX}/share/pixmaps ${INSTALL_DATA} ${WRKDIR}/${MOZILLA}.desktop ${STAGEDIR}${PREFIX}/share/applications/ ${LN} -sf ${FIREFOX_ICON_SRC} ${STAGEDIR}${PREFIX}/share/pixmaps/${FIREFOX_ICON} .include Index: head/www/firefox/Makefile.options =================================================================== --- head/www/firefox/Makefile.options (revision 454669) +++ head/www/firefox/Makefile.options (revision 454670) @@ -1,33 +1,32 @@ # -*- makefile-bsdmake -*- OPTIONS_DEFINE+= BUNDLED_CAIRO CANBERRA DBUS DEBUG DTRACE FFMPEG GCONF \ - GNOMEUI INTEGER_SAMPLES LIBPROXY \ + INTEGER_SAMPLES LIBPROXY \ OPTIMIZED_CFLAGS PROFILE TEST OPTIONS_DEFAULT+= DBUS DTRACE FFMPEG OPTIMIZED_CFLAGS PROFILE \ ${OPTIONS_MULTI_AUDIO:NSNDIO} \ ${MACHINE_CPU:Msoftfp:C/.+/INTEGER_SAMPLES/} OPTIONS_MULTI+= AUDIO OPTIONS_MULTI_AUDIO= ALSA JACK PULSEAUDIO SNDIO # WebRTC legacy audio library only supports ALSA and PulseAudio JACK_IMPLIES= ALSA # No lazy-bindings and inconsistent fallback order (libcubeb vs. audio_device) SNDIO_PREVENTS= ${OPTIONS_MULTI_AUDIO:NSNDIO} # dragonfly, sparc64, riscv .if !exists(/usr/sbin/dtrace) OPTIONS_EXCLUDE+= DTRACE .endif # ld(1) fails to link probes: Relocations in generic ELF (EM: 0) OPTIONS_EXCLUDE_aarch64= DTRACE BUNDLED_CAIRO_DESC?= Use bundled fork of cairo-1.9.5 CANBERRA_DESC?= Sound theme alerts -GNOMEUI_DESC?= libgnomeui support module INTEGER_SAMPLES_DESC?= Integer audio sample format LIBPROXY_DESC?= Proxy support via libproxy LIGHTNING_DESC?= Calendar extension RUST_DESC?= Build with components written in Rust language Index: head/www/libxul/Makefile =================================================================== --- head/www/libxul/Makefile (revision 454669) +++ head/www/libxul/Makefile (revision 454670) @@ -1,81 +1,81 @@ # Created by: Michael Johnson # $FreeBSD$ PORTNAME= libxul DISTVERSION= 45.9.0 -PORTREVISION= 7 +PORTREVISION= 8 CATEGORIES?= www devel MASTER_SITES= MOZILLA/firefox/releases/${DISTVERSION}esr/source \ MOZILLA/firefox/candidates/${DISTVERSION}esr-candidates/build3/source DISTNAME= firefox-${DISTVERSION}esr.source MAINTAINER?= gecko@FreeBSD.org COMMENT?= Mozilla runtime package that can be used to bootstrap XUL+XPCOM apps BUILD_DEPENDS= nspr>=4.12:devel/nspr \ nss>=3.21.3:security/nss \ libevent>=2.0.21_2:devel/libevent \ soundtouch>=1.9.0:audio/soundtouch \ harfbuzz>=1.1.0:print/harfbuzz \ graphite2>=1.3.6:graphics/graphite2 \ png>=1.6.19:graphics/png \ libvorbis>=1.3.5,3:audio/libvorbis \ libvpx>=1.5.0:multimedia/libvpx \ sqlite3>=3.9.1:databases/sqlite3 \ ${PYTHON_PKGNAMEPREFIX}sqlite3>0:databases/py-sqlite3 \ v4l_compat>0:multimedia/v4l_compat \ autoconf-2.13:devel/autoconf213 \ yasm:devel/yasm \ zip:archivers/zip LIB_DEPENDS= libv4l2.so:multimedia/libv4l WRKSRC:= ${WRKDIR}/firefox-${DISTVERSION}esr USE_GL= gl USES= pathfix shebangfix tar:xz SHEBANG_FILES= xpcom/idl-parser/xpidl/xpidl.py \ xpcom/typelib/xpt/tools/xpt.py MAKE_ENV= SKIP_GRE_REGISTRATION=1 mozappdir=${PREFIX}/lib/${MOZILLA} LDFLAGS+= -Wl,-rpath,${PREFIX}/lib/${MOZ_RPATH} USE_LDCONFIG= ${PREFIX}/lib/${MOZILLA} BUNDLE_LIBS= yes MOZ_OPTIONS?= --enable-application=xulrunner MOZ_CHANNEL= esr USE_GECKO= gecko CPE_PRODUCT= firefox_esr MOZILLA_EXEC_NAME=xulrunner USE_MOZILLA= # empty MOZILLA_PLIST_DIRS= bin include lib share/idl libdata MOZ_PKGCONFIG_FILES= libxul-embedding libxul mozilla-js \ mozilla-plugin OPTIONS_DEFINE= RUST OPTIONS_DEFAULT= BUNDLED_CAIRO GTK2 OPTIONS_SINGLE+= TOOLKIT OPTIONS_SINGLE_TOOLKIT= GTK2 GTK3 .include "${.CURDIR}/../../www/firefox/Makefile.options" OPTIONS_MULTI_AUDIO:= ${OPTIONS_MULTI_AUDIO:NJACK} .if ${USE_MOZILLA:M-nss} MOZ_PKGCONFIG_FILES+= mozilla-nss .endif post-patch: @${REINPLACE_CMD} -e 's|%%LOCALBASE%%|${LOCALBASE}|g' \ ${WRKSRC}/xulrunner/stub/nsXULStub.cpp pre-configure: (cd ${WRKSRC} && ${LOCALBASE}/bin/autoconf-2.13) (cd ${WRKSRC}/js/src/ && ${LOCALBASE}/bin/autoconf-2.13) post-build: @${REINPLACE_CMD} -e "s|\(Libs:.*\)\($$\)|\1 -Wl,-rpath,${PREFIX}/lib/${MOZ_RPATH}\2| ; \ s|%sdkdir%|%sdkdir%/sdk|g ; \ s|%%MOZ_LIBDIR%%|${PREFIX}/lib/${MOZILLA}|g" \ ${WRKSRC}/xulrunner/installer/*.pc.in || ${TRUE} .include Index: head/www/libxul/files/patch-bug694570 =================================================================== --- head/www/libxul/files/patch-bug694570 (nonexistent) +++ head/www/libxul/files/patch-bug694570 (revision 454670) @@ -0,0 +1,794 @@ +diff --git toolkit/xre/nsAppRunner.cpp toolkit/xre/nsAppRunner.cpp +index b4077bc883f1..d088dcb3fa46 100644 +--- toolkit/xre/nsAppRunner.cpp ++++ toolkit/xre/nsAppRunner.cpp +@@ -275,6 +275,7 @@ SaveToEnv(const char *putenv) + if (expr) + PR_SetEnv(expr); + // We intentionally leak |expr| here since it is required by PR_SetEnv. ++ MOZ_LSAN_INTENTIONALLY_LEAK_OBJECT(expr); + } + + // Tests that an environment variable exists and has a value +diff --git toolkit/xre/nsNativeAppSupportUnix.cpp toolkit/xre/nsNativeAppSupportUnix.cpp +index 96ee13034f77..75652e38f5db 100644 +--- toolkit/xre/nsNativeAppSupportUnix.cpp ++++ toolkit/xre/nsNativeAppSupportUnix.cpp +@@ -1,4 +1,5 @@ +-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ ++/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ ++/* vim: set ts=8 sts=2 et sw=2 tw=80: */ + /* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +@@ -33,7 +34,12 @@ + + #ifdef MOZ_X11 + #include +-#include ++#include ++#include ++#include ++#include "nsThreadUtils.h" ++ ++#include + #endif + + #ifdef MOZ_ENABLE_DBUS +@@ -46,94 +52,398 @@ + You have GTK+ %d.%d.\nThis application requires GTK+ %d.%d or newer.\n\n\ + Please upgrade your GTK+ library if you wish to use this application." + +-typedef struct _GnomeProgram GnomeProgram; +-typedef struct _GnomeModuleInfo GnomeModuleInfo; +-typedef struct _GnomeClient GnomeClient; +- +-typedef enum { +- GNOME_SAVE_GLOBAL, +- GNOME_SAVE_LOCAL, +- GNOME_SAVE_BOTH +-} GnomeSaveStyle; +- +-typedef enum { +- GNOME_INTERACT_NONE, +- GNOME_INTERACT_ERRORS, +- GNOME_INTERACT_ANY +-} GnomeInteractStyle; +- +-typedef enum { +- GNOME_DIALOG_ERROR, +- GNOME_DIALOG_NORMAL +-} GnomeDialogType; +- +-#if defined(MOZ_X11) && (MOZ_WIDGET_GTK == 2) +-typedef GnomeProgram * (*_gnome_program_init_fn)(const char *, const char *, +- const GnomeModuleInfo *, int, +- char **, const char *, ...); +-typedef GnomeProgram * (*_gnome_program_get_fn)(void); +-typedef const GnomeModuleInfo * (*_libgnomeui_module_info_get_fn)(); +-typedef GnomeClient * (*_gnome_master_client_fn)(void); +-typedef void (*_gnome_client_set_restart_command_fn)(GnomeClient*, gint, gchar*[]); +- +-static _gnome_client_set_restart_command_fn gnome_client_set_restart_command; ++#if MOZ_X11 ++#undef IceSetIOErrorHandler ++#undef IceAddConnectionWatch ++#undef IceConnectionNumber ++#undef IceProcessMessages ++#undef IceGetConnectionContext ++#undef SmcInteractDone ++#undef SmcSaveYourselfDone ++#undef SmcInteractRequest ++#undef SmcCloseConnection ++#undef SmcOpenConnection ++#undef SmcSetProperties ++ ++typedef IceIOErrorHandler (*IceSetIOErrorHandlerFn) (IceIOErrorHandler); ++typedef int (*IceAddConnectionWatchFn) (IceWatchProc, IcePointer); ++typedef int (*IceConnectionNumberFn) (IceConn); ++typedef IceProcessMessagesStatus (*IceProcessMessagesFn) (IceConn, IceReplyWaitInfo*, Bool*); ++typedef IcePointer (*IceGetConnectionContextFn) (IceConn); ++ ++typedef void (*SmcInteractDoneFn) (SmcConn, Bool); ++typedef void (*SmcSaveYourselfDoneFn) (SmcConn, Bool); ++typedef int (*SmcInteractRequestFn) (SmcConn, int, SmcInteractProc, SmPointer); ++typedef SmcCloseStatus (*SmcCloseConnectionFn) (SmcConn, int, char**); ++typedef SmcConn (*SmcOpenConnectionFn) (char*, SmPointer, int, int, ++ unsigned long, SmcCallbacks*, ++ const char*, char**, int, char*); ++typedef void (*SmcSetPropertiesFn) (SmcConn, int, SmProp**); ++ ++static IceSetIOErrorHandlerFn IceSetIOErrorHandlerPtr; ++static IceAddConnectionWatchFn IceAddConnectionWatchPtr; ++static IceConnectionNumberFn IceConnectionNumberPtr; ++static IceProcessMessagesFn IceProcessMessagesPtr; ++static IceGetConnectionContextFn IceGetConnectionContextPtr; ++static SmcInteractDoneFn SmcInteractDonePtr; ++static SmcSaveYourselfDoneFn SmcSaveYourselfDonePtr; ++static SmcInteractRequestFn SmcInteractRequestPtr; ++static SmcCloseConnectionFn SmcCloseConnectionPtr; ++static SmcOpenConnectionFn SmcOpenConnectionPtr; ++static SmcSetPropertiesFn SmcSetPropertiesPtr; ++ ++#define IceSetIOErrorHandler IceSetIOErrorHandlerPtr ++#define IceAddConnectionWatch IceAddConnectionWatchPtr ++#define IceConnectionNumber IceConnectionNumberPtr ++#define IceProcessMessages IceProcessMessagesPtr ++#define IceGetConnectionContext IceGetConnectionContextPtr ++#define SmcInteractDone SmcInteractDonePtr ++#define SmcSaveYourselfDone SmcSaveYourselfDonePtr ++#define SmcInteractRequest SmcInteractRequestPtr ++#define SmcCloseConnection SmcCloseConnectionPtr ++#define SmcOpenConnection SmcOpenConnectionPtr ++#define SmcSetProperties SmcSetPropertiesPtr ++ ++enum ClientState { ++ STATE_DISCONNECTED, ++ STATE_REGISTERING, ++ STATE_IDLE, ++ STATE_INTERACTING, ++ STATE_SHUTDOWN_CANCELLED ++}; ++ ++static const char *gClientStateTable[] = { ++ "DISCONNECTED", ++ "REGISTERING", ++ "IDLE", ++ "INTERACTING", ++ "SHUTDOWN_CANCELLED" ++}; ++ ++static LazyLogModule sMozSMLog("MozSM"); ++#endif /* MOZ_X11 */ ++ ++class nsNativeAppSupportUnix : public nsNativeAppSupportBase ++{ ++public: ++#if MOZ_X11 ++ nsNativeAppSupportUnix(): mSessionConnection(nullptr), ++ mClientState(STATE_DISCONNECTED) {}; ++ ~nsNativeAppSupportUnix() ++ { ++ // this goes out of scope after "web-workers-shutdown" async shutdown phase ++ // so it's safe to disconnect here (i.e. the application won't lose data) ++ DisconnectFromSM(); ++ }; ++ ++ void DisconnectFromSM(); ++#endif ++ NS_IMETHOD Start(bool* aRetVal); ++ NS_IMETHOD Stop(bool *aResult); ++ NS_IMETHOD Enable(); ++ ++private: ++#if MOZ_X11 ++ static void SaveYourselfCB(SmcConn smc_conn, SmPointer client_data, ++ int save_style, Bool shutdown, int interact_style, ++ Bool fast); ++ static void DieCB(SmcConn smc_conn, SmPointer client_data); ++ static void InteractCB(SmcConn smc_conn, SmPointer client_data); ++ static void SaveCompleteCB(SmcConn smc_conn, SmPointer client_data) {}; ++ static void ShutdownCancelledCB(SmcConn smc_conn, SmPointer client_data); ++ void DoInteract(); ++ void SetClientState(ClientState aState) ++ { ++ mClientState = aState; ++ MOZ_LOG(sMozSMLog, LogLevel::Debug, ("New state = %s\n", gClientStateTable[aState])); ++ } ++ ++ SmcConn mSessionConnection; ++ ClientState mClientState; + #endif ++}; + +-gboolean save_yourself_cb(GnomeClient *client, gint phase, +- GnomeSaveStyle style, gboolean shutdown, +- GnomeInteractStyle interact, gboolean fast, +- gpointer user_data) ++#if MOZ_X11 ++static gboolean ++process_ice_messages(IceConn connection) ++{ ++ IceProcessMessagesStatus status; ++ ++ status = IceProcessMessages(connection, nullptr, nullptr); ++ ++ switch (status) { ++ case IceProcessMessagesSuccess: ++ return TRUE; ++ ++ case IceProcessMessagesIOError: { ++ nsNativeAppSupportUnix *native = ++ static_cast(IceGetConnectionContext(connection)); ++ native->DisconnectFromSM(); ++ } ++ return FALSE; ++ ++ case IceProcessMessagesConnectionClosed: ++ return FALSE; ++ ++ default: ++ g_assert_not_reached (); ++ } ++} ++ ++static gboolean ++ice_iochannel_watch(GIOChannel *channel, GIOCondition condition, ++ gpointer client_data) ++{ ++ return process_ice_messages(static_cast(client_data)); ++} ++ ++static void ++ice_connection_watch(IceConn connection, IcePointer client_data, ++ Bool opening, IcePointer *watch_data) ++{ ++ guint watch_id; ++ ++ if (opening) { ++ GIOChannel *channel; ++ int fd = IceConnectionNumber(connection); ++ ++ fcntl(fd, F_SETFD, fcntl(fd, F_GETFD, 0) | FD_CLOEXEC); ++ channel = g_io_channel_unix_new(fd); ++ watch_id = g_io_add_watch(channel, ++ static_cast(G_IO_IN | G_IO_ERR), ++ ice_iochannel_watch, connection); ++ g_io_channel_unref(channel); ++ ++ *watch_data = GUINT_TO_POINTER(watch_id); ++ } else { ++ watch_id = GPOINTER_TO_UINT(*watch_data); ++ g_source_remove(watch_id); ++ } ++} ++ ++static void ++ice_io_error_handler(IceConn connection) ++{ ++ // override the default handler which would exit the application; ++ // do nothing and let ICELib handle the failure of the connection gracefully. ++} ++ ++static void ++ice_init(void) ++{ ++ static bool initted = false; ++ ++ if (!initted) { ++ IceSetIOErrorHandler(ice_io_error_handler); ++ IceAddConnectionWatch(ice_connection_watch, nullptr); ++ initted = true; ++ } ++} ++ ++void ++nsNativeAppSupportUnix::InteractCB(SmcConn smc_conn, SmPointer client_data) ++{ ++ nsNativeAppSupportUnix *self = ++ static_cast(client_data); ++ ++ self->SetClientState(STATE_INTERACTING); ++ ++ // We do this asynchronously, as we spin the event loop recursively if ++ // a dialog is displayed. If we do this synchronously, we don't finish ++ // processing the current ICE event whilst the dialog is displayed, which ++ // means we won't process any more. libsm hates us if we do the InteractDone ++ // with a pending ShutdownCancelled, and we would certainly like to handle Die ++ // whilst a dialog is displayed ++ NS_DispatchToCurrentThread(NS_NewRunnableMethod(self, &nsNativeAppSupportUnix::DoInteract)); ++} ++ ++void ++nsNativeAppSupportUnix::DoInteract() + { + nsCOMPtr obsServ = + mozilla::services::GetObserverService(); ++ if (!obsServ) { ++ SmcInteractDone(mSessionConnection, False); ++ SmcSaveYourselfDone(mSessionConnection, True); ++ SetClientState(STATE_IDLE); ++ return; ++ } + +- nsCOMPtr didSaveSession = ++ nsCOMPtr cancelQuit = + do_CreateInstance(NS_SUPPORTS_PRBOOL_CONTRACTID); + +- if (!obsServ || !didSaveSession) +- return TRUE; // OOM ++ bool abortQuit = false; ++ if (cancelQuit) { ++ cancelQuit->SetData(false); ++ obsServ->NotifyObservers(cancelQuit, "quit-application-requested", nullptr); + +- // Notify observers to save the session state +- didSaveSession->SetData(false); +- obsServ->NotifyObservers(didSaveSession, "session-save", nullptr); ++ cancelQuit->GetData(&abortQuit); ++ } ++ ++ if (!abortQuit && mClientState == STATE_DISCONNECTED) { ++ // The session manager disappeared, whilst we were interacting, so ++ // quit now ++ nsCOMPtr appService = ++ do_GetService("@mozilla.org/toolkit/app-startup;1"); ++ ++ if (appService) { ++ appService->Quit(nsIAppStartup::eForceQuit); ++ } ++ } else { ++ if (mClientState != STATE_SHUTDOWN_CANCELLED) { ++ // Only do this if the shutdown wasn't cancelled ++ SmcInteractDone(mSessionConnection, !!abortQuit); ++ SmcSaveYourselfDone(mSessionConnection, !abortQuit); ++ } ++ ++ SetClientState(STATE_IDLE); ++ } ++} + +- bool status; +- didSaveSession->GetData(&status); ++void ++nsNativeAppSupportUnix::SaveYourselfCB(SmcConn smc_conn, SmPointer client_data, ++ int save_style, Bool shutdown, ++ int interact_style, Bool fast) ++{ ++ nsNativeAppSupportUnix *self = ++ static_cast(client_data); ++ ++ // Expect a SaveYourselfCB if we're registering a new client. ++ // All properties are already set in Start() so just reply with ++ // SmcSaveYourselfDone if the callback matches the expected signature. ++ // ++ // Ancient versions (?) of xsm do not follow such an early SaveYourself with ++ // SaveComplete. This is a problem if the application freezes interaction ++ // while waiting for a response to SmcSaveYourselfDone. So never freeze ++ // interaction when in STATE_REGISTERING. ++ // ++ // That aside, we could treat each combination of flags appropriately and not ++ // special-case this. ++ if (self->mClientState == STATE_REGISTERING) { ++ self->SetClientState(STATE_IDLE); ++ ++ if (save_style == SmSaveLocal && interact_style == SmInteractStyleNone && ++ !shutdown && !fast) { ++ SmcSaveYourselfDone(self->mSessionConnection, True); ++ return; ++ } ++ } ++ ++ if (self->mClientState == STATE_SHUTDOWN_CANCELLED) { ++ // The last shutdown request was cancelled whilst we were interacting, ++ // and we haven't finished interacting yet. Switch the state back again ++ self->SetClientState(STATE_INTERACTING); ++ } ++ ++ nsCOMPtr obsServ = ++ mozilla::services::GetObserverService(); ++ if (!obsServ) { ++ SmcSaveYourselfDone(smc_conn, True); ++ return; ++ } + +- // If there was no session saved and the save_yourself request is +- // caused by upcoming shutdown we like to prepare for it +- if (!status && shutdown) { +- nsCOMPtr cancelQuit = ++ bool status = false; ++ if (save_style != SmSaveGlobal) { ++ nsCOMPtr didSaveSession = + do_CreateInstance(NS_SUPPORTS_PRBOOL_CONTRACTID); + +- cancelQuit->SetData(false); +- obsServ->NotifyObservers(cancelQuit, "quit-application-requested", nullptr); ++ if (!didSaveSession) { ++ SmcSaveYourselfDone(smc_conn, True); ++ return; ++ } + +- bool abortQuit; +- cancelQuit->GetData(&abortQuit); ++ // Notify observers to save the session state ++ didSaveSession->SetData(false); ++ obsServ->NotifyObservers(didSaveSession, "session-save", nullptr); ++ ++ didSaveSession->GetData(&status); + } + +- return TRUE; ++ // If the interact style permits us to, we are shutting down and we didn't ++ // manage to (or weren't asked to) save the local state, then notify the user ++ // in advance that we are doing to quit (assuming that we aren't already ++ // doing so) ++ if (!status && shutdown && interact_style != SmInteractStyleNone) { ++ if (self->mClientState != STATE_INTERACTING) { ++ SmcInteractRequest(smc_conn, SmDialogNormal, ++ nsNativeAppSupportUnix::InteractCB, client_data); ++ } ++ } else { ++ SmcSaveYourselfDone(smc_conn, True); ++ } + } + +-void die_cb(GnomeClient *client, gpointer user_data) ++void ++nsNativeAppSupportUnix::DieCB(SmcConn smc_conn, SmPointer client_data) + { + nsCOMPtr appService = + do_GetService("@mozilla.org/toolkit/app-startup;1"); + +- if (appService) ++ if (appService) { + appService->Quit(nsIAppStartup::eForceQuit); ++ } ++ // Quit causes the shutdown to begin but the shutdown process is asynchronous ++ // so we can't DisconnectFromSM() yet + } + +-class nsNativeAppSupportUnix : public nsNativeAppSupportBase ++void ++nsNativeAppSupportUnix::ShutdownCancelledCB(SmcConn smc_conn, ++ SmPointer client_data) + { +-public: +- NS_IMETHOD Start(bool* aRetVal); +- NS_IMETHOD Stop(bool *aResult); +- NS_IMETHOD Enable(); ++ nsNativeAppSupportUnix *self = ++ static_cast(client_data); ++ ++ // Interacting is the only time when we wouldn't already have called ++ // SmcSaveYourselfDone. Do that now, then set the state to make sure we ++ // don't send it again after finishing interacting ++ if (self->mClientState == STATE_INTERACTING) { ++ SmcSaveYourselfDone(smc_conn, False); ++ self->SetClientState(STATE_SHUTDOWN_CANCELLED); ++ } ++} + +-private: +-}; ++void ++nsNativeAppSupportUnix::DisconnectFromSM() ++{ ++ // the SM is free to exit any time after we disconnect, so callers must be ++ // sure to have reached a sufficiently advanced phase of shutdown that there ++ // is no risk of data loss: ++ // e.g. all async writes are complete by the end of "profile-before-change" ++ if (mSessionConnection) { ++ SetClientState(STATE_DISCONNECTED); ++ SmcCloseConnection(mSessionConnection, 0, nullptr); ++ mSessionConnection = nullptr; ++ gdk_x11_set_sm_client_id(nullptr); // follow gnome-client behaviour ++ } ++} ++ ++static void ++SetSMValue(SmPropValue& val, const nsCString& data) ++{ ++ val.value = static_cast(const_cast(data.get())); ++ val.length = data.Length(); ++} ++ ++static void ++SetSMProperty(SmProp& prop, const char* name, const char* type, int numVals, ++ SmPropValue vals[]) ++{ ++ prop.name = const_cast(name); ++ prop.type = const_cast(type); ++ prop.num_vals = numVals; ++ prop.vals = vals; ++} ++#endif /* MOZ_X11 */ ++ ++static void RemoveArg(char **argv) ++{ ++ do { ++ *argv = *(argv + 1); ++ ++argv; ++ } while (*argv); ++ ++ --gArgc; ++} + + NS_IMETHODIMP + nsNativeAppSupportUnix::Start(bool *aRetVal) +@@ -168,79 +478,132 @@ nsNativeAppSupportUnix::Start(bool *aRetVal) + + *aRetVal = true; + +-#if defined(MOZ_X11) && (MOZ_WIDGET_GTK == 2) ++#ifdef MOZ_X11 ++ gboolean sm_disable = FALSE; ++ if (!getenv("SESSION_MANAGER")) { ++ sm_disable = TRUE; ++ } + +- PRLibrary *gnomeuiLib = PR_LoadLibrary("libgnomeui-2.so.0"); +- if (!gnomeuiLib) +- return NS_OK; ++ nsAutoCString prev_client_id; ++ ++ char **curarg = gArgv + 1; ++ while (*curarg) { ++ char *arg = *curarg; ++ if (arg[0] == '-' && arg[1] == '-') { ++ arg += 2; ++ if (!strcmp(arg, "sm-disable")) { ++ RemoveArg(curarg); ++ sm_disable = TRUE; ++ continue; ++ } else if (!strcmp(arg, "sm-client-id")) { ++ RemoveArg(curarg); ++ if (*curarg[0] != '-') { ++ prev_client_id = *curarg; ++ RemoveArg(curarg); ++ } ++ continue; ++ } ++ } + +- PRLibrary *gnomeLib = PR_LoadLibrary("libgnome-2.so.0"); +- if (!gnomeLib) { +- PR_UnloadLibrary(gnomeuiLib); +- return NS_OK; ++ ++curarg; + } + +- _gnome_program_init_fn gnome_program_init = +- (_gnome_program_init_fn)PR_FindFunctionSymbol(gnomeLib, "gnome_program_init"); +- _gnome_program_get_fn gnome_program_get = +- (_gnome_program_get_fn)PR_FindFunctionSymbol(gnomeLib, "gnome_program_get"); +- _libgnomeui_module_info_get_fn libgnomeui_module_info_get = (_libgnomeui_module_info_get_fn)PR_FindFunctionSymbol(gnomeuiLib, "libgnomeui_module_info_get"); +- if (!gnome_program_init || !gnome_program_get || !libgnomeui_module_info_get) { +- PR_UnloadLibrary(gnomeuiLib); +- PR_UnloadLibrary(gnomeLib); +- return NS_OK; ++ if (prev_client_id.IsEmpty()) { ++ prev_client_id = getenv("DESKTOP_AUTOSTART_ID"); + } + +-#endif /* MOZ_X11 && (MOZ_WIDGET_GTK == 2) */ ++ // We don't want child processes to use the same ID ++ unsetenv("DESKTOP_AUTOSTART_ID"); + +-#ifdef ACCESSIBILITY +- // We will load gail, atk-bridge by ourself later +- // We can't run atk-bridge init here, because gail get the control +- // Set GNOME_ACCESSIBILITY to 0 can avoid this +- static const char *accEnv = "GNOME_ACCESSIBILITY"; +- const char *accOldValue = getenv(accEnv); +- setenv(accEnv, "0", 1); +-#endif ++ char *client_id = nullptr; ++ if (!sm_disable) { ++ PRLibrary *iceLib = PR_LoadLibrary("libICE.so.6"); ++ if (!iceLib) { ++ return NS_OK; ++ } + +-#if defined(MOZ_X11) && (MOZ_WIDGET_GTK == 2) +- if (!gnome_program_get()) { +- gnome_program_init("Gecko", "1.0", libgnomeui_module_info_get(), +- gArgc, gArgv, nullptr); +- } +-#endif /* MOZ_X11 && (MOZ_WIDGET_GTK == 2) */ ++ PRLibrary *smLib = PR_LoadLibrary("libSM.so.6"); ++ if (!smLib) { ++ PR_UnloadLibrary(iceLib); ++ return NS_OK; ++ } + +-#ifdef ACCESSIBILITY +- if (accOldValue) { +- setenv(accEnv, accOldValue, 1); +- } else { +- unsetenv(accEnv); ++ IceSetIOErrorHandler = (IceSetIOErrorHandlerFn)PR_FindFunctionSymbol(iceLib, "IceSetIOErrorHandler"); ++ IceAddConnectionWatch = (IceAddConnectionWatchFn)PR_FindFunctionSymbol(iceLib, "IceAddConnectionWatch"); ++ IceConnectionNumber = (IceConnectionNumberFn)PR_FindFunctionSymbol(iceLib, "IceConnectionNumber"); ++ IceProcessMessages = (IceProcessMessagesFn)PR_FindFunctionSymbol(iceLib, "IceProcessMessages"); ++ IceGetConnectionContext = (IceGetConnectionContextFn)PR_FindFunctionSymbol(iceLib, "IceGetConnectionContext"); ++ if (!IceSetIOErrorHandler || !IceAddConnectionWatch || ++ !IceConnectionNumber || !IceProcessMessages || !IceGetConnectionContext) { ++ PR_UnloadLibrary(iceLib); ++ PR_UnloadLibrary(smLib); ++ return NS_OK; ++ } ++ ++ SmcInteractDone = (SmcInteractDoneFn)PR_FindFunctionSymbol(smLib, "SmcInteractDone"); ++ SmcSaveYourselfDone = (SmcSaveYourselfDoneFn)PR_FindFunctionSymbol(smLib, "SmcSaveYourselfDone"); ++ SmcInteractRequest = (SmcInteractRequestFn)PR_FindFunctionSymbol(smLib, "SmcInteractRequest"); ++ SmcCloseConnection = (SmcCloseConnectionFn)PR_FindFunctionSymbol(smLib, "SmcCloseConnection"); ++ SmcOpenConnection = (SmcOpenConnectionFn)PR_FindFunctionSymbol(smLib, "SmcOpenConnection"); ++ SmcSetProperties = (SmcSetPropertiesFn)PR_FindFunctionSymbol(smLib, "SmcSetProperties"); ++ if (!SmcInteractDone || !SmcSaveYourselfDone || !SmcInteractRequest || ++ !SmcCloseConnection || !SmcOpenConnection || !SmcSetProperties) { ++ PR_UnloadLibrary(iceLib); ++ PR_UnloadLibrary(smLib); ++ return NS_OK; ++ } ++ ++ ice_init(); ++ ++ // all callbacks are mandatory in libSM 1.0, so listen even if we don't care. ++ unsigned long mask = SmcSaveYourselfProcMask | SmcDieProcMask | ++ SmcSaveCompleteProcMask | SmcShutdownCancelledProcMask; ++ ++ SmcCallbacks callbacks; ++ callbacks.save_yourself.callback = nsNativeAppSupportUnix::SaveYourselfCB; ++ callbacks.save_yourself.client_data = static_cast(this); ++ ++ callbacks.die.callback = nsNativeAppSupportUnix::DieCB; ++ callbacks.die.client_data = static_cast(this); ++ ++ callbacks.save_complete.callback = nsNativeAppSupportUnix::SaveCompleteCB; ++ callbacks.save_complete.client_data = nullptr; ++ ++ callbacks.shutdown_cancelled.callback = ++ nsNativeAppSupportUnix::ShutdownCancelledCB; ++ callbacks.shutdown_cancelled.client_data = static_cast(this); ++ ++ char errbuf[256]; ++ mSessionConnection = SmcOpenConnection(nullptr, this, SmProtoMajor, ++ SmProtoMinor, mask, &callbacks, ++ prev_client_id.get(), &client_id, ++ sizeof(errbuf), errbuf); + } +-#endif + +- // Careful! These libraries cannot be unloaded after this point because +- // gnome_program_init causes atexit handlers to be registered. Strange +- // crashes will occur if these libraries are unloaded. ++ if (!mSessionConnection) { ++ return NS_OK; ++ } + +- // TODO GTK3 - see Bug 694570 - Stop using libgnome and libgnomeui on Linux +-#if defined(MOZ_X11) && (MOZ_WIDGET_GTK == 2) +- gnome_client_set_restart_command = (_gnome_client_set_restart_command_fn) +- PR_FindFunctionSymbol(gnomeuiLib, "gnome_client_set_restart_command"); ++ LogModule::Init(); // need to make sure initialized before SetClientState ++ if (prev_client_id.IsEmpty() || ++ (client_id && !prev_client_id.Equals(client_id))) { ++ SetClientState(STATE_REGISTERING); ++ } else { ++ SetClientState(STATE_IDLE); ++ } + +- _gnome_master_client_fn gnome_master_client = (_gnome_master_client_fn) +- PR_FindFunctionSymbol(gnomeuiLib, "gnome_master_client"); ++ gdk_x11_set_sm_client_id(client_id); + +- GnomeClient *client = gnome_master_client(); +- g_signal_connect(client, "save-yourself", G_CALLBACK(save_yourself_cb), nullptr); +- g_signal_connect(client, "die", G_CALLBACK(die_cb), nullptr); ++ // Set SM Properties ++ // SmCloneCommand, SmProgram, SmRestartCommand, SmUserID are required ++ // properties so must be set, and must have a sensible fallback value. + +- // Set the correct/requested restart command in any case. ++ // Determine executable path to use for XSMP session restore + + // Is there a request to suppress default binary launcher? +- nsAutoCString path; +- char* argv1 = getenv("MOZ_APP_LAUNCHER"); ++ nsAutoCString path(getenv("MOZ_APP_LAUNCHER")); + +- if(!argv1) { +- // Tell the desktop the command for restarting us so that we can be part of XSMP session restore ++ if (path.IsEmpty()) { + NS_ASSERTION(gDirServiceProvider, "gDirServiceProvider is NULL! This shouldn't happen!"); + nsCOMPtr executablePath; + nsresult rv; +@@ -258,14 +621,60 @@ nsNativeAppSupportUnix::Start(bool *aRetVal) + } + + executablePath->GetNativePath(path); +- argv1 = (char*)(path.get()); + } + } + +- if (argv1) { +- gnome_client_set_restart_command(client, 1, &argv1); ++ if (path.IsEmpty()) { ++ // can't determine executable path. Best fallback is name from ++ // application.ini but it might not resolve to the same executable at ++ // launch time. ++ path = gAppData->name; // will always be set ++ ToLowerCase(path); ++ MOZ_LOG(sMozSMLog, LogLevel::Warning, ++ ("Could not determine executable path. Falling back to %s.", path.get())); + } +-#endif /* MOZ_X11 && (MOZ_WIDGET_GTK == 2) */ ++ ++ SmProp propRestart, propClone, propProgram, propUser, *props[4]; ++ SmPropValue valsRestart[3], valsClone[1], valsProgram[1], valsUser[1]; ++ int n = 0; ++ ++ NS_NAMED_LITERAL_CSTRING(kClientIDParam, "--sm-client-id"); ++ ++ SetSMValue(valsRestart[0], path); ++ SetSMValue(valsRestart[1], kClientIDParam); ++ SetSMValue(valsRestart[2], nsDependentCString(client_id)); ++ SetSMProperty(propRestart, SmRestartCommand, SmLISTofARRAY8, 3, valsRestart); ++ props[n++] = &propRestart; ++ ++ SetSMValue(valsClone[0], path); ++ SetSMProperty(propClone, SmCloneCommand, SmLISTofARRAY8, 1, valsClone); ++ props[n++] = &propClone; ++ ++ nsAutoCString appName(gAppData->name); // will always be set ++ ToLowerCase(appName); ++ ++ SetSMValue(valsProgram[0], appName); ++ SetSMProperty(propProgram, SmProgram, SmARRAY8, 1, valsProgram); ++ props[n++] = &propProgram; ++ ++ nsAutoCString userName; // username that started the program ++ struct passwd* pw = getpwuid(getuid()); ++ if (pw && pw->pw_name) { ++ userName = pw->pw_name; ++ } else { ++ userName = NS_LITERAL_CSTRING("nobody"); ++ MOZ_LOG(sMozSMLog, LogLevel::Warning, ++ ("Could not determine user-name. Falling back to %s.", userName.get())); ++ } ++ ++ SetSMValue(valsUser[0], userName); ++ SetSMProperty(propUser, SmUserID, SmARRAY8, 1, valsUser); ++ props[n++] = &propUser; ++ ++ SmcSetProperties(mSessionConnection, n, props); ++ ++ g_free(client_id); ++#endif /* MOZ_X11 */ + + return NS_OK; + } +diff --git widget/gtk/compat/gdk/gdkx.h widget/gtk/compat/gdk/gdkx.h +index 5d59720d2f91..240c12e3013a 100644 +--- widget/gtk/compat/gdk/gdkx.h ++++ widget/gtk/compat/gdk/gdkx.h +@@ -5,9 +5,14 @@ + #ifndef GDKX_WRAPPER_H + #define GDKX_WRAPPER_H + ++#include ++ + #define gdk_x11_window_foreign_new_for_display gdk_x11_window_foreign_new_for_display_ + #define gdk_x11_window_lookup_for_display gdk_x11_window_lookup_for_display_ + #define gdk_x11_window_get_xid gdk_x11_window_get_xid_ ++#if !GTK_CHECK_VERSION(2,24,0) ++#define gdk_x11_set_sm_client_id gdk_x11_set_sm_client_id_ ++#endif + #include_next + #undef gdk_x11_window_foreign_new_for_display + #undef gdk_x11_window_lookup_for_display +@@ -35,4 +40,12 @@ gdk_x11_window_get_xid(GdkWindow *window) + #define GDK_IS_X11_DISPLAY(a) (true) + #endif + ++#if !GTK_CHECK_VERSION(2,24,0) ++#undef gdk_x11_set_sm_client_id ++static inline void ++gdk_x11_set_sm_client_id (const gchar *sm_client_id) ++{ ++ gdk_set_sm_client_id(sm_client_id); ++} ++#endif + #endif /* GDKX_WRAPPER_H */ +diff --git widget/gtk/mozgtk/mozgtk.c widget/gtk/mozgtk/mozgtk.c +index 0bb4dfd04144..17c98fe3dd61 100644 +--- widget/gtk/mozgtk/mozgtk.c ++++ widget/gtk/mozgtk/mozgtk.c +@@ -132,6 +132,7 @@ STUB(gdk_x11_window_foreign_new_for_display) + STUB(gdk_x11_window_lookup_for_display) + STUB(gdk_x11_window_set_user_time) + STUB(gdk_x11_xatom_to_atom) ++STUB(gdk_x11_set_sm_client_id) + STUB(gtk_accel_label_new) + STUB(gtk_alignment_get_type) + STUB(gtk_alignment_new) Property changes on: head/www/libxul/files/patch-bug694570 ___________________________________________________________________ Added: fbsd:nokeywords ## -0,0 +1 ## +yes \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property