#-*- mode: makefile; tab-width: 4; -* # ex:ts=4 # # New ports collection makefile for: xpi infrastructure # Date created: 28 March 2006 # Whom: Andrew Pantyukhin # # $FreeBSD$ # # XPI_ID - Extension id, might be in {12345-...} or dev@org format # XPI_NUM - Extension number, as in addons.mozilla.org URL # XPI_FILES - List of files in xpi archive. This is used to produce # PLIST_FILES. XPI_FILES can be generated by xpi-gen, but be # sure to put chrome.manifest in ${FILESDIR} before that if you # need it. # XPI_DIRS - List of directories in xpi archive. This is used to produce # PLIST_DIRS. # XPI_DISTNAME - The name of distribution # Default: ${PORTNAME} # PORTNAME, PORTVERSION, DISTVERSIONSUFFIX, CATEGORIES, MAINTAINER, COMMENT # - These should all be set manually for port to be functional. See # ${PORTSDIR}/Mk/bsd.port.mk for details. # MASTER_SITES - This should be set if port is unavailable at the default site. # Default: ${MASTER_SITE_MOZILLA} # MASTER_SITE_SUBDIR # - Default: extensions/${PORTNAME} # LATEST_LINK - Default: ${PKGBASE:S/_//g} # XPI_LIBDIR - Name of the directory to install extensions in. # Default: ${PREFIX}/lib/xpi # XPI_XPIDIR - Name of the directory to install extension's files in. # Default: ${XPI_LIBDIR}/${XPI_ID} # USE_XPI - If set, the port installs one or more xpi extensions. # If this is set to a list of apps (wildcards possible) the # extensions will be installed for them only. # WITH_XPI - A user-tunable variable, determines which apps should # extension be made available for. Can be set to a list of # apps, same as USE_XPI, and/or to "ext:app[,app,app,...]" tuples. # ext should be a portname. If ext starts and ends with a slash # (`/'), it is treated as an extended regular expression (see # re_format(7)). Right of the colon should be a list of apps in # the same format as USE_XPI, but comma- instead of whitespace- # delimited. If no matching tuples for an extension are found, # WITH_XPI is scanned for non tuple-records which are then treated # as a USE_XPI list. If several tuples match, the last non-regexp # one takes precedence, then the last regexp one. # # This Makefile is a beta-version of the new xpi infrastructure. It currently # supports Gecko 1.8+ (Firefox 1.5+). Support for Gecko 1.7x (and Seamonkey 1.0) # may be merged later from Thierry Thomas works. # # A new xpi will require a PORTNAME, PORTVERSION, DISTVERSIONSUFFIX and # CATEGORIES. In case it is not published on the mozilla.org sites, MASTER_SITES # can be redefined. XPI_* vars will also need to be defined manually, which helps # keep the infrastructure simpler. # # Gecko 1.8 xpi engine tries to detect various compatibility issues all by itself. # Thus, xpi's are installed into ${LOCALBASE}/lib/xpi/${XPI_ID} by default and # links are made to all apps which have the engine (firefox, thunderbird, sunbird # thunderbird3, seamonkey and flock at the moment). relink and relink-all targets # can be invoked to refarm the links of a single extensions or all installed # extensions accordingly. # # In case an xpi does not have chrome.manifest, it should be generated manually by # a maintainer and placed in files, where it will be noticed. # # xpi ports do not depend on their master applications. You can install an # extension before the app and run relink when the app is present. .ifndef MASTER_SITES MASTER_SITES?= MOZILLA_EXTENDED .ifdef XPI_NUM MASTER_SITE_SUBDIR?= addons/${XPI_NUM} .endif MASTER_SITE_SUBDIR?= extensions/${XPI_DISTNAME} .endif PKGNAMEPREFIX?= xpi- EXTRACT_SUFX?= .xpi DISTNAME?= ${XPI_DISTNAME}-${DISTVERSIONPREFIX}${DISTVERSION}${DISTVERSIONSUFFIX} DIST_SUBDIR?= xpi LATEST_LINK?= ${PKGBASE:S/_//g} NO_BUILD= yes USE_ZIP= yes EXTRACT_AFTER_ARGS= -d ${WRKSRC} XPI_DISTNAME?= ${PORTNAME} XPI_APPS_ALL_WC= *firefox* *thunderbird* *flock* *sunbird* *seamonkey* XPI_APPS_ALL= firefox firefox3 firefox35 linux-firefox linux-firefox-devel \ flock linux-flock thunderbird thunderbird3 linux-thunderbird \ seamonkey sunbird linux-sunbird # kompozer linux-kompozer # Other apps: mango # === Let's process WITH_XPI into WITH_XPI_APPS WITH_XPI_TUPLES= ${WITH_XPI:M*?\:?*} WITH_XPI_NTUPLES= ${WITH_XPI:N*\:*} WITH_XPI_TUPLES_RX= ${WITH_XPI_TUPLES:M/*?*/\:?*} WITH_XPI_TUPLES_WC= ${WITH_XPI_TUPLES:N/*?*/\:?*} WITH_XPI_MATCH?= ${PORTNAME} WITH_XPI_MATCHSTRING?= _=~match~=_ .for tuple_rx in ${WITH_XPI_TUPLES_RX} _rx= ${tuple_rx:C!/(.*)/\:.*!\1!} _apps= ${tuple_rx:C!/.*/\:(.*)!\1!} _testrx=${WITH_XPI_MATCH:C!.*${_rx}.*!${WITH_XPI_MATCHSTRING}!} .if ${_testrx} == ${WITH_XPI_MATCHSTRING} WITH_XPI_APPS:= ${_apps:S/,/ /g} .endif .endfor .for tuple_wc in ${WITH_XPI_TUPLES_WC} _wc= ${tuple_wc:C!(.*)\:.*!\1!} _apps= ${tuple_wc:C!.*\:(.*)!\1!} .if ${_wc} == ${WITH_XPI_MATCH} WITH_XPI_APPS:= ${_apps:S/,/ /g} .endif .endfor .if ${WITH_XPI_NTUPLES} WITH_XPI_APPS?= ${WITH_XPI_NTUPLES} .endif # === WITH_XPI has been processed .ifdef WITH_XPI_APPS USE_XPI= ${WITH_XPI_APPS} .endif .if !defined(USE_XPI) || ${USE_XPI:U} == "YES" || ${USE_XPI} == "*" USE_XPI= ${XPI_APPS_ALL_WC} .endif XPI_APPS?= ${USE_XPI:S.^.${LOCALBASE}/lib/.:S.$./extensions.} XPI_SLDIRS_ALL= ${XPI_APPS_ALL:S.^.${XPI_SLDIR}/.} XPI_SLDIRS= ${USE_XPI:S.^.${XPI_SLDIR}/.} XPI_LINKFARMS= ${XPI_APPS} ${XPI_SLDIRS} XPI_LIBDIR?= ${PREFIX}/lib/xpi XPI_SLDIR?= ${XPI_LIBDIR}/symlinks .ifndef XPI_DISTNAMES XPI_XPIDIR?= ${XPI_LIBDIR}/${XPI_ID} .endif XPI_DIRS_TRY= ${XPI_SLDIRS_ALL:S,^${PREFIX}/,,} \ ${XPI_SLDIR:S,^${PREFIX}/,,} \ ${XPI_LIBDIR:S,^${PREFIX}/,,} PLIST_SUB+= XPI_LIBDIR="${XPI_LIBDIR:S,^${PREFIX}/,,}" \ XPI_XPIDIR="${XPI_XPIDIR:S,^${PREFIX}/,,}" _TD= ${XPI_XPIDIR:S,^${PREFIX}/,,} _TD_FULL= ${XPI_XPIDIR} _A= >> ${TMPPLIST} _Q= 2>/dev/null || true PLIST_FILES+= ${XPI_FILES:S!^!${_TD}/!} PLIST_DIRS+= ${XPI_DIRS:S!^!${_TD}/!} ${_TD} .for dist in ${XPI_DISTNAMES} XPI_XPIDIR_${dist}= ${XPI_LIBDIR}/${XPI_ID_${dist}} _TD_${dist}= ${XPI_XPIDIR_${dist}:S,^${PREFIX}/,,} PLIST_FILES+= ${XPI_FILES_${dist}:S!^!${_TD_${dist}}/!} PLIST_DIRS+= ${XPI_DIRS_${dist}:S!^!${_TD_${dist}}/!} ${_TD_${dist}} .endfor .if !target(do-install) do-install: @${INSTALL} -d ${_TD_FULL} ${XPI_SLDIRS_ALL} @${CP} -R ${WRKSRC}/ ${_TD_FULL}/ @if [ -d ${FILESDIR} -a -f ${FILESDIR}/chrome.manifest ] ; \ then ${CP} ${FILESDIR}/chrome.manifest ${_TD_FULL}/ ; fi @${CHOWN} -R ${SHAREOWN}:${SHAREGRP} ${_TD_FULL}/ @${CHMOD} -R a+rX,go-w ${_TD_FULL}/ @for _dir in ${XPI_LINKFARMS} ; { ${LN} -sf ${_TD_FULL} $$_dir/ ${_Q} ; } @${ECHO_CMD} '@exec ${INSTALL} -d ${XPI_SLDIRS_ALL:S,^${PREFIX},%D,}' ${_A} @${ECHO_CMD} '@exec for _dir in ${XPI_LINKFARMS} ; { ${LN} -sf ${_TD_FULL} $$_dir/ ${_Q}; }' ${_A} @${ECHO_CMD} '@unexec for _dir in ${XPI_LINKFARMS} ; { ${RM} -f $$_dir/${XPI_ID} ; }' ${_A} @${ECHO_CMD} '@unexec rmdir ${XPI_DIRS_TRY:S,^,%D/,} ${_Q}' ${_A} .endif .if !target(relink) relink: @-for _app in ${XPI_APPS} ; { ${LN} -sf ${_TD_FULL} $$_app ${_Q} ; } .endif .if !target(relink-all) relink-all: @-for _app in ${XPI_APPS} ; { for _xpi in ${XPI_LIBDIR}/*[\{@]* ; { \ ${LN} -sf $$_xpi $$_app ${_Q} ; } ; } .endif # Maintainer section xpi-gen: extract @${ECHO_CMD} -n 'XPI_ID=' @${GREP} -Em1 'em:id|' ${WRKSRC}/install.rdf | ${CUT} -f2- -d\> | \ ${CUT} -f1 -d\< | ${CUT} -f2 -d\" @${ECHO_CMD} -n 'XPI_FILES=' @cd ${WRKSRC} && ${FIND} -s . -not -type d | cut -f2- -d/ | ${TR} '\n' ' ' @if [ -d ${FILESDIR} -a -f ${FILESDIR}/chrome.manifest ] ; \ then ${ECHO_CMD} chrome.manifest ; fi @${ECHO_CMD} @${ECHO_CMD} -n 'XPI_DIRS=' @cd ${WRKSRC} && ${FIND} -ds . -not -name . -type d | cut -f2- -d/ | ${TR} '\n' ' ' @${ECHO_CMD} xpi-plist: extract @${FIND} -s ${WRKSRC} -not -type d | ${SED} -e "s,^${WRKSRC},%%XPI_XPIDIR%%," > ${PLIST} @if [ -d ${FILESDIR} -a -f ${FILESDIR}/chrome.manifest ] ; \ then ${ECHO_CMD} %%XPI_XPIDIR%%/chrome.manifest >> ${PLIST} ; fi @${FIND} -ds ${WRKSRC} -type d -not -name ${DISTNAME} | \ ${SED} -e "s,^${WRKSRC},@dirrm %%XPI_XPIDIR%%," >> ${PLIST} xpi-pre-chrome: @${CHMOD} g+w ${_TD_FULL} @${RM} -f ${_TD_FULL}/chrome.manifest xpi-post-chrome: @${CP} -f ${_TD_FULL}/chrome.manifest ${FILESDIR}/