1 #-*- mode: makefile; tab-width: 4; -*
4 # New ports collection makefile for: npapi infrastructure
5 # Date created: 27 June 2006
6 # Whom: Andrew Pantyukhin <infofarmer@FreeBSD.org>
8 # $FreeBSD: ports/www/linux-mplayer-plugin/Makefile.npapi,v 1.7 2012/11/17 06:02:39 svnexp Exp $
11 # NPAPI_ID - Extension id, might be in {12345-...} or dev@org format
12 # NPAPI_FILES - List of files in npapi archive. This is used to produce
13 # PLIST_FILES. NPAPI_FILES can be generated by npapi-gen, but be
14 # sure to put chrome.manifest in ${FILESDIR} before that if you
16 # NPAPI_DIRS - List of directories in npapi archive. This is used to produce
18 # PORTNAME, PORTVERSION, DISTVERSIONSUFFIX, CATEGORIES, MAINTAINER, COMMENT
19 # - These should all be set manually for port to be functional.
20 # See ${PORTSDIR}/Mk/bsd.port.mk for details.
21 # NPAPI_LIBDIR - Name of the directory to install plugins in.
22 # Default: ${PREFIX}/lib/npapi
24 # - Name of the directory to install plugin's files in.
25 # Default: ${NPAPI_LIBDIR}/${NPAPI_ID}
26 # USE_NPAPI - If set, the port installs one or more npapi plugins.
27 # If this is set to a list of apps (wildcards possible) the
28 # plugins will be installed for them only. "linux" and "native"
29 # keywords can be used to support all linux-compat and native
30 # browsers, correspondingly. "embed" keyword prevents the
31 # do-install target being set to a default.
32 # WITH_NPAPI - A user-tunable variable, determines which apps should
33 # plugin be made available for. Can be set to a list of
34 # apps, same as USE_NPAPI, and/or to "ext:app[,app,app,...]"
35 # tuples. ext should be a portname. If ext starts and ends with
36 # a slash (`/'), it is treated as an extended regular expression
37 # (see re_format(7)). Right of the colon should be a list of
38 # apps in the same format as USE_NPAPI, but comma- instead of
39 # whitespace-delimited. If no matching tuples for an plugin are
40 # found, WITH_NPAPI is scanned for non tuple-records which are
41 # then treated as a USE_NPAPI list. If several tuples match, the
42 # last non-regexp one takes precedence, then the last regexp
45 # This Makefile is an alpha-version of the new npapi infrastructure.
47 # Npapi's are installed into ${LOCALBASE}/lib/npapi/${NPAPI_ID} by default and
48 # links are made to all apps which have the engine (firefox, thunderbird, flock,
49 # netscape messenger and navigator at the moment). relink and relink-all targets
50 # can be invoked to refarm the links of a single plugins or all installed
51 # plugins accordingly.
53 # npapi ports do not depend on their master applications. You can install an
54 # plugin before the app and run relink when the app is present.
57 NPAPI_DISTNAME?= ${PORTNAME}
58 NPAPI_WRKSRC?= ${WRKSRC}
59 NPAPI_PKGINSTALL?= ${WRKDIR}/npapi-pkg-install
60 NPAPI_PKGDEINSTALL?= ${WRKDIR}/npapi-pkg-deinstall
61 PKGINSTALL?= ${NPAPI_PKGINSTALL}
62 PKGDEINSTALL?= ${NPAPI_PKGDEINSTALL}
64 NPAPI_APPS_ALL_WC= *mozilla* *firefox* *flock* *seamonkey* *opera* \
65 *netscape-messenger* *netscape-navigator*
66 NPAPI_APPS_ALL_WC_LINUX= ${NPAPI_APPS_ALL_WC:S/^*/linux-/}
67 NPAPI_APPS_ALL_WC_NATIVE= ${NPAPI_APPS_ALL_WC:S/^*//}
68 NPAPI_APPS_ALL= firefox firefox-devel linux-firefox linux-firefox-devel \
69 flock flock-devel linux-flock linux-flock-devel \
70 mozilla mozilla-devel linux-mozilla firefox3 firefox35 \
71 linux-netscape-messenger linux-netscape-navigator \
73 opera opera-devel linux-opera linux-opera-devel \
74 seamonkey seamonkey-devel linux-seamonkey linux-seamonkey-devel \
75 sunbird sunbird-devel linux-sunbird linux-sunbird-devel
77 # === Let's process WITH_NPAPI into WITH_NPAPI_APPS
78 WITH_NPAPI_TUPLES= ${WITH_NPAPI:M*?\:?*}
79 WITH_NPAPI_NTUPLES= ${WITH_NPAPI:N*\:*}
80 WITH_NPAPI_TUPLES_RX= ${WITH_NPAPI_TUPLES:M/*?*/\:?*}
81 WITH_NPAPI_TUPLES_WC= ${WITH_NPAPI_TUPLES:N/*?*/\:?*}
82 WITH_NPAPI_MATCH?= ${PORTNAME}
83 WITH_NPAPI_MATCHSTRING?= _=~match~=_
85 .for tuple_rx in ${WITH_NPAPI_TUPLES_RX}
86 _rx= ${tuple_rx:C!/(.*)/\:.*!\1!}
87 _apps= ${tuple_rx:C!/.*/\:(.*)!\1!}
88 _testrx=${WITH_NPAPI_MATCH:C!.*${_rx}.*!${WITH_NPAPI_MATCHSTRING}!}
89 .if ${_testrx} == ${WITH_NPAPI_MATCHSTRING}
90 WITH_NPAPI_APPS:= ${_apps:S/,/ /g}
94 .for tuple_wc in ${WITH_NPAPI_TUPLES_WC}
95 _wc= ${tuple_wc:C!(.*)\:.*!\1!}
96 _apps= ${tuple_wc:C!.*\:(.*)!\1!}
97 .if ${_wc} == ${WITH_NPAPI_MATCH}
98 WITH_NPAPI_APPS:= ${_apps:S/,/ /g}
102 .if ${WITH_NPAPI_NTUPLES}
103 WITH_NPAPI_APPS?= ${WITH_NPAPI_NTUPLES}
105 # === WITH_NPAPI has been processed
107 .ifdef WITH_NPAPI_APPS
108 USE_NPAPI= ${WITH_NPAPI_APPS}
111 .if !defined(USE_NPAPI) || ${USE_NPAPI:tu} == "YES" || ${USE_NPAPI} == "*"
112 USE_NPAPI= ${NPAPI_APPS_ALL_WC}
115 .for _TEMP_APP__ in ${NPAPI_APPS_ALL}
116 _TEMP_APP_=${_TEMP_APP__}
118 . for _TEMP_USE__ in ${USE_NPAPI}
119 _TEMP_USE_=${_TEMP_USE__}
120 . if !${_TEMP_APP_:C!${_TEMP_USE_:S/*/.*/:S/?/./}!!} || \
121 ( ${_TEMP_APP_:Mlinux-*} && ${_TEMP_USE_:Mlinux} ) || \
122 ( ${_TEMP_APP_:Nlinux-*} && ${_TEMP_USE_:Mnative} )
127 USE_NPAPI_EXP+= ${_TEMP_APP__}
131 NPAPI_APPS?= ${USE_NPAPI_EXP:S.^.${LOCALBASE}/lib/.:S.$./plugins.:N*opera*} \
132 ${USE_NPAPI_EXP:S.^.${LOCALBASE}/share/.:S.$./plugins.:M*/opera*}
133 NPAPI_SLDIRS_ALL= ${NPAPI_APPS_ALL:S.^.${NPAPI_SLDIR}/.}
134 NPAPI_SLDIRS= ${USE_NPAPI_EXP:S.^.${NPAPI_SLDIR}/.}
135 NPAPI_LINKFARMS= ${NPAPI_APPS} ${NPAPI_SLDIRS}
137 NPAPI_LIBDIR?= ${PREFIX}/lib/npapi
138 NPAPI_SLDIR?= ${NPAPI_LIBDIR}/symlinks
139 .ifndef NPAPI_DISTNAMES
140 NPAPI_NPAPIDIR?= ${NPAPI_LIBDIR}/${NPAPI_ID}
142 NPAPI_DIRS_TRY= ${NPAPI_SLDIRS_ALL:S,^${PREFIX}/,,} \
143 ${NPAPI_SLDIR:S,^${PREFIX}/,,} \
144 ${NPAPI_LIBDIR:S,^${PREFIX}/,,}
146 PLIST_SUB+= NPAPI_LIBDIR="${NPAPI_LIBDIR:S,^${PREFIX}/,,}" \
147 NPAPI_NPAPIDIR="${NPAPI_NPAPIDIR:S,^${PREFIX}/,,}"
149 _TD= ${NPAPI_NPAPIDIR:S,^${PREFIX}/,,}
150 _TD_FULL= ${NPAPI_NPAPIDIR}
152 _PI= ${NPAPI_PKGINSTALL}
153 _PD= ${NPAPI_PKGDEINSTALL}
154 _Q= 2>/dev/null || true
155 PLIST_FILES+= ${NPAPI_FILES:S!^!${_TD}/!}
156 PLIST_DIRS+= ${NPAPI_DIRS:S!^!${_TD}/!} ${_TD}
158 .for dist in ${NPAPI_DISTNAMES}
159 NPAPI_NPAPIDIR_${dist}= ${NPAPI_LIBDIR}/${NPAPI_ID_${dist}}
160 _TD_${dist}= ${NPAPI_NPAPIDIR_${dist}:S,^${PREFIX}/,,}
161 PLIST_FILES+= ${NPAPI_FILES_${dist}:S!^!${_TD_${dist}}/!}
162 PLIST_DIRS+= ${NPAPI_DIRS_${dist}:S!^!${_TD_${dist}}/!} ${_TD_${dist}}
166 @${INSTALL} -d ${_TD_FULL} ${NPAPI_SLDIRS_ALL}
167 @${CP} -p ${NPAPI_FILES:S,^,${NPAPI_WRKSRC}/,} ${_TD_FULL}/
168 @${CHOWN} -R ${SHAREOWN}:${SHAREGRP} ${_TD_FULL}/
169 @${CHMOD} -R a+rX,go-w ${_TD_FULL}/
170 @for _dir in ${NPAPI_LINKFARMS} ; { ${LN} -sf ${_TD_FULL}/* $$_dir ${_Q} ; }
171 @${ECHO_CMD} '${INSTALL} -d ${NPAPI_SLDIRS_ALL}' > ${_PI}
172 @${ECHO_CMD} 'for _dir in ${NPAPI_LINKFARMS} ; \
173 { ${LN} -sf ${NPAPI_FILES:S,^,${_TD_FULL}/,} $$_dir/ ${_Q}; }' >> ${_PI}
174 @${ECHO_CMD} 'for _dir in ${NPAPI_LINKFARMS} ; \
175 { ${RM} -f ${NPAPI_FILES:S,^,\$_dir/,} ; }' > ${_PD}
176 @${ECHO_CMD} 'rmdir ${NPAPI_DIRS_TRY:S,^,${PREFIX}/,} ${_Q}' >> ${_PD}
177 .if ${PKGINSTALL} != ${NPAPI_PKGINSTALL}
178 @${CAT} ${NPAPI_PKGINSTALL} >> ${PKGINSTALL}
180 .if ${PKGDEINSTALL} != ${NPAPI_PKGDEINSTALL}
181 @${CAT} ${NPAPI_PKGDEINSTALL} >> ${PKGDEINSTALL}
184 .if !target(do-install) && !${USE_NPAPI:Membed}
185 do-install: npapi-do-install
190 @-for _app in ${NPAPI_APPS} ; { ${LN} -sf ${_TD_FULL}/* $$_app ${_Q} ; }
195 @${ECHO_CMD} -n 'NPAPI_FILES='
196 @cd ${NPAPI_WRKSRC} && ${FIND} -s . -not -type d | cut -f2- -d/ | ${TR} '\n' ' '
198 @${ECHO_CMD} -n 'NPAPI_DIRS='
199 @cd ${NPAPI_WRKSRC} && ${FIND} -ds . -not -name . -type d | cut -f2- -d/ | ${TR} '\n' ' '
203 @${FIND} -s ${NPAPI_WRKSRC} -not -type d | \
204 ${SED} -e "s,^${NPAPI_WRKSRC},%%NPAPI_NPAPIDIR%%," > ${PLIST}
205 @${FIND} -ds ${NPAPI_WRKSRC} -type d -not -name ${DISTNAME} | \
206 ${SED} -e "s,^${NPAPI_WRKSRC},@dirrm %%NPAPI_NPAPIDIR%%," >> ${PLIST}