1 # XScreenSaver for Android
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".
25 # These hacks have interdependencies with others, so we can't build without
26 # including them or there are link errors:
36 # These are the ones that currently work, at least to some degree:
38 export ANDROID_HACKS= \
39 $(ANDROID_BASE_HACKS) \
243 # These don't work well enough to turn on by default:
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
270 # Android actually wants these to be 160x160 but our source is 200x150.
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 \
285 # If we are making the m6502 hack, create the header file for Android
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"; \
295 xscreensaver/res/drawable/%.png:
297 FILE1=`echo "$@" | sed 's!^.*/\([^/]*\)\.png$$!\1.jpg!'` ; \
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..." ; \
304 $(WGET) -O- "$$URL" | \
305 convert jpg:- $(CVT) "$$FILE2" ; \
306 if [ ! -s "$$FILE2" ]; then \
307 echo "$$FILE2 failed" >&2 ; \
312 @for f in $(ANDROID_HACKS) $(ANDROID_TODO) ; do \
313 $(MAKE) xscreensaver/res/drawable/$$f.png ; \
318 for f in $(ANDROID_HACKS) $(ANDROID_TODO) ; do \
319 rm -f xscreensaver/res/drawable/$$f.png ; \
322 distclean:: clean_thumbs clean
325 EXTRA_TARFILES = xscreensaver/res/drawable/thumbnail.png \
328 @FILES=`find . $(EXTRA_TARFILES) \( \( \
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 \
340 -o -name .gitignore \
348 -o \( \( -type f -o -type l \) \
355 cd ../hacks/images && $(MAKE)
358 ../hacks/check-configs.pl --build-android $(ANDROID_HACKS)
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
367 KEYSTORE = xscreensaver.jks
369 keytool -genkey -v -keystore $@ \
370 -alias xscreensaver -keyalg RSA -keysize 2048 -validity 10000
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
377 TOOLDIR = $(shell ls -d $$HOME/Library/Android/sdk/build-tools/* | tail -1)
378 ZIPALIGN = $(TOOLDIR)/zipalign
379 JARSIGNER = jarsigner
382 cp -p $(APK_UNSIGNED) $(APK_UNALIGNED)
383 $(JARSIGNER) -verbose -sigalg SHA1withRSA -digestalg SHA1 \
384 -keystore $(KEYSTORE) $(APK_UNALIGNED) xscreensaver
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)
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 ; \
399 cp -p $(APK_SIGNED) ../archive/$$HEAD.apk
402 ## #### Pare it down for faster debugging...
403 #export APP_ABI = armeabi-v7a
404 #export APP_ABI = x86
406 #export ANDROID_HACKS= \
407 # $(ANDROID_BASE_HACKS) \