bf8af850ff277abe2f5af4d3f521e59ece970a3d
[samba.git] / webapps / swat / Makefile
1 ###################################################################################
2 # PUBLIC VARIABLES
3 ###################################################################################
4
5 QOOXDOO = ../qooxdoo-0.6.3-sdk
6 SCRIPTNAME = swat.js
7 APPCLASS = swat.main.Main
8 INCLUDEALL = false
9 OPTIMIZESTRINGS = false
10 OPTIMIZEVARIABLES = false
11 SOURCELOADER=
12 NICE=10
13 LOCALINSTALLDIR = /usr/local/samba/share/swat/apps/swat
14
15
16 ###################################################################################
17 # PRIVATE VARIABLES
18 ###################################################################################
19
20 FRONTEND = $(QOOXDOO)/frontend
21 FRAMEWORK = $(FRONTEND)/framework
22 API = $(FRONTEND)/api
23 CACHE = $(FRAMEWORK)/.cache
24 GENERATOR = $(FRAMEWORK)/tool/generator.py
25
26
27 ifeq ($(INCLUDEALL),false)
28   INCLUDE = --include $(APPCLASS)
29 else
30   INCLUDE =
31 endif
32
33 ifeq ($(OPTIMIZESTRINGS),true)
34   OPTIMIZESTR = --optimize-strings
35 else
36   OPTIMIZESTR =
37 endif
38
39 ifeq ($(OPTIMIZEVARIABLES),true)
40   OPTIMIZEVAR = --optimize-variables
41 else
42   OPTIMIZEVAR =
43 endif
44
45 ifneq ($(SOURCELOADER),)
46   SOURCELDR = --source-loader-type $(SOURCELOADER)
47 else
48   SOURCELDR =
49 endif
50
51
52 ###################################################################################
53 # DEFAULT TARGET
54 ###################################################################################
55
56 all: build
57
58
59
60 ###################################################################################
61 # COMMON TARGETS
62 ###################################################################################
63
64 source: info-source \
65         generate-script-source \
66         generate-api-data
67
68 build:  info-build \
69         generate-script-build \
70         generate-api-data \
71         copy-build-files \
72         fix-build-rights
73
74 api: generate-api-build generate-api-data
75         @echo
76         @echo "  CREATE COPY OF HTML FILE"
77         @echo "----------------------------------------------------------------------------"
78         @echo "  * Copying file..."
79         @cp -f $(API)/source/index.html api/index.html
80
81 pretty: generate-pretty
82 fix: generate-fix
83
84
85
86 ###################################################################################
87 # CLEANUP TARGETS
88 ###################################################################################
89
90 clean:
91         @echo
92         @echo "  CLEANUP OF GENERATED FILES"
93         @echo "----------------------------------------------------------------------------"
94         @echo "  * Deleting files..."
95         @rm -f source/script/$(SCRIPTNAME) build/script/$(SCRIPTNAME)
96
97 realclean: clean
98         @echo
99         @echo "  CLEANUP OF GENERATED FILES (REAL)"
100         @echo "----------------------------------------------------------------------------"
101         @echo "  * Deleting files..."
102         @nice -n $(NICE) rm -rf build
103
104 distclean: realclean
105         @echo
106         @echo "  CLEANUP OF GENERATED FILES (DIST)"
107         @echo "----------------------------------------------------------------------------"
108         @echo "  * Deleting files..."
109         @nice -n $(NICE) find . -name "*~" -o -name "*.bak" -o -name "*.old" | xargs rm -rf
110         @nice -n $(NICE) rm -rf $(CACHE)
111
112
113
114 ###################################################################################
115 # GENERATOR TARGETS
116 ###################################################################################
117
118 generate-script-source:
119         @chmod u+x $(GENERATOR) && nice -n $(NICE) $(GENERATOR) \
120           --script-input $(FRAMEWORK)/source/class \
121           --source-script-path ../$(FRAMEWORK)/source/class \
122           --script-input $(API)/source/class \
123           --source-script-path ../$(API)/source/class \
124           --script-input source/class \
125           --source-script-path class \
126           --generate-source-script $(SOURCELDR) \
127           $(INCLUDE) \
128           --source-script-file source/script/$(SCRIPTNAME) \
129           --define-runtime-setting qx.manager.object.AliasManager.resourceUri:../$(FRAMEWORK)/source/resource \
130           --cache-directory $(CACHE) \
131           --add-new-lines
132
133 #
134 # djl: --script-input begins a set for which --resource-input and
135 #      --resource-output apply.  Since there is a --resource-input and a
136 #      --resource-output defined for one set, it must be defined for each set
137 #
138 generate-script-build:
139         @chmod u+x $(GENERATOR) && nice -n $(NICE) $(GENERATOR) \
140           --script-input $(FRAMEWORK)/source/class \
141           --resource-input $(FRAMEWORK)/source/resource \
142           --resource-output build/resource \
143           --script-input $(API)/source/class \
144           --resource-input $(API)/source/resource \
145           --resource-output build/resource \
146           --script-input source/class \
147           --resource-input source/resource \
148           --resource-output build/resource \
149           --generate-compiled-script \
150           $(INCLUDE) $(OPTIMIZESTR) $(OPTIMIZEVAR) \
151           --compiled-script-file build/script/$(SCRIPTNAME) \
152           --copy-resources \
153           --define-runtime-setting qx.manager.object.AliasManager.resourceUri:./resource \
154           --cache-directory $(CACHE) \
155           --add-new-lines
156
157 generate-api-build:
158         @chmod u+x $(GENERATOR) && nice -n $(NICE) $(GENERATOR) \
159           --script-input $(FRAMEWORK)/source/class \
160           --resource-input $(FRAMEWORK)/source/resource \
161           --resource-output api/resource/qooxdoo \
162           --script-input $(API)/source/class \
163           --resource-input $(API)/source/resource \
164           --resource-output api/resource \
165           --include api \
166           $(OPTIMIZESTR) $(OPTIMIZEVAR) \
167           --generate-compiled-script \
168           --compiled-script-file api/script/api.js \
169           --define-runtime-setting qx.manager.object.AliasManager.resourceUri:resource/qooxdoo \
170           --define-runtime-setting api.Viewer.title:Swat \
171           --copy-resources \
172           --cache-directory $(CACHE)
173
174 generate-api-data:
175         @chmod u+x $(GENERATOR) && nice -n $(NICE) $(GENERATOR) \
176           --script-input $(FRAMEWORK)/source/class \
177           --script-input $(API)/source/class \
178           --script-input source/class \
179           --generate-api-documentation \
180           --api-documentation-json-file build/script/data.js \
181           --cache-directory $(CACHE)
182
183 generate-pretty:
184         @chmod u+x $(GENERATOR) && nice -n $(NICE) $(GENERATOR) \
185           --script-input source/class \
186           --script-input $(FRAMEWORK)/source/class \
187           --include-without-dependencies api.* \
188           --pretty-print \
189           --cache-directory $(CACHE)
190
191 generate-fix:
192         @chmod u+x $(GENERATOR) && nice -n $(NICE) $(GENERATOR) \
193           --script-input source/class \
194           --script-input $(FRAMEWORK)/source/class \
195           --include-without-dependencies api.* \
196           --fix-source \
197           --cache-directory $(CACHE)
198
199
200
201 ###################################################################################
202 # ADDITIONAL TARGETS
203 ###################################################################################
204
205 copy-build-files:
206         @echo
207         @echo "  CREATE COPY OF HTML FILE"
208         @echo "----------------------------------------------------------------------------"
209         @echo "  * Copying file..."
210         @cp -f source/index.html build/index.html
211
212 fix-build-rights:
213         @echo
214         @echo "  FIX RIGHTS ON BUILD FILES"
215         @echo "----------------------------------------------------------------------------"
216         @echo "  * Fixing file rights..."
217         @nice -n $(NICE) find build -type d | xargs chmod a+rx
218         @nice -n $(NICE) find build -type f | xargs chmod a+r
219
220
221
222
223
224 ###################################################################################
225 # INFO TARGETS
226 ###################################################################################
227
228 info-build:
229         @echo "****************************************************************************"
230         @echo "  GENERATING SWAT WEB APPLICATION BUILD"
231         @echo "****************************************************************************"
232
233 info-source:
234         @echo "****************************************************************************"
235         @echo "  GENERATING SWAT WEB APPLICATION SOURCE"
236         @echo "****************************************************************************"
237
238 ###################################################################################
239 # INSTALL TARGETS (for developer use only)
240 ###################################################################################
241
242 install:        
243         @echo "****************************************************************************"
244         @echo "  INSTALLING SWAT"
245         @echo "****************************************************************************"
246         @echo "  * Installing swat files..."
247         @rsync -av --exclude=crystalsvg --delete build/ $(LOCALINSTALLDIR)