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