git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [1.8.0] reorganize the mess that the source tree has become

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Feb 1, 2011, 11:14 UTC
Message-ID
<20110201111429.GA10165@elie>
In-Reply-To
<201102011342.06910.trast@student.ethz.ch>
Thomas Rast wrote:
Show 8 quoted lines
> In particular a prospective git hacker would not care whether
> something is a source file or a script (you seem to imply the
> opposite).  He would instead expect to find git-foo implemented in
> something named of that sort, so we could probably help him by mapping
> 
>   git-foo.sh      ->   git-foo.sh
>   builtin/bar.c   ->   git-bar.c
>   baz.c           ->   lib/baz.c

I agree. This sets off my "time to resist change" alarms much less than "git mv *.c *.sh src/", for what it's worth.

>   baz.o           ->   build/baz.o (or whatever, just elsewhere)
>   baz.gcov        ->   build/baz.gcov (ditto)
Maybe something like this to start?
-- 8< --
Subject: Makefile: basic support for separate build dir
 - python and perl machinery haven't been tweaked yet
 - requires good VPATH support
 - relies on COMPUTE_HEADER_DIRECTORIES to make the object file
   directories
 - does not support paths with spaces
Usage:
	mkdir output
	cd output
	echo COMPUTE_HEADER_DIRECTORIES=1 >config.mak
	make -f ../Makefile GIT_SRC=$(pwd)/../ -j2
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
 Makefile            |   41 ++++++++++++++++++++++++++---------------
 generate-cmdlist.sh |    4 ++--
 perl/Makefile       |    2 +-
 3 files changed, 29 insertions(+), 18 deletions(-)
diff --git a/Makefile b/Makefile
index 775ee83..b258a24 100644
--- a/Makefile
+++ b/Makefile
@@ -243,8 +243,18 @@ all::
 #
 # Define NATIVE_CRLF if your platform uses CRLF for line endings.
 
+# Absolute path to the toplevel of the git sources, with trailing /.
+# Leave empty for an in-place build.
+GIT_SRC =
+ifdef GIT_SRC
+	NO_PYTHON = YesPlease
+	NO_PERL_MAKEMAKER = YesPlease
+endif
+
+VPATH := $(if $(GIT_SRC),$(GIT_SRC),$(CURDIR))
+
 GIT-VERSION-FILE: FORCE
-	@$(SHELL_PATH) ./GIT-VERSION-GEN
+	@$(SHELL_PATH) $(GIT_SRC)/GIT-VERSION-GEN
 -include GIT-VERSION-FILE
 
 uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
@@ -305,6 +315,7 @@ lib = lib
 pathsep = :
 
 export prefix bindir sharedir sysconfdir gitwebdir
+export GIT_SRC
 
 CC = gcc
 AR = ar
@@ -333,7 +344,7 @@ SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
 # Those must not be GNU-specific; they are shared with perl/ which may
 # be built by a different compiler. (Note that this is an artifact now
 # but it still might be nice to keep that distinction.)
-BASIC_CFLAGS = -I.
+BASIC_CFLAGS = -I$(GIT_SRC). -I.
 BASIC_LDFLAGS =
 
 # Guard against environment variables
@@ -1562,7 +1573,7 @@ ifeq ($(PYTHON_PATH),)
 NO_PYTHON=NoThanks
 endif
 
-QUIET_SUBDIR0  = +$(MAKE) -C # space to separate -C and subdir
+QUIET_SUBDIR0  = +$(MAKE) -C $(GIT_SRC)# no space before subdir
 QUIET_SUBDIR1  =
 
 ifneq ($(findstring $(MAKEFLAGS),w),w)
@@ -1582,7 +1593,7 @@ ifndef V
 	QUIET_GCOV     = @echo '   ' GCOV $@;
 	QUIET_SUBDIR0  = +@subdir=
 	QUIET_SUBDIR1  = ;$(NO_SUBDIR) echo '   ' SUBDIR $$subdir; \
-			 $(MAKE) $(PRINT_DIR) -C $$subdir
+			 $(MAKE) $(PRINT_DIR) -C $(GIT_SRC)$$subdir
 	export V
 	export QUIET_GEN
 	export QUIET_BUILT_IN
@@ -1696,10 +1707,10 @@ $(BUILT_INS): git$X
 	ln -s git$X $@ 2>/dev/null || \
 	cp git$X $@
 
-common-cmds.h: ./generate-cmdlist.sh command-list.txt
+common-cmds.h: generate-cmdlist.sh command-list.txt
 
 common-cmds.h: $(wildcard Documentation/git-*.txt)
-	$(QUIET_GEN)./generate-cmdlist.sh > $@+ && mv $@+ $@
+	$(QUIET_GEN)$(GIT_SRC)./generate-cmdlist.sh > $@+ && mv $@+ $@
 
 define cmd_munge_script
 $(RM) $@ $@+ && \
@@ -1709,7 +1720,7 @@ sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
     -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
     -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
     -e $(BROKEN_PATH_FIX) \
-    $@.sh >$@+
+    $(GIT_SRC)$@.sh >$@+
 endef
 
 $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
@@ -1729,7 +1740,7 @@ perl/perl.mak: GIT-CFLAGS perl/Makefile perl/Makefile.PL
 
 $(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl
 	$(QUIET_GEN)$(RM) $@ $@+ && \
-	INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C perl -s --no-print-directory instlibdir` && \
+	INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C $(GIT_SRC)perl -s --no-print-directory instlibdir` && \
 	sed -e '1{' \
 	    -e '	s|#!.*perl|#!$(PERL_PATH_SQ)|' \
 	    -e '	h' \
@@ -1738,7 +1749,7 @@ $(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl
 	    -e '	x' \
 	    -e '}' \
 	    -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
-	    $@.perl >$@+ && \
+	    $(GIT_SRC)$@.perl >$@+ && \
 	chmod +x $@+ && \
 	mv $@+ $@
 
@@ -1780,7 +1791,7 @@ git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/static/gitweb.css gitweb/
 	    -e 's/@@NO_CURL@@/$(NO_CURL)/g' \
 	    -e 's|@@GITWEBDIR@@|$(gitwebdir_SQ)|g' \
 	    -e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \
-	    $@.sh > $@+ && \
+	    $(GIT_SRC)$@.sh > $@+ && \
 	chmod +x $@+ && \
 	mv $@+ $@
 else # NO_PERL
@@ -1788,7 +1799,7 @@ $(patsubst %.perl,%,$(SCRIPT_PERL)) git-instaweb: % : unimplemented.sh
 	$(QUIET_GEN)$(RM) $@ $@+ && \
 	sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
 	    -e 's|@@REASON@@|NO_PERL=$(NO_PERL)|g' \
-	    unimplemented.sh >$@+ && \
+	    $(GIT_SRC)unimplemented.sh >$@+ && \
 	chmod +x $@+ && \
 	mv $@+ $@
 endif # NO_PERL
@@ -1803,7 +1814,7 @@ $(patsubst %.py,%,$(SCRIPT_PYTHON)): % : %.py
 	sed -e '1s|#!.*python|#!$(PYTHON_PATH_SQ)|' \
 	    -e 's|\(os\.getenv("GITPYTHONLIB"\)[^)]*)|\1,"@@INSTLIBDIR@@")|' \
 	    -e 's|@@INSTLIBDIR@@|'"$$INSTLIBDIR"'|g' \
-	    $@.py >$@+ && \
+	    $(GIT_SRC)$@.py >$@+ && \
 	chmod +x $@+ && \
 	mv $@+ $@
 else # NO_PYTHON
@@ -1811,7 +1822,7 @@ $(patsubst %.py,%,$(SCRIPT_PYTHON)): % : unimplemented.sh
 	$(QUIET_GEN)$(RM) $@ $@+ && \
 	sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
 	    -e 's|@@REASON@@|NO_PYTHON=$(NO_PYTHON)|g' \
-	    unimplemented.sh >$@+ && \
+	    $(GIT_SRC)unimplemented.sh >$@+ && \
 	chmod +x $@+ && \
 	mv $@+ $@
 endif # NO_PYTHON
@@ -2142,7 +2153,7 @@ test-%$X: test-%.o $(GITLIBS)
 	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(filter %.a,$^) $(LIBS)
 
 check-sha1:: test-sha1$X
-	./test-sha1.sh
+	$(GIT_SRC)./test-sha1.sh
 
 check: common-cmds.h
 	if sparse; \
@@ -2229,7 +2240,7 @@ endif
 		ln -s "git-remote-http$X" "$$execdir/$$p" 2>/dev/null || \
 		cp "$$execdir/git-remote-http$X" "$$execdir/$$p" || exit; \
 	done && \
-	./check_bindir "z$$bindir" "z$$execdir" "$$bindir/git-add$X"
+	$(GIT_SRC)./check_bindir "z$$bindir" "z$$execdir" "$$bindir/git-add$X"
 
 install-gitweb:
 	$(MAKE) -C gitweb install
diff --git a/generate-cmdlist.sh b/generate-cmdlist.sh
index 75c68d9..f718633 100755
--- a/generate-cmdlist.sh
+++ b/generate-cmdlist.sh
@@ -9,7 +9,7 @@ struct cmdname_help
 
 static struct cmdname_help common_cmds[] = {"
 
-sed -n -e 's/^git-\([^ 	]*\)[ 	].* common.*/\1/p' command-list.txt |
+sed -n -e 's/^git-\([^ 	]*\)[ 	].* common.*/\1/p' "$GIT_SRC"command-list.txt |
 sort |
 while read cmd
 do
@@ -19,6 +19,6 @@ do
             x
             s/.*git-'"$cmd"' - \(.*\)/  {"'"$cmd"'", "\1"},/
 	    p
-     }' "Documentation/git-$cmd.txt"
+     }' "${GIT_SRC}Documentation/git-$cmd.txt"
 done
 echo "};"
diff --git a/perl/Makefile b/perl/Makefile
index a2ffb64..7c3a82a 100644
--- a/perl/Makefile
+++ b/perl/Makefile
@@ -44,4 +44,4 @@ endif
 # this is just added comfort for calling make directly in perl dir
 # (even though GIT-CFLAGS aren't used yet. If ever)
 ../GIT-CFLAGS:
-	$(MAKE) -C .. GIT-CFLAGS
+	$(MAKE) -C $(GIT_SRC).. GIT-CFLAGS
-- 
1.7.2.3
Previous: Thomas RastNext: Jonathan Nieder
Message 48 of 126 in “What's cooking in git.git (Jan 2011, #06; Sun, 30)”
  1. Junio C HamanoJan 31, 2011
  2. Sverre RabbelierJan 31, 2011
  3. Sverre RabbelierFeb 8, 2011
  4. Junio C HamanoFeb 8, 2011
  5. Planning for 1.7.5 and 1.8.0Junio C Hamano, Jan 31, 2011
  6. [1.8.0] default "git merge" without argument to "git merge @{u}"Junio C Hamano, Jan 31, 2011
  7. Jeff KingJan 31, 2011
  8. Junio C HamanoJan 31, 2011
  9. Felipe ContrerasJan 31, 2011
  10. [1.8.0] (v2) default "git merge" without argument to "git merge @{u}"Junio C Hamano, Jan 31, 2011
  11. Jeff KingJan 31, 2011
  12. Thomas AdamFeb 1, 2011
  13. Scott ChaconFeb 1, 2011
  14. moving to a git-backed wikiJeff King, Feb 1, 2011
  15. Jay SoffianFeb 1, 2011
  16. J.H.Feb 1, 2011
  17. Vincent HanquezFeb 2, 2011
  18. Felipe ContrerasFeb 2, 2011
  19. Jakub NarebskiFeb 2, 2011
  20. J.H.Feb 3, 2011
  21. Jeff KingFeb 3, 2011
  22. Sverre RabbelierFeb 3, 2011
  23. Jeff KingFeb 4, 2011
  24. Felipe ContrerasFeb 3, 2011
  25. Jeff KingFeb 4, 2011
  26. Felipe ContrerasFeb 4, 2011
  27. Joey HessFeb 4, 2011
  28. david@lang.hmFeb 5, 2011
  29. Thomas HochsteinFeb 4, 2011
  30. Add support for merging from upstream by default.Jared Hance, Feb 4, 2011
  31. [1.8.0] Unify "pathspec" semanticsJunio C Hamano, Jan 31, 2011
  32. Nguyen Thai Ngoc DuyFeb 1, 2011
  33. [1.8.0] reorganize the mess that the source tree has becomeNicolas Pitre, Jan 31, 2011
  34. Junio C HamanoJan 31, 2011
  35. Matthieu MoyJan 31, 2011
  36. Nicolas PitreJan 31, 2011
  37. Nicolas PitreJan 31, 2011
  38. Jeff KingJan 31, 2011
  39. Nicolas PitreJan 31, 2011
  40. Junio C HamanoJan 31, 2011
  41. João P. SampaioJan 31, 2011
  42. Nicolas PitreJan 31, 2011
  43. Jeff KingJan 31, 2011
  44. Nicolas PitreFeb 1, 2011
  45. Jeff KingFeb 1, 2011
  46. Nicolas PitreFeb 1, 2011
  47. Thomas RastFeb 1, 2011
  48. Jonathan NiederFeb 1, 2011
  49. Jonathan NiederFeb 1, 2011
  50. Nicolas PitreFeb 1, 2011
  51. Nguyen Thai Ngoc DuyFeb 1, 2011
  52. Junio C HamanoFeb 1, 2011
  53. Erik Faye-LundFeb 1, 2011
  54. Jeff KingFeb 1, 2011
  55. Sverre RabbelierFeb 1, 2011
  56. Jeff KingFeb 1, 2011
  57. Jay SoffianFeb 1, 2011
  58. Andreas EricssonFeb 1, 2011
  59. Jakub NarebskiJan 31, 2011
  60. Nicolas PitreJan 31, 2011
  61. Alex BudovskiFeb 1, 2011
  62. Nicolas PitreFeb 1, 2011
  63. Jakub NarebskiFeb 1, 2011
  64. Junio C HamanoFeb 1, 2011
  65. Sam VilainFeb 2, 2011
  66. [1.8.0] split largest remaining scripts, gitk and gitwebJakub Narebski, Feb 1, 2011
  67. Junio C HamanoFeb 1, 2011
  68. Jakub NarebskiFeb 1, 2011
  69. Martin von ZweigbergkFeb 5, 2011
  70. [1.8.0] make two-argument fetch update remote branchesThomas Rast, Jan 31, 2011
  71. Matthieu MoyJan 31, 2011
  72. Junio C HamanoJan 31, 2011
  73. Eugene SajineJan 31, 2011
  74. Junio C HamanoJan 31, 2011
  75. Eugene SajineJan 31, 2011
  76. Junio C HamanoFeb 1, 2011
  77. Jeff KingJan 31, 2011
  78. Jay SoffianFeb 1, 2011
  79. Nguyen Thai Ngoc DuyFeb 1, 2011
  80. Junio C HamanoFeb 1, 2011
  81. A Large Angry SCMFeb 1, 2011
  82. Thomas RastFeb 1, 2011
  83. A Large Angry SCMFeb 1, 2011
  84. [1.8.0] forbid full fetchspecs in git-pullThomas Rast, Jan 31, 2011
  85. Junio C HamanoJan 31, 2011
  86. Dmitry PotapovJan 31, 2011
  87. Thomas RastFeb 1, 2011
  88. Dmitry PotapovFeb 1, 2011
  89. Nguyen Thai Ngoc DuyFeb 1, 2011
  90. Nicolas PitreFeb 1, 2011
  91. [1.8.0] Tag namespacesMarc Branchaud, Feb 1, 2011
  92. Nguyen Thai Ngoc DuyFeb 1, 2011
  93. [1.8.0] Remove deprecated commandsRené Scharfe, Feb 1, 2011
  94. Junio C HamanoFeb 1, 2011
  95. Jonathan NiederFeb 2, 2011
  96. René ScharfeFeb 10, 2011
  97. Jonathan NiederFeb 10, 2011
  98. Junio C HamanoFeb 10, 2011
  99. René ScharfeFeb 12, 2011
  100. Jonathan NiederFeb 12, 2011
  101. Junio C HamanoFeb 13, 2011
  102. [1.8.0] Handle submodule config options consistently in diff plumbingJens Lehmann, Feb 1, 2011
  103. [1.8.0] Tracking empty directoriesJakub Narebski, Feb 2, 2011
  104. Jay SoffianFeb 2, 2011
  105. David AguilarFeb 2, 2011
  106. Jakub NarebskiFeb 2, 2011
  107. Wesley J. LandakerFeb 3, 2011
  108. Jonathan NiederFeb 3, 2011
  109. Matthieu MoyFeb 3, 2011
  110. Pete HarlanFeb 5, 2011
  111. Thomas KochFeb 5, 2011
  112. Sverre RabbelierFeb 5, 2011
  113. Jared HanceFeb 5, 2011
  114. Junio C HamanoFeb 6, 2011
  115. Sverre RabbelierFeb 6, 2011
  116. Nguyen Thai Ngoc DuyFeb 6, 2011
  117. [1.8.0] git-stash invocation changesThomas Rast, Feb 2, 2011
  118. Shawn PearceFeb 2, 2011
  119. Matthieu MoyFeb 2, 2011
  120. Thomas RastFeb 2, 2011
  121. Pat NotzFeb 9, 2011
  122. [1.8.0] Don't copy "submodule.<name>.update" to .git/config on submodule initJens Lehmann, Feb 23, 2011
  123. Junio C HamanoFeb 23, 2011
  124. Jens LehmannFeb 23, 2011
  125. Junio C HamanoFeb 24, 2011
  126. Jens LehmannFeb 24, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.