fix xpi extraction
[dports.git] / Mk / bsd.gecko.mk
1 #-*- tab-width: 4; -*-
2 # ex:ts=4
3 #
4 # Date created:         12 Nov 2005
5 # Whom:                 Michael Johnson <ahze@FreeBSD.org>
6 #
7 # $FreeBSD$
8 #
9 # 4 column tabs prevent hair loss and tooth decay!
10
11 # bsd.gecko.mk abstracts the selection of gecko-based backends. It allows users
12 # and porters to support any available gecko backend without needing to build
13 # many conditional tests. ${USE_GECKO} is the list of backends that your port
14 # can handle, and ${GECKO} is set by bsd.gecko.mk to be the chosen backend.
15 # Users set ${WITH_GECKO} to the list of gecko backends they want on their
16 # system.
17
18 .if defined(USE_GECKO)
19 .if !defined(_POSTMKINCLUDED) && !defined(Gecko_Pre_Include)
20 Gecko_Pre_Include=      bsd.gecko.mk
21
22 # This file contains some reusable components for mozilla ports. It's of
23 # use primarily to apps from the mozilla project itself (such as Firefox,
24 # Thunderbird, etc.), and probably won't be of use for gecko-based ports
25 # like epiphany, galeon, etc.
26 #
27 # You need to make sure to add USE_GECKO=gecko to for your port can uses
28 # one of these options below.
29 #
30 # Ports can use the following:
31 #
32 # USE_MOZILLA                   By default, it enables every system dependency
33 #                                               listed in '_ALL_DEPENDS'. If your port doesn't
34 #                                               need one of those then you can use '-' like
35 #                                               'USE_MOZILLA= -png -vpx' to subtract the
36 #                                               dependencies. Experimental deps use '+' like
37 #                                               'USE_MOZILLA= +speex +theora'.
38 #
39 # GECKO_PLIST_PRE_FILES Manual add files in the plist if it needs.
40 #
41 # GECKO_PLIST_PRE_DIRS  Manual directories in the plist if it needs.
42 #
43 # MOZILLA_PLIST_DIRS    List of directories to descend into when installing
44 #                                               and creating the plist
45 #
46 # MOZ_PIS_SCRIPTS               List of scripts residing in ${FILESDIR} to be
47 #                                               filtered through MOZCONFIG_SED and installed along
48 #                                               with our Pluggable Init Scripts (PIS)
49 #
50 # MOZ_SED_ARGS                  sed(1) commands through which MOZ_PIS_SCRIPTS are
51 #                                               filtered. There is a default set defined here, so
52 #                                               you probably want to add to MOZ_SED_ARGS rather
53 #                                               than clobber it
54 #
55 # MOZ_OPTIONS                   configure arguments (added to .mozconfig). If
56 #                                               NOMOZCONFIG is defined, you probably want to set
57 #                                               CONFIGURE_ARGS+=${MOZ_OPTIONS}
58 #
59 # MOZ_MK_OPTIONS                The make(1) arguments (added to .mozconfig). If
60 #                                               NOMOZCONFIG is defined, you probably want to set
61 #                                               MAKE_ARGS+=${MOZ_MK_OPTIONS}
62 #
63 # MOZ_EXPORT                    Environment variables for the build process (added
64 #                                               to .mozconfig). If NOMOZCONFIG is defined, you
65 #                                               probably want to set MAKE_ENV+=${MOZ_EXPORT}
66 #
67 # MOZ_CHROME                    A variable for the --enable-chrome-format= in
68 #                                               CONFIGURE_ARGS. The default is omni.
69 #
70 # MOZ_TOOLKIT                   A variable for the --enable-default-toolkit= in
71 #                                               CONFIGURE_ARGS. The default is cairo-gtk2.
72 #
73 # MOZ_EXTENSIONS                A list of extensions to build
74 #
75 # MOZ_PROTOCOLS                 A list of protocols to build (http, ftp, etc.)
76 #
77 # PORT_MOZCONFIG                Defaults to ${FILESDIR}/mozconfig.in, but can be
78 #                                               set to a generic mozconfig included with the port
79 #
80 # NOGECKO_INSTALL               Don't install the built gecko (most likely for
81 #                                               testing)
82 #
83 # NOGECKO_PLIST                 Don't create a dynamically-generated playlist
84 #
85 # NOMOZCONFIG                   Don't drop a customized .mozconfig into the build
86 #                                               directory. Options will have to be specified in
87 #                                               CONFIGURE_ARGS instead
88 #
89
90 MAINTAINER?=    gecko@FreeBSD.org
91
92 MOZILLA?=       ${PORTNAME}
93 MOZILLA_VER?=   ${PORTVERSION}
94 MOZILLA_BIN?=   ${PORTNAME}-bin
95 MOZILLA_EXEC_NAME?=${MOZILLA}
96 MOZ_RPATH?=     ${MOZILLA}
97 USE_GNOME+=     desktopfileutils
98 USES+=          compiler:c++11-lib gmake iconv perl5 pkgconfig
99 USE_PERL5=      build
100 USE_XORG=       xext xrender xt
101
102 NO_STAGE=       yes
103
104 MOZILLA_SUFX?=  none
105 MOZSRC?=        ${WRKSRC}
106 WRKSRC?=        ${WRKDIR}/mozilla
107 FAKEDIR?=       ${WRKDIR}/fake
108 PLIST?=         ${WRKDIR}/plist
109 PLISTD?=        ${WRKDIR}/plist_dirs
110 PLISTF?=        ${WRKDIR}/plist_files
111
112 MOZ_PIS_DIR?=           lib/${MOZILLA}/init.d
113
114 PORT_MOZCONFIG?=        ${FILESDIR}/mozconfig.in
115 MOZCONFIG?=             ${WRKSRC}/.mozconfig
116 MOZILLA_PLIST_DIRS?=    bin lib
117 PKGINSTALL?=    ${WRKDIR}/pkg-install
118 PKGDEINSTALL?=  ${WRKDIR}/pkg-deinstall
119 PKGINSTALL_INC?=        ${.CURDIR}/../../www/firefox/files/pkg-install.in
120 PKGDEINSTALL_INC?=      ${.CURDIR}/../../www/firefox/files/pkg-deinstall.in
121
122 EXTRACT_AFTER_ARGS?=    --exclude */CVS/*       \
123                         --exclude */macbuild/*                  \
124                         --exclude */package/*                   \
125                         --exclude mozilla*/gc/boehm
126
127 MOZ_PKGCONFIG_FILES?=   ${MOZILLA}-gtkmozembed ${MOZILLA}-js \
128                         ${MOZILLA}-xpcom ${MOZILLA}-plugin
129
130 MOZ_EXPORT+=    ${CONFIGURE_ENV} \
131                                 LIBS="${LIBS}" PERL="${PERL}"
132 MOZ_OPTIONS+=   --prefix="${FAKEDIR}"
133
134 CPPFLAGS+=              -isystem${LOCALBASE}/include
135 LDFLAGS+=               -L${LOCALBASE}/lib -Wl,-rpath,${PREFIX}/lib/${MOZILLA}
136
137 # use jemalloc 3.0.0 API for stats/tuning
138 MOZ_EXPORT+=    MOZ_JEMALLOC3=1
139 .if ${OSVERSION} < 1000012
140 MOZ_OPTIONS+=   --enable-jemalloc
141 .endif
142
143 # Standard depends
144 _ALL_DEPENDS=   cairo event ffi graphite harfbuzz hunspell icu jpeg nspr nss opus png pixman soundtouch sqlite vorbis vpx
145
146 cairo_LIB_DEPENDS=      libcairo.so:${PORTSDIR}/graphics/cairo
147 cairo_MOZ_OPTIONS=      --enable-system-cairo
148 cairo_EXTRACT_AFTER_ARGS=       --exclude mozilla*/gfx/cairo/cairo
149
150 event_LIB_DEPENDS=      libevent-2.0.so:${PORTSDIR}/devel/libevent2
151 event_MOZ_OPTIONS=      --with-system-libevent
152 event_EXTRACT_AFTER_ARGS=       --exclude mozilla*/ipc/chromium/src/third_party/libevent
153
154 ffi_LIB_DEPENDS=        libffi.so:${PORTSDIR}/devel/libffi
155 ffi_MOZ_OPTIONS=        --enable-system-ffi
156 ffi_EXTRACT_AFTER_ARGS= --exclude mozilla*/js/src/ctypes/libffi
157
158 .if exists(${FILESDIR}/patch-bug847568) || exists(${FILESDIR}/patch-z-bug847568)
159 graphite_LIB_DEPENDS=   libgraphite2.so:${PORTSDIR}/graphics/graphite2
160 graphite_MOZ_OPTIONS=   --with-system-graphite2
161 graphite_EXTRACT_AFTER_ARGS=    --exclude mozilla*/gfx/graphite2
162
163 harfbuzz_LIB_DEPENDS=   libharfbuzz.so:${PORTSDIR}/print/harfbuzz
164 harfbuzz_MOZ_OPTIONS=   --with-system-harfbuzz
165 harfbuzz_EXTRACT_AFTER_ARGS=    --exclude mozilla*/gfx/harfbuzz
166 .endif
167
168 hunspell_LIB_DEPENDS=   libhunspell-1.3.so:${PORTSDIR}/textproc/hunspell
169 hunspell_MOZ_OPTIONS=   --enable-system-hunspell
170
171 icu_LIB_DEPENDS=                libicui18n.so:${PORTSDIR}/devel/icu
172 icu_MOZ_OPTIONS=                --with-system-icu --with-intl-api --enable-intl-api
173
174 -jpeg_BUILD_DEPENDS=yasm:${PORTSDIR}/devel/yasm
175 # XXX depends on ports/180159 or package flavor support
176 #jpeg_LIB_DEPENDS=      libjpeg.so:${PORTSDIR}/graphics/libjpeg-turbo
177 jpeg_LIB_DEPENDS=       libjpeg.so:${PORTSDIR}/graphics/jpeg
178 jpeg_MOZ_OPTIONS=       --with-system-jpeg=${LOCALBASE}
179 jpeg_EXTRACT_AFTER_ARGS=        --exclude mozilla*/media/libjpeg
180
181 nspr_LIB_DEPENDS=       libnspr4.so:${PORTSDIR}/devel/nspr
182 nspr_MOZ_OPTIONS=       --with-system-nspr
183
184 nss_LIB_DEPENDS=        libnss3.so:${PORTSDIR}/security/nss
185 nss_MOZ_OPTIONS=        --with-system-nss
186 nss_EXTRACT_AFTER_ARGS= --exclude mozilla*/dbm \
187                                                 --exclude mozilla*/security/coreconf \
188                                                 --exclude mozilla*/security/nss
189
190 .if exists(${FILESDIR}/patch-z-bug517422) || exists(${FILESDIR}/patch-zz-bug517422)
191 opus_LIB_DEPENDS=       libopus.so:${PORTSDIR}/audio/opus
192 opus_MOZ_OPTIONS=       --with-system-opus
193 opus_EXTRACT_AFTER_ARGS=        --exclude mozilla*/media/libopus
194 .endif
195
196 pixman_LIB_DEPENDS=     libpixman-1.so:${PORTSDIR}/x11/pixman
197 pixman_MOZ_OPTIONS=     --enable-system-pixman
198 pixman_EXTRACT_AFTER_ARGS=      --exclude mozilla*/gfx/cairo/libpixman
199
200 png_LIB_DEPENDS=        libpng15.so:${PORTSDIR}/graphics/png
201 png_MOZ_OPTIONS=        --with-system-png=${LOCALBASE}
202 png_EXTRACT_AFTER_ARGS= --exclude mozilla*/media/libpng
203
204 .if exists(${FILESDIR}/patch-z-bug517422) || exists(${FILESDIR}/patch-zz-bug517422)
205 soundtouch_LIB_DEPENDS= libSoundTouch.so:${PORTSDIR}/audio/soundtouch
206 soundtouch_MOZ_OPTIONS= --with-system-soundtouch
207 soundtouch_EXTRACT_AFTER_ARGS=  --exclude mozilla*/media/libsoundtouch
208
209 # XXX disabled: bug 913854 not yet upstreamed
210 speex_LIB_DEPENDS=      libspeexdsp.so:${PORTSDIR}/audio/speex
211 speex_MOZ_OPTIONS=      --with-system-speex
212 speex_EXTRACT_AFTER_ARGS=       --exclude mozilla*/media/libspeex_resampler
213 .endif
214
215 sqlite_LIB_DEPENDS=     libsqlite3.so:${PORTSDIR}/databases/sqlite3
216 sqlite_MOZ_OPTIONS=     --enable-system-sqlite
217 sqlite_EXTRACT_AFTER_ARGS=      --exclude mozilla*/db/sqlite3
218
219 .if exists(${FILESDIR}/patch-z-bug517422) || exists(${FILESDIR}/patch-zz-bug517422)
220 # XXX disabled: update to 1.2.x or review backported fixes
221 theora_LIB_DEPENDS=     libtheora.so:${PORTSDIR}/multimedia/libtheora
222 theora_MOZ_OPTIONS=     --with-system-theora
223 theora_EXTRACT_AFTER_ARGS=      --exclude mozilla*/media/libtheora
224
225 vorbis_LIB_DEPENDS=     libvorbis.so:${PORTSDIR}/audio/libvorbis
226 vorbis_MOZ_OPTIONS=     --with-system-vorbis --with-system-ogg
227 vorbis_EXTRACT_AFTER_ARGS=      --exclude mozilla*/media/libvorbis \
228                                                         --exclude mozilla*/media/libogg
229 .endif
230
231 -vpx_BUILD_DEPENDS=     yasm:${PORTSDIR}/devel/yasm
232 vpx_LIB_DEPENDS=        libvpx.so:${PORTSDIR}/multimedia/libvpx
233 vpx_MOZ_OPTIONS=        --with-system-libvpx
234 vpx_EXTRACT_AFTER_ARGS= --exclude mozilla*/media/libvpx
235
236 .for use in ${USE_MOZILLA}
237 ${use:S/-/_WITHOUT_/}=  ${TRUE}
238 .endfor
239
240 .for dep in ${_ALL_DEPENDS} ${USE_MOZILLA:M+*:S/+//}
241 .if !defined(_WITHOUT_${dep})
242 BUILD_DEPENDS+= ${${dep}_BUILD_DEPENDS}
243 LIB_DEPENDS+=   ${${dep}_LIB_DEPENDS}
244 RUN_DEPENDS+=   ${${dep}_RUN_DEPENDS}
245 MOZ_OPTIONS+=   ${${dep}_MOZ_OPTIONS}
246 EXTRACT_AFTER_ARGS+=    ${${dep}_EXTRACT_AFTER_ARGS}
247 .else
248 BUILD_DEPENDS+= ${-${dep}_BUILD_DEPENDS}
249 .endif
250 .endfor
251
252 # Standard options
253 MOZ_CHROME?=    omni
254 MOZ_TOOLKIT?=   cairo-gtk2
255 MOZ_OPTIONS+=   \
256                 --enable-chrome-format=${MOZ_CHROME} \
257                 --enable-default-toolkit=${MOZ_TOOLKIT} \
258                 --with-pthreads
259 # Configure options for install
260 .if !defined(MOZ_EXTENSIONS)
261 MOZ_OPTIONS+=   --enable-extensions=default
262 .else
263 MOZ_OPTIONS+=   --enable-extensions=${MOZ_EXTENSIONS}
264 .endif
265 .if !defined(MOZ_PROTOCOLS)
266 MOZ_OPTIONS+=   --enable-necko-protocols=default
267 .else
268 MOZ_OPTIONS+=   --enable-necko-protocols=${MOZ_PROTOCOLS}
269 .endif
270 # others
271 MOZ_OPTIONS+=   --with-system-zlib              \
272                 --with-system-bz2               \
273                 --enable-unified-compilation    \
274                 --disable-debug-symbols         \
275                 --disable-glibtest              \
276                 --disable-gtktest               \
277                 --disable-freetypetest          \
278                 --disable-installer             \
279                 --disable-updater               \
280                 --disable-pedantic
281
282 # XXX stolen from www/chromium
283 MOZ_EXPORT+=    MOZ_GOOGLE_API_KEY=AIzaSyBsp9n41JLW8jCokwn7vhoaMejDFRd1mp8
284
285 .if ${PORT_OPTIONS:MGTK3}
286 MOZ_TOOLKIT=    cairo-gtk3
287 .endif
288
289 .if ${MOZ_TOOLKIT:Mcairo-qt}
290 # don't use - transparent backgrounds (bug 521582),
291 USE_MOZILLA+=   -cairo # ports/169343
292 USE_DISPLAY=yes # install
293 USE_GNOME+=     pango
294 . if ${MOZILLA_VER:R:R} >= 30
295 USE_QT5+=       qmake_build buildtools_build gui network quick printsupport
296 . else
297 USE_QT4+=       qmake_build moc_build rcc_build gui network opengl
298 . endif
299 MOZ_EXPORT+=    HOST_QMAKE="${QMAKE}" HOST_MOC="${MOC}" HOST_RCC="${RCC}"
300 .elif ${MOZ_TOOLKIT:Mcairo-gtk3}
301 USE_GNOME+=     gtk30
302 .else # gtk2, cairo-gtk2
303 USE_GNOME+=     gtk20
304 .endif
305
306 .if ${PORT_OPTIONS:MOPTIMIZED_CFLAGS}
307 CFLAGS+=                -O3
308 MOZ_EXPORT+=    MOZ_OPTIMIZE_FLAGS="${CFLAGS:M-O*}"
309 MOZ_OPTIONS+=   --enable-optimize
310 .else
311 MOZ_OPTIONS+=   --disable-optimize
312 .endif
313
314 .if ${PORT_OPTIONS:MDBUS}
315 BUILD_DEPENDS+= libnotify>0:${PORTSDIR}/devel/libnotify
316 LIB_DEPENDS+=   libdbus-glib-1.so:${PORTSDIR}/devel/dbus-glib \
317                                 libstartup-notification-1.so:${PORTSDIR}/x11/startup-notification
318 MOZ_OPTIONS+=   --enable-startup-notification
319 .else
320 MOZ_OPTIONS+=   --disable-dbus --disable-libnotify
321 .endif
322
323 .if ${PORT_OPTIONS:MGSTREAMER}
324 . if ${MOZILLA_VER:R:R} >= 30 || exists(${FILESDIR}/patch-bug806917)
325 USE_GSTREAMER1?=good libav
326 MOZ_OPTIONS+=   --enable-gstreamer=1.0
327 . else
328 USE_GSTREAMER?= good ffmpeg
329 MOZ_OPTIONS+=   --enable-gstreamer
330 . endif
331 .else
332 MOZ_OPTIONS+=   --disable-gstreamer
333 .endif
334
335 .if ${PORT_OPTIONS:MGCONF}
336 BUILD_DEPENDS+= ${gconf2_DETECT}:${gconf2_LIB_DEPENDS:C/.*://}
337 USE_GNOME+=             gconf2:build
338 MOZ_OPTIONS+=   --enable-gconf
339 .else
340 MOZ_OPTIONS+=   --disable-gconf
341 .endif
342
343 .if ${PORT_OPTIONS:MGIO} && ! ${MOZ_TOOLKIT:Mcairo-qt}
344 MOZ_OPTIONS+=   --enable-gio
345 .else
346 MOZ_OPTIONS+=   --disable-gio
347 .endif
348
349 .if ${PORT_OPTIONS:MGNOMEUI}
350 BUILD_DEPENDS+= ${libgnomeui_DETECT}:${libgnomeui_LIB_DEPENDS:C/.*://}
351 USE_GNOME+=             libgnomeui:build
352 MOZ_OPTIONS+=   --enable-gnomeui
353 .else
354 MOZ_OPTIONS+=   --disable-gnomeui
355 .endif
356
357 .if ${PORT_OPTIONS:MGNOMEVFS2}
358 BUILD_DEPENDS+= ${gnomevfs2_DETECT}:${gnomevfs2_LIB_DEPENDS:C/.*://}
359 USE_GNOME+=             gnomevfs2:build
360 MOZ_OPTIONS+=   --enable-gnomevfs
361 MOZ_OPTIONS:=   ${MOZ_OPTIONS:C/(extensions)=(.*)/\1=\2,gnomevfs/}
362 .else
363 MOZ_OPTIONS+=   --disable-gnomevfs
364 .endif
365
366 .if ${PORT_OPTIONS:MLIBPROXY}
367 LIB_DEPENDS+=   libproxy.so:${PORTSDIR}/net/libproxy
368 MOZ_OPTIONS+=   --enable-libproxy
369 .else
370 MOZ_OPTIONS+=   --disable-libproxy
371 .endif
372
373 .if ${PORT_OPTIONS:MPGO}
374 USE_GCC?=       yes
375 USE_DISPLAY=yes
376
377 .undef GNU_CONFIGURE
378 MAKEFILE=       ${WRKSRC}/client.mk
379 ALL_TARGET=     profiledbuild
380 MOZ_EXPORT+=MOZ_OPTIMIZE_FLAGS="-Os" MOZ_PGO_OPTIMIZE_FLAGS="${CFLAGS:M-O*}"
381 .endif
382
383 .if ${PORT_OPTIONS:MALSA}
384 LIB_DEPENDS+=   libasound.so:${PORTSDIR}/audio/alsa-lib
385 RUN_DEPENDS+=   ${LOCALBASE}/lib/alsa-lib/libasound_module_pcm_oss.so:${PORTSDIR}/audio/alsa-plugins
386 MOZ_OPTIONS+=   --enable-alsa
387 .endif
388
389 .if ${PORT_OPTIONS:MPULSEAUDIO}
390 . if ${PORT_OPTIONS:MALSA}
391 BUILD_DEPENDS+= pulseaudio>0:${PORTSDIR}/audio/pulseaudio
392 . else
393 # pull pulse package if we cannot fallback to another backend
394 LIB_DEPENDS+=   libpulse.so:${PORTSDIR}/audio/pulseaudio
395 . endif
396 MOZ_OPTIONS+=   --enable-pulseaudio
397 .else
398 MOZ_OPTIONS+=   --disable-pulseaudio
399 .endif
400
401 .if ${PORT_OPTIONS:MDEBUG}
402 MOZ_OPTIONS+=   --enable-debug --disable-release
403 STRIP=  # ports/184285
404 .else
405 MOZ_OPTIONS+=   --disable-debug --enable-release
406 .endif
407
408 .if ${PORT_OPTIONS:MLOGGING} || ${PORT_OPTIONS:MDEBUG}
409 MOZ_OPTIONS+=   --enable-logging
410 .else
411 MOZ_OPTIONS+=   --disable-logging
412 .endif
413
414 .if ${PORT_OPTIONS:MPROFILE}
415 MOZ_OPTIONS+=   --enable-profiling
416 STRIP=
417 .else
418 MOZ_OPTIONS+=   --disable-profiling
419 .endif
420
421 .if ${PORT_OPTIONS:MTEST}
422 USE_XORG+=              xscrnsaver
423 MOZ_OPTIONS+=   --enable-tests
424 .else
425 MOZ_OPTIONS+=   --disable-tests
426 .endif
427
428 .if !defined(STRIP) || ${STRIP} == ""
429 MOZ_OPTIONS+=   --disable-strip --disable-install-strip
430 .else
431 MOZ_OPTIONS+=   --enable-strip --enable-install-strip
432 .endif
433
434 MOZ_SED_ARGS+=  -e's|@CPPFLAGS@|${CPPFLAGS}|g'          \
435                 -e 's|@CFLAGS@|${CFLAGS}|g'             \
436                 -e 's|@LDFLAGS@|${LDFLAGS}|g'           \
437                 -e 's|@LIBS@|${LIBS}|g'                 \
438                 -e 's|@LOCALBASE@|${LOCALBASE}|g'       \
439                 -e 's|@FAKEDIR@|${FAKEDIR}|g'           \
440                 -e 's|@PERL@|${PERL5}|g'                        \
441                 -e 's|@MOZDIR@|${PREFIX}/lib/${MOZILLA}|g'      \
442                 -e 's|%%PREFIX%%|${PREFIX}|g'           \
443                 -e 's|%%CFLAGS%%|${CFLAGS}|g'           \
444                 -e 's|%%LDFLAGS%%|${LDFLAGS}|g'         \
445                 -e 's|%%LIBS%%|${LIBS}|g'               \
446                 -e 's|%%LOCALBASE%%|${LOCALBASE}|g'     \
447                 -e 's|%%FAKEDIR%%|${FAKEDIR}|g'         \
448                 -e 's|%%PERL%%|${PERL5}|g'              \
449                 -e 's|%%MOZILLA%%|${MOZILLA}|g'         \
450                 -e 's|%%MOZILLA_BIN%%|${MOZILLA_BIN}|g' \
451                 -e 's|%%MOZDIR%%|${PREFIX}/lib/${MOZILLA}|g'
452 MOZCONFIG_SED?= ${SED} ${MOZ_SED_ARGS}
453
454 .if ${ARCH} == amd64
455 CONFIGURE_TARGET=x86_64-unknown-${OPSYS:tl}${OSREL}
456 . if ${USE_MOZILLA:M-nss}
457 USE_BINUTILS=   # intel-gcm.s
458 CFLAGS+=        -B${LOCALBASE}/bin
459 LDFLAGS+=       -B${LOCALBASE}/bin
460 .  if ${OSVERSION} < 1000041 && exists(/usr/lib/libcxxrt.so) && \
461         ${CXXFLAGS:M-stdlib=libc++}
462 LIBS+=          -lcxxrt
463 .  endif
464 . endif
465 .elif ${ARCH:Mpowerpc*}
466 USE_GCC?=       yes
467 CFLAGS+=        -D__STDC_CONSTANT_MACROS
468 . if ${ARCH} == "powerpc64"
469 MOZ_EXPORT+=    UNAME_m="${ARCH}"
470 CFLAGS+=        -mminimal-toc
471 . endif
472 .elif ${ARCH} == "sparc64"
473 # Work around miscompilation/mislinkage of the sCanonicalVTable hacks.
474 MOZ_OPTIONS+=   --disable-v1-string-abi
475 .endif
476
477 .if defined(OBJDIR_BUILD)
478 CONFIGURE_SCRIPT=../configure
479
480 MOZ_OBJDIR=             ${WRKSRC}/obj-${CONFIGURE_TARGET}
481 CONFIGURE_WRKSRC=${MOZ_OBJDIR}
482 BUILD_WRKSRC=   ${MOZ_OBJDIR}
483 INSTALL_WRKSRC= ${MOZ_OBJDIR}
484 .else
485 MOZ_OBJDIR=             ${WRKSRC}
486 .endif
487
488 .else # bsd.port.post.mk
489
490 pre-extract: gecko-pre-extract
491
492 gecko-pre-extract:
493 .if ${PORT_OPTIONS:MPGO}
494         @${ECHO} "*****************************************************************"
495         @${ECHO} "**************************** attention **************************"
496         @${ECHO} "*****************************************************************"
497         @${ECHO} "To build ${MOZILLA} with PGO support you need a running X server and"
498         @${ECHO} "   build this port with an user who could access the X server!   "
499         @${ECHO} ""
500         @${ECHO} "During the build a ${MOZILLA} instance will start and run some test."
501         @${ECHO} "      Do not interrupt or close ${MOZILLA} during this tests!       "
502         @${ECHO} "*****************************************************************"
503         @sleep 10
504 .endif
505
506 post-patch: gecko-post-patch gecko-moz-pis-patch
507
508 gecko-post-patch:
509 .if exists(${PKGINSTALL_INC})
510         @${MOZCONFIG_SED} < ${PKGINSTALL_INC} > ${PKGINSTALL}
511 .endif
512 .if exists(${PKGDEINSTALL_INC})
513         @${MOZCONFIG_SED} < ${PKGDEINSTALL_INC} > ${PKGDEINSTALL}
514 .endif
515         @${RM} -f ${MOZCONFIG}
516 .if !defined(NOMOZCONFIG)
517         @if [ -e ${PORT_MOZCONFIG} ] ; then \
518                 ${MOZCONFIG_SED} < ${PORT_MOZCONFIG} >> ${MOZCONFIG} ; \
519         fi
520 .for arg in ${MOZ_OPTIONS}
521         @${ECHO_CMD} ac_add_options ${arg:Q} >> ${MOZCONFIG}
522 .endfor
523 .for arg in ${MOZ_MK_OPTIONS}
524         @${ECHO_CMD} mk_add_options ${arg:Q} >> ${MOZCONFIG}
525 .endfor
526 .for var in ${MOZ_EXPORT}
527         @${ECHO_CMD} export ${var:Q} >> ${MOZCONFIG}
528 .endfor
529 .endif # .if !defined(NOMOZCONFIG)
530 .if exists(${MOZSRC}/build/unix/mozilla-config.in)
531         @${REINPLACE_CMD} -e  's/%{idldir}/%idldir%/g ; \
532                 s|"%FULL_NSPR_CFLAGS%"|`nspr-config --cflags`|g ; \
533                 s|"%FULL_NSPR_LIBS%"|`nspr-config --libs`|g' \
534                         ${MOZSRC}/build/unix/mozilla-config.in
535 .endif
536 .if ${USE_MOZILLA:M-nspr}
537         @${ECHO_MSG} "===>  Applying NSPR patches"
538         @for i in ${.CURDIR}/../../devel/nspr/files/patch-*; do \
539                 ${PATCH} ${PATCH_ARGS} -d ${MOZSRC}/nsprpub/build < $$i; \
540         done
541 .endif
542 .if ${USE_MOZILLA:M-nss}
543         @${ECHO_MSG} "===>  Applying NSS patches"
544         @for i in ${.CURDIR}/../../security/nss/files/patch-*; do \
545                 ${PATCH} ${PATCH_ARGS} -d ${MOZSRC}/security/nss < $$i; \
546         done
547 .endif
548         @for f in \
549                         ${WRKSRC}/directory/c-sdk/config/FreeBSD.mk \
550                         ${WRKSRC}/directory/c-sdk/configure \
551                         ${MOZSRC}/security/coreconf/FreeBSD.mk \
552                         ${MOZSRC}/js/src/Makefile.in \
553                         ${MOZSRC}/js/src/configure \
554                         ${MOZSRC}/configure \
555                         ${WRKSRC}/configure; do \
556                 if [ -f $$f ] ; then \
557                         ${REINPLACE_CMD} -Ee 's|-lc_r|${PTHREAD_LIBS}|g ; \
558                                 s|-l?pthread|${PTHREAD_LIBS}|g ; \
559                                 s|echo aout|echo elf|g ; \
560                                 s|/usr/X11R6|${LOCALBASE}|g' \
561                                 $$f; \
562                 fi; \
563         done
564         @if [ -f ${WRKSRC}/config/baseconfig.mk ] ; then \
565                 ${REINPLACE_CMD} -e 's|%%MOZILLA%%|${MOZILLA}|g' \
566                         ${WRKSRC}/config/baseconfig.mk; \
567         else \
568                 ${REINPLACE_CMD} -e 's|%%MOZILLA%%|${MOZILLA}|g' \
569                         ${WRKSRC}/config/autoconf.mk.in; \
570         fi
571         @${REINPLACE_CMD} -e 's|%%PREFIX%%|${PREFIX}|g ; \
572                 s|%%LOCALBASE%%|${LOCALBASE}|g' \
573                         ${MOZSRC}/build/unix/run-mozilla.sh
574         @${REINPLACE_CMD} -e 's|/usr/local/netscape|${LOCALBASE}|g ; \
575                 s|/usr/local/lib/netscape|${LOCALBASE}/lib|g' \
576                 ${MOZSRC}/xpcom/io/SpecialSystemDirectory.cpp
577         @${REINPLACE_CMD} -e 's|/etc|${PREFIX}&|g' \
578                 ${MOZSRC}/xpcom/build/nsXPCOMPrivate.h
579         @${REINPLACE_CMD} -e 's|/usr/local|${LOCALBASE}|g' \
580                 -e 's|mozilla/plugins|browser_plugins|g' \
581                 -e 's|share/mozilla/extensions|lib/xpi|g' \
582                 ${MOZSRC}/xpcom/io/nsAppFileLocationProvider.cpp \
583                 ${MOZSRC}/toolkit/xre/nsXREDirProvider.cpp
584         @${REINPLACE_CMD} -e 's|%%LOCALBASE%%|${LOCALBASE}|g' \
585                 ${MOZSRC}/extensions/spellcheck/hunspell/src/mozHunspell.cpp
586
587 # handles mozilla pis scripts.
588 gecko-moz-pis-patch:
589 .for moz in ${MOZ_PIS_SCRIPTS}
590         @${MOZCONFIG_SED} < ${FILESDIR}/${moz} > ${WRKDIR}/${moz}
591 .endfor
592
593 pre-configure: gecko-pre-configure
594
595 gecko-pre-configure:
596 .if defined(OBJDIR_BUILD)
597         ${MKDIR} ${MOZ_OBJDIR}
598 .endif
599
600 post-configure: gecko-post-configure
601
602 gecko-post-configure:
603         @${ECHO_CMD} "#define JNIIMPORT" >> ${MOZSRC}/mozilla-config.h
604
605 pre-install: gecko-moz-pis-pre-install gecko-pre-install port-pre-install gecko-create-plist
606
607 .if !target(port-pre-install)
608 port-pre-install:
609                 @${DO_NADA}
610 .endif
611
612 gecko-pre-install:
613 .if !defined(NOGECKO_PLIST)
614         @${RM} -rf ${FAKEDIR} ${PLIST} ${PLISTD} ${PLISTF}
615         @${TOUCH} -f ${PLIST} ${PLISTD} ${PLISTF}
616         @cd ${INSTALL_WRKSRC} && ${SETENV} ${MAKE_ENV} ${GMAKE} ${MAKE_FLAGS} \
617                 ${MAKEFILE} ${MAKE_ARGS} prefix=${FAKEDIR} ${INSTALL_TARGET}
618 .if defined(MOZILLA_SUFX) && ${MOZILLA_SUFX}!="none"
619         ${MV} ${FAKEDIR}/bin/${MOZILLA_EXEC_NAME:S/${MOZILLA_SUFX}//} ${FAKEDIR}/bin/${MOZILLA}
620 .if exists(${FAKEDIR}/bin/${MOZILLA_EXEC_NAME:S/${MOZILLA_SUFX}//}-config)
621         ${MV} ${FAKEDIR}/bin/${MOZILLA_EXEC_NAME:S/${MOZILLA_SUFX}//}-config ${FAKEDIR}/bin/${MOZILLA}-config
622 .endif
623 .for pc in ${MOZ_PKGCONFIG_FILES:S|${MOZILLA_SUFX}||}
624         ${SED} -e 's|Requires: ${MOZILLA:S/${MOZILLA_SUFX}//}|Requires: ${MOZILLA}|' \
625         ${FAKEDIR}/lib/pkgconfig/${pc}.pc > ${FAKEDIR}/lib/pkgconfig/${pc:S/${MOZILLA:S,${MOZILLA_SUFX},,}/${MOZILLA}/}.pc
626 .endfor
627         @${REINPLACE_CMD} -e 's|${MOZILLA_BIN}|${MOZILLA:S/${MOZILLA_SUFX}//}|; \
628                 s|$${progbase}-bin|${MOZILLA:S/${MOZILLA_SUFX}//}-bin|' \
629                 -e 's|${FAKEDIR}|${PREFIX}|g' \
630                 -i '' $$(${REALPATH} ${FAKEDIR}/bin/${MOZILLA}*)
631 .else
632         @${REINPLACE_CMD} -e 's|${FAKEDIR}|${PREFIX}|g' \
633                 -i '' $$(${REALPATH} ${FAKEDIR}/bin/${MOZILLA_EXEC_NAME}*)
634 .endif
635 .endif
636
637 gecko-create-plist:
638 .if !defined(NOGECKO_PLIST)
639 # Create the plist
640 .for f in ${GECKO_PLIST_PRE_FILES}
641         ${ECHO_CMD} ${f} >> ${PLISTF}
642 .endfor
643 .for f in ${GECKO_PLIST_PRE_DIRS}
644         ${ECHO_CMD} "@dirrm ${f}" >> ${PLISTD}
645 .endfor
646         ${MKDIR} ${FAKEDIR}/libdata
647         ${MV} -f ${FAKEDIR}/lib/pkgconfig ${FAKEDIR}/libdata/ || ${TRUE}
648         ${RM} -f ${FAKEDIR}/lib/pkgconfig
649 .for dir in ${MOZILLA_PLIST_DIRS}
650         @cd ${FAKEDIR}/${dir} && ${FIND} -H -s * ! -type d | \
651                 ${SED} -e 's|^|${dir}/|' >> ${PLISTF} && \
652                 ${FIND} -d * -type d | \
653                 ${SED} -e 's|^|@dirrm ${dir}/|' >> ${PLISTD}
654 .endfor
655 .for pcfile in ${MOZ_PKGCONFIG_FILES}
656         ${ECHO_CMD} "libdata/pkgconfig/${pcfile}.pc" >> ${PLISTF}
657         @${REINPLACE_CMD} -e 's|${FAKEDIR}|${PREFIX}|g' \
658                 -e 's|${MOZILLA}-nspr = ${PORTVERSION}|nspr|' \
659                 ${FAKEDIR}/libdata/pkgconfig/${pcfile}.pc
660 .endfor
661         ${CAT} ${PLISTF} | ${SORT} >> ${PLIST}
662         ${CAT} ${PLISTD} | ${SORT} -r >> ${PLIST}
663         ${ECHO_CMD} "@exec ${LOCALBASE}/bin/update-desktop-database > /dev/null || ${TRUE}" >> ${PLIST}
664         ${ECHO_CMD} "@unexec ${LOCALBASE}/bin/update-desktop-database > /dev/null || ${TRUE}" >> ${PLIST}
665 .endif # !defined(NOGECKO_PLIST)
666
667 do-install: gecko-do-install
668
669 gecko-do-install:
670 .if !defined(NOGECKO_INSTALL)
671 .for dir in ${MOZILLA_PLIST_DIRS}
672 .if !exists(${PREFIX}/${dir})
673         ${MKDIR} ${PREFIX}/${dir}
674 .endif
675         ${TAR} cf - -C${FAKEDIR}/${dir} -s'|${FAKEDIR}|${PREFIX}|s' . | \
676                 ${TAR} xof - -C${PREFIX}/${dir}
677 .endfor
678 .for pcfile in ${MOZ_PKGCONFIG_FILES}
679         ${INSTALL_DATA} ${FAKEDIR}/libdata/pkgconfig/${pcfile}.pc \
680                 ${PREFIX}/libdata/pkgconfig/${pcfile}.pc
681 .endfor
682 .endif # !defined(NOGECKO_INSTALL)
683
684 gecko-moz-pis-pre-install:
685 .if defined(MOZ_PIS_SCRIPTS)
686         ${MKDIR} ${FAKEDIR}/${MOZ_PIS_DIR}
687 .for moz in ${MOZ_PIS_SCRIPTS}
688         ${INSTALL_SCRIPT} ${WRKDIR}/${moz} ${FAKEDIR}/${MOZ_PIS_DIR}
689 .endfor
690 .endif
691
692 post-install: gecko-post-install
693
694 gecko-post-install:
695 .if !defined(PACKAGE_BUILDING) && !defined(NO_MOZPKGINSTALL)
696         @if [ -e ${PKGINSTALL} ] ; then \
697                 ${SETENV} PKG_PREFIX=${PREFIX} ${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL; \
698         fi
699 .endif
700         @-update-desktop-database
701
702 .endif
703 .endif
704 # HERE THERE BE TACOS -- adamw