Merge branch 'sw/safe-create-leading-dir-race'
[gitweb.git] / git_remote_helpers / Makefile
index c62dfd0f4ddafbc82be15519f17815bbfcd62e8b..3d122328c8d1d5e6f53c008aeee0da2c7d2fba80 100644 (file)
@@ -7,7 +7,11 @@ pysetupfile:=setup.py
 DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
 
 ifndef PYTHON_PATH
-       PYTHON_PATH = /usr/bin/python
+       ifeq ($(uname_S),FreeBSD)
+               PYTHON_PATH = /usr/local/bin/python
+       else
+               PYTHON_PATH = /usr/bin/python
+       endif
 endif
 ifndef prefix
        prefix = $(HOME)
@@ -19,10 +23,16 @@ endif
 
 PYLIBDIR=$(shell $(PYTHON_PATH) -c \
         "import sys; \
-        print 'lib/python%i.%i/site-packages' % sys.version_info[:2]")
+        print('lib/python%i.%i/site-packages' % sys.version_info[:2])")
+
+py_version=$(shell $(PYTHON_PATH) -c \
+       'import sys; print("%i.%i" % sys.version_info[:2])')
 
 all: $(pysetupfile)
-       $(QUIET)$(PYTHON_PATH) $(pysetupfile) $(QUIETSETUP) build
+       $(QUIET)test "$$(cat GIT-PYTHON-VERSION 2>/dev/null)" = "$(py_version)" || \
+       flags=--force; \
+       $(PYTHON_PATH) $(pysetupfile) $(QUIETSETUP) build $$flags
+       $(QUIET)echo "$(py_version)" >GIT-PYTHON-VERSION
 
 install: $(pysetupfile)
        $(PYTHON_PATH) $(pysetupfile) install --prefix $(DESTDIR_SQ)$(prefix)
@@ -32,4 +42,4 @@ instlibdir: $(pysetupfile)
 
 clean:
        $(QUIET)$(PYTHON_PATH) $(pysetupfile) $(QUIETSETUP) clean -a
-       $(RM) *.pyo *.pyc
+       $(RM) *.pyo *.pyc GIT-PYTHON-VERSION