Merge branch 'ds/uintmax-config' (early part)
authorJunio C Hamano <gitster@pobox.com>
Thu, 13 Nov 2008 06:27:33 +0000 (22:27 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 13 Nov 2008 06:27:33 +0000 (22:27 -0800)
* 'ds/uintmax-config' (early part):
Add autoconf tests for pthreads
Make Pthread link flags configurable
Add Makefile check for FreeBSD 4.9-SECURITY
Build: add NO_UINTMAX_T to support ancient systems

Conflicts:
Makefile

1  2 
Makefile
configure.ac
diff --combined Makefile
index 920cb4207844648f9a7ae7e74be8b426543ea7e4,02f68e05f5f78def774b02ab6af843bc48a9f0c9..35adafa011bdc8b3728bea942d86fba96a90fe6a
+++ b/Makefile
@@@ -229,6 -229,7 +229,7 @@@ INSTALL = instal
  RPMBUILD = rpmbuild
  TCL_PATH = tclsh
  TCLTK_PATH = wish
+ PTHREAD_LIBS = -lpthread
  
  export TCL_PATH TCLTK_PATH
  
@@@ -640,6 -641,8 +641,6 @@@ ifeq ($(uname_S),Darwin
        endif
        NO_STRLCPY = YesPlease
        NO_MEMMEM = YesPlease
 -      COMPAT_CFLAGS += -Icompat/regex
 -      COMPAT_OBJS += compat/regex/regex.o
  endif
  ifeq ($(uname_S),SunOS)
        NEEDS_SOCKET = YesPlease
@@@ -690,6 -693,13 +691,11 @@@ ifeq ($(uname_S),FreeBSD
        BASIC_LDFLAGS += -L/usr/local/lib
        DIR_HAS_BSD_GROUP_SEMANTICS = YesPlease
        THREADED_DELTA_SEARCH = YesPlease
 -      COMPAT_CFLAGS += -Icompat/regex
 -      COMPAT_OBJS += compat/regex/regex.o
+       ifeq ($(shell expr "$(uname_R)" : '4\.'),2)
+               PTHREAD_LIBS = -pthread
+               NO_UINTMAX_T = YesPlease
+               NO_STRTOUMAX = YesPlease
+       endif
  endif
  ifeq ($(uname_S),OpenBSD)
        NO_STRCASESTR = YesPlease
@@@ -716,6 -726,8 +722,6 @@@ ifeq ($(uname_S),AIX
        INTERNAL_QSORT = UnfortunatelyYes
        NEEDS_LIBICONV=YesPlease
        BASIC_CFLAGS += -D_LARGE_FILES
 -      COMPAT_CFLAGS += -Icompat/regex
 -      COMPAT_OBJS += compat/regex/regex.o
  endif
  ifeq ($(uname_S),GNU)
        # GNU/Hurd
@@@ -949,6 -961,9 +955,9 @@@ endi
  ifdef NO_IPV6
        BASIC_CFLAGS += -DNO_IPV6
  endif
+ ifdef NO_UINTMAX_T
+       BASIC_CFLAGS += -Duintmax_t=uint32_t
+ endif
  ifdef NO_SOCKADDR_STORAGE
  ifdef NO_IPV6
        BASIC_CFLAGS += -Dsockaddr_storage=sockaddr_in
@@@ -1010,7 -1025,7 +1019,7 @@@ endi
  
  ifdef THREADED_DELTA_SEARCH
        BASIC_CFLAGS += -DTHREADED_DELTA_SEARCH
-       EXTLIBS += -lpthread
+       EXTLIBS += $(PTHREAD_LIBS)
        LIB_OBJS += thread-utils.o
  endif
  ifdef DIR_HAS_BSD_GROUP_SEMANTICS
@@@ -1355,16 -1370,7 +1364,16 @@@ check-sha1:: test-sha1$
        ./test-sha1.sh
  
  check: common-cmds.h
 -      for i in *.c; do sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i || exit; done
 +      if sparse; \
 +      then \
 +              for i in *.c; \
 +              do \
 +                      sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i || exit; \
 +              done; \
 +      else \
 +              echo 2>&1 "Did you mean 'make test'?"; \
 +              exit 1; \
 +      fi
  
  remove-dashes:
        ./fixup-builtins $(BUILT_INS) $(PROGRAMS) $(SCRIPTS)
@@@ -1414,9 -1420,6 +1423,9 @@@ endi
  install-doc:
        $(MAKE) -C Documentation install
  
 +install-man:
 +      $(MAKE) -C Documentation install-man
 +
  install-html:
        $(MAKE) -C Documentation install-html
  
@@@ -1426,9 -1429,6 +1435,9 @@@ install-info
  quick-install-doc:
        $(MAKE) -C Documentation quick-install
  
 +quick-install-man:
 +      $(MAKE) -C Documentation quick-install-man
 +
  quick-install-html:
        $(MAKE) -C Documentation quick-install-html
  
diff --combined configure.ac
index ef544e877879a21e5507ab7767984f3d8c66b3d7,3f058a087b109fad3b60e6073bdfacad4a16b6f5..42567420e0b6ab01bc0a905b61c3fd7939f800f9
@@@ -65,17 -65,7 +65,17 @@@ else 
  fi \
  ])# GIT_PARSE_WITH
  
 -
 +dnl
 +dnl GIT_CHECK_FUNC(FUNCTION, IFTRUE, IFFALSE)
 +dnl -----------------------------------------
 +dnl Similar to AC_CHECK_FUNC, but on systems that do not generate
 +dnl warnings for missing prototypes (e.g. FreeBSD when compiling without
 +dnl -Wall), it does not work.  By looking for function definition in
 +dnl libraries, this problem can be worked around.
 +AC_DEFUN([GIT_CHECK_FUNC],[AC_CHECK_FUNC([$1],[
 +  AC_SEARCH_LIBS([$1],,
 +  [$2],[$3])
 +],[$3])])
  ## Site configuration related to programs (before tests)
  ## --with-PACKAGE[=ARG] and --without-PACKAGE
  #
@@@ -335,7 -325,7 +335,7 @@@ AC_SUBST(NO_SOCKADDR_STORAGE
  #
  # Define NO_IPV6 if you lack IPv6 support and getaddrinfo().
  AC_CHECK_TYPE([struct addrinfo],[
 - AC_CHECK_FUNC([getaddrinfo],
 + GIT_CHECK_FUNC([getaddrinfo],
    [NO_IPV6=],
    [NO_IPV6=YesPlease])
  ],[NO_IPV6=YesPlease],[
@@@ -429,43 -419,51 +429,51 @@@ AC_SUBST(SNPRINTF_RETURNS_BOGUS
  AC_MSG_NOTICE([CHECKS for library functions])
  #
  # Define NO_STRCASESTR if you don't have strcasestr.
 -AC_CHECK_FUNC(strcasestr,
 +GIT_CHECK_FUNC(strcasestr,
  [NO_STRCASESTR=],
  [NO_STRCASESTR=YesPlease])
  AC_SUBST(NO_STRCASESTR)
  #
  # Define NO_MEMMEM if you don't have memmem.
 -AC_CHECK_FUNC(memmem,
 +GIT_CHECK_FUNC(memmem,
  [NO_MEMMEM=],
  [NO_MEMMEM=YesPlease])
  AC_SUBST(NO_MEMMEM)
  #
  # Define NO_STRLCPY if you don't have strlcpy.
 -AC_CHECK_FUNC(strlcpy,
 +GIT_CHECK_FUNC(strlcpy,
  [NO_STRLCPY=],
  [NO_STRLCPY=YesPlease])
  AC_SUBST(NO_STRLCPY)
  #
+ # Define NO_UINTMAX_T if your platform does not have uintmax_t
+ AC_CHECK_TYPE(uintmax_t,
+ [NO_UINTMAX_T=],
+ [NO_UINTMAX_T=YesPlease],[
+ #include <inttypes.h>
+ ])
+ AC_SUBST(NO_UINTMAX_T)
+ #
  # Define NO_STRTOUMAX if you don't have strtoumax in the C library.
 -AC_CHECK_FUNC(strtoumax,
 +GIT_CHECK_FUNC(strtoumax,
  [NO_STRTOUMAX=],
  [NO_STRTOUMAX=YesPlease])
  AC_SUBST(NO_STRTOUMAX)
  #
  # Define NO_SETENV if you don't have setenv in the C library.
 -AC_CHECK_FUNC(setenv,
 +GIT_CHECK_FUNC(setenv,
  [NO_SETENV=],
  [NO_SETENV=YesPlease])
  AC_SUBST(NO_SETENV)
  #
  # Define NO_UNSETENV if you don't have unsetenv in the C library.
 -AC_CHECK_FUNC(unsetenv,
 +GIT_CHECK_FUNC(unsetenv,
  [NO_UNSETENV=],
  [NO_UNSETENV=YesPlease])
  AC_SUBST(NO_UNSETENV)
  #
  # Define NO_MKDTEMP if you don't have mkdtemp in the C library.
 -AC_CHECK_FUNC(mkdtemp,
 +GIT_CHECK_FUNC(mkdtemp,
  [NO_MKDTEMP=],
  [NO_MKDTEMP=YesPlease])
  AC_SUBST(NO_MKDTEMP)
  #
  # Define NO_SYMLINK_HEAD if you never want .git/HEAD to be a symbolic link.
  # Enable it on Windows.  By default, symrefs are still used.
+ #
+ # Define PTHREAD_LIBS to the linker flag used for Pthread support.
+ AC_LANG_CONFTEST([AC_LANG_PROGRAM(
+   [[#include <pthread.h>]],
+   [[pthread_mutex_t test_mutex;]]
+ )])
+ ${CC} -pthread conftest.c -o conftest.o > /dev/null 2>&1
+ if test $? -eq 0;then
+  PTHREAD_LIBS="-pthread"
+ else
+  ${CC} -lpthread conftest.c -o conftest.o > /dev/null 2>&1
+  if test $? -eq 0;then
+   PTHREAD_LIBS="-lpthread"
+  fi
+ fi
+ AC_SUBST(PTHREAD_LIBS)
  
  ## Site configuration (override autodetection)
  ## --with-PACKAGE[=ARG] and --without-PACKAGE