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