blob: 5f63a9bfe08d0fa3c3e60dd0b65d295fdb7a419d [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
Alexandre Lision43b9aeb2014-07-15 14:21:19 -04005ARCH = $(ANDROID_ABI)
Tristan Matthews322b9fd2013-07-18 15:55:43 -04006
Alexandre Lision68d8f2e2014-07-30 17:42:40 -04007SRC=sflphone-android
Alexandre Lisionec1f3ee2014-08-04 19:12:42 -04008export SFLPHONE_SRC=$(PWD)/sflphone
9LIBSFLPHONEJNI_H=sflphone/daemon/src/sflphone.h
Alexandre Lision864f9b82014-08-01 14:26:45 -040010LIBSFLPHONEJNI=$(SRC)/obj/local/$(ARCH)/libsflphone.so
Alexandre Lisionec1f3ee2014-08-04 19:12:42 -040011
Tristan Matthews9c450ae2014-08-07 12:29:58 -040012JAVA_SOURCES=$(shell find $(SRC)/src/org/sflphone/ -type f -name "*.java")
Alexandre Lisionec1f3ee2014-08-04 19:12:42 -040013JNI_SOURCES=$(SRC)/jni/*.cpp $(SRC)/jni/*.h
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040014
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040015ifneq ($(V),)
16ANT_OPTS += -v
17VERBOSE =
18GEN =
19else
20VERBOSE = @
21GEN = @echo "Generating" $@;
22endif
23
24ifeq ($(RELEASE),1)
25ANT_TARGET = release
Alexandre Lision7d400dc2014-07-31 17:51:44 -040026SFLPHONE_APK=$(SRC)/bin/SFLphone-release-unsigned.apk
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040027NDK_DEBUG=0
28else
29ANT_TARGET = debug
Alexandre Lision7d400dc2014-07-31 17:51:44 -040030SFLPHONE_APK=$(SRC)/bin/SFLphone-debug.apk
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040031NDK_DEBUG=1
32endif
33
Alexandre Lision864f9b82014-08-01 14:26:45 -040034$(SFLPHONE_APK): $(LIBSFLPHONEJNI) $(JAVA_SOURCES)
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040035 @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 Lision43b9aeb2014-07-15 14:21:19 -040041 $(VERBOSE)cd $(SRC) && ant $(ANT_OPTS) $(ANT_TARGET)
42
Alexandre Lision864f9b82014-08-01 14:26:45 -040043$(LIBSFLPHONEJNI): $(JNI_SOURCES) $(LIBSFLPHONEJNI_H)
Alexandre Lision7d400dc2014-07-31 17:51:44 -040044 @if [ -z "$(SFLPHONE_BUILD_DIR)" ]; then echo "SFLPHONE_BUILD_DIR not defined" ; exit 1; fi
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040045 @if [ -z "$(ANDROID_NDK)" ]; then echo "ANDROID_NDK not defined" ; exit 1; fi
46 @echo
Alexandre Lision864f9b82014-08-01 14:26:45 -040047 @echo "=== Building libsflphonejni ==="
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040048 @echo
Alexandre Lision449ca842014-08-05 11:22:50 -040049 $(VERBOSE)if [ -z "$(SFLPHONE_SRC_DIR)" ] ; then SFLPHONE_SRC_DIR=./sflphone; fi ; \
Alexandre Lision7d400dc2014-07-31 17:51:44 -040050 if [ -z "$(SFLPHONE_CONTRIB)" ] ; then SFLPHONE_CONTRIB="$$SFLPHONE_SRC_DIR/contrib/$(TARGET_TUPLE)"; fi ; \
Alexandre Lision7d400dc2014-07-31 17:51:44 -040051 if [ `echo "$(SFLPHONE_BUILD_DIR)" | head -c 1` != "/" ] ; then \
Alexandre Lision7d400dc2014-07-31 17:51:44 -040052 SFLPHONE_BUILD_DIR="../$(SFLPHONE_BUILD_DIR)"; \
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040053 fi ; \
Alexandre Lision7d400dc2014-07-31 17:51:44 -040054 [ `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 Lision43b9aeb2014-07-15 14:21:19 -040056 $(ANDROID_NDK)/ndk-build -C $(SRC) \
Alexandre Lision7d400dc2014-07-31 17:51:44 -040057 SFLPHONE_SRC_DIR="$$SFLPHONE_SRC_DIR" \
58 SFLPHONE_CONTRIB="$$SFLPHONE_CONTRIB" \
59 SFLPHONE_BUILD_DIR="$$SFLPHONE_BUILD_DIR" \
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040060 NDK_DEBUG=$(NDK_DEBUG) \
Alexandre Lision7d400dc2014-07-31 17:51:44 -040061 TARGET_CFLAGS="$$SFLPHONE_EXTRA_CFLAGS"
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040062
63apkclean:
Alexandre Lision7d400dc2014-07-31 17:51:44 -040064 rm -f $(SFLPHONE_APK)
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040065
66lightclean:
Alexandre Lision9abb7c92014-08-04 19:22:55 -040067 cd $(SRC) && rm -rf libs/armeabi-v7a libs/x86 libs/mips obj bin $(SFLPHONE_APK)
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040068
69clean: lightclean
70 rm -rf $(SRC)/gen java-libs/*/gen java-libs/*/bin .sdk vlc-sdk/ vlc-sdk.7z
71
72jniclean: lightclean
Alexandre Lisionec1f3ee2014-08-04 19:12:42 -040073 rm -f $(LIBSFLPHONEJNI)
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040074
75distclean: clean jniclean
76
Alexandre Lision7d400dc2014-07-31 17:51:44 -040077install: $(SFLPHONE_APK)
78 @echo "=== Installing SFLphone on device ==="
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040079 adb wait-for-device
Alexandre Lision7d400dc2014-07-31 17:51:44 -040080 adb install -r $(SFLPHONE_APK)
Tristan Matthews5bb1b5d2013-07-18 14:32:58 -040081
Tristan Matthewsfdd94e52013-07-19 16:44:44 -040082uninstall:
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040083 adb wait-for-device
Alexandre Lision7d400dc2014-07-31 17:51:44 -040084 adb uninstall org.sflphone
Tristan Matthewsfdd94e52013-07-19 16:44:44 -040085
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040086run:
Alexandre Lision7d400dc2014-07-31 17:51:44 -040087 @echo "=== Running SFLphone on device ==="
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040088 adb wait-for-device
Alexandre Lision7d400dc2014-07-31 17:51:44 -040089 adb shell am start -n org.sflphone/org.sflphone.client.HomeActivity
Alexandre Lision43b9aeb2014-07-15 14:21:19 -040090
91build-and-run: install run
92
93apkclean-run: apkclean build-and-run
94 adb logcat -c
95
96distclean-run: distclean build-and-run
97 adb logcat -c
98
99vlc-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