From efc07debaf60f5aa81bef78dc3219962ba88c3b8 Mon Sep 17 00:00:00 2001 From: Brandon Casey Date: Wed, 27 May 2009 21:17:05 -0500 Subject: Makefile: use /usr/ucb/install on SunOS platforms rather than ginstall We can avoid a GNU dependency by using /usr/ucb/install. Signed-off-by: Brandon Casey Signed-off-by: Junio C Hamano diff --git a/Makefile b/Makefile index eaae45d..ba78077 100644 --- a/Makefile +++ b/Makefile @@ -715,7 +715,7 @@ ifeq ($(uname_S),SunOS) NO_C99_FORMAT = YesPlease NO_STRTOUMAX = YesPlease endif - INSTALL = ginstall + INSTALL = /usr/ucb/install TAR = gtar BASIC_CFLAGS += -D__EXTENSIONS__ endif -- cgit v0.10.2-6-g49f6 From 70cf991093d4ab8854de0090aca9cf8d10ebd8f8 Mon Sep 17 00:00:00 2001 From: Brandon Casey Date: Fri, 5 Jun 2009 18:36:10 -0500 Subject: Makefile: add NEEDS_RESOLV to optionally add -lresolv to compile arguments This library is required on Solaris when compiling with NO_IPV6 since hstrerror resides in libresolv. Additionally, Solaris 7 will need it, since inet_ntop and inet_pton reside there too. Signed-off-by: Brandon Casey Signed-off-by: Junio C Hamano diff --git a/Makefile b/Makefile index ba78077..d36e92c 100644 --- a/Makefile +++ b/Makefile @@ -91,6 +91,10 @@ all:: # Define NEEDS_SOCKET if linking with libc is not enough (SunOS, # Patrick Mauritz). # +# Define NEEDS_RESOLV if linking with -lnsl and/or -lsocket is not enough. +# Notably on Solaris hstrerror resides in libresolv and on Solaris 7 +# inet_ntop and inet_pton additionally reside there. +# # Define NO_MMAP if you want to avoid mmap. # # Define NO_PTHREADS if you do not have or do not want to use Pthreads. @@ -700,7 +704,6 @@ ifeq ($(uname_S),SunOS) SHELL_PATH = /bin/bash NO_STRCASESTR = YesPlease NO_MEMMEM = YesPlease - NO_HSTRERROR = YesPlease NO_MKDTEMP = YesPlease OLD_ICONV = UnfortunatelyYes ifeq ($(uname_R),5.8) @@ -715,6 +718,9 @@ ifeq ($(uname_S),SunOS) NO_C99_FORMAT = YesPlease NO_STRTOUMAX = YesPlease endif + ifdef NO_IPV6 + NEEDS_RESOLV = YesPlease + endif INSTALL = /usr/ucb/install TAR = gtar BASIC_CFLAGS += -D__EXTENSIONS__ @@ -956,6 +962,9 @@ endif ifdef NEEDS_NSL EXTLIBS += -lnsl endif +ifdef NEEDS_RESOLV + EXTLIBS += -lresolv +endif ifdef NO_D_TYPE_IN_DIRENT BASIC_CFLAGS += -DNO_D_TYPE_IN_DIRENT endif -- cgit v0.10.2-6-g49f6 From 309dbc82e39ea0b402ea06579fd9246df5cf6a01 Mon Sep 17 00:00:00 2001 From: Brandon Casey Date: Fri, 5 Jun 2009 18:36:12 -0500 Subject: On Solaris choose the OLD_ICONV iconv() declaration based on the UNIX spec OLD_ICONV is only necessary on Solaris until UNIX03. This is indicated by the private macro _XPG6 which is set in /usr/include/sys/feature_tests.h. Signed-off-by: Brandon Casey Signed-off-by: Junio C Hamano diff --git a/Makefile b/Makefile index d36e92c..d8f9c22 100644 --- a/Makefile +++ b/Makefile @@ -705,7 +705,7 @@ ifeq ($(uname_S),SunOS) NO_STRCASESTR = YesPlease NO_MEMMEM = YesPlease NO_MKDTEMP = YesPlease - OLD_ICONV = UnfortunatelyYes + NO_MKSTEMPS = YesPlease ifeq ($(uname_R),5.8) NO_UNSETENV = YesPlease NO_SETENV = YesPlease diff --git a/utf8.c b/utf8.c index ddfdc5e..db706ac 100644 --- a/utf8.c +++ b/utf8.c @@ -354,7 +354,7 @@ int is_encoding_utf8(const char *name) * with iconv. If the conversion fails, returns NULL. */ #ifndef NO_ICONV -#ifdef OLD_ICONV +#if defined(OLD_ICONV) || (defined(__sun__) && !defined(_XPG6)) typedef const char * iconv_ibp; #else typedef char * iconv_ibp; -- cgit v0.10.2-6-g49f6 From 4cb18a49dfd37f9ecabad603d845382863513378 Mon Sep 17 00:00:00 2001 From: Brandon Casey Date: Fri, 5 Jun 2009 18:36:13 -0500 Subject: git-compat-util.h: tweak the way _XOPEN_SOURCE is set on Solaris On Solaris, when _XOPEN_EXTENDED is set, its header file forces the programs to be XPG4v2, defeating any _XOPEN_SOURCE setting to say we are XPG5 or XPG6. Also on Solaris, XPG6 programs must be compiled with a c99 compiler, while non XPG6 programs must be compiled with a pre-c99 compiler. So when compiling on Solaris, always refrain from setting _XOPEN_EXTENDED, and then set _XOPEN_SOURCE to 600 or 500 based on whether a c99 compiler is being used or not. Signed-off-by: Brandon Casey Signed-off-by: Junio C Hamano diff --git a/git-compat-util.h b/git-compat-util.h index c7cf2d5..71197d9 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -39,7 +39,20 @@ /* Approximation of the length of the decimal representation of this type. */ #define decimal_length(x) ((int)(sizeof(x) * 2.56 + 0.5) + 1) -#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__USLC__) && !defined(_M_UNIX) +#if defined(__sun__) + /* + * On Solaris, when _XOPEN_EXTENDED is set, its header file + * forces the programs to be XPG4v2, defeating any _XOPEN_SOURCE + * setting to say we are XPG5 or XPG6. Also on Solaris, + * XPG6 programs must be compiled with a c99 compiler, while + * non XPG6 programs must be compiled with a pre-c99 compiler. + */ +# if __STDC_VERSION__ - 0 >= 199901L +# define _XOPEN_SOURCE 600 +# else +# define _XOPEN_SOURCE 500 +# endif +#elif !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__USLC__) && !defined(_M_UNIX) #define _XOPEN_SOURCE 600 /* glibc2 and AIX 5.3L need 500, OpenBSD needs 600 for S_ISLNK() */ #define _XOPEN_SOURCE_EXTENDED 1 /* AIX 5.3L needs this */ #endif -- cgit v0.10.2-6-g49f6 From b213019c00740289997f12e5f53b1baae588ac8a Mon Sep 17 00:00:00 2001 From: Brandon Casey Date: Fri, 5 Jun 2009 18:36:14 -0500 Subject: Makefile: define __sun__ on SunOS The SUNWspro compiler does not define __sun__ (like GCC does). A check of this macro was recently added to detect compilation on SunOS and to modify the handling of the NO_ICONV and _XOPEN_SOURCE feature macros. Signed-off-by: Brandon Casey Signed-off-by: Junio C Hamano diff --git a/Makefile b/Makefile index d8f9c22..4f838b2 100644 --- a/Makefile +++ b/Makefile @@ -723,7 +723,7 @@ ifeq ($(uname_S),SunOS) endif INSTALL = /usr/ucb/install TAR = gtar - BASIC_CFLAGS += -D__EXTENSIONS__ + BASIC_CFLAGS += -D__EXTENSIONS__ -D__sun__ endif ifeq ($(uname_O),Cygwin) NO_D_TYPE_IN_DIRENT = YesPlease -- cgit v0.10.2-6-g49f6 From 0e0aea5a47b675ab2dca9c77180b8fe9bc6bdeec Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 5 Jun 2009 18:36:15 -0500 Subject: Makefile: introduce SANE_TOOL_PATH for prepending required elements to PATH Some platforms (like SunOS and family) have kept their common binaries at some historical moment in time, and introduced new binaries with modern features in a special location like /usr/xpg4/bin or /usr/ucb. Some of the features provided by these modern binaries are expected and required by git. If the featureful binaries are not in the users path, then git could end up using the less featureful binary and fail. So provide a mechanism to prepend elements to the users PATH at runtime so the modern binaries will be found. Signed-off-by: Brandon Casey Signed-off-by: Junio C Hamano diff --git a/Makefile b/Makefile index 4f838b2..50002ed 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,11 @@ all:: # Define V=1 to have a more verbose compile. # +# Define SHELL_PATH to a POSIX shell if your /bin/sh is broken. +# +# Define SANE_TOOL_PATH to a colon-separated list of paths to prepend +# to PATH if your tools in /usr/bin are broken. +# # Define SNPRINTF_RETURNS_BOGUS if your are on a system which snprintf() # or vsnprintf() return -1 instead of number of characters which would # have been written to the final string if enough space had been available. @@ -702,6 +707,7 @@ ifeq ($(uname_S),SunOS) NEEDS_SOCKET = YesPlease NEEDS_NSL = YesPlease SHELL_PATH = /bin/bash + SANE_TOOL_PATH = /usr/xpg6/bin:/usr/xpg4/bin NO_STRCASESTR = YesPlease NO_MEMMEM = YesPlease NO_MKDTEMP = YesPlease @@ -864,6 +870,13 @@ endif -include config.mak.autogen -include config.mak +ifdef SANE_TOOL_PATH +BROKEN_PATH_FIX = s|^. @@PATH@@|PATH=$(SANE_TOOL_PATH)| +PATH := $(SANE_TOOL_PATH):${PATH} +else +BROKEN_PATH_FIX = d +endif + ifeq ($(uname_S),Darwin) ifndef NO_FINK ifeq ($(shell test -d /sw/lib && echo y),y) @@ -1265,6 +1278,7 @@ $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \ -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \ -e 's/@@NO_CURL@@/$(NO_CURL)/g' \ + -e '/^# @@PATH@@/$(BROKEN_PATH_FIX)' \ $@.sh >$@+ && \ chmod +x $@+ && \ mv $@+ $@ diff --git a/git-sh-setup.sh b/git-sh-setup.sh index 8382339..7802581 100755 --- a/git-sh-setup.sh +++ b/git-sh-setup.sh @@ -11,6 +11,8 @@ # exporting it. unset CDPATH +# @@PATH@@:$PATH + die() { echo >&2 "$@" exit 1 -- cgit v0.10.2-6-g49f6 From a7a24ee7e0721db5427e9a5f6906e8531510d607 Mon Sep 17 00:00:00 2001 From: Brandon Casey Date: Fri, 5 Jun 2009 18:36:16 -0500 Subject: Makefile: add section for SunOS 5.7 Signed-off-by: Brandon Casey Signed-off-by: Junio C Hamano diff --git a/Makefile b/Makefile index 50002ed..3890a0e 100644 --- a/Makefile +++ b/Makefile @@ -712,6 +712,16 @@ ifeq ($(uname_S),SunOS) NO_MEMMEM = YesPlease NO_MKDTEMP = YesPlease NO_MKSTEMPS = YesPlease + ifeq ($(uname_R),5.7) + NEEDS_RESOLV = YesPlease + NO_IPV6 = YesPlease + NO_SOCKADDR_STORAGE = YesPlease + NO_UNSETENV = YesPlease + NO_SETENV = YesPlease + NO_STRLCPY = YesPlease + NO_C99_FORMAT = YesPlease + NO_STRTOUMAX = YesPlease + endif ifeq ($(uname_R),5.8) NO_UNSETENV = YesPlease NO_SETENV = YesPlease -- cgit v0.10.2-6-g49f6 From 203ee91fd273ae424deeeee5ddcc7947a4c76ccd Mon Sep 17 00:00:00 2001 From: Brandon Casey Date: Mon, 8 Jun 2009 18:53:48 -0500 Subject: git-compat-util.h: avoid using c99 flex array feature with Sun compiler 5.8 The Sun c99 compiler as recent as version 5.8 Patch 121016-06 2007/08/01 produces an error when compiling diff-delta.c. This source file #includes the delta.h header file which pre-declares a struct which is later defined to contain a flex array member. The Sun c99 compiler fails to compile diff-delta.c and gives the following error: "diff-delta.c", line 314: identifier redeclared: create_delta current : function(pointer to const struct delta_index {unsigned long memsize, pointer to const void src_buf, unsigned long src_size, unsigned int hash_mask, array[-1] of pointer to struct index_entry {..} hash}, pointer to const void, unsigned long, pointer to unsigned long, unsigned long) returning pointer to void previous: function(pointer to const struct delta_index {unsigned long memsize, pointer to const void src_buf, unsigned long src_size, unsigned int hash_mask, array[-1] of pointer to struct index_entry {..} hash}, pointer to const void, unsigned long, pointer to unsigned long, unsigned long) returning pointer to void : "delta.h", line 44 c99: acomp failed for diff-delta.c So, avoid using this c99 feature when compiling with the Sun c compilers version 5.8 and older (the most recent version tested). Signed-off-by: Brandon Casey Signed-off-by: Junio C Hamano diff --git a/git-compat-util.h b/git-compat-util.h index 71197d9..48d99fa 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -7,7 +7,7 @@ /* * See if our compiler is known to support flexible array members. */ -#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) +#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && (!defined(__SUNPRO_C) || (__SUNPRO_C > 0x580)) # define FLEX_ARRAY /* empty */ #elif defined(__GNUC__) # if (__GNUC__ >= 3) -- cgit v0.10.2-6-g49f6 From 61dbb3c4415169194d9351cc4b68dd88788a93c5 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 8 Jun 2009 09:41:49 -0700 Subject: Makefile: insert SANE_TOOL_PATH to PATH before /bin or /usr/bin In an earlier patch, we introduced SANE_TOOL_PATH that is prepended to user's PATH. This had an unintended consequence of overriding user's private binary directory that typically comes earlier in the PATH to holds even saner commands than whatever comes with the system. For example, a user may have ~/bin that is early in the path and contains a shell script "vi" that launches system's /bin/vi with specific options. Prepending SANE_TOOL_PATH to the PATH that happens to have "vi" in it defeats such customization. This fixes the issue by inserting SANE_TOOL_PATH just before /bin or /usr/bin appears on the PATH. Signed-off-by: Junio C Hamano diff --git a/Makefile b/Makefile index 3890a0e..1197b2f 100644 --- a/Makefile +++ b/Makefile @@ -881,10 +881,11 @@ endif -include config.mak ifdef SANE_TOOL_PATH -BROKEN_PATH_FIX = s|^. @@PATH@@|PATH=$(SANE_TOOL_PATH)| +SANE_TOOL_PATH_SQ = $(subst ','\'',$(SANE_TOOL_PATH)) +BROKEN_PATH_FIX = 's|^\# @@BROKEN_PATH_FIX@@$$|git_broken_path_fix $(SANE_TOOL_PATH_SQ)|' PATH := $(SANE_TOOL_PATH):${PATH} else -BROKEN_PATH_FIX = d +BROKEN_PATH_FIX = '/^\# @@BROKEN_PATH_FIX@@$$/d' endif ifeq ($(uname_S),Darwin) @@ -1288,7 +1289,7 @@ $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \ -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \ -e 's/@@NO_CURL@@/$(NO_CURL)/g' \ - -e '/^# @@PATH@@/$(BROKEN_PATH_FIX)' \ + -e $(BROKEN_PATH_FIX) \ $@.sh >$@+ && \ chmod +x $@+ && \ mv $@+ $@ diff --git a/git-sh-setup.sh b/git-sh-setup.sh index 7802581..80acb7d 100755 --- a/git-sh-setup.sh +++ b/git-sh-setup.sh @@ -11,7 +11,33 @@ # exporting it. unset CDPATH -# @@PATH@@:$PATH +git_broken_path_fix () { + case ":$PATH:" in + *:$1:*) : ok ;; + *) + PATH=$( + SANE_TOOL_PATH="$1" + IFS=: path= sep= + set x $PATH + shift + for elem + do + case "$SANE_TOOL_PATH:$elem" in + (?*:/bin | ?*:/usr/bin) + path="$path$sep$SANE_TOOL_PATH" + sep=: + SANE_TOOL_PATH= + esac + path="$path$sep$elem" + sep=: + done + echo "$path" + ) + ;; + esac +} + +# @@BROKEN_PATH_FIX@@ die() { echo >&2 "$@" -- cgit v0.10.2-6-g49f6 From 8fccb009fa539080a6c4fb18204dfea0be434433 Mon Sep 17 00:00:00 2001 From: Ralf Wildenhues Date: Sun, 7 Jun 2009 07:40:29 +0200 Subject: configure: test whether -lresolv is needed Check if -lresolv is needed for hstrerror; set NEEDS_RESOLV accordingly, and substitute in config.mak.in. Signed-off-by: Ralf Wildenhues Signed-off-by: Junio C Hamano diff --git a/config.mak.in b/config.mak.in index 7cce0c1..d0cd155 100644 --- a/config.mak.in +++ b/config.mak.in @@ -32,6 +32,7 @@ NO_CURL=@NO_CURL@ NO_EXPAT=@NO_EXPAT@ NEEDS_LIBICONV=@NEEDS_LIBICONV@ NEEDS_SOCKET=@NEEDS_SOCKET@ +NEEDS_RESOLV=@NEEDS_RESOLV@ NO_SYS_SELECT_H=@NO_SYS_SELECT_H@ NO_D_INO_IN_DIRENT=@NO_D_INO_IN_DIRENT@ NO_D_TYPE_IN_DIRENT=@NO_D_TYPE_IN_DIRENT@ diff --git a/configure.ac b/configure.ac index 4e728bc..0a37af7 100644 --- a/configure.ac +++ b/configure.ac @@ -467,6 +467,15 @@ AC_CHECK_LIB([c], [socket], AC_SUBST(NEEDS_SOCKET) test -n "$NEEDS_SOCKET" && LIBS="$LIBS -lsocket" +# +# Define NEEDS_RESOLV if linking with -lnsl and/or -lsocket is not enough. +# Notably on Solaris hstrerror resides in libresolv and on Solaris 7 +# inet_ntop and inet_pton additionally reside there. +AC_CHECK_LIB([resolv], [hstrerror], +[NEEDS_RESOLV=], +[NEEDS_RESOLV=YesPlease]) +AC_SUBST(NEEDS_RESOLV) +test -n "$NEEDS_RESOLV" && LIBS="$LIBS -lresolv" ## Checks for header files. AC_MSG_NOTICE([CHECKS for header files]) -- cgit v0.10.2-6-g49f6