summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 0620b39)
raw | patch | inline | side by side (parent: 0620b39)
author | David Aguilar <davvid@gmail.com> | |
Sun, 31 May 2009 08:35:51 +0000 (01:35 -0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 1 Jun 2009 00:57:59 +0000 (17:57 -0700) |
Some systems such as Windows lack libgen.h so provide a
basename() implementation for cross-platform use.
This introduces the NO_LIBGEN_H construct to the Makefile
and autoconf scripts.
Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
basename() implementation for cross-platform use.
This introduces the NO_LIBGEN_H construct to the Makefile
and autoconf scripts.
Signed-off-by: David Aguilar <davvid@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Makefile | patch | blob | history | |
compat/basename.c | [new file with mode: 0644] | patch | blob |
config.mak.in | patch | blob | history | |
configure.ac | patch | blob | history | |
git-compat-util.h | patch | blob | history |
diff --git a/Makefile b/Makefile
index a70b5f0dde655c3bb4efbcecf0ffd4831d83906d..a59f10687bd158757422809ad20022d84ead9b9a 100644 (file)
--- a/Makefile
+++ b/Makefile
#
# Define NO_MKSTEMPS if you don't have mkstemps in the C library.
#
+# Define NO_LIBGEN_H if you don't have libgen.h.
+#
# Define NO_SYS_SELECT_H if you don't have sys/select.h.
#
# Define NO_SYMLINK_HEAD if you never want .git/HEAD to be a symbolic link.
NO_PREAD = YesPlease
NO_OPENSSL = YesPlease
NO_CURL = YesPlease
+ NO_LIBGEN_H = YesPlease
NO_SYMLINK_HEAD = YesPlease
NO_IPV6 = YesPlease
NO_SETENV = YesPlease
endif
endif
+ifdef NO_LIBGEN_H
+ COMPAT_CFLAGS += -DNO_LIBGEN_H
+ COMPAT_OBJS += compat/basename.o
+endif
+
ifdef NO_CURL
BASIC_CFLAGS += -DNO_CURL
else
diff --git a/compat/basename.c b/compat/basename.c
--- /dev/null
+++ b/compat/basename.c
@@ -0,0 +1,15 @@
+#include "../git-compat-util.h"
+
+/* Adapted from libiberty's basename.c. */
+char *gitbasename (char *path)
+{
+ const char *base;
+ /* Skip over the disk name in MSDOS pathnames. */
+ if (has_dos_drive_prefix(path))
+ path += 2;
+ for (base = path; *path; path++) {
+ if (is_dir_sep(*path))
+ base = path + 1;
+ }
+ return (char *)base;
+}
diff --git a/config.mak.in b/config.mak.in
index b6619af1b92c55b004721b531672680579bdb128..e8d96e88b92a2305e50eb1adcff7f9d0f3310996 100644 (file)
--- a/config.mak.in
+++ b/config.mak.in
NO_OPENSSL=@NO_OPENSSL@
NO_CURL=@NO_CURL@
NO_EXPAT=@NO_EXPAT@
+NO_LIBGEN_H=@NO_LIBGEN_H@
NEEDS_LIBICONV=@NEEDS_LIBICONV@
NEEDS_SOCKET=@NEEDS_SOCKET@
NO_SYS_SELECT_H=@NO_SYS_SELECT_H@
diff --git a/configure.ac b/configure.ac
index 953da071314a371e245f50c292c27ff3bf2377ae..108a97fa8bdca8b6d685f2c5b1057df3d7af40a2 100644 (file)
--- a/configure.ac
+++ b/configure.ac
## (in default C library and libraries checked by AC_CHECK_LIB)
AC_MSG_NOTICE([CHECKS for library functions])
#
+# Define NO_LIBGEN_H if you don't have libgen.h.
+AC_CHECK_HEADER([libgen.h],
+[NO_LIBGEN_H=],
+[NO_LIBGEN_H=YesPlease])
+AC_SUBST(NO_LIBGEN_H)
+#
# Define NO_STRCASESTR if you don't have strcasestr.
GIT_CHECK_FUNC(strcasestr,
[NO_STRCASESTR=],
diff --git a/git-compat-util.h b/git-compat-util.h
index f7217ad4309b42f65c3f4beae4f8d0c5b501e59d..71445c6aac392c2ca43edc4e6b16780f0bf75e2b 100644 (file)
--- a/git-compat-util.h
+++ b/git-compat-util.h
#include "compat/mingw.h"
#endif /* __MINGW32__ */
+#ifndef NO_LIBGEN_H
+#include <libgen.h>
+#else
+#define basename gitbasename
+extern char *gitbasename(char *);
+#endif
+
#ifndef NO_ICONV
#include <iconv.h>
#endif