1 #---------------------------------------------------------
2 # Makefile.am for xul/staff_client
3 ## Process this file with automake to generate Makefile.in
4 #---------------------------------------------------------
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 = $$(/bin/cat build/STAMP_ID)
10 # from http://closure-compiler.googlecode.com/files/compiler-latest.zip FIXME: Autotools this?
11 export CLOSURE_COMPILER_JAR = ~/closure-compiler/compiler.jar
12 XULRUNNER_VERSION=1.9.2.19
13 XULRUNNER_WINFILE=xulrunner-$(XULRUNNER_VERSION).en-US.win32.zip
14 XULRUNNER_LINUXFILE=xulrunner-$(XULRUNNER_VERSION).en-US.linux-i686.tar.bz2
15 XULRUNNER_URL=http://releases.mozilla.org/pub/mozilla.org/xulrunner/releases/$(XULRUNNER_VERSION)/runtimes/
17 OPENSRF_JSLIBS = "$(OPENSRF_LIBS)/javascript"
18 CHROME_LOCALES = $$(ls -1 chrome/locale)
19 SKIN_CSS = $$(ls -1 server/skin/*css | sed -e "s/.css/_custom.css/")
20 UPDATESDIR=@localstatedir@/updates
22 GIT_BRANCH=$$(echo $$(git rev-parse --abbrev-ref HEAD || echo master) | sed 's|.*/||')
23 GIT_TAG=$$(git rev-parse --short HEAD) # For auto-tagging builds
26 export NSIS_WICON=$$(if [ -f client/evergreen.ico ]; then echo '-DWICON'; fi)
27 export NSIS_AUTOUPDATE=$$([ -f client/defaults/preferences/autoupdate.js ] && echo '-DAUTOUPDATE')
28 export NSIS_DEV=$$([ -f client/defaults/preferences/developers.js ] && echo '-DDEVELOPER')
29 export NSIS_PERMACHINE=$$([ -f client/defaults/preferences/aa_per_machine.js ] && echo '-DPERMACHINE')
30 export NSIS_EXTRAS=$$([ -f extras.nsi ] && echo '-DEXTRAS')
31 # Url taken from http://nsis.sourceforge.net/AccessControl_plug-in
32 NSIS_ACCESSCONTROL=http://nsis.sourceforge.net/mediawiki/images/4/4a/AccessControl.zip
34 #------------------------------
35 # Build ILS XUL CLIENT/SERVER
36 #------------------------------
39 OILSSERVER_INST = server-xul
42 install-exec-local: $(OILSSERVER_INST)
45 # For when you want to add devbuild/permachine/autoupdate to an existing stamp id
46 rebuild: export STAFF_CLIENT_STAMP_ID=`cat PREV_STAMP_ID`
47 rebuild: export STAFF_CLIENT_VERSION=`cat PREV_VERSION`
51 @echo ' * Rigging for release branding'
52 @cp xulrunner-stub.release.exe xulrunner-stub.exe
54 @cp evergreen-icon.ico branding/evergreen.ico
55 @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
58 @echo ' * Rigging for beta branding'
59 @cp xulrunner-stub.beta.exe xulrunner-stub.exe
61 @cp evergreen-icon-beta.ico branding/evergreen.ico
62 @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
65 @echo ' * Copying in developer preferences'
66 @cp external/developers.js build/defaults/preferences/
69 @echo ' * Copying in default to machine level registration file'
70 @cp external/aa_per_machine.js build/defaults/preferences/
72 build: build_dir chrome2remote localize_manifest generated custom_skins open-ils stamp
73 @echo To test the staff client:
75 @echo " xulrunner application.ini"
78 @echo ' * Creating and populating build/ '
83 @cp -fR defaults build/
84 @cp -fR components build/
85 @cp application.ini build/
86 @if [ -f "install.mccoy.rdf" ]; then cp install.mccoy.rdf build/install.rdf; else cp install.rdf build/; fi
87 @cp -fR build/chrome/content/util/ build/server/
88 @cp -fR build/chrome/content/auth/ build/server/
89 @cp build/chrome/content/main/constants.js build/server/main/constants.js
90 @cp build/chrome/content/main/bindings.xml build/server/main/bindings.xml
91 @cp build/chrome/content/OpenILS/data.js build/server/OpenILS/data.js
92 @cp build/chrome/content/OpenILS/global_util.js build/server/OpenILS/global_util.js
93 @if [ -d branding ]; then cp -fR branding/* build/; fi
94 @external/prune_dirs.sh build/
96 # Convert chrome to remote for server localization
98 @for loc in $(CHROME_LOCALES); do \
99 cp -fr chrome/locale/$$loc build/server/locale/. ; \
102 # Update the manifest for our installed locales
104 @for loc in $(CHROME_LOCALES) ; do \
105 if [ "$$loc" != "en-US" ]; then ( echo "locale open_ils_staff_client $$loc locale/$$loc/" >> build/chrome/chrome.manifest ) ; fi; \
109 # https://developer.mozilla.org/en/xul_application_packaging
110 # The Documentation states:
111 # BUILD ID should be a unique build identifier, usually date based, and should be different for each released version
112 # VERSION should be in a format as described here:
113 # https://developer.mozilla.org/en/Toolkit_version_format
115 # The default "automatic" BUILD ID is acceptable.
117 # The version from the README usually conforms to that documentation, unless it is master.
118 # If we are in master, we probably have git kicking around, ask it for the revision and build an appropriate version string.
120 # Neither really applies to the STAMP, though.
121 # 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.
122 # Master VERSION will end up with 0branch.release, master STAMP ID will be 0branch_release.
124 @/bin/date +"%Y%m%d.%H%M%S" > build/BUILD_ID
125 @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
126 @if [ -z "${STAFF_CLIENT_BUILD_ID}" ]; then ( echo "No Build ID for versioning" ; echo "none" > build/BUILD_ID ) ; fi
127 @sed -n -e '1 s/^.* \([^ ]*\)$$/\1/p' @top_srcdir@/README > build/VERSION
128 @if [ "${STAFF_CLIENT_VERSION}" == "master" ]; then echo "0${GIT_BRANCH}.${GIT_TAG}" > build/VERSION; fi
129 @if [ -n "${STAFF_CLIENT_VERSION}" ]; then ( echo "Stamping with Version: ${STAFF_CLIENT_VERSION}" ; echo ${STAFF_CLIENT_VERSION} > build/VERSION ) ; fi
130 @if [ -z "${STAFF_CLIENT_VERSION}" ]; then ( echo "No Version" ; echo "none" > build/VERSION ) ; fi
131 @sed -e 's/\./_/g' -e 's/^\([0-9_]*\)$$/rel_&/' build/VERSION > build/STAMP_ID
132 @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
133 @if [ -z "${STAFF_CLIENT_STAMP_ID}" ]; then ( echo "No Stamp ID for versioning" ; echo "none" > build/STAMP_ID ) ; fi
134 @if [ -n "${STAFF_CLIENT_VERSION}" ]; then sed -i -e s/^Version=.\*/Version=${STAFF_CLIENT_VERSION}/ build/application.ini ; fi
135 @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
136 @if [ -n "${STAFF_CLIENT_VERSION}" ]; then find build/ -name 'constants.js' -exec sed -i -e "s/\(CLIENT_VERSION *= '\)'/\1${STAFF_CLIENT_VERSION}'/" {} \; ; fi
137 @if [ -n "${STAFF_CLIENT_BUILD_ID}" ]; then sed -i -e s/^BuildID=.\*/BuildID=${STAFF_CLIENT_BUILD_ID}/ build/application.ini ; fi
138 @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
139 @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
140 @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
141 @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
142 @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
143 @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
144 @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
145 @if [ -z "${AUTOUPDATE_HOST}" ]; then rm -f build/defaults/preferences/autoupdate.js; fi
146 @if [ -z "${AUTOUPDATE_HOST}" ]; then sed -i -e /updateURL/d build/install.rdf; fi
147 @if [ -n "${AUTOUPDATE_HOST}" ]; then echo "Applying automatic update host ${AUTOUPDATE_HOST}"; fi
148 @if [ -n "${AUTOUPDATE_HOST}" ]; then sed -i -e "s|::HOSTNAME::|${AUTOUPDATE_HOST}|" -e "s|https\?://\(https\?://\)|\1|" build/defaults/preferences/autoupdate.js; fi
149 @if [ -n "${AUTOUPDATE_HOST}" ]; then sed -i -e "s|::HOSTNAME::|${AUTOUPDATE_HOST}|" -e "s|https\?://\(https\?://\)|\1|" build/install.rdf; fi
150 @cp build/STAMP_ID PREV_STAMP_ID
151 @cp build/VERSION PREV_VERSION
154 @perl -e 'print "Ringing bell..." . chr(7) . "\n";'
157 @rm -f build/build.tar
158 @tar -c --exclude=server -f build.tar build/
160 @md5sum build/build.tar > build/build.tar.md5
163 @echo ' * Grabbing lang.dtd from the OPAC code '
164 @cp @top_srcdir@/Open-ILS/web/opac/locale/en-US/lang.dtd build/chrome/locale/en-US/
167 @echo ' * Grabbing more OPAC code and legacy code and custom code'
168 @cp @top_srcdir@/Open-ILS/web/opac/common/js/*.js build/chrome/content/OpenILS/util/
169 @cp $(OPENSRF_JSLIBS)/*.js build/chrome/content/OpenILS/util/
170 @external/prune_dirs.sh build/
173 @for skin in $(SKIN_CSS); do \
174 if [ ! -f "$$skin" ]; then ( touch build/"$$skin" ); fi \
178 @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
180 server-xul: needwebdir build
182 mkdir -p $(DESTDIR)$(WEBDIR)
183 mkdir -p $(DESTDIR)$(WEBDIR)/xul/
184 @echo "STAMP_ID = $(STAFF_CLIENT_STAMP_ID)"
185 @echo "Copying xul into $(DESTDIR)$(WEBDIR)/xul/$(STAFF_CLIENT_STAMP_ID)"
186 mkdir -p "$(DESTDIR)$(WEBDIR)/xul/$(STAFF_CLIENT_STAMP_ID)"
187 cp -R @top_srcdir@/Open-ILS/xul/staff_client/build/server "$(DESTDIR)${WEBDIR}/xul/${STAFF_CLIENT_STAMP_ID}/"
189 compress-javascript: build
190 @echo "Size of build/ before compression = " `du -sh build/`
191 @echo " * Running Google's Closure Compiler against javascript. Errors in build/compression.err"
192 @external/closure_compiler.sh $(CLOSURE_COMPILER_JAR) 2>> build/compression.err
193 @echo `find build/ -name '*.js~' -size 0 -print | wc -l` compression failures
194 @find build/ -name '*.js~' -size 0 -exec rm {} \; # remove the output files for those that did not compile
195 @echo `find build/ -name '*.js~' -print | wc -l` compression successes
196 @find build/ -name '*.js~' -exec perl -e '$$a = "{}"; chop $$a; `mv $$a~ $$a`;' \;
197 @echo "Size of build/ (minus compression.err) after compression = " `du -sh --exclude compression.err build/`
199 # Easy way to make all three kinds of clients
206 # By doing this we don't change the original build in the build folder
207 # Great for adding/changing things without a full rebuild
210 @if [ ! -f build/BUILD_ID ]; then echo 'ERROR! Current build not stamped!'; exit 1; fi
211 @echo 'Prepping Client Set'
214 @cp -fR build/* client/
215 @rm -rf client/server/
216 @rm -f client/build.tar*
218 # When building as a standalone client install.rdf is a bad thing
219 # as we haven't "sanitized" the client for extension use
221 client_app: client_dir
222 @echo 'Cleaning Extension Information'
223 @rm -f client/install.rdf
225 # If automatic updates are enabled, or the standalone_xul_app.js is present,
226 # the extension can break Firefox.
227 # Remove those, and we need a chrome.manifest
229 client_ext: client_dir
230 @echo 'Cleaning App Information'
231 @rm -f client/application.ini
232 @rm -f client/defaults/preferences/autoupdate.js
233 @rm -f client/defaults/preferences/autochannel.js
234 @rm -f client/defaults/preferences/standalone_xul_app.js
235 @echo 'Prepping chrome.manifest'
236 @perl -ne 'if(/open_ils_staff_client/) { s/ (?!chrome:\/\/open_ils_staff_client)([^ ]*)$$/ chrome\/\1/; print; }' client/chrome/chrome.manifest > client/chrome.manifest
238 # Would merge client_ext into this one, but this way an installer that doesn't
239 # use an xpi can be made for extension later, if desired
241 extension: client_ext
242 @echo ' * Packaging as an XPI'
243 @(cd client/ && zip -q -r ../evergreen.xpi * -x defaults/preferences/standalone_xul_app.js)
244 @md5sum evergreen.xpi > evergreen.xpi.md5
246 # Generic client, as an xpi, theoretically suitable for --install-app usage
248 generic-client: client_app
249 @echo 'Packing Generic Client via zip (as xpi file)'
250 @rm -f evergreen_staff_client.xpi
251 @cd client && zip -q -r ../evergreen_staff_client.xpi *
254 # These two targets complete the layout defined on
255 # https://developer.mozilla.org/en/XULRunner/Deploying_XULRunner_1.8
256 # for their respective platforms in regards to XULRunner deployment
259 @echo 'Checking for makensis'
260 @type -P makensis > /dev/null || ( echo 'MAKENSIS NOT FOUND: Cannot continue. Do you need to install the NSIS package?' && exit 1 )
263 @echo 'Checking for unzip'
264 @type -P unzip > /dev/null || ( echo 'UNZIP NOT FOUND: Cannot continue.' && exit 1 )
267 @echo 'Checking for branding'
268 @[ -f xulrunner-stub.exe ] || echo 'xulrunner-stub.exe not found'
269 @[ -f build/evergreen.ico ] || echo 'build/evergreen.ico not found'
270 @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
272 # Note that I decided to use win/lin channels for ease of coding platform specific updates
274 win-xulrunner: unzip_check branding_check client_app
275 @echo 'Preparing Windows xulrunner'
276 @if [ ! -f ${XULRUNNER_WINFILE} ]; then wget ${XULRUNNER_URL}${XULRUNNER_WINFILE}; fi
277 @unzip -q ${XULRUNNER_WINFILE} -dclient
278 @if [ -f client/defaults/preferences/autoupdate.js ]; then echo 'pref("app.update.channel","win");' >> client/defaults/preferences/autochannel.js; fi;
279 @echo 'Preparing stub'
280 @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
282 linux-xulrunner: client_app
283 @echo 'Preparing Linux xulrunner'
284 @if [ ! -f ${XULRUNNER_LINUXFILE} ]; then wget ${XULRUNNER_URL}${XULRUNNER_LINUXFILE}; fi
285 @cd client; tar xjf ../${XULRUNNER_LINUXFILE}; cd ..
286 @if [ -f client/defaults/preferences/autoupdate.js ]; then echo 'pref("app.update.channel","lin");' >> client/defaults/preferences/autochannel.js; fi;
287 @echo 'Preparing stub'
288 @mv client/xulrunner/xulrunner-stub client/evergreen
290 # Build a windows installer.
292 win-client: nsis_check win-xulrunner
293 @if [ "${NSIS_AUTOUPDATE}${NSIS_PERMACHINE}" -a ! -d AccessControl ]; then echo 'Fetching AccessControl Plugin'; wget ${NSIS_ACCESSCONTROL} -O AccessControl.zip; unzip AccessControl.zip; fi
294 @echo 'Building installer'
295 @makensis -V2 -DPRODUCT_VERSION="${STAFF_CLIENT_VERSION}" ${NSIS_WICON} ${NSIS_AUTOUPDATE} ${NSIS_DEV} ${NSIS_PERMACHINE} ${NSIS_EXTRAS} ${NSIS_EXTRAOPTS} windowssetup.nsi
298 # For linux, just build a tar.bz2 archive
300 linux-client: linux-xulrunner
301 @echo 'Packing as evergreen_staff_client.tar.bz2'
302 @rm -f evergreen_staff_client.tar.bz2
303 @cd client; tar cjf ../evergreen_staff_client.tar.bz2 *; cd ..
306 # For running the updates script with the correct updates directory, optionally building clients as well
308 updates updates-client win-updates win-updates-client linux-updates linux-updates-client generic-updates generic-updates-client extension-updates:
309 @if [ ! -f build/BUILD_ID ]; then echo 'ERROR! Current build not stamped!'; exit 1; fi
310 @if [ ! -x external/make_updates.sh ]; then chmod u+x external/make_updates.sh; fi
311 @if [ ! -x external/make_updates.sh ]; then echo 'ERROR! external/make_updates.sh is not executable!'; exit 1; fi
312 @external/make_updates.sh ${UPDATESDIR} $@