LP#1790923: disable XUL staff client by default
[working/Evergreen.git] / Open-ILS / xul / staff_client / Makefile.am
1 #---------------------------------------------------------
2 # Makefile.am for xul/staff_client
3 ## Process this file with automake to generate Makefile.in
4 #---------------------------------------------------------
5 export WEBDIR=@localstatedir@/web
6 export STAFF_CLIENT_BUILD_ID = $$(/bin/cat build/BUILD_ID)
7 export STAFF_CLIENT_VERSION = $$(/bin/cat build/VERSION)
8 export STAFF_CLIENT_STAMP_ID = legacy
9
10 # from http://closure-compiler.googlecode.com/files/compiler-latest.zip  FIXME: Autotools this?
11 export CLOSURE_COMPILER_JAR = ~/closure-compiler/compiler.jar
12
13 # XULRunner is our base.
14 XULRUNNER_VERSION=14.0.1
15 XULRUNNER_WINFILE=xulrunner-$(XULRUNNER_VERSION).en-US.win32.zip
16 XULRUNNER_LINUX32FILE=xulrunner-$(XULRUNNER_VERSION).en-US.linux-i686.tar.bz2
17 XULRUNNER_LINUX64FILE=xulrunner-$(XULRUNNER_VERSION).en-US.linux-x86_64.tar.bz2
18 XULRUNNER_URL=http://archive.mozilla.org/pub/mozilla.org/xulrunner/releases/$(XULRUNNER_VERSION)/runtimes/
19 XULRUNNER_MAJOR_VERSION=$$(echo ${XULRUNNER_VERSION} | cut -d. -f1)
20
21 # Extensions we include when not an extension ourselves
22 # Grab the latest. If that becomes a problem we can swap them out for specific versions.
23 DOMINSPECTOR_URL=https://addons.mozilla.org/firefox/downloads/latest/6622/addon-6622-latest.xpi
24 DOMINSPECTOR_ID=inspector@mozilla.org
25 VENKMAN_URL=https://addons.mozilla.org/firefox/downloads/latest/216/addon-216-latest.xpi
26 VENKMAN_ID={f13b157f-b174-47e7-a34d-4815ddfdfeb8}
27
28 OPENSRF_JSLIBS = "$(OPENSRF_LIBS)/javascript"
29 CHROME_LOCALES = $$(ls -1 chrome/locale)
30 SKIN_CSS = $$(ls -1 server/skin/*css | sed -e "s/.css/_custom.css/")
31 UPDATESDIR=@localstatedir@/updates
32
33 GIT_BRANCH=$$(echo $$(git rev-parse --abbrev-ref HEAD || echo master) | sed 's|.*/||')
34 GIT_TAG=$$(git rev-parse --short HEAD) # For auto-tagging builds
35
36 export NSIS_EXTRAOPTS
37 export NSIS_WICON=$$(if [ -f client/evergreen.ico ]; then echo '-DWICON'; fi)
38 export NSIS_AUTOUPDATE=$$([ -f client/defaults/preferences/autoupdate.js ] && echo '-DAUTOUPDATE')
39 export NSIS_DEV=$$([ -f client/defaults/preferences/developers.js ] && echo '-DDEVELOPER')
40 export NSIS_PERMACHINE=$$([ -f client/defaults/preferences/aa_per_machine.js ] && echo '-DPERMACHINE')
41 export NSIS_EXTRAS=$$([ -f extras.nsi ] && echo '-DEXTRAS')
42 # Url taken from http://nsis.sourceforge.net/AccessControl_plug-in
43 NSIS_ACCESSCONTROL=http://nsis.sourceforge.net/mediawiki/images/4/4a/AccessControl.zip
44
45 #------------------------------
46 # Build ILS XUL CLIENT/SERVER
47 #------------------------------
48
49 if BUILDILSCLIENT
50 OILSSERVER_INST = server-xul
51 endif
52
53 install-exec-local: $(OILSSERVER_INST)
54
55 # Helper target
56 # For when you want to add devbuild/permachine/autoupdate to an existing stamp id
57 rebuild: export STAFF_CLIENT_STAMP_ID=`cat PREV_STAMP_ID`
58 rebuild: export STAFF_CLIENT_VERSION=`cat PREV_VERSION`
59 rebuild: build
60
61 rigrelease:
62         @echo ' * Rigging for release branding'
63         @cp xulrunner-stub.release.exe xulrunner-stub.exe
64         @mkdir -p branding
65         @cp evergreen-icon.ico branding/evergreen.ico
66         @sed -i -e 's/^\s*;\?\s*!define UI_IMAGESET "release"/!define UI_IMAGESET "release"/' -e 's/^\s*;\?\s*!define UI_IMAGESET "beta"/;!define UI_IMAGESET "beta"/' windowssetup.nsi
67
68 rigbeta:
69         @echo ' * Rigging for beta branding'
70         @cp xulrunner-stub.beta.exe xulrunner-stub.exe
71         @mkdir -p branding
72         @cp evergreen-icon-beta.ico branding/evergreen.ico
73         @sed -i -e 's/^\s*;\?\s*!define UI_IMAGESET "release"/;!define UI_IMAGESET "release"/' -e 's/^\s*;\?\s*!define UI_IMAGESET "beta"/!define UI_IMAGESET "beta"/' windowssetup.nsi
74
75 devbuild: build
76         @echo ' * Copying in developer preferences'
77         @cp external/developers.js build/defaults/preferences/
78
79 permachine: build
80         @echo ' * Copying in default to machine level registration file'
81         @cp external/aa_per_machine.js build/defaults/preferences/
82
83 build: build_dir chrome2remote localize_manifest generated custom_skins open-ils stamp 
84         @echo To test the staff client:
85         @echo "  cd build/"
86         @echo "  xulrunner application.ini"
87
88 build_dir:
89         @echo ' * Creating and populating build/ '
90         @rm -rf build/
91         @mkdir -p build/
92         @cp -fR chrome build/
93         @cp -fR server build/
94         @cp -fR defaults build/
95         @cp -fR components build/
96         @cp application.ini build/
97         @cp chrome.manifest build/
98         @if [ -f "install.mccoy.rdf" ]; then cp install.mccoy.rdf build/install.rdf; else cp install.rdf build/; fi
99         @cp -fR build/chrome/content/util/ build/server/
100         @cp -fR build/chrome/content/auth/ build/server/
101         @cp build/chrome/content/main/constants.js build/server/main/constants.js
102         @cp build/chrome/content/main/bindings.xml build/server/main/bindings.xml
103         @cp build/chrome/content/OpenILS/data.js build/server/OpenILS/data.js
104         @cp build/chrome/content/OpenILS/global_util.js build/server/OpenILS/global_util.js
105         @cp build/chrome/content/OpenILS/event_util.js build/server/OpenILS/event_util.js
106         @if [ -d branding ]; then cp -fR branding/* build/; fi
107         @external/prune_dirs.sh build/
108
109 # Convert chrome to remote for server localization
110 chrome2remote:
111         @for loc in $(CHROME_LOCALES); do \
112                 cp -fr chrome/locale/$$loc build/server/locale/. ; \
113         done;
114
115 # Update the manifest for our installed locales
116 localize_manifest:
117         @for loc in $(CHROME_LOCALES) ; do \
118                 if [ "$$loc" != "en-US" ]; then ( echo "locale open_ils_staff_client $$loc locale/$$loc/" >> build/chrome/chrome.manifest ) ; fi; \
119         done;
120
121 # On this page:
122 # https://developer.mozilla.org/en/xul_application_packaging
123 # The Documentation states:
124 # BUILD ID should be a unique build identifier, usually date based, and should be different for each released version
125 # VERSION should be in a format as described here:
126 # https://developer.mozilla.org/en/Toolkit_version_format
127
128 # The default "automatic" BUILD ID is acceptable.
129
130 # The version from the README usually conforms to that documentation, unless it is master.
131 # If we are in master, we probably have git kicking around, ask it for the revision and build an appropriate version string.
132
133 # Neither really applies to the STAMP, though.
134 # The method below gives the same format STAMPS as previous instructions provided. If README has version 1.2.3.4 then STAMP_ID will become rel_1_2_3_4.
135 # Master VERSION will end up with 0branch.release, master STAMP ID will be 0branch_release.
136 stamp:
137         @/bin/date +"%Y%m%d.%H%M%S" > build/BUILD_ID
138         @if [ -n "${STAFF_CLIENT_BUILD_ID}" ]; then ( echo "Stamping with Build ID: ${STAFF_CLIENT_BUILD_ID}" ; echo ${STAFF_CLIENT_BUILD_ID} > build/BUILD_ID ) ; fi
139         @if [ -z "${STAFF_CLIENT_BUILD_ID}" ]; then ( echo "No Build ID for versioning" ; echo "none" > build/BUILD_ID ) ; fi
140         @sed -n -e 's/^AC_INIT([^,]*, \([^,]*\),.*$$/\1/p' @top_srcdir@/configure.ac > build/VERSION
141         @if [ "${STAFF_CLIENT_VERSION}" == "trunk" ]; then echo "0${GIT_BRANCH}.${GIT_TAG}" > build/VERSION; fi 
142         @if [ -n "${STAFF_CLIENT_VERSION}" ]; then ( echo "Stamping with Version: ${STAFF_CLIENT_VERSION}" ; echo ${STAFF_CLIENT_VERSION} > build/VERSION ) ; fi
143         @if [ -z "${STAFF_CLIENT_VERSION}" ]; then ( echo "No Version" ; echo "none" > build/VERSION ) ; fi
144         @sed -e 's/\./_/g' -e 's/^\([0-9_]*\)$$/rel_&/' build/VERSION > build/STAMP_ID
145         @if [ -n "${STAFF_CLIENT_STAMP_ID}" ]; then ( echo "Stamping with Stamp ID: ${STAFF_CLIENT_STAMP_ID}" ; echo ${STAFF_CLIENT_STAMP_ID} > build/STAMP_ID ) ; fi
146         @if [ -z "${STAFF_CLIENT_STAMP_ID}" ]; then ( echo "No Stamp ID for versioning" ; echo "none" > build/STAMP_ID ) ; fi
147         @if [ -n "${STAFF_CLIENT_VERSION}" ]; then sed -i -e s/^Version=.\*/Version=${STAFF_CLIENT_VERSION}/ build/application.ini ; fi
148         @if [ -n "${STAFF_CLIENT_VERSION}" ]; then sed -i -e "s|<em:version>.*</em:version>|<em:version>${STAFF_CLIENT_VERSION}</em:version>|" build/install.rdf ; fi
149         @if [ -n "${STAFF_CLIENT_VERSION}" ]; then find build/ -name 'constants.js' -exec sed -i -e "s/\(CLIENT_VERSION *= '\)'/\1${STAFF_CLIENT_VERSION}'/" {} \; ; fi
150         @if [ -n "${STAFF_CLIENT_BUILD_ID}" ]; then sed -i -e s/^BuildID=.\*/BuildID=${STAFF_CLIENT_BUILD_ID}/ build/application.ini ; fi
151         @if [ -n "${STAFF_CLIENT_STAMP_ID}" ]; then find build/ -name '*.css' -exec sed -i -e s/xul\\\/server/xul\\\/${STAFF_CLIENT_STAMP_ID}\\\/server/g {} \; ; fi
152         @if [ -n "${STAFF_CLIENT_STAMP_ID}" ]; then find build/ -name '*.xul' -exec sed -i -e s/xul\\\/server/xul\\\/${STAFF_CLIENT_STAMP_ID}\\\/server/g {} \; ; fi
153         @if [ -n "${STAFF_CLIENT_STAMP_ID}" ]; then find build/ -name '*.html' -exec sed -i -e s/xul\\\/server/xul\\\/${STAFF_CLIENT_STAMP_ID}\\\/server/g {} \; ; fi
154         @if [ -n "${STAFF_CLIENT_STAMP_ID}" ]; then find build/ -name '*.xhtml' -exec sed -i -e s/xul\\\/server/xul\\\/${STAFF_CLIENT_STAMP_ID}\\\/server/g {} \; ; fi
155         @if [ -n "${STAFF_CLIENT_STAMP_ID}" ]; then find build/ -name '*.js' -exec sed -i -e s/xul\\\/server/xul\\\/${STAFF_CLIENT_STAMP_ID}\\\/server/g {} \; ; fi
156         @if [ -n "${STAFF_CLIENT_STAMP_ID}" ]; then find build/ -name '*.xml' -exec sed -i -e s/xul\\\/server/xul\\\/${STAFF_CLIENT_STAMP_ID}\\\/server/g {} \; ; fi
157         @if [ -n "${STAFF_CLIENT_STAMP_ID}" ]; then find build/ -name 'constants.js' -exec sed -i -e "s/\(CLIENT_STAMP *= '\)'/\1${STAFF_CLIENT_STAMP_ID}'/" {} \; ; fi
158         @if [ -n "${STAFF_CLIENT_NAME}" ]; then sed -i -e s/^Name=.\*/Name=${STAFF_CLIENT_NAME}/ build/application.ini ; fi
159         @if [ -z "${AUTOUPDATE_HOST}" ]; then rm -f build/defaults/preferences/autoupdate.js; fi
160         @if [ -z "${AUTOUPDATE_HOST}" ]; then sed -i -e /updateURL/d build/install.rdf; fi
161         @if [ -n "${AUTOUPDATE_HOST}" ]; then echo "Applying automatic update host ${AUTOUPDATE_HOST}"; fi
162         @if [ -n "${AUTOUPDATE_HOST}" ]; then sed -i -e "s|::HOSTNAME::|${AUTOUPDATE_HOST}|" -e "s|https\?://\(https\?://\)|\1|" build/defaults/preferences/autoupdate.js; fi
163         @if [ -n "${AUTOUPDATE_HOST}" ]; then sed -i -e "s|::HOSTNAME::|${AUTOUPDATE_HOST}|" -e "s|https\?://\(https\?://\)|\1|" build/install.rdf; fi
164         @if [ -z "${INITIAL_HOST}" ]; then rm -f build/defaults/preferences/initialhost.js; fi
165         @if [ -n "${INITIAL_HOST}" ]; then sed -i -e "s/%INITIAL_HOST%/${INITIAL_HOST}/" build/defaults/preferences/initialhost.js; fi
166         @cp build/STAMP_ID PREV_STAMP_ID
167         @cp build/VERSION PREV_VERSION
168
169 bell:
170         @perl -e 'print "Ringing bell..." . chr(7) . "\n";'
171
172 bundle:
173         @rm -f build/build.tar
174         @tar -c --exclude=server -f build.tar build/
175         @mv build.tar build/
176         @md5sum build/build.tar > build/build.tar.md5
177
178 generated:
179         @echo ' * Grabbing lang.dtd from the OPAC code '
180         @cp @top_srcdir@/Open-ILS/web/opac/locale/en-US/lang.dtd build/chrome/locale/en-US/
181
182 open-ils:
183         @echo ' * Grabbing more OPAC code and legacy code and custom code'
184         @cp @top_srcdir@/Open-ILS/web/opac/common/js/*.js build/chrome/content/OpenILS/util/
185         @cp $(OPENSRF_JSLIBS)/*.js build/chrome/content/OpenILS/util/
186         @external/prune_dirs.sh build/
187
188 custom_skins:
189         @for skin in $(SKIN_CSS); do \
190                 if [ ! -f "$$skin" ]; then ( touch build/"$$skin" ); fi \
191         done;
192
193 needwebdir:
194         @if [ -z "$(WEBDIR)" ]; then echo "!!!--------!!!"; echo "WEBDIR is not set. Must use top level Makefile or set WEBDIR to use this target."; echo "!!!--------!!!"; exit 1; fi
195
196 server-xul: needwebdir build
197         @echo $@
198         mkdir -p $(DESTDIR)$(WEBDIR)
199         mkdir -p $(DESTDIR)$(WEBDIR)/xul/
200         @echo "STAMP_ID = $(STAFF_CLIENT_STAMP_ID)"
201         @echo "Copying xul into $(DESTDIR)$(WEBDIR)/xul/$(STAFF_CLIENT_STAMP_ID)"
202         mkdir -p "$(DESTDIR)$(WEBDIR)/xul/$(STAFF_CLIENT_STAMP_ID)"
203         cp -R @top_srcdir@/Open-ILS/xul/staff_client/build/server "$(DESTDIR)${WEBDIR}/xul/${STAFF_CLIENT_STAMP_ID}/"
204         @if [ "${STAFF_CLIENT_STAMP_ID}" == "legacy" ]; then \
205                 echo "Installing the legacy parts of the XUL staff client"; \
206                 if [ -L "$(DESTDIR)${WEBDIR}/xul/server" ]; then \
207                         echo "Updating XUL server symlink to point to legacy code"; \
208                         rm $(DESTDIR)${WEBDIR}/xul/server; \
209                         ( cd "$(DESTDIR)${WEBDIR}/xul"; ln -s legacy/server server; ); \
210                 else \
211                         if [ ! -f "$(DESTDIR)${WEBDIR}/xul/server" ]; then \
212                                 echo "Creating XUL server symlink to point to legacy code"; \
213                                 ( cd "$(DESTDIR)${WEBDIR}/xul"; ln -s legacy/server server; ); \
214                         else \
215                                 if [ -d "$(DESTDIR)${WEBDIR}/xul/server" ]; then \
216                                         echo "WARNING: $(DESTDIR)${WEBDIR}/xul/server is a directory; "; \
217                                         echo "Not overwriting it, but you should probably do the following: "; \
218                                         echo "1. Remove or move it, and "; \
219                                         echo "2. Create a symlink from $(DESTDIR)${WEBDIR}/xul/legacy/server to $(DESTDIR)${WEBDIR}/xul/server "; \
220                                 fi; \
221                         fi; \
222                 fi; \
223         fi; # manage the server symlink if installing the 'legacy' staff client
224
225 compress-javascript: build
226         @echo "Size of build/ before compression = " `du -sh build/`
227         @echo " * Running Google's Closure Compiler against javascript.  Errors in build/compression.err"
228         @external/closure_compiler.sh $(CLOSURE_COMPILER_JAR) 2>> build/compression.err
229         @echo `find build/ -name '*.js~' -size 0 -print | wc -l` compression failures
230         @find build/ -name '*.js~' -size 0 -exec rm {} \; # remove the output files for those that did not compile
231         @echo `find build/ -name '*.js~' -print | wc -l` compression successes
232         @find build/ -name '*.js~' -exec perl -e '$$a = "{}"; chop $$a; `mv $$a~ $$a`;' \;
233         @echo "Size of build/ (minus compression.err) after compression = " `du -sh --exclude compression.err build/`
234
235 # Easy way to make all three kinds of clients
236
237 clients:
238         @make win-client
239         @make linux32-client
240         @make linux64-client
241         @make generic-client
242
243 # By doing this we don't change the original build in the build folder
244 # Great for adding/changing things without a full rebuild
245
246 client_dir:
247         @if [ ! -f build/BUILD_ID ]; then echo 'ERROR! Current build not stamped!'; exit 1; fi
248         @echo 'Prepping Client Set'
249         @rm -rf client/
250         @mkdir -p client
251         @cp -fR build/* client/
252         @rm -rf client/server/
253         @rm -f client/build.tar*
254
255 # When building as a standalone client install.rdf is a bad thing
256 # as we haven't "sanitized" the client for extension use
257
258 client_app: client_dir
259         @echo 'Cleaning Extension Information'
260         @rm -f client/install.rdf
261         @echo 'Installing Extensions'
262         @mkdir -p client/extensions
263 # Note: XULRunner before 4 requires extracted extensions
264 # XULRunner after 4 keeps them in XPI form...unless their manifest says to unpack
265 # This block is thus structured to make it easy to add the latter kind later.
266         @if [ ${XULRUNNER_MAJOR_VERSION} -lt 4 ]; then \
267                 if [ -f extensions/${DOMINSPECTOR_ID}.xpi ]; then \
268                         mkdir -p client/extensions/${DOMINSPECTOR_ID}/; \
269                         unzip extensions/${DOMINSPECTOR_ID}.xpi -d client/extensions/${DOMINSPECTOR_ID}/; \
270                 fi; \
271                 if [ -f extensions/${VENKMAN_ID}.xpi ]; then \
272                         mkdir -p client/extensions/${VENKMAN_ID}/; \
273                         unzip extensions/${VENKMAN_ID}.xpi -d client/extensions/${VENKMAN_ID}/; \
274                 fi; \
275         else \
276                 if [ -f extensions/${DOMINSPECTOR_ID}.xpi ]; then \
277                         cp extensions/${DOMINSPECTOR_ID}.xpi client/extensions/; \
278                 fi; \
279                 if [ -f extensions/${VENKMAN_ID}.xpi ]; then \
280                         cp extensions/${VENKMAN_ID}.xpi client/extensions/; \
281                 fi; \
282         fi
283
284 # If automatic updates are enabled, or the standalone_xul_app.js is present,
285 # the extension can break Firefox.
286 # Also, per machine registration + extension mode is probably a bad idea.
287 # Remove those, and we need an updated chrome.manifest
288
289 client_ext: client_dir
290         @echo 'Cleaning App Information'
291         @rm -f client/application.ini
292         @rm -f client/defaults/preferences/autoupdate.js
293         @rm -f client/defaults/preferences/autochannel.js
294         @rm -f client/defaults/preferences/standalone_xul_app.js
295         @rm -f client/defaults/preferences/aa_per_machine.js
296         @echo 'Prepping chrome.manifest'
297         @perl -ne 'if(/open_ils_staff_client/) { s/ (?!chrome:\/\/open_ils_staff_client)([^ ]*)$$/ chrome\/\1/; print; }' client/chrome/chrome.manifest > client/chrome.manifest
298         @grep -v manifest build/chrome.manifest >> client/chrome.manifest
299
300 # Would merge client_ext into this one, but this way an installer that doesn't
301 # use an xpi can be made for extension later, if desired
302
303 extension: client_ext
304         @echo ' * Packaging as an XPI'
305         @(cd client/ && zip -q -r ../evergreen.xpi * -x defaults/preferences/standalone_xul_app.js)
306         @md5sum evergreen.xpi > evergreen.xpi.md5
307
308 # Fetch extensions to load into the client
309 # This could be done in a "if they aren't there" fashion, but these are manually triggered anyway
310 # That, and this way you can update the extensions by running this target again
311 fetch-extensions: fetch-dom-inspector fetch-venkman
312
313 fetch-dom-inspector:
314         @echo 'Fetching DOM Inspector'
315         @mkdir -p extensions/
316         @wget -Oextensions/${DOMINSPECTOR_ID}.xpi ${DOMINSPECTOR_URL}
317
318 fetch-venkman:
319         @echo 'Fetching Venkman'
320         @mkdir -p extensions/
321         @wget -Oextensions/${VENKMAN_ID}.xpi ${VENKMAN_URL}
322
323 # Generic client, as an xpi, theoretically suitable for --install-app usage
324
325 generic-client: client_app
326         @echo 'Packing Generic Client via zip (as xpi file)'
327         @rm -f evergreen_staff_client.xpi
328         @cd client && zip -q -r ../evergreen_staff_client.xpi *
329         @echo done
330
331 # These two targets complete the layout defined on
332 # https://developer.mozilla.org/en/XULRunner/Deploying_XULRunner_1.8
333 # for their respective platforms in regards to XULRunner deployment
334
335 nsis_check:
336         @echo 'Checking for makensis'
337         @type -P makensis > /dev/null || ( echo 'MAKENSIS NOT FOUND: Cannot continue. Do you need to install the NSIS package?' && exit 1 )
338
339 unzip_check:
340         @echo 'Checking for unzip'
341         @type -P unzip > /dev/null || ( echo 'UNZIP NOT FOUND: Cannot continue.' && exit 1 )
342
343 branding_check:
344         @echo 'Checking for branding'
345         @[ -f xulrunner-stub.exe ] || echo 'xulrunner-stub.exe not found'
346         @[ -f build/evergreen.ico ] || echo 'build/evergreen.ico not found'
347         @if [ ! -f xulrunner-stub.exe -o ! -f build/evergreen.ico ]; then echo 'Branding incomplete. Did you forget to run "make rigbeta" or "make rigrelease"?'; echo 'You will need to "make rebuild" afterwards.'; exit 1; fi
348
349 # Note that I decided to use win/lin channels for ease of coding platform specific updates
350
351 win-xulrunner: unzip_check branding_check client_app
352         @echo 'Preparing Windows xulrunner'
353         @if [ ! -f ${XULRUNNER_WINFILE} ]; then wget ${XULRUNNER_URL}${XULRUNNER_WINFILE}; fi
354         @unzip -q ${XULRUNNER_WINFILE} -dclient
355         @if [ -f client/defaults/preferences/autoupdate.js ]; then echo 'pref("app.update.channel","win");' >> client/defaults/preferences/autochannel.js; fi;
356         @if [ -d branding_win ]; then cp -fR branding_win/* client/; fi
357         @echo 'Preparing stub'
358         @if [ -f xulrunner-stub.exe ]; then cp xulrunner-stub.exe client/evergreen.exe; rm client/xulrunner/xulrunner-stub.exe; else mv client/xulrunner/xulrunner-stub.exe client/evergreen.exe; fi
359         @if [ ${XULRUNNER_MAJOR_VERSION} -ge 4 -a -f client/xulrunner/mozcrt19.dll ]; then cp client/xulrunner/mozcrt19.dll client/; fi # XULRunner 4+ need this, if the file exists
360         @if [ ${XULRUNNER_MAJOR_VERSION} -ge 9 -a -f client/xulrunner/mozutils.dll ]; then cp client/xulrunner/mozutils.dll client/; fi # XULRunner 9+ need this, if the file exists
361
362 linux32-xulrunner: client_app
363         @echo 'Preparing Linux (32 bit) xulrunner'
364         @if [ ! -f ${XULRUNNER_LINUX32FILE} ]; then wget ${XULRUNNER_URL}${XULRUNNER_LINUX32FILE}; fi
365         @cd client; tar xjf ../${XULRUNNER_LINUX32FILE}; cd ..
366         @if [ -f client/defaults/preferences/autoupdate.js ]; then echo 'pref("app.update.channel","lin");' >> client/defaults/preferences/autochannel.js; fi;
367         @if [ -d branding_lin ]; then cp -fR branding_lin/* client/; fi
368         @echo 'Preparing stub'
369         @mv client/xulrunner/xulrunner-stub client/evergreen
370
371 linux64-xulrunner: client_app
372         @echo 'Preparing Linux (64 bit) xulrunner'
373         @if [ ! -f ${XULRUNNER_LINUX64FILE} ]; then wget ${XULRUNNER_URL}${XULRUNNER_LINUX64FILE}; fi
374         @cd client; tar xjf ../${XULRUNNER_LINUX64FILE}; cd ..
375         @if [ -f client/defaults/preferences/autoupdate.js ]; then echo 'pref("app.update.channel","lin64");' >> client/defaults/preferences/autochannel.js; fi;
376 # Note: We assume that we want 32 bit branding files, but provide a way to override for 64 bit
377         @if [ -d branding_lin ]; then cp -fR branding_lin/* client/; fi
378         @if [ -d branding_lin64 ]; then cp -fR branding_lin64/* client/; fi
379         @echo 'Preparing stub'
380         @mv client/xulrunner/xulrunner-stub client/evergreen
381
382
383 # Build a windows installer.
384
385 win-client: nsis_check win-xulrunner
386         @if [ "${NSIS_AUTOUPDATE}${NSIS_PERMACHINE}" -a ! -d AccessControl ]; then echo 'Fetching AccessControl Plugin'; wget ${NSIS_ACCESSCONTROL} -O AccessControl.zip; unzip AccessControl.zip $$(unzip -t AccessControl.zip | grep 'AccessControl/Contrib/' > /dev/null || echo "-dAccessControl"); fi
387         @echo 'Building installer'
388         @makensis -V2 -DPRODUCT_VERSION="${STAFF_CLIENT_VERSION}" ${NSIS_WICON} ${NSIS_AUTOUPDATE} ${NSIS_DEV} ${NSIS_PERMACHINE} ${NSIS_EXTRAS} ${NSIS_EXTRAOPTS} windowssetup.nsi
389         @echo 'Done'
390
391 # For linux, just build a tar.bz2 archive
392
393 linux32-client: linux32-xulrunner
394         @echo 'Packing as evergreen_staff_client_i686.tar.bz2'
395         @rm -f evergreen_staff_client_i686.tar.bz2
396         @cd client; tar cjf ../evergreen_staff_client_i686.tar.bz2 *; cd ..
397         @echo 'Done'
398
399 linux64-client: linux64-xulrunner
400         @echo 'Packing as evergreen_staff_client_x86_64.tar.bz2'
401         @rm -f evergreen_staff_client_x86_64.tar.bz2
402         @cd client; tar cjf ../evergreen_staff_client_x86_64.tar.bz2 *; cd ..
403         @echo 'Done'
404
405 # For running the updates script with the correct updates directory, optionally building clients as well
406
407 updates updates-client win-updates win-updates-client linux32-updates linux32-updates-client linux64-updates linux64-updates-client generic-updates generic-updates-client extension-updates:
408         @if [ ! -f build/BUILD_ID ]; then echo 'ERROR! Current build not stamped!'; exit 1; fi
409         @if [ ! -x external/make_updates.sh ]; then chmod u+x external/make_updates.sh; fi
410         @if [ ! -x external/make_updates.sh ]; then echo 'ERROR! external/make_updates.sh is not executable!'; exit 1; fi
411         @external/make_updates.sh ${UPDATESDIR} $@