To build rsync for Android you’ll need to have the Android NDK installed already.
Then clone the rsync for android source (e.g. from CyanogenMod LineageOS) …
1 2 3 4 | git clone https://github.com/LineageOS/android_external_rsync.git cd android_external_rsync # checkout the most recent branch git checkout cm-14.1 |
… create the missing
jni/Application.mk
build file (e.g. from this Gist) and adapt it to your case …
… and start the build with
1 | export NDK_PROJECT_PATH=<code>pwd</code> ndk-build -d rsync |
You’ll find your self-build rsync in
obj/local/*/rsync
. ?
Update 2017-10-06:
- Updated sources from CyanogenMod to LineageOS.
- Added links to Gist and Andoid NDK docs
- Updated steps to work with up-to-date setups
If you get something like the following warnings and errors …
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | [...] ./flist.c:454:16: warning: implicit declaration of function 'major' is invalid in C99 [-Wimplicit-function-declaration] if ((uint32)major(rdev) == rdev_major) ^ ./flist.c:458:41: warning: implicit declaration of function 'minor' is invalid in C99 [-Wimplicit-function-declaration] if (protocol_version < 30 && (uint32)minor(rdev) <= 0xFFu) ^ ./flist.c:467:11: warning: implicit declaration of function 'makedev' is invalid in C99 [-Wimplicit-function-declaration] rdev = MAKEDEV(major(rdev), 0); ^ ./rsync.h:446:36: note: expanded from macro 'MAKEDEV' #define MAKEDEV(devmajor,devminor) makedev(devmajor,devminor) ^ 3 warnings generated. [...] ./flist.c:473: error: undefined reference to 'makedev' ./flist.c:454: error: undefined reference to 'major' ./flist.c:457: error: undefined reference to 'major' ./flist.c:458: error: undefined reference to 'minor' ./flist.c:467: error: undefined reference to 'major' ./flist.c:467: error: undefined reference to 'makedev' ./flist.c:617: error: undefined reference to 'major' ./flist.c:619: error: undefined reference to 'minor' ./flist.c:621: error: undefined reference to 'minor' ./flist.c:788: error: undefined reference to 'makedev' ./flist.c:869: error: undefined reference to 'makedev' ./flist.c:1027: error: undefined reference to 'minor' clang++: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [obj/local/armeabi-v7a/rsync] Error 1 |
… you probably need to update
config.h
and change
/* #undef MAJOR_IN_SYSMACROS */
to
#define MAJOR_IN_SYSMACROS 1
.