]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/xul/staff_client/Makefile.am
Merge branch 'opac-tt-poc' of git+ssh://yeti.esilibrary.com/home/evergreen/evergreen...
[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
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)
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 XULRUNNER_VERSION=1.9.2.15
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/
16
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
21
22 SVN=svn # Because some people might need to override this to 'git svn' or something
23
24 export NSIS_EXTRAOPTS
25 export NSIS_WICON=$$(if [ -f client/evergreen.ico ]; then echo '-DWICON'; fi)
26 export NSIS_AUTOUPDATE=$$([ -f client/defaults/preferences/autoupdate.js ] && echo '-DAUTOUPDATE')
27 export NSIS_DEV=$$([ -f client/defaults/preferences/developers.js ] && echo '-DDEVELOPER')
28 export NSIS_PERMACHINE=$$([ -f client/defaults/preferences/aa_per_machine.js ] && echo '-DPERMACHINE')
29 # Url taken from http://nsis.sourceforge.net/AccessControl_plug-in
30 NSIS_ACCESSCONTROL=http://nsis.sourceforge.net/mediawiki/images/4/4a/AccessControl.zip
31
32 #------------------------------
33 # Build ILS XUL CLIENT/SERVER
34 #------------------------------
35
36 if BUILDILSCLIENT
37 OILSSERVER_INST = server-xul
38 endif
39
40 install-exec-local: $(OILSSERVER_INST)
41
42 devbuild: build
43         @echo ' * Copying in developer preferences'
44         @cp external/developers.js build/defaults/preferences/
45
46 permachine: build
47         @echo ' * Copying in default to machine level registration file'
48         @cp external/aa_per_machine.js build/defaults/preferences/
49
50 build: build_dir chrome2remote localize_manifest generated custom_skins open-ils stamp 
51         @echo To test the staff client:
52         @echo "  cd build/"
53         @echo "  xulrunner application.ini"
54
55 build_dir:
56         @echo ' * Creating and populating build/ '
57         @rm -rf build/
58         @mkdir -p build/
59         @cp -fR chrome build/
60         @cp -fR server build/
61         @cp -fR defaults build/
62         @cp -fR components build/
63         @cp application.ini build/
64         @if [ -f "install.mccoy.rdf" ]; then cp install.mccoy.rdf build/install.rdf; else cp install.rdf build/; fi
65         @cp -fR build/chrome/content/util/ build/server/
66         @cp -fR build/chrome/content/auth/ build/server/
67         @cp build/chrome/content/main/constants.js build/server/main/constants.js
68         @cp build/chrome/content/main/bindings.xml build/server/main/bindings.xml
69         @cp build/chrome/content/OpenILS/data.js build/server/OpenILS/data.js
70         @cp build/chrome/content/OpenILS/global_util.js build/server/OpenILS/global_util.js
71         @if [ -d branding ]; then cp -fR branding/* build/; fi
72         @external/prune_dirs.sh build/
73
74 # Convert chrome to remote for server localization
75 chrome2remote:
76         @for loc in $(CHROME_LOCALES); do \
77                 cp -fr chrome/locale/$$loc build/server/locale/. ; \
78         done;
79
80 # Update the manifest for our installed locales
81 localize_manifest:
82         @for loc in $(CHROME_LOCALES) ; do \
83                 if [ "$$loc" != "en-US" ]; then ( echo "locale open_ils_staff_client $$loc locale/$$loc/" >> build/chrome/chrome.manifest ) ; fi; \
84         done;
85
86 # On this page:
87 # https://developer.mozilla.org/en/xul_application_packaging
88 # The Documentation states:
89 # BUILD ID should be a unique build identifier, usually date based, and should be different for each released version
90 # VERSION should be in a format as described here:
91 # https://developer.mozilla.org/en/Toolkit_version_format
92
93 # The default "automatic" BUILD ID is acceptable.
94
95 # The version from the README usually conforms to that documentation, unless it is trunk.
96 # If we are in trunk, we probably have svn kicking around, ask it for the revision and build an appropriate version string.
97
98 # Neither really applies to the STAMP, though.
99 # 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.
100 # Trunk VERSION will end up with 0trunk.release, trunk STAMP ID will be 0trunk_release.
101 stamp:
102         @/bin/date +"%Y%m%d.%H%M%S" > build/BUILD_ID
103         @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
104         @if [ -z "${STAFF_CLIENT_BUILD_ID}" ]; then ( echo "No Build ID for versioning" ; echo "none" > build/BUILD_ID ) ; fi
105         @sed -n -e '1 s/^.* \([^ ]*\)$$/\1/p' @top_srcdir@/README > build/VERSION
106         @if [ "${STAFF_CLIENT_VERSION}" == "trunk" ]; then echo "0trunk.$$(${SVN} info | sed -n -e 's/Last Changed Rev: \([0-9][0-9]*\)/\1/p')" > build/VERSION; fi 
107         @if [ -n "${STAFF_CLIENT_VERSION}" ]; then ( echo "Stamping with Version: ${STAFF_CLIENT_VERSION}" ; echo ${STAFF_CLIENT_VERSION} > build/VERSION ) ; fi
108         @if [ -z "${STAFF_CLIENT_VERSION}" ]; then ( echo "No Version" ; echo "none" > build/VERSION ) ; fi
109         @sed -e 's/\./_/g' -e 's/^\([0-9_]*\)$$/rel_&/' build/VERSION > build/STAMP_ID
110         @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
111         @if [ -z "${STAFF_CLIENT_STAMP_ID}" ]; then ( echo "No Stamp ID for versioning" ; echo "none" > build/STAMP_ID ) ; fi
112         @if [ -n "${STAFF_CLIENT_VERSION}" ]; then sed -i -e s/^Version=.\*/Version=${STAFF_CLIENT_VERSION}/ build/application.ini ; fi
113         @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
114         @if [ -n "${STAFF_CLIENT_VERSION}" ]; then find build/ -name 'constants.js' -exec sed -i -e "s/\(CLIENT_VERSION *= '\)'/\1${STAFF_CLIENT_VERSION}'/" {} \; ; fi
115         @if [ -n "${STAFF_CLIENT_BUILD_ID}" ]; then sed -i -e s/^BuildID=.\*/BuildID=${STAFF_CLIENT_BUILD_ID}/ build/application.ini ; fi
116         @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
117         @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
118         @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
119         @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
120         @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
121         @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
122         @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
123         @if [ -z "${AUTOUPDATE_HOST}" ]; then rm -f build/defaults/preferences/autoupdate.js; fi
124         @if [ -z "${AUTOUPDATE_HOST}" ]; then sed -i -e /updateURL/d build/install.rdf; fi
125         @if [ -n "${AUTOUPDATE_HOST}" ]; then echo "Applying automatic update host ${AUTOUPDATE_HOST}"; fi
126         @if [ -n "${AUTOUPDATE_HOST}" ]; then sed -i -e "s|::HOSTNAME::|${AUTOUPDATE_HOST}|" -e "s|https\?://\(https\?://\)|\1|" build/defaults/preferences/autoupdate.js; fi
127         @if [ -n "${AUTOUPDATE_HOST}" ]; then sed -i -e "s|::HOSTNAME::|${AUTOUPDATE_HOST}|" -e "s|https\?://\(https\?://\)|\1|" build/install.rdf; fi
128
129 bell:
130         @perl -e 'print "Ringing bell..." . chr(7) . "\n";'
131
132 bundle:
133         @rm -f build/build.tar
134         @tar -c --exclude=server -f build.tar build/
135         @mv build.tar build/
136         @md5sum build/build.tar > build/build.tar.md5
137
138 generated:
139         @echo ' * Grabbing lang.dtd from the OPAC code '
140         @cp @top_srcdir@/Open-ILS/web/opac/locale/en-US/lang.dtd build/chrome/locale/en-US/
141
142 open-ils:
143         @echo ' * Grabbing more OPAC code and legacy code and custom code'
144         @cp @top_srcdir@/Open-ILS/web/opac/common/js/*.js build/chrome/content/OpenILS/util/
145         @cp $(OPENSRF_JSLIBS)/*.js build/chrome/content/OpenILS/util/
146         @external/prune_dirs.sh build/
147
148 custom_skins:
149         @for skin in $(SKIN_CSS); do \
150                 if [ ! -f "$$skin" ]; then ( touch build/"$$skin" ); fi \
151         done;
152
153 needwebdir:
154         @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
155
156 server-xul: needwebdir build
157         @echo $@
158         mkdir -p $(WEBDIR)
159         mkdir -p $(WEBDIR)/xul/
160         @echo "STAMP_ID = $(STAFF_CLIENT_STAMP_ID)"
161         @echo "Copying xul into $(WEBDIR)/xul/$(STAFF_CLIENT_STAMP_ID)"
162         mkdir -p "$(WEBDIR)/xul/$(STAFF_CLIENT_STAMP_ID)"
163         cp -R @top_srcdir@/Open-ILS/xul/staff_client/build/server "${WEBDIR}/xul/${STAFF_CLIENT_STAMP_ID}/"
164
165 compress-javascript: build
166         @echo "Size of build/ before compression = " `du -sh build/`
167         @echo " * Running Google's Closure Compiler against javascript.  Errors in build/compression.err"
168         @external/closure_compiler.sh $(CLOSURE_COMPILER_JAR) 2>> build/compression.err
169         @echo `find build/ -name '*.js~' -size 0 -print | wc -l` compression failures
170         @find build/ -name '*.js~' -size 0 -exec rm {} \; # remove the output files for those that did not compile
171         @echo `find build/ -name '*.js~' -print | wc -l` compression successes
172         @find build/ -name '*.js~' -exec perl -e '$$a = "{}"; chop $$a; `mv $$a~ $$a`;' \;
173         @echo "Size of build/ (minus compression.err) after compression = " `du -sh --exclude compression.err build/`
174
175 # Easy way to make all three kinds of clients
176
177 clients:
178         @make win-client
179         @make linux-client
180         @make generic-client
181
182 # By doing this we don't change the original build in the build folder
183 # Great for adding/changing things without a full rebuild
184
185 client_dir:
186         @if [ ! -f build/BUILD_ID ]; then echo 'ERROR! Current build not stamped!'; exit 1; fi
187         @echo 'Prepping Client Set'
188         @rm -rf client/
189         @mkdir -p client
190         @cp -fR build/* client/
191         @rm -rf client/server/
192         @rm -f client/build.tar*
193
194 # When building as a standalone client install.rdf is a bad thing
195 # as we haven't "sanitized" the client for extension use
196
197 client_app: client_dir
198         @echo 'Cleaning Extension Information'
199         @rm -f client/install.rdf
200
201 # If automatic updates are enabled, or the standalone_xul_app.js is present,
202 # the extension can break Firefox.
203 # Remove those, and we need a chrome.manifest
204
205 client_ext: client_dir
206         @echo 'Cleaning App Information'
207         @rm -f client/application.ini
208         @rm -f client/defaults/preferences/autoupdate.js
209         @rm -f client/defaults/preferences/autochannel.js
210         @rm -f client/defaults/preferences/standalone_xul_app.js
211         @echo 'Prepping chrome.manifest'
212         @perl -ne 'if(/open_ils_staff_client/) { s/ (?!chrome:\/\/open_ils_staff_client)([^ ]*)$$/ chrome\/\1/; print; }' client/chrome/chrome.manifest > client/chrome.manifest
213
214 # Would merge client_ext into this one, but this way an installer that doesn't
215 # use an xpi can be made for extension later, if desired
216
217 extension: client_ext
218         @echo ' * Packaging as an XPI'
219         @(cd client/ && zip -q -r ../evergreen.xpi * -x defaults/preferences/standalone_xul_app.js)
220         @md5sum evergreen.xpi > evergreen.xpi.md5
221
222 # Generic client, as an xpi, theoretically suitable for --install-app usage
223
224 generic-client: client_app
225         @echo 'Packing Generic Client via zip (as xpi file)'
226         @rm -f evergreen_staff_client.xpi
227         @cd client && zip -q -r ../evergreen_staff_client.xpi *
228         @echo done
229
230 # These two targets complete the layout defined on
231 # https://developer.mozilla.org/en/XULRunner/Deploying_XULRunner_1.8
232 # for their respective platforms in regards to XULRunner deployment
233
234 # Note that I decided to use win/lin channels for ease of coding platform specific updates
235
236 win-xulrunner: client_app
237         @echo 'Preparing Windows xulrunner'
238         @if [ ! -f ${XULRUNNER_WINFILE} ]; then wget ${XULRUNNER_URL}${XULRUNNER_WINFILE}; fi
239         @unzip -q ${XULRUNNER_WINFILE} -dclient
240         @if [ -f client/defaults/preferences/autoupdate.js ]; then echo 'pref("app.update.channel","win");' >> client/defaults/preferences/autochannel.js; fi;
241         @echo 'Preparing stub'
242         @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
243
244 linux-xulrunner: client_app
245         @echo 'Preparing Linux xulrunner'
246         @if [ ! -f ${XULRUNNER_LINUXFILE} ]; then wget ${XULRUNNER_URL}${XULRUNNER_LINUXFILE}; fi
247         @cd client; tar xjf ../${XULRUNNER_LINUXFILE}; cd ..
248         @if [ -f client/defaults/preferences/autoupdate.js ]; then echo 'pref("app.update.channel","lin");' >> client/defaults/preferences/autochannel.js; fi;
249         @echo 'Preparing stub'
250         @mv client/xulrunner/xulrunner-stub client/evergreen
251
252 # Build a windows installer.
253
254 win-client: win-xulrunner
255         @if [ "${NSIS_AUTOUPDATE}${NSIS_PERMACHINE}" -a ! -d AccessControl ]; then echo 'Fetching AccessControl Plugin'; wget ${NSIS_ACCESSCONTROL} -O AccessControl.zip; unzip AccessControl.zip; fi
256         @echo 'Building installer'
257         @makensis -V2 -DPRODUCT_VERSION="${STAFF_CLIENT_VERSION}" ${NSIS_WICON} ${NSIS_AUTOUPDATE} ${NSIS_DEV} ${NSIS_PERMACHINE} ${NSIS_EXTRAOPTS} windowssetup.nsi
258         @echo 'Done'
259
260 # For linux, just build a tar.bz2 archive
261
262 linux-client: linux-xulrunner
263         @echo 'Packing as evergreen_staff_client.tar.bz2'
264         @rm -f evergreen_staff_client.tar.bz2
265         @cd client; tar cjf ../evergreen_staff_client.tar.bz2 *; cd ..
266         @echo 'Done'
267
268 # For running the updates script with the correct updates directory, optionally building clients as well
269
270 updates updates-client win-updates win-updates-client linux-updates linux-updates-client generic-updates generic-updates-client extension-updates:
271         @if [ ! -f build/BUILD_ID ]; then echo 'ERROR! Current build not stamped!'; exit 1; fi
272         @if [ ! -x external/make_updates.sh ]; then chmod u+x external/make_updates.sh; fi
273         @if [ ! -x external/make_updates.sh ]; then echo 'ERROR! external/make_updates.sh is not executable!'; exit 1; fi
274         @external/make_updates.sh ${UPDATESDIR} $@