[toa] Add a support of building for the Android. 98/82198/3
authorSergey Sizonov <s.sizonov@samsung.com>
Mon, 1 Aug 2016 13:15:06 +0000 (16:15 +0300)
committerSergey Sizonov <s.sizonov@samsung.com>
Tue, 2 Aug 2016 11:48:58 +0000 (14:48 +0300)
Look to how_to_deploy.txt file to know how to build.

Change-Id: I2a2257eea92f4bfc455f176cb47375b05bf0554d
Signed-off-by: Sergey Sizonov <s.sizonov@samsung.com>
android/how_to_deploy.txt [new file with mode: 0755]
android/libtdm-1.3.0.spec [new file with mode: 0644]
configure.ac
src/Makefile.am
src/tdm_thread.c

diff --git a/android/how_to_deploy.txt b/android/how_to_deploy.txt
new file mode 100755 (executable)
index 0000000..23e5b22
--- /dev/null
@@ -0,0 +1,58 @@
+This guide for the development under the Android.
+
+> - host promt
+@ - chroot system promt
+$ - target promt
+
+- All commans are executed on the host unless otherwise specified.
+- Some files you may find on ownCloud -- Public/ToA .
+
+1. Create bootstrap:  https://debian.pro/440 (Russian)
+    > cd <directory you wanna use as your new system root directory.>
+    > sudo debootstrap trusty . http://mirror.yandex.ru/ubuntu
+
+2. Make some preparations to your new system:
+    - mount host's proc fs to your new system /proc
+    (you may make this mount permanently by adding an entry to /etc/fstab on the host)
+
+3. Login in created system:
+   > sudo chroot <directory you've placed bootstrap in>
+   - http://la2ha.ru/dev-seo-diy/unix/setting_locale_failed (Russian)
+
+4. Create an user you will use under the devopment (on your new system).
+5. Fix the problem with sudoers file (on your new system) -- http://unixforum.org/index.php?showtopic=135020 . (Russian)
+6. Install make, autoconf, libtool, texinfo and pkg-config packages (on your new system).
+7. Install android-tools-adb packages(amd64) (on your new system) -- http://packages.ubuntu.com/ru/trusty/devel/android-tools-adb .
+8. Download Android ndk -- https://developer.android.com/ndk/downloads/index.html .
+
+9. Extract a standalone android toolchain: -- https://developer.android.com/ndk/guides/standalone_toolchain.html
+   > cd <directory you've unpacked Android ndk into>
+   > build/tools/make-standalone-toolchain.sh --toolchain=arm-linux-androideabi-4.9 --platform=android-22 --install-dir=<directory on your chroot system, this how_to considers you've chosen ~/bin/android_toolchain>
+
+10. Add a path to the android toolchain to your system PATH env variable (on your new system):
+  @ echo "PATH=${HOME}/bin/android_toolchain/bin:${PATH}" >> ~/.bashrc
+
+11. Add a path to the ~/bin to your system PATH env variable (on your new system):
+  @ echo "PATH=${HOME}/bin/:${PATH}" >> ~/.bashrc
+
+12. Prepare rpm (on your new system):
+  @ sudo apt-get install rpm
+  @ mkdir -p ~/redhat/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
+  @ echo "%_topdir /home/$USER/redhat" >> ~/.rpmmacros
+
+Now you have the prepared environment to build for the Android.
+
+What to do next is your choise...
+
+Suggested steps are:
+ - download a sources for a project you want to build for the Android.
+ - create .spec file:
+   - set a prefix variable to /usr/local, if your project use an autotools,
+     to avoid a cluttering your chroot's root [by default prefix is /usr/local].
+ - run rpmbuild --target armv7l -bb <.spec file> .
+   - if you want to install the build results to a target add an option '--noclean' (you will be able
+     to copy the results to a target easy).
+ - install rpm packages to your chroot system: sudo rpm -ivh --nodeps --ignorearch <.rpm to install> .
+   - a next build will be able to use a resulst of the current build.
+ - copy the build results to a target: adb push ~/redhat/BUILDROOT/<name of project.arm> <wherever you want> .
+   - do not forget to remove an unnecessary files: *.la, *.h, *.pc and so on.
diff --git a/android/libtdm-1.3.0.spec b/android/libtdm-1.3.0.spec
new file mode 100644 (file)
index 0000000..ad6dada
--- /dev/null
@@ -0,0 +1,38 @@
+Name:           libtdm
+Version:        1.3.0
+Release:        0
+Summary:        User Library of Tizen Display Manager
+Group:          Development/Libraries
+License:        MIT
+Source0:        %{name}-%{version}.tar.gz
+
+%description
+Common user library of Tizen Display Manager : libtdm front-end library
+
+%prep
+# our %{name}-%{version}.tar.gz archive hasn't top-level directory,
+# so we create it
+%setup -q -c %{name}-%{version}
+
+%build
+PKG_CONFIG_PATH=/usr/local/lib/pkgconfig \
+./autogen.sh --build=x86_64-unknown-linux-gnu \
+            --host=arm-linux-androideabi \
+            --disable-static \
+            --enable-android-support \
+            CFLAGS="${CFLAGS} -Wall" \
+            LDFLAGS="${LDFLAGS} -Wl,--hash-style=both -Wl,--as-needed"
+
+make %{?_smp_mflags}
+
+%install
+rm -rf %{buildroot}
+
+%make_install
+
+%clean
+rm -rf %{buildroot}
+
+%files
+%defattr(-,root,root,-)
+/usr/local/*
index c2bb484..95e229e 100644 (file)
@@ -30,6 +30,16 @@ LT_INIT([disable-static])
 # Enable quiet compiles on automake 1.11.
 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
 
+AC_ARG_ENABLE([android-support], AS_HELP_STRING([--enable-android-support], [to build for the Android]),,
+             enable_android_support=no)
+
+AM_CONDITIONAL([ANDROID_SUPPORT], [test "x$enable_android_support" != "xno"])
+
+if test "x$enable_android_support" != "xno"; then
+   AC_MSG_WARN("Library is being built under the Android.")
+   AC_DEFINE(HAVE_ANDROID_SUPPORT, 1, [If the library is being built under the Android.])
+fi
+
 AC_PATH_PROG([wayland_scanner], [wayland-scanner])
 if test x$wayland_scanner = x; then
    AC_MSG_ERROR([wayland-scanner is needed to compile])
index 2af9638..3cae03b 100644 (file)
@@ -1,7 +1,15 @@
 libtdm_la_LTLIBRARIES = libtdm.la
 libtdm_ladir = $(libdir)
 libtdm_la_LDFLAGS = -version-number 1:0:0 -no-undefined
-libtdm_la_LIBADD = $(TDM_LIBS) -ldl -lpthread ../common/libtdm-common.la
+libtdm_la_LIBADD = $(TDM_LIBS) -ldl ../common/libtdm-common.la
+
+# the Android's libc (bionic) has the built-in support for pthread
+if ANDROID_SUPPORT
+libtdm_la_LIBADD += -lm
+else
+libtdm_la_LIBADD += -lpthread
+endif
+
 libtdm_la_CFLAGS = \
        $(CFLAGS) \
        $(WARN_CFLAGS) \
index 03ce03a..178d7f8 100644 (file)
@@ -179,9 +179,18 @@ tdm_thread_deinit(tdm_private_loop *private_loop)
 
        if (!private_loop->private_thread)
                return;
-
+       
+       /* TODO: the Android's libc (bionic) doesn't implement full POSIX threads
+        * functionality, in particular pthread_cancel, so we have to figure out
+        * how to stop this thread by the another means or to implement pthread_cancel by self.
+        * Now this function is called ONLY before a program termination, so we don't care
+        * about anything :-) */
+#ifndef HAVE_ANDROID_SUPPORT
        pthread_cancel(private_loop->private_thread->event_thread);
-
+#else
+       return;
+#endif
+       
        private_display = private_loop->dpy;
 
        /* before falling into the block of pthread_join, we have to unlock the mutex