1 # XScreenSaver for Android
4 GRADLE = cd project ; ./gradlew
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) \
185 # These don't work well enough to turn on by default:
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
263 # Android actually wants these to be 160x160 but our source is 200x150.
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 \
278 # If we are making the m6502 hack, create the header file for Android
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"; \
288 project/xscreensaver/res/drawable/%.png:
290 FILE1=`echo "$@" | sed 's!^.*/\([^/]*\)\.png$$!\1.jpg!'` ; \
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..." ; \
297 $(WGET) -O- "$$URL" | \
298 convert jpg:- $(CVT) "$$FILE2" ; \
299 if [ ! -s "$$FILE2" ]; then \
300 echo "$$FILE2 failed" >&2 ; \
305 @for f in $(ANDROID_HACKS) $(ANDROID_TODO) ; do \
306 $(MAKE) project/xscreensaver/res/drawable/$$f.png ; \
311 for f in $(ANDROID_HACKS) $(ANDROID_TODO) ; do \
312 rm -f project/xscreensaver/res/drawable/$$f.png ; \
315 distclean:: clean_thumbs clean
318 EXTRA_TARFILES = project/xscreensaver/res/drawable/thumbnail.png \
321 @FILES=`find . $(EXTRA_TARFILES) \( \( \
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 \
332 -o -name .gitignore \
340 -o \( \( -type f -o -type l \) \
347 ../hacks/check-configs.pl --build-android $(ANDROID_HACKS)
349 debug:: m6502.h run_check
350 $(GRADLE) assembleDebug
351 release:: m6502.h run_check
352 export APP_ABI=all ; \
353 $(GRADLE) assembleRelease
356 KEYSTORE = xscreensaver.keystore
358 keytool -genkey -v -keystore $@ \
359 -alias xscreensaver -keyalg RSA -keysize 2048 -validity 10000
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
366 TOOLDIR = $(shell echo $$HOME/Library/Android/sdk/build-tools/* | tail -1)
367 ZIPALIGN = $(TOOLDIR)/zipalign
368 JARSIGNER = jarsigner
371 cp -p $(APK_UNSIGNED) $(APK_UNALIGNED)
372 $(JARSIGNER) -verbose -sigalg SHA1withRSA -digestalg SHA1 \
373 -keystore $(KEYSTORE) $(APK_UNALIGNED) xscreensaver
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)
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 ; \
388 cp -p $(APK_SIGNED) ../archive/$$HEAD.apk
391 ## #### Pare it down for faster debugging...
392 #export APP_ABI = armeabi-v7a
393 #export APP_ABI = x86
395 #export ANDROID_HACKS= \
396 # $(ANDROID_BASE_HACKS) \