aboutsummaryrefslogtreecommitdiffstats
path: root/www/linux-mplayer-plugin/Makefile.npapi
blob: e1db9dcc5b008eb0c985f39b8bf2956b8198d623 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
#-*- mode: makefile; tab-width: 4; -*
# ex:ts=4
#
# New ports collection makefile for:    npapi infrastructure
# Date created:     27 June 2006
# Whom:             Andrew Pantyukhin <infofarmer@FreeBSD.org>
#
# $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= mozilla mozilla-devel linux-mozilla \
                firefox firefox-devel linux-firefox linux-firefox-devel \
                flock linux-flock \
                seamonkey linux-seamonkey linux-seamonkey-devel \
                opera linux-opera

# === 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}