blob: 75a57cf9b475fde0d4e0027ff73e54327e737575 [file] [log] [blame]
Alexandre Lision43b9aeb2014-07-15 14:21:19 -04001# Sources and objects
Tristan Matthewsccf51e32013-07-18 14:40:51 -04002
Alexandre Lision43b9aeb2014-07-15 14:21:19 -04003export ANDROID_HOME=$(ANDROID_SDK)
Tristan Matthews5bb1b5d2013-07-18 14:32:58 -04004
Ciro Santilli7ff57fb2016-02-20 22:23:17 +01005TOP=$(shell pwd)/ring-android
6SRC=$(TOP)/app/src/main
7LIBRINGJNI_H=${DAEMON_DIR}/src/dring/dring.h
8LIBRINGJNI=$(SRC)/obj/local/${ARCH}/libring.so
Alexandre Lisionec1f3ee2014-08-04 19:12:42 -04009
Adrien Béraudb00ed3f2015-06-07 15:36:06 -040010JAVA_SOURCES=$(shell find $(SRC)/java/cx/ring/ -type f -name "*.java")
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040011
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040012ifneq ($(V),)
Adrien Béraudb00ed3f2015-06-07 15:36:06 -040013GRADLE_OPTS += -d
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040014VERBOSE =
15GEN =
16else
17VERBOSE = @
18GEN = @echo "Generating" $@;
19endif
20
21ifeq ($(RELEASE),1)
Adrien Béraudb00ed3f2015-06-07 15:36:06 -040022GRADLE_TARGET = assembleRelease
Adrien Béraud04d822c2015-04-02 17:44:36 -040023RING_APK=$(SRC)/bin/Ring-release-unsigned.apk
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040024NDK_DEBUG=0
25else
Adrien Béraudb00ed3f2015-06-07 15:36:06 -040026GRADLE_TARGET = assembleDebug
Adrien Béraud04d822c2015-04-02 17:44:36 -040027RING_APK=$(SRC)/bin/Ring-debug.apk
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040028NDK_DEBUG=1
29endif
30
Alexandre Lision7d5df5d2014-10-27 13:10:01 -040031define build_apk
32 @echo
Adrien Béraud04d822c2015-04-02 17:44:36 -040033 @echo "=== Building $(RING_APK) for $(ARCH) ==="
Alexandre Lision7d5df5d2014-10-27 13:10:01 -040034 @echo
35 date +"%Y-%m-%d" > $(SRC)/assets/builddate.txt
36 echo `id -u -n`@`hostname` > $(SRC)/assets/builder.txt
37 git rev-parse --short HEAD > $(SRC)/assets/revision.txt
38 ./gen-env.sh $(SRC)
Adrien Béraudb00ed3f2015-06-07 15:36:06 -040039 # many times the gradlew script is not executable by default
Ciro Santilli7ff57fb2016-02-20 22:23:17 +010040 $(VERBOSE)cd $(TOP) && chmod +x ./gradlew && ./gradlew $(GRADLE_OPTS) $(GRADLE_TARGET) -Parchs=$(ARCH)
Alexandre Lision7d5df5d2014-10-27 13:10:01 -040041endef
42
Adrien Béraud04d822c2015-04-02 17:44:36 -040043$(RING_APK): $(LIBRINGJNI) $(JAVA_SOURCES)
Ciro Santilli7ff57fb2016-02-20 22:23:17 +010044 @echo
45 @echo "=== Building $@ for ${ARCH} ==="
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040046 @echo
47 date +"%Y-%m-%d" > $(SRC)/assets/builddate.txt
48 echo `id -u -n`@`hostname` > $(SRC)/assets/builder.txt
49 git rev-parse --short HEAD > $(SRC)/assets/revision.txt
Adrien Béraudb00ed3f2015-06-07 15:36:06 -040050 # many times the gradlew script is not executable by default
Ciro Santilli7ff57fb2016-02-20 22:23:17 +010051 $(VERBOSE)cd $(TOP) && chmod +x ./gradlew && ./gradlew $(GRADLE_OPTS) $(GRADLE_TARGET) -Parchs=$(ARCH)
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040052
Adrien Béraud04d822c2015-04-02 17:44:36 -040053$(LIBRINGJNI): $(LIBRINGJNI_H)
54 @if [ -z "$(RING_BUILD_DIR)" ]; then echo "RING_BUILD_DIR not defined" ; exit 1; fi
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040055 @if [ -z "$(ANDROID_NDK)" ]; then echo "ANDROID_NDK not defined" ; exit 1; fi
56 @echo
Adrien Béraud04d822c2015-04-02 17:44:36 -040057 @echo "=== Building libringjni ==="
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040058 @echo
Ciro Santilli7ff57fb2016-02-20 22:23:17 +010059 $(VERBOSE)if [ -z "$(RING_SRC_DIR)" ] ; then RING_SRC_DIR='${DAEMON_DIR}'; fi ; \
Adrien Béraud87d878d2015-06-03 15:09:19 -040060 if [ -z "$(RING_CONTRIB)" ] ; then RING_CONTRIB="$$RING_SRC_DIR/contrib/$(TARGET_TUPLE)"; fi ; \
Adrien Béraud04d822c2015-04-02 17:44:36 -040061 if [ `echo "$(RING_BUILD_DIR)" | head -c 1` != "/" ] ; then \
62 RING_BUILD_DIR="../$(RING_BUILD_DIR)"; \
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040063 fi ; \
Adrien Béraud04d822c2015-04-02 17:44:36 -040064 [ `echo "$$RING_CONTRIB" | head -c 1` != "/" ] && RING_CONTRIB="../$$RING_CONTRIB"; \
65 [ `echo "$$RING_SRC_DIR" | head -c 1` != "/" ] && RING_SRC_DIR="../$$RING_SRC_DIR"; \
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040066 $(ANDROID_NDK)/ndk-build -C $(SRC) \
Adrien Béraud04d822c2015-04-02 17:44:36 -040067 RING_SRC_DIR="$$RING_SRC_DIR" \
68 RING_CONTRIB="$$RING_CONTRIB" \
69 RING_BUILD_DIR="$$RING_BUILD_DIR" \
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040070 NDK_DEBUG=$(NDK_DEBUG) \
Adrien Béraud04d822c2015-04-02 17:44:36 -040071 TARGET_CFLAGS="$$RING_EXTRA_CFLAGS"
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040072
Alexandre Lision7d5df5d2014-10-27 13:10:01 -040073apk:
74 $(call build_apk)
75
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040076apkclean:
Adrien Béraud04d822c2015-04-02 17:44:36 -040077 rm -f $(RING_APK)
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040078
79lightclean:
Ciro Santilli7ff57fb2016-02-20 22:23:17 +010080 cd $(SRC) && rm -rf libs/armeabi-v7a libs/x86 obj bin $(RING_APK)
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040081
82clean: lightclean
Romain Bertozzi197c8c82016-04-04 14:18:11 -040083 rm -rf $(SRC)/gen java-libs/*/gen java-libs/*/bin
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040084
85jniclean: lightclean
Adrien Béraud04d822c2015-04-02 17:44:36 -040086 rm -f $(LIBRINGJNI)
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040087
88distclean: clean jniclean
89
Adrien Béraud04d822c2015-04-02 17:44:36 -040090install: $(RING_APK)
Adrien Béraud87d878d2015-06-03 15:09:19 -040091 @echo "=== Installing Ring on device ==="
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040092 adb wait-for-device
Adrien Béraud04d822c2015-04-02 17:44:36 -040093 adb install -r $(RING_APK)
Tristan Matthews5bb1b5d2013-07-18 14:32:58 -040094
Tristan Matthewsfdd94e52013-07-19 16:44:44 -040095uninstall:
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040096 adb wait-for-device
Adrien Béraud04d822c2015-04-02 17:44:36 -040097 adb uninstall cx.ring
Tristan Matthewsfdd94e52013-07-19 16:44:44 -040098
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040099run:
Adrien Béraud87d878d2015-06-03 15:09:19 -0400100 @echo "=== Running Ring on device ==="
Alexandre Lision43b9aeb2014-07-15 14:21:19 -0400101 adb wait-for-device
Adrien Béraud04d822c2015-04-02 17:44:36 -0400102 adb shell am start -n cx.ring/cx.ring.client.HomeActivity
Alexandre Lision43b9aeb2014-07-15 14:21:19 -0400103
104build-and-run: install run
105
106apkclean-run: apkclean build-and-run
107 adb logcat -c
108
109distclean-run: distclean build-and-run
110 adb logcat -c
111
Alexandre Lision43b9aeb2014-07-15 14:21:19 -0400112.PHONY: lightclean clean jniclean distclean distclean-run apkclean apkclean-run install run build-and-run