From http://www.jwz.org/xscreensaver/xscreensaver-5.40.tar.gz
[xscreensaver] / android / Makefile
1 # XScreenSaver for Android
2
3 export TERM=dumb
4 GRADLE = ./gradlew
5
6 default:: debug
7 all:: release
8
9 clean::
10         $(GRADLE) clean
11
12 distdepend::
13
14 # Set this to the set of platforms you want to compile for in debug mode.
15 # E.g., if you are running an x86 emulator, there's no point in compiling
16 # for a dozen other platforms.  Release builds override this to "all".
17 #
18 export APP_ABI = all
19
20
21 # TODO:
22 # check_versions:
23
24
25 # These hacks have interdependencies with others, so we can't build without
26 # including them or there are link errors:
27 #
28 ANDROID_BASE_HACKS=             \
29         apple2                  \
30         bubble3d                \
31         pacman                  \
32         polyhedra               \
33         sonar                   \
34         sproingies              \
35
36 # These are the ones that currently work, at least to some degree:
37 #
38 export ANDROID_HACKS=           \
39         $(ANDROID_BASE_HACKS)   \
40         abstractile             \
41         anemone                 \
42         anemotaxis              \
43         antmaze                 \
44         antspotlight            \
45         apollonian              \
46         atlantis                \
47         attraction              \
48         atunnel                 \
49         binaryring              \
50         blaster                 \
51         blinkbox                \
52         blitspin                \
53         blocktube               \
54         boing                   \
55         bouboule                \
56         bouncingcow             \
57         boxed                   \
58         boxfit                  \
59         braid                   \
60         bsod                    \
61         bumps                   \
62         cage                    \
63         ccurve                  \
64         celtic                  \
65         circuit                 \
66         cityflow                \
67         cloudlife               \
68         companioncube           \
69         compass                 \
70         coral                   \
71         crackberg               \
72         crumbler                \
73         crystal                 \
74         cube21                  \
75         cubenetic               \
76         cubestack               \
77         cubestorm               \
78         cubetwist               \
79         cubicgrid               \
80         cwaves                  \
81         cynosure                \
82         dangerball              \
83         decayscreen             \
84         deco                    \
85         deluxe                  \
86         demon                   \
87         discoball               \
88         discrete                \
89         distort                 \
90         dnalogo                 \
91         drift                   \
92         dymaxionmap             \
93         endgame                 \
94         energystream            \
95         engine                  \
96         epicycle                \
97         eruption                \
98         esper                   \
99         euler2d                 \
100         fadeplot                \
101         fiberlamp               \
102         filmleader              \
103         fireworkx               \
104         flame                   \
105         flipflop                \
106         flipscreen3d            \
107         flow                    \
108         fluidballs              \
109         flyingtoasters          \
110         fuzzyflakes             \
111         galaxy                  \
112         gears                   \
113         geodesic                \
114         geodesicgears           \
115         gflux                   \
116         glblur                  \
117         glcells                 \
118         gleidescope             \
119         glhanoi                 \
120         glknots                 \
121         glmatrix                \
122         glplanet                \
123         glschool                \
124         glslideshow             \
125         glsnake                 \
126         gltext                  \
127         goop                    \
128         grav                    \
129         greynetic               \
130         halo                    \
131         helix                   \
132         hexadrop                \
133         hexstrut                \
134         hilbert                 \
135         hopalong                \
136         hypertorus              \
137         hypnowheel              \
138         ifs                     \
139         imsmap                  \
140         interaggregate          \
141         interference            \
142         intermomentary          \
143         jigglypuff              \
144         jigsaw                  \
145         julia                   \
146         kaleidescope            \
147         kaleidocycle            \
148         klein                   \
149         kumppa                  \
150         lament                  \
151         lavalite                \
152         loop                    \
153         m6502                   \
154         maze                    \
155         maze3d                  \
156         memscroller             \
157         menger                  \
158         metaballs               \
159         mirrorblob              \
160         moebius                 \
161         moebiusgears            \
162         moire                   \
163         moire2                  \
164         morph3d                 \
165         mountain                \
166         munch                   \
167         nerverot                \
168         noof                    \
169         noseguy                 \
170         peepers                 \
171         penetrate               \
172         penrose                 \
173         petri                   \
174         piecewise               \
175         pinion                  \
176         pipes                   \
177         polytopes               \
178         pong                    \
179         popsquares              \
180         projectiveplane         \
181         providence              \
182         pulsar                  \
183         pyro                    \
184         quasicrystal            \
185         queens                  \
186         raverhoop               \
187         razzledazzle            \
188         rd-bomb                 \
189         ripples                 \
190         rocks                   \
191         romanboy                \
192         rorschach               \
193         rotzoomer               \
194         rubik                   \
195         rubikblocks             \
196         sballs                  \
197         shadebobs               \
198         sierpinski              \
199         sierpinski3d            \
200         skytentacles            \
201         slidescreen             \
202         slip                    \
203         spheremonics            \
204         splitflap               \
205         splodesic               \
206         spotlight               \
207         squiral                 \
208         stairs                  \
209         stonerview              \
210         strange                 \
211         substrate               \
212         superquadrics           \
213         surfaces                \
214         swirl                   \
215         tangram                 \
216         tessellimage            \
217         thornbird               \
218         timetunnel              \
219         topblock                \
220         triangle                \
221         tronbit                 \
222         truchet                 \
223         twang                   \
224         unknownpleasures        \
225         vermiculate             \
226         vfeedback               \
227         vigilance               \
228         voronoi                 \
229         wander                  \
230         whirlwindwarp           \
231         winduprobot             \
232         wormhole                \
233         xanalogtv               \
234         xflame                  \
235         xjack                   \
236         xlyap                   \
237         xmatrix                 \
238         xrayswarm               \
239         xspirograph             \
240         zoom                    \
241
242
243 # These don't work well enough to turn on by default:
244 #
245 ANDROID_TODO=                   \
246         antinspect              \
247         barcode                 \
248         carousel                \
249         fliptext                \
250         fontglide               \
251         halftone                \
252         juggler3d               \
253         molecule                \
254         pedal                   \
255         phosphor                \
256         photopile               \
257         polyominoes             \
258         qix                     \
259         speedmine               \
260         starfish                \
261         starwars                \
262         testx11                 \
263         unicrud                 \
264
265
266 # Download and resize images from jwz.org.
267 # This saves us having to include 4MB of images in the tar file
268 # that will only be used by a vast minority of people building
269 # from source.
270 # Android actually wants these to be 160x160 but our source is 200x150.
271
272 URL = https://www.jwz.org/xscreensaver/screenshots/
273 WGET = wget -q -U xscreensaver-build-android
274 CVT  = -thumbnail '150x150^' -gravity center -extent 150x150 \
275      \( +clone  -alpha extract \
276         -draw 'fill black polygon 0,0 0,15 15,0 fill white circle 15,15 15,0' \
277         \( +clone -flip \) -compose Multiply -composite \
278         \( +clone -flop \) -compose Multiply -composite \
279      \) -alpha off -compose CopyOpacity -composite \
280     -colorspace sRGB \
281     -strip \
282     -quality 95 \
283     +dither -colors 128
284
285 # If we are making the m6502 hack, create the header file for Android
286 m6502.h::
287         @for h in $(ANDROID_HACKS) ; do \
288                 if [ $${h} = "m6502" ] ; then \
289                         echo "Making $${h} header ..."; \
290                         ../hacks/m6502.sh ../hacks/m6502.h ../hacks/images/m6502/*.asm ; \
291                         echo "Made $${h} header"; \
292                 fi; \
293         done
294
295 xscreensaver/res/drawable/%.png:
296         @\
297         FILE1=`echo "$@" | sed 's!^.*/\([^/]*\)\.png$$!\1.jpg!'` ;      \
298         FILE2="$@" ;                                                    \
299         FILE1=`echo "$$FILE1" | sed s/rdbomb/rd-bomb/` ;                \
300         FILE2=`echo "$$FILE2" | sed s/rd-bomb/rdbomb/` ;                \
301         URL="$(URL)$$FILE1" ;                                           \
302         echo "converting $$URL..." ;                                    \
303         rm -f "$$FILE2" ;                                               \
304         $(WGET) -O- "$$URL" |                                           \
305         convert jpg:- $(CVT) "$$FILE2" ;                                \
306         if [ ! -s "$$FILE2" ]; then                                     \
307           echo "$$FILE2 failed" >&2 ;                                   \
308           exit 1 ;                                                      \
309         fi
310
311 thumbs::
312         @for f in $(ANDROID_HACKS) $(ANDROID_TODO) ; do                 \
313           $(MAKE) xscreensaver/res/drawable/$$f.png ;                   \
314         done
315
316 clean_thumbs::
317         @\
318         for f in $(ANDROID_HACKS) $(ANDROID_TODO) ; do                  \
319           rm -f xscreensaver/res/drawable/$$f.png ;                     \
320         done
321
322 distclean:: clean_thumbs clean
323
324
325 EXTRA_TARFILES = xscreensaver/res/drawable/thumbnail.png \
326
327 echo_tarfiles:
328         @FILES=`find . $(EXTRA_TARFILES) \( \(  \
329                    -name .DS_Store              \
330                 -o -name '*~'                   \
331                 -o -name '*.jks'                \
332                 -o -name '*.keystore'           \
333                 -o -name '*_dream.xml'          \
334                 -o -name '*_settings.xml'       \
335                 -o -name '*_wallpaper.xml'      \
336                 -o -name AndroidManifest.xml    \
337                 -o -name strings.xml            \
338                 -o -name settings.xml           \
339                 -o -name attrs.xml              \
340                 -o -name .gitignore             \
341                 -o -name .gradle                \
342                 -o -name drawable               \
343                 -o -name build                  \
344                 -o -name gen                    \
345                 -o -name libs                   \
346                 -o -name obj                    \
347                 \) -prune \)                    \
348                 -o \( \( -type f -o -type l \)  \
349                       -print \)                 \
350                 | sed 's@^\./@@'                \
351                 | sort` ;                       \
352         echo $$FILES
353
354 images_png_h:
355         cd ../hacks/images && $(MAKE)
356
357 run_check::
358         ../hacks/check-configs.pl --build-android $(ANDROID_HACKS)
359
360 debug:: m6502.h run_check images_png_h
361         $(GRADLE) assembleDebug
362 release:: m6502.h run_check images_png_h
363         export APP_ABI=all ; \
364         $(GRADLE) assembleRelease
365
366
367 KEYSTORE = xscreensaver.jks
368 $(KEYSTORE):
369         keytool -genkey -v -keystore $@ \
370         -alias xscreensaver -keyalg RSA -keysize 2048 -validity 10000
371
372 APK_DIR       = xscreensaver/build/outputs/apk/release/
373 APK_UNSIGNED  = $(APK_DIR)xscreensaver-release-unsigned.apk
374 APK_UNALIGNED = $(APK_DIR)xscreensaver-release-unaligned.apk
375 APK_SIGNED    = $(APK_DIR)xscreensaver-release.apk
376
377   TOOLDIR = $(shell ls -d $$HOME/Library/Android/sdk/build-tools/* | tail -1)
378  ZIPALIGN = $(TOOLDIR)/zipalign
379 JARSIGNER = jarsigner
380
381 sign_release::
382         cp -p $(APK_UNSIGNED) $(APK_UNALIGNED)
383         $(JARSIGNER) -verbose -sigalg SHA1withRSA -digestalg SHA1 \
384                      -keystore $(KEYSTORE) $(APK_UNALIGNED) xscreensaver
385         rm -f $(APK_SIGNED)
386         $(ZIPALIGN) -v 4 $(APK_UNALIGNED) $(APK_SIGNED)
387         rm -f $(APK_UNALIGNED)
388         $(JARSIGNER) -verify -verbose -certs $(APK_SIGNED)
389         @ls -lF $(APK_SIGNED)
390
391 apk:: release
392         @\
393   VERS=`sed -n 's/[^0-9]*\([0-9]\.[0-9][^. ]*\).*/\1/p' ../utils/version.h` ; \
394   HEAD="xscreensaver-$$VERS" ;                                                \
395   if [ ! -s $(APK_SIGNED) -o $(APK_UNSIGNED) -nt $(APK_SIGNED) ]; then  \
396     $(MAKE) sign_release ;                                              \
397   fi ;                                                                  \
398   set -x ;                                                              \
399   cp -p $(APK_SIGNED) ../archive/$$HEAD.apk
400
401
402 ## #### Pare it down for faster debugging...
403 #export APP_ABI = armeabi-v7a
404 #export APP_ABI = x86
405 #
406 #export ANDROID_HACKS=          \
407 #       $(ANDROID_BASE_HACKS)   \
408 #  bsod                         \
409 #  apollonian                   \
410 #  engine                       \
411 #  dnalogo                      \
412 #  twang                        \
413 #  memscroller                  \
414 #  phosphor                     \
415 #  discoball                    \
416 #  cubetwist                    \
417 #  cubestack                    \
418 #  splodesic                    \