Merge branch 'bc/solaris'
authorJunio C Hamano <gitster@pobox.com>
Sat, 13 Jun 2009 19:48:34 +0000 (12:48 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sat, 13 Jun 2009 19:48:34 +0000 (12:48 -0700)
* bc/solaris:
configure: test whether -lresolv is needed
Makefile: insert SANE_TOOL_PATH to PATH before /bin or /usr/bin
git-compat-util.h: avoid using c99 flex array feature with Sun compiler 5.8
Makefile: add section for SunOS 5.7
Makefile: introduce SANE_TOOL_PATH for prepending required elements to PATH
Makefile: define __sun__ on SunOS
git-compat-util.h: tweak the way _XOPEN_SOURCE is set on Solaris
On Solaris choose the OLD_ICONV iconv() declaration based on the UNIX spec
Makefile: add NEEDS_RESOLV to optionally add -lresolv to compile arguments
Makefile: use /usr/ucb/install on SunOS platforms rather than ginstall

Conflicts:
Makefile

1  2 
Makefile
config.mak.in
configure.ac
git-compat-util.h
diff --combined Makefile
index 04bf8b1cebd15e115a930a4a49f88619843cf263,1197b2fd4dcf5eb79f646b7486c45120440670e6..735ab079c07b73964b37dfc6c5ac4ee6d1ebcf57
+++ b/Makefile
@@@ -3,6 -3,11 +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.
  #
  # Define NO_MKDTEMP if you don't have mkdtemp in the C library.
  #
 +# 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.
  # 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.
@@@ -340,6 -345,7 +349,6 @@@ PROGRAMS += git-index-pack$
  PROGRAMS += git-merge-index$X
  PROGRAMS += git-merge-tree$X
  PROGRAMS += git-mktag$X
 -PROGRAMS += git-mktree$X
  PROGRAMS += git-pack-redundant$X
  PROGRAMS += git-patch-id$X
  PROGRAMS += git-shell$X
@@@ -593,7 -599,6 +602,7 @@@ BUILTIN_OBJS += builtin-merge-base.
  BUILTIN_OBJS += builtin-merge-file.o
  BUILTIN_OBJS += builtin-merge-ours.o
  BUILTIN_OBJS += builtin-merge-recursive.o
 +BUILTIN_OBJS += builtin-mktree.o
  BUILTIN_OBJS += builtin-mv.o
  BUILTIN_OBJS += builtin-name-rev.o
  BUILTIN_OBJS += builtin-pack-objects.o
@@@ -640,12 -645,10 +649,12 @@@ EXTLIBS 
  
  ifeq ($(uname_S),Linux)
        NO_STRLCPY = YesPlease
 +      NO_MKSTEMPS = YesPlease
        THREADED_DELTA_SEARCH = YesPlease
  endif
  ifeq ($(uname_S),GNU/kFreeBSD)
        NO_STRLCPY = YesPlease
 +      NO_MKSTEMPS = YesPlease
        THREADED_DELTA_SEARCH = YesPlease
  endif
  ifeq ($(uname_S),UnixWare)
        SHELL_PATH = /usr/local/bin/bash
        NO_IPV6 = YesPlease
        NO_HSTRERROR = YesPlease
 +      NO_MKSTEMPS = YesPlease
        BASIC_CFLAGS += -Kthread
        BASIC_CFLAGS += -I/usr/local/include
        BASIC_LDFLAGS += -L/usr/local/lib
@@@ -681,7 -683,6 +690,7 @@@ ifeq ($(uname_S),SCO_SV
        SHELL_PATH = /usr/bin/bash
        NO_IPV6 = YesPlease
        NO_HSTRERROR = YesPlease
 +      NO_MKSTEMPS = YesPlease
        BASIC_CFLAGS += -I/usr/local/include
        BASIC_LDFLAGS += -L/usr/local/lib
        NO_STRCASESTR = YesPlease
@@@ -706,13 -707,20 +715,20 @@@ 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_HSTRERROR = YesPlease
        NO_MKDTEMP = YesPlease
        NO_MKSTEMPS = YesPlease
-       ifneq ($(uname_R),5.11)
-               OLD_ICONV = UnfortunatelyYes
+       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_C99_FORMAT = YesPlease
                NO_STRTOUMAX = YesPlease
        endif
-       INSTALL = ginstall
+       ifdef NO_IPV6
+               NEEDS_RESOLV = YesPlease
+       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
        NO_D_INO_IN_DIRENT = YesPlease
        NO_STRCASESTR = YesPlease
        NO_MEMMEM = YesPlease
 +      NO_MKSTEMPS = YesPlease
        NO_SYMLINK_HEAD = YesPlease
        NEEDS_LIBICONV = YesPlease
        NO_FAST_WORKING_DIRECTORY = UnfortunatelyYes
@@@ -779,13 -789,11 +798,13 @@@ ifeq ($(uname_S),NetBSD
        BASIC_LDFLAGS += -L/usr/pkg/lib $(CC_LD_DYNPATH)/usr/pkg/lib
        THREADED_DELTA_SEARCH = YesPlease
        USE_ST_TIMESPEC = YesPlease
 +      NO_MKSTEMPS = YesPlease
  endif
  ifeq ($(uname_S),AIX)
        NO_STRCASESTR=YesPlease
        NO_MEMMEM = YesPlease
        NO_MKDTEMP = YesPlease
 +      NO_MKSTEMPS = YesPlease
        NO_STRLCPY = YesPlease
        NO_NSEC = YesPlease
        FREAD_READS_DIRECTORIES = UnfortunatelyYes
@@@ -801,14 -809,12 +820,14 @@@ endi
  ifeq ($(uname_S),GNU)
        # GNU/Hurd
        NO_STRLCPY=YesPlease
 +      NO_MKSTEMPS = YesPlease
  endif
  ifeq ($(uname_S),IRIX64)
        NO_IPV6=YesPlease
        NO_SETENV=YesPlease
        NO_STRCASESTR=YesPlease
        NO_MEMMEM = YesPlease
 +      NO_MKSTEMPS = YesPlease
        NO_STRLCPY = YesPlease
        NO_SOCKADDR_STORAGE=YesPlease
        SHELL_PATH=/usr/gnu/bin/bash
@@@ -821,7 -827,6 +840,7 @@@ ifeq ($(uname_S),HP-UX
        NO_SETENV=YesPlease
        NO_STRCASESTR=YesPlease
        NO_MEMMEM = YesPlease
 +      NO_MKSTEMPS = YesPlease
        NO_STRLCPY = YesPlease
        NO_MKDTEMP = YesPlease
        NO_UNSETENV = YesPlease
@@@ -838,7 -843,6 +857,7 @@@ ifneq (,$(findstring MINGW,$(uname_S))
        NO_PREAD = YesPlease
        NO_OPENSSL = YesPlease
        NO_CURL = YesPlease
 +      NO_LIBGEN_H = YesPlease
        NO_SYMLINK_HEAD = YesPlease
        NO_IPV6 = YesPlease
        NO_SETENV = YesPlease
        NO_C99_FORMAT = YesPlease
        NO_STRTOUMAX = YesPlease
        NO_MKDTEMP = YesPlease
 +      NO_MKSTEMPS = YesPlease
        SNPRINTF_RETURNS_BOGUS = YesPlease
        NO_SVN_TESTS = YesPlease
        NO_PERL_MAKEMAKER = YesPlease
  endif
  ifneq (,$(findstring arm,$(uname_M)))
        ARM_SHA1 = YesPlease
 +      NO_MKSTEMPS = YesPlease
  endif
  
  -include config.mak.autogen
  -include config.mak
  
+ ifdef 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 = '/^\# @@BROKEN_PATH_FIX@@$$/d'
+ endif
  ifeq ($(uname_S),Darwin)
        ifndef NO_FINK
                ifeq ($(shell test -d /sw/lib && echo y),y)
@@@ -904,11 -914,6 +931,11 @@@ ifndef CC_LD_DYNPAT
        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
@@@ -981,6 -986,9 +1008,9 @@@ endi
  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
@@@ -1036,10 -1044,6 +1066,10 @@@ ifdef NO_MKDTEM
        COMPAT_CFLAGS += -DNO_MKDTEMP
        COMPAT_OBJS += compat/mkdtemp.o
  endif
 +ifdef NO_MKSTEMPS
 +      COMPAT_CFLAGS += -DNO_MKSTEMPS
 +      COMPAT_OBJS += compat/mkstemps.o
 +endif
  ifdef NO_UNSETENV
        COMPAT_CFLAGS += -DNO_UNSETENV
        COMPAT_OBJS += compat/unsetenv.o
@@@ -1285,6 -1289,7 +1315,7 @@@ $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %
            -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \
            -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
            -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
+           -e $(BROKEN_PATH_FIX) \
            $@.sh >$@+ && \
        chmod +x $@+ && \
        mv $@+ $@
@@@ -1524,8 -1529,6 +1555,8 @@@ test-delta$X: diff-delta.o patch-delta.
  
  test-parse-options$X: parse-options.o
  
 +test-parse-options.o: parse-options.h
 +
  .PRECIOUS: $(patsubst test-%$X,test-%.o,$(TEST_PROGRAMS))
  
  test-%$X: test-%.o $(GITLIBS)
diff --combined config.mak.in
index e8d96e88b92a2305e50eb1adcff7f9d0f3310996,d0cd1558117bd944f63250f3f09d366d8875e62f..dd6045131880111bb09306cb3e48330a0e5acdac
@@@ -30,9 -30,9 +30,10 @@@ NEEDS_SSL_WITH_CRYPTO=@NEEDS_SSL_WITH_C
  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@
+ 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@
@@@ -47,7 -47,6 +48,7 @@@ NO_STRTOUMAX=@NO_STRTOUMAX
  NO_SETENV=@NO_SETENV@
  NO_UNSETENV=@NO_UNSETENV@
  NO_MKDTEMP=@NO_MKDTEMP@
 +NO_MKSTEMPS=@NO_MKSTEMPS@
  NO_ICONV=@NO_ICONV@
  OLD_ICONV=@OLD_ICONV@
  NO_DEFLATE_BOUND=@NO_DEFLATE_BOUND@
diff --combined configure.ac
index 108a97fa8bdca8b6d685f2c5b1057df3d7af40a2,0a37af74a260a396bf2e4627f6e57786d3570f7f..7937e604be34eadddc314c0eff0cea226af19c9c
@@@ -467,6 -467,15 +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])
@@@ -627,12 -636,6 +636,12 @@@ AC_SUBST(SNPRINTF_RETURNS_BOGUS
  ## (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=],
@@@ -683,13 -686,6 +692,13 @@@ GIT_CHECK_FUNC(mkdtemp
  [NO_MKDTEMP=YesPlease])
  AC_SUBST(NO_MKDTEMP)
  #
 +# Define NO_MKSTEMPS if you don't have mkstemps in the C library.
 +GIT_CHECK_FUNC(mkstemps,
 +[NO_MKSTEMPS=],
 +[NO_MKSTEMPS=YesPlease])
 +AC_SUBST(NO_MKSTEMPS)
 +#
 +#
  # Define NO_MMAP if you want to avoid mmap.
  #
  # Define NO_ICONV if your libc does not properly support iconv.
diff --combined git-compat-util.h
index f25f7f1a9eda48477485c2406402a0a06fd9c8e3,48d99fab863eb2462a266cd1bac31d88ffd59f8d..919b7f1ade9cab3c4ba907f9506e3cb518fb9e7f
@@@ -7,7 -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)
  /* 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() */
 +#ifndef __sun__
  #define _XOPEN_SOURCE_EXTENDED 1 /* AIX 5.3L needs this */
  #endif
 +#endif
  #define _ALL_SOURCE 1
  #define _GNU_SOURCE 1
  #define _BSD_SOURCE 1
  #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
@@@ -241,11 -245,6 +254,11 @@@ extern int gitsetenv(const char *, cons
  extern char *gitmkdtemp(char *);
  #endif
  
 +#ifdef NO_MKSTEMPS
 +#define mkstemps gitmkstemps
 +extern int gitmkstemps(char *, int);
 +#endif
 +
  #ifdef NO_UNSETENV
  #define unsetenv gitunsetenv
  extern void gitunsetenv(const char *);