All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: Thomas Rast <trast@student.ethz.ch>
Cc: Nicolas Pitre <nico@fluxnic.net>, Jeff King <peff@peff.net>,
	Junio C Hamano <gitster@pobox.com>,
	git@vger.kernel.org
Subject: Re: [1.8.0] reorganize the mess that the source tree has become
Date: Tue, 1 Feb 2011 05:14:29 -0600	[thread overview]
Message-ID: <20110201111429.GA10165@elie> (raw)
In-Reply-To: <201102011342.06910.trast@student.ethz.ch>

Thomas Rast wrote:

> 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

  reply	other threads:[~2011-02-01 20:13 UTC|newest]

Thread overview: 138+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-31  5:53 What's cooking in git.git (Jan 2011, #06; Sun, 30) Junio C Hamano
2011-01-31 15:08 ` Sverre Rabbelier
2011-02-08 17:48   ` Sverre Rabbelier
2011-02-08 19:27     ` Junio C Hamano
2011-01-31 17:05 ` Planning for 1.7.5 and 1.8.0 Junio C Hamano
2011-01-31 17:06   ` [1.8.0] default "git merge" without argument to "git merge @{u}" Junio C Hamano
2011-01-31 20:14     ` Jeff King
2011-01-31 20:17       ` Junio C Hamano
2011-01-31 20:32         ` Felipe Contreras
2011-01-31 20:50     ` [1.8.0] (v2) " Junio C Hamano
2011-01-31 22:55       ` Jeff King
2011-02-01  0:01         ` Thomas Adam
2011-02-01 18:34         ` Scott Chacon
2011-02-01 20:11           ` moving to a git-backed wiki Jeff King
2011-02-01 22:36             ` Jay Soffian
2011-02-01 22:48               ` J.H.
2011-02-02  9:55                 ` Vincent Hanquez
2011-02-02 10:53                   ` Felipe Contreras
2011-02-02 11:14                     ` Jakub Narebski
2011-02-03  2:24                   ` J.H.
2011-02-03 17:45                     ` Jeff King
2011-02-03 19:06                       ` Sverre Rabbelier
2011-02-04  6:03                         ` Jeff King
2011-02-03 20:34                       ` Felipe Contreras
2011-02-04  6:16                         ` Jeff King
2011-02-04 17:50                           ` Felipe Contreras
2011-02-04 14:34                       ` Joey Hess
2011-02-05  7:00                         ` david
2011-02-04  7:31         ` [1.8.0] (v2) default "git merge" without argument to "git merge @{u}" Thomas Hochstein
2011-02-04 23:01     ` [PATCH/RFC] Add support for merging from upstream by default Jared Hance
2011-01-31 17:07   ` [1.8.0] Unify "pathspec" semantics Junio C Hamano
2011-02-01 14:56     ` Nguyen Thai Ngoc Duy
2011-01-31 20:28   ` [1.8.0] reorganize the mess that the source tree has become Nicolas Pitre
2011-01-31 20:57     ` Junio C Hamano
2011-01-31 21:08       ` Matthieu Moy
2011-01-31 21:33         ` Nicolas Pitre
2011-01-31 21:19       ` Nicolas Pitre
2011-01-31 21:00     ` Jeff King
2011-01-31 21:28       ` Nicolas Pitre
2011-01-31 22:17         ` Junio C Hamano
2011-01-31 22:36           ` João P. Sampaio
2011-01-31 22:37           ` Nicolas Pitre
2011-01-31 23:12         ` Jeff King
2011-02-01  0:29           ` Nicolas Pitre
2011-02-01  1:48             ` Jeff King
2011-02-01  4:05               ` Nicolas Pitre
2011-02-01 12:42                 ` Thomas Rast
2011-02-01 11:14                   ` Jonathan Nieder [this message]
2011-02-01 11:22                     ` Jonathan Nieder
2011-02-01 13:08                   ` Nicolas Pitre
2011-02-01 16:02                   ` Nguyen Thai Ngoc Duy
2011-02-01 21:53               ` Junio C Hamano
2011-02-01  0:35           ` Erik Faye-Lund
2011-02-01  1:53             ` Jeff King
2011-02-01  1:00           ` Sverre Rabbelier
2011-02-01  1:57             ` Jeff King
2011-02-01  7:24           ` Jay Soffian
2011-02-01 14:42         ` Andreas Ericsson
2011-01-31 21:59     ` [1.8.0] 't/' is standard name for directory with tests Jakub Narebski
2011-01-31 22:32       ` Nicolas Pitre
2011-02-01  0:12         ` Alex Budovski
2011-02-01  0:33           ` Nicolas Pitre
2011-02-01  0:58             ` Jakub Narebski
2011-02-01  1:15             ` Junio C Hamano
2011-02-02 23:55               ` Sam Vilain
2011-02-01 18:26     ` [1.8.0] split largest remaining scripts, gitk and gitweb Jakub Narebski
2011-02-01 22:15       ` Junio C Hamano
2011-02-01 23:20         ` Jakub Narebski
2011-02-05  3:21     ` [1.8.0] reorganize the mess that the source tree has become Martin von Zweigbergk
2011-01-31 21:44   ` [1.8.0] make two-argument fetch update remote branches Thomas Rast
2011-01-31 22:18     ` Matthieu Moy
2011-01-31 22:24     ` Junio C Hamano
2011-01-31 22:27     ` Eugene Sajine
2011-01-31 23:06       ` Junio C Hamano
2011-01-31 23:39         ` Eugene Sajine
2011-02-01  1:13           ` Junio C Hamano
2011-01-31 23:22     ` Jeff King
2011-02-01  7:04     ` Jay Soffian
2011-02-01 15:58       ` Nguyen Thai Ngoc Duy
2011-02-01 22:09       ` Junio C Hamano
2011-02-01 21:05     ` A Large Angry SCM
2011-02-01 22:39       ` Thomas Rast
2011-02-01 23:25         ` A Large Angry SCM
2011-01-31 21:55   ` [1.8.0] forbid full fetchspecs in git-pull Thomas Rast
2011-01-31 22:38     ` Junio C Hamano
2011-01-31 23:15     ` Dmitry Potapov
2011-02-01 15:14       ` Thomas Rast
2011-02-01 20:23         ` Dmitry Potapov
2011-02-01  3:20   ` Planning for 1.7.5 and 1.8.0 Nguyen Thai Ngoc Duy
2011-02-01  4:16     ` Nicolas Pitre
2011-02-01 14:54     ` [1.8.0] Tag namespaces Marc Branchaud
2011-02-01 15:21       ` Nguyen Thai Ngoc Duy
2011-02-01 18:37   ` [1.8.0] Remove deprecated commands René Scharfe
2011-02-01 22:16     ` Junio C Hamano
2011-02-02  0:57     ` Jonathan Nieder
2011-02-10 19:42       ` René Scharfe
2011-02-10 20:56         ` Jonathan Nieder
2011-02-10 21:08           ` Junio C Hamano
2011-02-12 13:24           ` René Scharfe
2011-02-12 21:04             ` Jonathan Nieder
2011-02-13 23:14             ` Junio C Hamano
2011-02-01 21:41   ` [1.8.0] Handle submodule config options consistently in diff plumbing Jens Lehmann
2011-02-02 11:56   ` [1.8.0] Tracking empty directories Jakub Narebski
2011-02-02 23:23     ` Jay Soffian
2011-02-02 23:33       ` David Aguilar
2011-02-02 23:52         ` Jakub Narebski
2011-02-03  2:21         ` Wesley J. Landaker
2011-02-03  5:53           ` Jonathan Nieder
2011-02-03 10:07           ` Matthieu Moy
2011-02-05  7:43         ` Pete Harlan
2011-02-05 18:31     ` Thomas Koch
2011-02-05 19:00       ` Sverre Rabbelier
2011-02-05 22:37         ` Jared Hance
2011-02-06 20:41         ` Junio C Hamano
2011-02-06 20:46           ` Sverre Rabbelier
2011-02-06  4:42       ` Nguyen Thai Ngoc Duy
2011-02-02 17:23   ` [1.8.0] git-stash invocation changes Thomas Rast
2011-02-02 17:35     ` Shawn Pearce
2011-02-02 18:15       ` Matthieu Moy
2011-02-02 18:51         ` Thomas Rast
2011-02-09 14:35           ` Pat Notz
2011-02-23 19:54   ` [1.8.0] Don't copy "submodule.<name>.update" to .git/config on submodule init Jens Lehmann
2011-02-23 20:28     ` Junio C Hamano
2011-02-23 22:43       ` Jens Lehmann
2011-02-24  0:34         ` Junio C Hamano
2011-02-24 23:44           ` Jens Lehmann
  -- strict thread matches above, loose matches on Subject: below --
2011-02-02  2:29 [1.8.0] reorganize the mess that the source tree has become George Spelvin
2011-02-02  8:31 ` Erik Faye-Lund
2011-02-02 20:01   ` Pascal Obry
2011-02-03  6:16 ` Nicolas Pitre
2011-02-03  8:09   ` Miles Bader
2011-02-03 18:01   ` Andreas Schwab
2011-02-03 18:46   ` Eugene Sajine
2011-02-03 21:42     ` Hilco Wijbenga
2011-02-04  2:06       ` Miles Bader
2011-02-04  8:30         ` Tor Arntsen
2011-02-04 10:49           ` Jakub Narebski
2011-02-04 11:17         ` Erik Faye-Lund

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110201111429.GA10165@elie \
    --to=jrnieder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=nico@fluxnic.net \
    --cc=peff@peff.net \
    --cc=trast@student.ethz.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.