#-*- mode: makefile; tab-width: 4; -* # ex:ts=4 # # New ports collection makefile for: npapi infrastructure # Date created: 27 June 2006 # Whom: Andrew Pantyukhin # # $FreeBSD$ # # NPAPI_ID - Extension id, might be in {12345-...} or dev@org format # NPAPI_FILES - List of files in npapi archive. This is used to produce # PLIST_FILES. NPAPI_FILES can be generated by npapi-gen, but be # sure to put chrome.manifest in ${FILESDIR} before that if you # need it. # NPAPI_DIRS - List of directories in npapi archive. This is used to produce # PLIST_DIRS. # 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. # NPAPI_LIBDIR - Name of the directory to install plugins in. # Default: ${PREFIX}/lib/npapi # NPAPI_NPAPIDIR # - Name of the directory to install plugin's files in. # Default: ${NPAPI_LIBDIR}/${NPAPI_ID} # USE_NPAPI - If set, the port installs one or more npapi plugins. # If this is set to a list of apps (wildcards possible) the # plugins will be installed for them only. "linux" and "native" # keywords can be used to support all linux-compat and native # browsers, correspondingly. "embed" keyword prevents the # do-install target being set to a default. # WITH_NPAPI - A user-tunable variable, determines which apps should # plugin be made available for. Can be set to a list of # apps, same as USE_NPAPI, 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_NPAPI, but comma- instead of whitespace- # delimited. If no matching tuples for an plugin are found, # WITH_NPAPI is scanned for non tuple-records which are then treated # as a USE_NPAPI list. If several tuples match, the last non-regexp # one takes precedence, then the last regexp one. # # This Makefile is an alpha-version of the new npapi infrastructure. # # Npapi's are installed into ${LOCALBASE}/lib/npapi/${NPAPI_ID} by default and # links are made to all apps which have the engine (firefox, thunderbird and flock # at the moment). relink and relink-all targets can be invoked to refarm the links # of a single plugins or all installed plugins accordingly. # # npapi ports do not depend on their master applications. You can install an # plugin before the app and run relink when the app is present. NPAPI_ID?= ${PKGBASE} NPAPI_DISTNAME?= ${PORTNAME} NPAPI_WRKSRC?= ${WRKSRC} NPAPI_PKGINSTALL?= ${WRKDIR}/npapi-pkg-install NPAPI_PKGDEINSTALL?= ${WRKDIR}/npapi-pkg-deinstall PKGINSTALL?= ${NPAPI_PKGINSTALL} PKGDEINSTALL?= ${NPAPI_PKGDEINSTALL} NPAPI_APPS_ALL_WC= *mozilla* *firefox* *flock* *seamonkey* *opera* NPAPI_APPS_ALL_WC_LINUX= ${NPAPI_APPS_ALL_WC:S/^*/linux-/} NPAPI_APPS_ALL_WC_NATIVE= ${NPAPI_APPS_ALL_WC:S/^*//} NPAPI_APPS_ALL= firefox firefox-devel linux-firefox linux-firefox-devel \ flock flock-devel linux-flock linux-flock-devel \ mozilla mozilla-devel linux-mozilla \ nvu linux-nvu \ opera opera-devel linux-opera linux-opera-devel \ seamonkey seamonkey-devel linux-seamonkey linux-seamonkey-devel \ sunbird sunbird-devel linux-sunbird linux-sunbird-devel # === Let's process WITH_NPAPI into WITH_NPAPI_APPS WITH_NPAPI_TUPLES= ${WITH_NPAPI:M*?\:?*} WITH_NPAPI_NTUPLES= ${WITH_NPAPI:N*\:*} WITH_NPAPI_TUPLES_RX= ${WITH_NPAPI_TUPLES:M/*?*/\:?*} WITH_NPAPI_TUPLES_WC= ${WITH_NPAPI_TUPLES:N/*?*/\:?*} WITH_NPAPI_MATCH?= ${PORTNAME} WITH_NPAPI_MATCHSTRING?= _=~match~=_ .for tuple_rx in ${WITH_NPAPI_TUPLES_RX} _rx= ${tuple_rx:C!/(.*)/\:.*!\1!} _apps= ${tuple_rx:C!/.*/\:(.*)!\1!} _testrx=${WITH_NPAPI_MATCH:C!.*${_rx}.*!${WITH_NPAPI_MATCHSTRING}!} .if ${_testrx} == ${WITH_NPAPI_MATCHSTRING} WITH_NPAPI_APPS:= ${_apps:S/,/ /g} .endif .endfor .for tuple_wc in ${WITH_NPAPI_TUPLES_WC} _wc= ${tuple_wc:C!(.*)\:.*!\1!} _apps= ${tuple_wc:C!.*\:(.*)!\1!} .if ${_wc} == ${WITH_NPAPI_MATCH} WITH_NPAPI_APPS:= ${_apps:S/,/ /g} .endif .endfor .if ${WITH_NPAPI_NTUPLES} WITH_NPAPI_APPS?= ${WITH_NPAPI_NTUPLES} .endif # === WITH_NPAPI has been processed .ifdef WITH_NPAPI_APPS USE_NPAPI= ${WITH_NPAPI_APPS} .endif .if !defined(USE_NPAPI) || ${USE_NPAPI:U} == "YES" || ${USE_NPAPI} == "*" USE_NPAPI= ${NPAPI_APPS_ALL_WC} .endif .for _TEMP_APP__ in ${NPAPI_APPS_ALL} _TEMP_APP_=${_TEMP_APP__} _TEMP_FLAG_=0 . for _TEMP_USE__ in ${USE_NPAPI} _TEMP_USE_=${_TEMP_USE__} . if !${_TEMP_APP_:C!${_TEMP_USE_:S/*/.*/:S/?/./}!!} || \ ( ${_TEMP_APP_:Mlinux-*} && ${_TEMP_USE_:Mlinux} ) || \ ( ${_TEMP_APP_:Nlinux-*} && ${_TEMP_USE_:Mnative} ) _TEMP_FLAG_=1 . endif . endfor . if ${_TEMP_FLAG_} USE_NPAPI_EXP+= ${_TEMP_APP__} . endif .endfor NPAPI_APPS?= ${USE_NPAPI_EXP:S.^.${LOCALBASE}/lib/.:S.$./plugins.:N*opera*} \ ${USE_NPAPI_EXP:S.^.${X11BASE}/lib/.:S.$./plugins.:N*opera*} \ ${USE_NPAPI_EXP:S.^.${LOCALBASE}/share/.:S.$./plugins.:M*/opera*} \ ${USE_NPAPI_EXP:S.^.${X11BASE}/share/.:S.$./plugins.:M*/opera*} NPAPI_SLDIRS_ALL= ${NPAPI_APPS_ALL:S.^.${NPAPI_SLDIR}/.} NPAPI_SLDIRS= ${USE_NPAPI_EXP:S.^.${NPAPI_SLDIR}/.} NPAPI_LINKFARMS= ${NPAPI_APPS} ${NPAPI_SLDIRS} NPAPI_LIBDIR?= ${PREFIX}/lib/npapi NPAPI_SLDIR?= ${NPAPI_LIBDIR}/symlinks .ifndef NPAPI_DISTNAMES NPAPI_NPAPIDIR?= ${NPAPI_LIBDIR}/${NPAPI_ID} .endif NPAPI_DIRS_TRY= ${NPAPI_SLDIRS_ALL:S,^${PREFIX}/,,} \ ${NPAPI_SLDIR:S,^${PREFIX}/,,} \ ${NPAPI_LIBDIR:S,^${PREFIX}/,,} PLIST_SUB+= NPAPI_LIBDIR="${NPAPI_LIBDIR:S,^${PREFIX}/,,}" \ NPAPI_NPAPIDIR="${NPAPI_NPAPIDIR:S,^${PREFIX}/,,}" _TD= ${NPAPI_NPAPIDIR:S,^${PREFIX}/,,} _TD_FULL= ${NPAPI_NPAPIDIR} _A= >> ${TMPPLIST} _PI= ${NPAPI_PKGINSTALL} _PD= ${NPAPI_PKGDEINSTALL} _Q= 2>/dev/null || true PLIST_FILES+= ${NPAPI_FILES:S!^!${_TD}/!} PLIST_DIRS+= ${NPAPI_DIRS:S!^!${_TD}/!} ${_TD} .for dist in ${NPAPI_DISTNAMES} NPAPI_NPAPIDIR_${dist}= ${NPAPI_LIBDIR}/${NPAPI_ID_${dist}} _TD_${dist}= ${NPAPI_NPAPIDIR_${dist}:S,^${PREFIX}/,,} PLIST_FILES+= ${NPAPI_FILES_${dist}:S!^!${_TD_${dist}}/!} PLIST_DIRS+= ${NPAPI_DIRS_${dist}:S!^!${_TD_${dist}}/!} ${_TD_${dist}} .endfor npapi-do-install: @${INSTALL} -d ${_TD_FULL} ${NPAPI_SLDIRS_ALL} @${CP} -p ${NPAPI_FILES:S,^,${NPAPI_WRKSRC}/,} ${_TD_FULL}/ @${CHOWN} -R ${SHAREOWN}:${SHAREGRP} ${_TD_FULL}/ @${CHMOD} -R a+rX,go-w ${_TD_FULL}/ @for _dir in ${NPAPI_LINKFARMS} ; { ${LN} -sf ${_TD_FULL}/* $$_dir ${_Q} ; } @${ECHO_CMD} '${INSTALL} -d ${NPAPI_SLDIRS_ALL}' > ${_PI} @${ECHO_CMD} 'for _dir in ${NPAPI_LINKFARMS} ; \ { ${LN} -sf ${NPAPI_FILES:S,^,${_TD_FULL}/,} $$_dir/ ${_Q}; }' >> ${_PI} @${ECHO_CMD} 'for _dir in ${NPAPI_LINKFARMS} ; \ { ${RM} -f ${NPAPI_FILES:S,^,\$_dir/,} ; }' > ${_PD} @${ECHO_CMD} 'rmdir ${NPAPI_DIRS_TRY:S,^,${PREFIX}/,} ${_Q}' >> ${_PD} .if ${PKGINSTALL} != ${NPAPI_PKGINSTALL} @${CAT} ${NPAPI_PKGINSTALL} >> ${PKGINSTALL} .endif .if ${PKGDEINSTALL} != ${NPAPI_PKGDEINSTALL} @${CAT} ${NPAPI_PKGDEINSTALL} >> ${PKGDEINSTALL} .endif .if !target(do-install) && !${USE_NPAPI:Membed} do-install: npapi-do-install .endif .if !target(relink) relink: @-for _app in ${NPAPI_APPS} ; { ${LN} -sf ${_TD_FULL}/* $$_app ${_Q} ; } .endif # Maintainer section npapi-gen: extract @${ECHO_CMD} -n 'NPAPI_FILES=' @cd ${NPAPI_WRKSRC} && ${FIND} -s . -not -type d | cut -f2- -d/ | ${TR} '\n' ' ' @${ECHO_CMD} @${ECHO_CMD} -n 'NPAPI_DIRS=' @cd ${NPAPI_WRKSRC} && ${FIND} -ds . -not -name . -type d | cut -f2- -d/ | ${TR} '\n' ' ' @${ECHO_CMD} npapi-plist: extract @${FIND} -s ${NPAPI_WRKSRC} -not -type d | \ ${SED} -e "s,^${NPAPI_WRKSRC},%%NPAPI_NPAPIDIR%%," > ${PLIST} @${FIND} -ds ${NPAPI_WRKSRC} -type d -not -name ${DISTNAME} | \ ${SED} -e "s,^${NPAPI_WRKSRC},@dirrm %%NPAPI_NPAPIDIR%%," >> ${PLIST}