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