Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 1 | # Sources and objects |
Tristan Matthews | ccf51e3 | 2013-07-18 14:40:51 -0400 | [diff] [blame] | 2 | |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 3 | export ANDROID_HOME=$(ANDROID_SDK) |
Tristan Matthews | 5bb1b5d | 2013-07-18 14:32:58 -0400 | [diff] [blame] | 4 | |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 5 | ARCH = $(ANDROID_ABI) |
Tristan Matthews | 322b9fd | 2013-07-18 15:55:43 -0400 | [diff] [blame] | 6 | |
Alexandre Lision | 68d8f2e | 2014-07-30 17:42:40 -0400 | [diff] [blame] | 7 | SRC=sflphone-android |
Alexandre Lision | ec1f3ee | 2014-08-04 19:12:42 -0400 | [diff] [blame] | 8 | export SFLPHONE_SRC=$(PWD)/sflphone |
| 9 | LIBSFLPHONEJNI_H=sflphone/daemon/src/sflphone.h |
Alexandre Lision | 864f9b8 | 2014-08-01 14:26:45 -0400 | [diff] [blame] | 10 | LIBSFLPHONEJNI=$(SRC)/obj/local/$(ARCH)/libsflphone.so |
Alexandre Lision | ec1f3ee | 2014-08-04 19:12:42 -0400 | [diff] [blame] | 11 | |
Tristan Matthews | 9c450ae | 2014-08-07 12:29:58 -0400 | [diff] [blame] | 12 | JAVA_SOURCES=$(shell find $(SRC)/src/org/sflphone/ -type f -name "*.java") |
Alexandre Lision | ec1f3ee | 2014-08-04 19:12:42 -0400 | [diff] [blame] | 13 | JNI_SOURCES=$(SRC)/jni/*.cpp $(SRC)/jni/*.h |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 14 | |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 15 | ifneq ($(V),) |
| 16 | ANT_OPTS += -v |
| 17 | VERBOSE = |
| 18 | GEN = |
| 19 | else |
| 20 | VERBOSE = @ |
| 21 | GEN = @echo "Generating" $@; |
| 22 | endif |
| 23 | |
| 24 | ifeq ($(RELEASE),1) |
| 25 | ANT_TARGET = release |
Alexandre Lision | 7d400dc | 2014-07-31 17:51:44 -0400 | [diff] [blame] | 26 | SFLPHONE_APK=$(SRC)/bin/SFLphone-release-unsigned.apk |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 27 | NDK_DEBUG=0 |
| 28 | else |
| 29 | ANT_TARGET = debug |
Alexandre Lision | 7d400dc | 2014-07-31 17:51:44 -0400 | [diff] [blame] | 30 | SFLPHONE_APK=$(SRC)/bin/SFLphone-debug.apk |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 31 | NDK_DEBUG=1 |
| 32 | endif |
| 33 | |
Alexandre Lision | 864f9b8 | 2014-08-01 14:26:45 -0400 | [diff] [blame] | 34 | $(SFLPHONE_APK): $(LIBSFLPHONEJNI) $(JAVA_SOURCES) |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 35 | @echo |
| 36 | @echo "=== Building $@ for $(ARCH) ===" |
| 37 | @echo |
| 38 | date +"%Y-%m-%d" > $(SRC)/assets/builddate.txt |
| 39 | echo `id -u -n`@`hostname` > $(SRC)/assets/builder.txt |
| 40 | git rev-parse --short HEAD > $(SRC)/assets/revision.txt |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 41 | $(VERBOSE)cd $(SRC) && ant $(ANT_OPTS) $(ANT_TARGET) |
| 42 | |
Alexandre Lision | 864f9b8 | 2014-08-01 14:26:45 -0400 | [diff] [blame] | 43 | $(LIBSFLPHONEJNI): $(JNI_SOURCES) $(LIBSFLPHONEJNI_H) |
Alexandre Lision | 7d400dc | 2014-07-31 17:51:44 -0400 | [diff] [blame] | 44 | @if [ -z "$(SFLPHONE_BUILD_DIR)" ]; then echo "SFLPHONE_BUILD_DIR not defined" ; exit 1; fi |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 45 | @if [ -z "$(ANDROID_NDK)" ]; then echo "ANDROID_NDK not defined" ; exit 1; fi |
| 46 | @echo |
Alexandre Lision | 864f9b8 | 2014-08-01 14:26:45 -0400 | [diff] [blame] | 47 | @echo "=== Building libsflphonejni ===" |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 48 | @echo |
Alexandre Lision | 449ca84 | 2014-08-05 11:22:50 -0400 | [diff] [blame] | 49 | $(VERBOSE)if [ -z "$(SFLPHONE_SRC_DIR)" ] ; then SFLPHONE_SRC_DIR=./sflphone; fi ; \ |
Alexandre Lision | 7d400dc | 2014-07-31 17:51:44 -0400 | [diff] [blame] | 50 | if [ -z "$(SFLPHONE_CONTRIB)" ] ; then SFLPHONE_CONTRIB="$$SFLPHONE_SRC_DIR/contrib/$(TARGET_TUPLE)"; fi ; \ |
Alexandre Lision | 7d400dc | 2014-07-31 17:51:44 -0400 | [diff] [blame] | 51 | if [ `echo "$(SFLPHONE_BUILD_DIR)" | head -c 1` != "/" ] ; then \ |
Alexandre Lision | 7d400dc | 2014-07-31 17:51:44 -0400 | [diff] [blame] | 52 | SFLPHONE_BUILD_DIR="../$(SFLPHONE_BUILD_DIR)"; \ |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 53 | fi ; \ |
Alexandre Lision | 7d400dc | 2014-07-31 17:51:44 -0400 | [diff] [blame] | 54 | [ `echo "$$SFLPHONE_CONTRIB" | head -c 1` != "/" ] && SFLPHONE_CONTRIB="../$$SFLPHONE_CONTRIB"; \ |
| 55 | [ `echo "$$SFLPHONE_SRC_DIR" | head -c 1` != "/" ] && SFLPHONE_SRC_DIR="../$$SFLPHONE_SRC_DIR"; \ |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 56 | $(ANDROID_NDK)/ndk-build -C $(SRC) \ |
Alexandre Lision | 7d400dc | 2014-07-31 17:51:44 -0400 | [diff] [blame] | 57 | SFLPHONE_SRC_DIR="$$SFLPHONE_SRC_DIR" \ |
| 58 | SFLPHONE_CONTRIB="$$SFLPHONE_CONTRIB" \ |
| 59 | SFLPHONE_BUILD_DIR="$$SFLPHONE_BUILD_DIR" \ |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 60 | NDK_DEBUG=$(NDK_DEBUG) \ |
Alexandre Lision | 7d400dc | 2014-07-31 17:51:44 -0400 | [diff] [blame] | 61 | TARGET_CFLAGS="$$SFLPHONE_EXTRA_CFLAGS" |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 62 | |
| 63 | apkclean: |
Alexandre Lision | 7d400dc | 2014-07-31 17:51:44 -0400 | [diff] [blame] | 64 | rm -f $(SFLPHONE_APK) |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 65 | |
| 66 | lightclean: |
Alexandre Lision | 9abb7c9 | 2014-08-04 19:22:55 -0400 | [diff] [blame] | 67 | cd $(SRC) && rm -rf libs/armeabi-v7a libs/x86 libs/mips obj bin $(SFLPHONE_APK) |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 68 | |
| 69 | clean: lightclean |
| 70 | rm -rf $(SRC)/gen java-libs/*/gen java-libs/*/bin .sdk vlc-sdk/ vlc-sdk.7z |
| 71 | |
| 72 | jniclean: lightclean |
Alexandre Lision | ec1f3ee | 2014-08-04 19:12:42 -0400 | [diff] [blame] | 73 | rm -f $(LIBSFLPHONEJNI) |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 74 | |
| 75 | distclean: clean jniclean |
| 76 | |
Alexandre Lision | 7d400dc | 2014-07-31 17:51:44 -0400 | [diff] [blame] | 77 | install: $(SFLPHONE_APK) |
| 78 | @echo "=== Installing SFLphone on device ===" |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 79 | adb wait-for-device |
Alexandre Lision | 7d400dc | 2014-07-31 17:51:44 -0400 | [diff] [blame] | 80 | adb install -r $(SFLPHONE_APK) |
Tristan Matthews | 5bb1b5d | 2013-07-18 14:32:58 -0400 | [diff] [blame] | 81 | |
Tristan Matthews | fdd94e5 | 2013-07-19 16:44:44 -0400 | [diff] [blame] | 82 | uninstall: |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 83 | adb wait-for-device |
Alexandre Lision | 7d400dc | 2014-07-31 17:51:44 -0400 | [diff] [blame] | 84 | adb uninstall org.sflphone |
Tristan Matthews | fdd94e5 | 2013-07-19 16:44:44 -0400 | [diff] [blame] | 85 | |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 86 | run: |
Alexandre Lision | 7d400dc | 2014-07-31 17:51:44 -0400 | [diff] [blame] | 87 | @echo "=== Running SFLphone on device ===" |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 88 | adb wait-for-device |
Alexandre Lision | 7d400dc | 2014-07-31 17:51:44 -0400 | [diff] [blame] | 89 | adb shell am start -n org.sflphone/org.sflphone.client.HomeActivity |
Alexandre Lision | 43b9aeb | 2014-07-15 14:21:19 -0400 | [diff] [blame] | 90 | |
| 91 | build-and-run: install run |
| 92 | |
| 93 | apkclean-run: apkclean build-and-run |
| 94 | adb logcat -c |
| 95 | |
| 96 | distclean-run: distclean build-and-run |
| 97 | adb logcat -c |
| 98 | |
| 99 | vlc-sdk.7z: .sdk |
| 100 | 7z a $@ vlc-sdk/ |
| 101 | |
| 102 | .sdk: |
| 103 | mkdir -p vlc-sdk/libs |
| 104 | cd vlc-android; cp -r libs/* ../vlc-sdk/libs |
| 105 | mkdir -p vlc-sdk/src/org/videolan |
| 106 | cp -r vlc-android/src/org/videolan/libvlc vlc-sdk/src/org/videolan |
| 107 | touch $@ |
| 108 | |
| 109 | .PHONY: lightclean clean jniclean distclean distclean-run apkclean apkclean-run install run build-and-run |