1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-12-23 04:23:08 +00:00
freebsd-ports/www/xpi-adblock/Makefile.xpi
Mathieu Arnold eabbfd75e3 ${RM} already has -f.
PR:		213570
Submitted by:	mat
Exp-run by:	antoine
Sponsored by:	Absolight
2016-10-21 12:51:40 +00:00

217 lines
7.6 KiB
Makefile

# Created by: Andrew Pantyukhin <infofarmer@FreeBSD.org>
# $FreeBSD$
# XPI_ID - Extension id, might be in {12345-...} or dev@org format
# XPI_NUM - Extension number, as in addons.cdn.mozilla.net 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_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 (defined below):
# MOZILLA_ADDONS/addons/${XPI_NUM}
# or
# MOZILLA_ADDONS/extensions/${XPI_DISTNAME}
# 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
.ifdef XPI_NUM
MASTER_SITES?= MOZILLA_ADDONS/addons/${XPI_NUM}
.else
MASTER_SITES?= MOZILLA_ADDONS/extensions/${XPI_DISTNAME}
.endif
.endif
PKGNAMEPREFIX?= xpi-
EXTRACT_SUFX?= .xpi
DISTNAME?= ${XPI_DISTNAME}-${DISTVERSIONPREFIX}${DISTVERSION}${DISTVERSIONSUFFIX}
DIST_SUBDIR?= xpi
NO_BUILD= yes
USES+= zip:infozip
EXTRACT_AFTER_ARGS= -d ${WRKSRC}
XPI_DISTNAME?= ${PORTNAME}
XPI_APPS_ALL_WC= *firefox* *thunderbird* *seamonkey*
XPI_APPS_ALL= firefox linux-firefox thunderbird linux-thunderbird \
seamonkey linux-seamonkey
# 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:tu} == "YES" || ${USE_XPI} == "*"
USE_XPI= ${XPI_APPS_ALL_WC}
.endif
.if !defined(XPI_APPS)
.for xpi in ${USE_XPI}
_xpi:= ${xpi}
.if ${_xpi:M*firefox*}
XPI_APPS+= ${LOCALBASE}/lib/${xpi}/browser/extensions
.else
XPI_APPS+= ${LOCALBASE}/lib/${xpi}/extensions
.endif
.endfor
.endif
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
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}/!}
.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}}/!}
.endfor
.if !target(do-install)
do-install:
@${MKDIR} ${STAGEDIR}${_TD_FULL} ${XPI_SLDIRS_ALL:S/^/${STAGEDIR}/}
@cd ${WRKSRC}; ${PAX} -rw . ${STAGEDIR}${_TD_FULL}/
@if [ -d ${FILESDIR} -a -f ${FILESDIR}/chrome.manifest ] ; \
then ${INSTALL_DATA} ${FILESDIR}/chrome.manifest ${STAGEDIR}${_TD_FULL}/ ; fi
@${CHMOD} -R a+rX,go-w ${STAGEDIR}${_TD_FULL}/
@for sldir in ${XPI_SLDIRS_ALL}; do \
${ECHO_CMD} "@dir $${sldir}" ${_A}; \
done
@${ECHO_CMD} '@exec for _dir in ${XPI_LINKFARMS} ; { ${LN} -sf ${_TD_FULL} $$_dir/ ${_Q}; }' ${_A}
@${ECHO_CMD} '@unexec for _dir in ${XPI_LINKFARMS} ; { ${RM} $$_dir/${XPI_ID} ; }' ${_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
.if !target(xpi-post-extract)
xpi-post-extract:
.endif
post-extract: xpi-post-extract
@${RM} -r ${WRKSRC}/META-INF
# Maintainer section
xpi-gen: extract
@${ECHO_CMD} -n 'XPI_ID='
@${SED} -En '/<(RDF:)?Description (RDF:)?about="urn:mozilla:install-manifest"/,/>/p' ${WRKSRC}/install.rdf | \
${GREP} -Em1 'em:id|<id>' | ${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}
@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
xpi-pre-chrome:
@${CHMOD} g+w ${_TD_FULL}
@${RM} ${_TD_FULL}/chrome.manifest
xpi-post-chrome:
@${CP} -f ${_TD_FULL}/chrome.manifest ${FILESDIR}/