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