{"thread":{"id":"43338","subject":"Re: [PATCH] Allow building GIT in a different directory from the source directory","startedAt":"2006-12-11T13:56:57Z","lastAt":"2006-12-13T09:28:03Z","messageCount":5,"participants":["Johannes Schindelin","Junio C Hamano","Han-Wen Nienhuys","Andreas Ericsson"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"297457","messageId":"eljo2u$pnq$2@sea.gmane.org","threadId":"43338","inReplyTo":null,"subject":"[PATCH] Allow building GIT in a different directory from the source directory","fromName":"Han-Wen Nienhuys","fromEmail":"hanwen@xs4all.nl","sentAt":"2006-12-11T13:56:57Z","receivedAt":"2006-12-11T13:56:57Z","isPatch":true,"sender":{"key":"hanwen@google.com","avatar":"https://avatars.githubusercontent.com/u/31547?v=4"},"body":"\nGIT can now be built in a separate builddirectory. This is done as\nfollows:\n\n  mkdir build\n  cd build\n  $my_git_dir/configure\n  make\n\nIn this case, configure creates an empty directory tree based on the\nsource directory, and wraps Makefiles from source directory in the\nbuild directory.  The rest of the functionality is delivered with the\nVPATH feature of Make.\n\nTo make this work the Makefile should not mention ./ explicitly in\nrules, but rather use $< and $^ to automatically look in the source\ndir too.\n\nperl/Makefile and perl/Makefile.PL need special massaging because perl\nis not VPATH aware.\n\nThe documentation subdirectory has limited support for separate building, \nas asciidoc doesn't have a --include-path option.\n\n Documentation/Makefile |   36 ++++++++++++++++++++++--------------\n INSTALL                |    7 +++++++\n Makefile               |   23 ++++++++++++++---------\n config.mak.in          |    9 ++++-----\n configure.ac           |   34 ++++++++++++++++++++++++++++++++++\n generate-cmdlist.sh    |    2 +-\n perl/Makefile          |    4 ++++\n perl/Makefile.PL       |   16 +++++++++++++---\n 8 files changed, 99 insertions(+), 32 deletions(-)\n\ndiff --git a/Documentation/Makefile b/Documentation/Makefile\nindex c00f5f6..39bcd45 100644\n--- a/Documentation/Makefile\n+++ b/Documentation/Makefile\n@@ -1,6 +1,6 @@\n MAN1_TXT= \\\n-\t$(filter-out $(addsuffix .txt, $(ARTICLES) $(SP_ARTICLES)), \\\n-\t\t$(wildcard git-*.txt)) \\\n+\t$(filter-out $(foreach i, $(ARTICLES) $(SP_ARTICLES), $(here-srcdir)/$(i).txt), \\\n+\t\t$(wildcard $(here-srcdir)/git-*.txt)) \\\n \tgitk.txt\n MAN7_TXT=git.txt\n \n@@ -33,8 +33,16 @@ # DESTDIR=\n \n INSTALL?=install\n \n--include ../config.mak.autogen\n+ifndef srcdir\n+srcdir=..\n+endif\n+\n+\n+here-srcdir=$(srcdir)/Documentation\n \n+ASCIIDOC_CONF=$(here-srcdir)/asciidoc.conf\n+\n+-include ../config.mak.autogen\n #\n # Please note that there is a minor bug in asciidoc.\n # The version after 6.0.3 _will_ include the patch found here:\n@@ -63,9 +71,9 @@ install: man\n #\n # Determine \"include::\" file references in asciidoc files.\n #\n-doc.dep : $(wildcard *.txt) build-docdep.perl\n+doc.dep : $(wildcard $(here-srcdir)/*.txt) build-docdep.perl\n \trm -f $@+ $@\n-\tperl ./build-docdep.perl >$@+\n+\tperl $(lastword $^) >$@+\n \tmv $@+ $@\n \n -include doc.dep\n@@ -80,35 +88,35 @@ clean:\n \trm -f *.xml *.html *.1 *.7 howto-index.txt howto/*.html doc.dep README\n \n %.html : %.txt\n-\tasciidoc -b xhtml11 -d manpage -f asciidoc.conf $<\n+\tasciidoc -b xhtml11 -d manpage -f $(ASCIIDOC_CONF) $<\n \n %.1 %.7 : %.xml\n-\txmlto -m callouts.xsl man $<\n+\txmlto --searchpath $(here-srcdir)/  -m callouts.xsl man $<\n \n %.xml : %.txt\n-\tasciidoc -b docbook -d manpage -f asciidoc.conf $<\n+\tasciidoc -b docbook -d manpage -f $(ASCIIDOC_CONF) $<\n \n git.html: git.txt README\n \n glossary.html : glossary.txt sort_glossary.pl\n \tcat $< | \\\n-\tperl sort_glossary.pl | \\\n+\tperl $(lastword $^) | \\\n \tasciidoc -b xhtml11 - > glossary.html\n \n-howto-index.txt: howto-index.sh $(wildcard howto/*.txt)\n+howto-index.txt: howto-index.sh $(wildcard $(here-srcdir)/howto/*.txt)\n \trm -f $@+ $@\n-\tsh ./howto-index.sh $(wildcard howto/*.txt) >$@+\n+\tsh $^ >$@+\n \tmv $@+ $@\n \n $(patsubst %,%.html,$(ARTICLES)) : %.html : %.txt\n-\tasciidoc -b xhtml11 $*.txt\n+\tasciidoc -b xhtml11 $<\n \n WEBDOC_DEST = /pub/software/scm/git/docs\n \n-$(patsubst %.txt,%.html,$(wildcard howto/*.txt)): %.html : %.txt\n+$(patsubst %.txt,%.html,$(wildcard $(here-srcdir)/howto/*.txt)): %.html : %.txt\n \trm -f $@+ $@\n \tsed -e '1,/^$$/d' $< | asciidoc -b xhtml11 - >$@+\n \tmv $@+ $@\n \n install-webdoc : html\n-\tsh ./install-webdoc.sh $(WEBDOC_DEST)\n+\tsh $(here-srcdir)/install-webdoc.sh $(WEBDOC_DEST)\ndiff --git a/INSTALL b/INSTALL\nindex 8f69039..b1355fa 100644\n--- a/INSTALL\n+++ b/INSTALL\n@@ -21,6 +21,13 @@ set up install paths (via config.mak.aut\n \t$ make all doc ;# as yourself\n \t# make install install-doc ;# as root\n \n+When using configure, git may be built in a separate directory. Use\n+\n+\t$ mkdir builddir\n+\t$ cd builddir\n+\t$ GIT-SOURCE-DIR/configure [options]\n+\t$ make\n+\t# make install                          \n \n Issues of note:\n \ndiff --git a/Makefile b/Makefile\nindex a1861de..8e6ec62 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -97,7 +97,7 @@ # MakeMaker (e.g. using ActiveState unde\n #\n \n GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE\n-\t@$(SHELL_PATH) ./GIT-VERSION-GEN\n+\t@$(SHELL_PATH) $(srcdir)/GIT-VERSION-GEN\n -include GIT-VERSION-FILE\n \n uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')\n@@ -110,15 +110,20 @@ # CFLAGS and LDFLAGS are for the users t\n \n CFLAGS = -g -O2 -Wall\n LDFLAGS =\n-ALL_CFLAGS = $(CFLAGS)\n+ALL_CFLAGS = $(CFLAGS) -I.\n ALL_LDFLAGS = $(LDFLAGS)\n STRIP ?= strip\n \n prefix = $(HOME)\n bindir = $(prefix)/bin\n gitexecdir = $(bindir)\n-template_dir = $(prefix)/share/git-core/templates/\n-# DESTDIR=\n+datadir = $(prefix)/share\n+GIT_datadir = $(datadir)/git-core\n+template_dir = $(GIT_datadir)/templates/\n+srcdir = .\n+\n+# this is usually set on the make command line.\n+DESTDIR=\n \n # default configuration for gitweb\n GITWEB_CONFIG = gitweb_config.perl\n@@ -595,8 +600,8 @@ git-merge-recur$X: git-merge-recursive$X\n $(BUILT_INS): git$X\n \trm -f $@ && ln git$X $@\n \n-common-cmds.h: Documentation/git-*.txt\n-\t./generate-cmdlist.sh > $@+\n+common-cmds.h: $(wildcard $(srcdir)/Documentation/git-*.txt)\n+\t$(srcdir)/generate-cmdlist.sh $(srcdir)/Documentation/ > $@+\n \tmv $@+ $@\n \n $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh\n@@ -605,7 +610,7 @@ common-cmds.h: Documentation/git-*.txt\n \t    -e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \\\n \t    -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \\\n \t    -e 's/@@NO_CURL@@/$(NO_CURL)/g' \\\n-\t    $@.sh >$@+\n+\t    $^ >$@+\n \tchmod +x $@+\n \tmv $@+ $@\n \n@@ -626,7 +631,7 @@ perl/perl.mak: GIT-CFLAGS\n \t    -e '}' \\\n \t    -e 's|@@INSTLIBDIR@@|'\"$$INSTLIBDIR\"'|g' \\\n \t    -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \\\n-\t    $@.perl >$@+\n+\t    $^ >$@+\n \tchmod +x $@+\n \tmv $@+ $@\n \n@@ -670,7 +675,7 @@ git-instaweb: git-instaweb.sh gitweb/git\n \t    -e '/@@GITWEB_CGI@@/d' \\\n \t    -e '/@@GITWEB_CSS@@/r gitweb/gitweb.css' \\\n \t    -e '/@@GITWEB_CSS@@/d' \\\n-\t    $@.sh > $@+\n+\t    $< > $@+\n \tchmod +x $@+\n \tmv $@+ $@\n \ndiff --git a/config.mak.in b/config.mak.in\nindex 9a57840..bfbbf46 100644\n--- a/config.mak.in\n+++ b/config.mak.in\n@@ -10,17 +10,16 @@ #INSTALL = @INSTALL@\t\t# needs install-sh\n prefix = @prefix@\n exec_prefix = @exec_prefix@\n bindir = @bindir@\n-#gitexecdir = @libexecdir@/git-core/\n+mandir=@mandir@\n+\n+## unused, but necessary for some autoconf versions (?)\n datarootdir = @datarootdir@\n-template_dir = @datadir@/git-core/templates/\n \n-mandir=@mandir@\n \n srcdir = @srcdir@\n-VPATH = @srcdir@\n \n export exec_prefix mandir\n-export srcdir VPATH\n+export srcdir \n \n NEEDS_SSL_WITH_CRYPTO=@NEEDS_SSL_WITH_CRYPTO@\n NO_OPENSSL=@NO_OPENSSL@\ndiff --git a/configure.ac b/configure.ac\nindex 34e3478..403c410 100644\n--- a/configure.ac\n+++ b/configure.ac\n@@ -5,6 +5,7 @@ AC_PREREQ(2.59)\n AC_INIT([git], [@@GIT_VERSION@@], [git@vger.kernel.org])\n \n AC_CONFIG_SRCDIR([git.c])\n+srcdir=`cd $srcdir && pwd`\n \n config_file=config.mak.autogen\n config_append=config.mak.append\n@@ -334,6 +335,39 @@ ## Output files\n AC_CONFIG_FILES([\"${config_file}\":\"${config_in}\":\"${config_append}\"])\n AC_OUTPUT\n \n+if test \"$srcdir\" != \".\"; then\n+\n+  ## if we're building in another directory\n+  ## we need to set it up like the sourcedir\n+  for d in `cd $srcdir &&  find . -type d -print | grep -v '\\.git'` ;\n+  do\n+    if test ! -d  $d ; then\n+      echo creating $d \n+      mkdir $d\n+    fi\n+\n+    if test -f $srcdir/$d/Makefile ; then\n+\n+      dnl [[]] is to keep m4 happy\n+      depth=`echo $d/ | sed -e 's!^\\./!!g' -e 's![[^/]]*/!../!g'`\n+      echo creating $d/Makefile\n+\n+      if test \"$depth\"  = \"\";  then\n+        INCLUDE_AUTOGEN=\"include config.mak.autogen\" ;\n+      else\n+        INCLUDE_AUTOGEN=\"srcdir=$srcdir\" \n+      fi\n+ \n+      cat << EOF > $d/Makefile\n+$INCLUDE_AUTOGEN\n+VPATH = $srcdir/$d\n+export VPATH\n+include $srcdir/$d/Makefile\n+EOF\n+\n+    fi \n+  done\n+fi\n \n ## Cleanup\n rm -f \"${config_append}\"\ndiff --git a/generate-cmdlist.sh b/generate-cmdlist.sh\nindex 5450918..e744fbb 100755\n--- a/generate-cmdlist.sh\n+++ b/generate-cmdlist.sh\n@@ -47,6 +47,6 @@ do\n             x\n             s/.*git-'\"$cmd\"' - \\(.*\\)/  {\"'\"$cmd\"'\", \"\\1\"},/\n \t    p\n-     }' \"Documentation/git-$cmd.txt\"\n+     }' \"$1/git-$cmd.txt\"\n done\n echo \"};\"\ndiff --git a/perl/Makefile b/perl/Makefile\nindex 099beda..ae61cf6 100644\n--- a/perl/Makefile\n+++ b/perl/Makefile\n@@ -28,6 +28,10 @@ instdir_SQ = $(subst ','\\'',$(prefix)/li\n \techo instlibdir: >> $@\n \techo '\techo $(instdir_SQ)' >> $@\n else\n+\n+PERL_SRCDIR=$(srcdir)/perl\n+export PERL_SRCDIR\n+\n $(makfile): Makefile.PL ../GIT-CFLAGS\n \t'$(PERL_PATH_SQ)' $< PREFIX='$(prefix_SQ)'\n endif\ndiff --git a/perl/Makefile.PL b/perl/Makefile.PL\nindex 4168775..c136231 100644\n--- a/perl/Makefile.PL\n+++ b/perl/Makefile.PL\n@@ -8,21 +8,31 @@ instlibdir:\n MAKE_FRAG\n }\n \n-my %pm = ('Git.pm' => '$(INST_LIBDIR)/Git.pm');\n+\n+$src_prefix = \"\";\n+if (defined ($ENV{PERL_SRCDIR})) {\n+    $src_prefix = \"$ENV{PERL_SRCDIR}/\"\n+}\n+\n+\n+my %pm = (\"$src_prefix/Git.pm\" => '$(INST_LIBDIR)/Git.pm');\n+\n+\n \n # We come with our own bundled Error.pm. It's not in the set of default\n # Perl modules so install it if it's not available on the system yet.\n eval { require Error };\n if ($@) {\n-\t$pm{'private-Error.pm'} = '$(INST_LIBDIR)/Error.pm';\n+\t$pm{\"$src_prefix/private-Error.pm\"} = '$(INST_LIBDIR)/Error.pm';\n }\n \n my %extra;\n $extra{DESTDIR} = $ENV{DESTDIR} if $ENV{DESTDIR};\n \n+\n WriteMakefile(\n \tNAME            => 'Git',\n-\tVERSION_FROM    => 'Git.pm',\n+\tVERSION_FROM    => \"$src_prefix/Git.pm\",\n \tPM\t\t=> \\%pm,\n \tMAKEFILE\t=> 'perl.mak',\n \t%extra\n \n \n-- \n Han-Wen Nienhuys - hanwen@xs4all.nl - http://www.xs4all.nl/~hanwen\n"},{"id":"295308","messageId":"7vbqm9xz8z.fsf@assigned-by-dhcp.cox.net","threadId":"43338","inReplyTo":"eljo2u$pnq$2@sea.gmane.org","subject":"Re: [PATCH] Allow building GIT in a different directory from the source directory","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-12-12T09:03:08Z","receivedAt":"2006-12-12T09:03:08Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Han-Wen Nienhuys <hanwen@xs4all.nl> writes:\n\n> GIT can now be built in a separate builddirectory. This is done as\n> follows:\n>\n>   mkdir build\n>   cd build\n>   $my_git_dir/configure\n>   make\n\nSomehow making this depend on the use of configure feels wrong,\nsince we tried to keep that config.mak.gen built by configure\nstrictly optional.  In other words, I think the result of your\npatch should be buildable with or without ./configure in a\nseparate directory if we are going to do this.\n\nCare to explain why it is too cumbersome to handle without\n./configure magic?\n"},{"id":"296697","messageId":"457E979F.9060307@xs4all.nl","threadId":"43338","inReplyTo":"7vbqm9xz8z.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Allow building GIT in a different directory from the source directory","fromName":"Han-Wen Nienhuys","fromEmail":"hanwen@xs4all.nl","sentAt":"2006-12-12T11:50:55Z","receivedAt":"2006-12-12T11:50:55Z","isPatch":true,"sender":{"key":"hanwen@google.com","avatar":"https://avatars.githubusercontent.com/u/31547?v=4"},"body":"Junio C Hamano escreveu:\n> Han-Wen Nienhuys <hanwen@xs4all.nl> writes:\n> \n>> GIT can now be built in a separate builddirectory. This is done as\n>> follows:\n>>\n>>   mkdir build\n>>   cd build\n>>   $my_git_dir/configure\n>>   make\n> \n> Somehow making this depend on the use of configure feels wrong,\n> since we tried to keep that config.mak.gen built by configure\n> strictly optional.  In other words, I think the result of your\n> patch should be buildable with or without ./configure in a\n> separate directory if we are going to do this.\n> \n> Care to explain why it is too cumbersome to handle without\n> ./configure magic?\n\nI already tried to explain in a previous thread on the list. \nSee \n\n  http://article.gmane.org/gmane.comp.version-control.git/33487\n  \nyou can still build git in the same directory as source \nwithout using autoconf, and plain make.\n\nIf you insist, I can create a separate\n\n  setup-builddir.sh\n\nto setup the build directory; according to the principle of least\nsurprise, it should happen in the configure script though.\n\nI still don't understand the problem with autoconf; there are already\nplenty of baroque shell scripts in GIT.  I hate writing m4 macros as\nwell, but that's not a problem for GIT users (ie. people who compile\nGIT).\n\nFor them, \n\n  ./configure ; make ; make check ; make install\n\nis actually the standard way to compile stuff.\n\n\n-- \n"},{"id":"294404","messageId":"Pine.LNX.4.63.0612121951000.2807@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"43338","inReplyTo":"457E979F.9060307@xs4all.nl","subject":"Re: [PATCH] Allow building GIT in a different directory from the source directory","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-12-12T18:55:06Z","receivedAt":"2006-12-12T18:55:06Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 12 Dec 2006, Han-Wen Nienhuys wrote:\n\n> I still don't understand the problem with autoconf; there are already \n> plenty of baroque shell scripts in GIT.  I hate writing m4 macros as \n> well, but that's not a problem for GIT users (ie. people who compile \n> GIT).\n\nThat, together with the complexity of GIT_EXEC_DIR and path mangling \nproblems, makes me take every opportunity to suggest we should build in \nmost if not all of Git into the \"git wrapper\".\n\nGranted, without completion scripts, the \"git-\" convention was nice.\n\nGranted, with bash, Perl and even Python, you can rapidly prototype your \nthoughts (even if I often miss the power of C there).\n\nBut in the end, I'd say it makes lots of sense to have everything in one \nexecutable.\n\nCiao,\nDscho\n"},{"id":"298202","messageId":"457FC7A3.60206@op5.se","threadId":"43338","inReplyTo":"Pine.LNX.4.63.0612121951000.2807@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH] Allow building GIT in a different directory from the source directory","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2006-12-13T09:28:03Z","receivedAt":"2006-12-13T09:28:03Z","isPatch":true,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"Johannes Schindelin wrote:\n> Hi,\n> \n> On Tue, 12 Dec 2006, Han-Wen Nienhuys wrote:\n> \n>> I still don't understand the problem with autoconf; there are already \n>> plenty of baroque shell scripts in GIT.  I hate writing m4 macros as \n>> well, but that's not a problem for GIT users (ie. people who compile \n>> GIT).\n> \n> That, together with the complexity of GIT_EXEC_DIR and path mangling \n> problems, makes me take every opportunity to suggest we should build in \n> most if not all of Git into the \"git wrapper\".\n> \n> Granted, without completion scripts, the \"git-\" convention was nice.\n> \n> Granted, with bash, Perl and even Python, you can rapidly prototype your \n> thoughts (even if I often miss the power of C there).\n> \n\nWe could still allow that by simply not removing the \"run this external \nprogram\" code from the git wrapper even if we make all default commands \nbuilt-ins. Pluggable git, just as it is today, and when something turns \nout to be useful, feature-complete and stable enough \"someone\" will \nhopefully hop in to make it a built-in.\n\n> But in the end, I'd say it makes lots of sense to have everything in one \n> executable.\n> \n\nYup. Not least for portability issues. The lack of a native windows \nclient has already made us lose at least one major \"customer\", and afaiu \nit was *only* the lack of a native windows client that caused this, so \nobviously it's a big issue for big cross-platform projects.\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\n"}]}