[PATCH] add Android support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Currently, it is not possible to compile git for Android as the C library (Bionic)
is neither providing getpass nor pw_gecos in struct passwd. Therefore,
NO_GETPASS and NO_PW_GECOS are defined in Makefile. As code for Android can only
be cross-compiled, ANDROID is defined.

Signed-off-by: Rafael Gieschke <rafael@xxxxxxxxxxx>
---
 Makefile  |   27 +++++++++++++++++++++++++++
 connect.c |    4 ++++
 ident.c   |    7 ++++++-
 3 files changed, 37 insertions(+), 1 deletions(-)

diff --git a/Makefile b/Makefile
index c4db5af..e010efb 100644
--- a/Makefile
+++ b/Makefile
@@ -71,6 +71,11 @@ all::
 #
 # Define NO_STRTOK_R if you don't have strtok_r in the C library.
 #
+# Define NO_GETPASS if you don't have getpass in the C library.
+#
+# Define NO_PW_GECOS if you don't have pw_gecos in struct passwd
+# in the C library.
+#
 # Define NO_FNMATCH if you don't have fnmatch in the C library.
 #
 # Define NO_FNMATCH_CASEFOLD if your fnmatch function doesn't have the
@@ -248,6 +253,8 @@ all::
 # dependency rules.
 #
 # Define NATIVE_CRLF if your platform uses CRLF for line endings.
+#
+# Define ANDROID if you are cross-compiling for Android.
 
 GIT-VERSION-FILE: FORCE
 	@$(SHELL_PATH) ./GIT-VERSION-GEN
@@ -789,6 +796,20 @@ ifeq ($(uname_S),OSF1)
 	NO_STRTOULL = YesPlease
 	NO_NSEC = YesPlease
 endif
+ifdef ANDROID
+	uname_S := Linux
+	NO_GETPASS = YesPlease
+	NO_PW_GECOS = YesPlease
+	NO_NSEC = YesPlease
+	NO_MKDTEMP = YesPlease
+	NO_PTHREADS = YesPlease
+	NO_PERL = YesPlease
+	NO_OPENSSL = YesPlease
+	NO_CURL = YesPlease
+	NO_EXPAT = YesPlease
+	NO_TCLTK = YesPlease
+	NO_ICONV = YesPlease
+endif
 ifeq ($(uname_S),Linux)
 	NO_STRLCPY = YesPlease
 	NO_MKSTEMPS = YesPlease
@@ -1404,6 +1425,12 @@ ifdef NO_STRTOK_R
 	COMPAT_CFLAGS += -DNO_STRTOK_R
 	COMPAT_OBJS += compat/strtok_r.o
 endif
+ifdef NO_GETPASS
+	COMPAT_CFLAGS += -DNO_GETPASS
+endif
+ifdef NO_PW_GECOS
+	COMPAT_CFLAGS += -DNO_PW_GECOS
+endif
 ifdef NO_FNMATCH
 	COMPAT_CFLAGS += -Icompat/fnmatch
 	COMPAT_CFLAGS += -DNO_FNMATCH
diff --git a/connect.c b/connect.c
index 57dc20c..15b285e 100644
--- a/connect.c
+++ b/connect.c
@@ -632,7 +632,11 @@ char *git_getpass(const char *prompt)
 	if (!askpass)
 		askpass = getenv("SSH_ASKPASS");
 	if (!askpass || !(*askpass)) {
+		#ifndef NO_GETPASS
 		char *result = getpass(prompt);
+		#else
+		char *result = NULL;
+		#endif
 		if (!result)
 			die_errno("Could not read password");
 		return result;
diff --git a/ident.c b/ident.c
index 1c4adb0..76fa786 100644
--- a/ident.c
+++ b/ident.c
@@ -20,7 +20,12 @@ static void copy_gecos(const struct passwd *w, char *name, size_t sz)
 	 * with commas.  Also & stands for capitalized form of the login name.
 	 */
 
-	for (len = 0, dst = name, src = w->pw_gecos; len < sz; src++) {
+	#ifndef NO_PW_GECOS
+	src = w->pw_gecos;
+	#else
+	src = "&";
+	#endif
+	for (len = 0, dst = name; len < sz; src++) {
 		int ch = *src;
 		if (ch != '&') {
 			*dst++ = ch;
-- 
1.7.4

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]