You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by "Ralf S. Engelschall" <rs...@engelschall.com> on 1998/10/27 15:40:21 UTC

[PATCH] Build outside of source tree (take 2: alternative solution)

Ok, today I'd spent 4 hours on Wilfredo Sanchez's `[PATCH] Build outside of
source tree', fighted unsuccessfully with special cases which were not taken
into account and finally disovered that an alternative solution is possible
which provides exactly the same functionality. So I'd investigated again
one hour and created the above patch. 

It provides a --shadow=DIR option variant for APACI in addition to the already
existing --shadow option. The difference is just this now:

   --shadow ........ creates an internal build shadow tree

   --shadow=DIR .... creates first an external build shadow tree
                     and then there the internal build shadow tree

The result is obvious: With --shadow=DIR you now can mount the extracted
Apache distribution tree read-only from NFS or CDROM or whatever and still use
the complete functionality of APACI, _INCLUDING_ creating the internal build
shadow trees to solve the parallel-platform conflict.

The patch to configure and Makefile.tmpl is a little bit shorter than
Wilfredo's patch. But it has two major differnces: First $(TOP) is still
existing and can even fixed so it now can be used a little bit like VPATH. And
second the special cases for APACI are gone which means we reduce the
possibilities of bugs and problems. Just one thing we have to change: We have
to use the -h (don't follow symlinks) option of `tar' under `make install'. I
checked this against FreeBSD, Linux, SunOS and Solaris and -h really seems a
very old and well-supported option.

Now the use case:

    $ cd apache_1.3.x
    $ ./configure --shadow=/tmp/apache [...]
    $ make -f /tmp/apache/Makefile
    $ make -f /tmp/apache/Makefile install

Or alternatively:

    $ cd apache_1.3.x
    $ ./configure --shadow=/tmp/apache [...]
    $ cd /tmp/apache
    $ make 
    $ make install

As you can see this is _very_ similar to the non-shadow situation ;-):

    $ cd apache_1.3.x
    $ ./configure [...]
    $ make 
    $ make install

Wilfredo and Martin: I appreciate that especially you guys please 
try it out and give feedback. Because you wanted this feature... ;-)

Greetings,
                                       Ralf S. Engelschall
                                       rse@engelschall.com
                                       www.engelschall.com
Index: src/CHANGES
===================================================================
RCS file: /e/apache/REPOS/apache-1.3/src/CHANGES,v
retrieving revision 1.1125
diff -u -r1.1125 CHANGES
--- CHANGES	1998/10/27 10:20:00	1.1125
+++ CHANGES	1998/10/27 14:27:40
@@ -1,5 +1,13 @@
 Changes with Apache 1.3.4
 
+  *) Add APACI --shadow=DIR variant (in addition to --shadow). This now first
+     creates an external package shadow tree in DIR before the local build
+     shadow tree is generated under DIR. This way one can have the extracte
+     Apache distribution tree read-only on NFS or CDROM and still build Apache
+     from these sources. An automatically triggered VPATH-like mechanism is
+     provided through the TOP variable, too.
+     [Ralf S. Engelschall, Wilfredo Sanchez <ws...@apple.com>]
+
   *) Add APACI --permute-module=foo:bar option which can be used to
      on-the-fly/batch permute the order of two modules (mod_foo and mod_bar)
      in the Configuration[.apaci] file. Two special and important variants are
Index: configure
===================================================================
RCS file: /e/apache/REPOS/apache-1.3/configure,v
retrieving revision 1.49
diff -u -r1.49 configure
--- configure	1998/10/27 10:20:12	1.49
+++ configure	1998/10/27 14:13:27
@@ -77,6 +77,7 @@
 addconf=src/.apaci.addconf
 tplconf=src/.apaci.tplconf
 configstatus=config.status
+shadow=''
 
 ##
 ##  pre-determine runtime modes
@@ -337,7 +338,27 @@
         --verbose | -v)
             verbose=yes
             ;;
-        --shadow)
+        --shadow*)
+            #   if we use an external shadow tree, first shadow all of ourself
+            #   to this tree and switch over to to it for internal (=platform)
+            #   shadowing...
+            case "$apc_option" in
+                --shadow=*)
+                    shadow="$apc_optarg"
+                    if [ .$quiet = .no ]; then
+                        echo " + creating external package shadow tree ($shadow)"
+                    fi
+                    rm -rf $shadow 2>/dev/null
+                    $aux/mkshadow.sh . $shadow
+                    for file in $mkf $sedsubst $addconf $tplconf $configstatus; do
+                        rm -f $shadow/$file 2>/dev/null
+                    done
+                    if [ .$quiet = .no ]; then
+                        echo " + switching to external package shadow tree ($shadow)"
+                    fi
+                    cd $shadow
+                    ;;
+            esac
             #   determine GNU platform triple
             gnutriple=`$aux/GuessOS | sed -e 's:/:-:g' | $AWK '{ printf("%s",$1); }'`
             #   create Makefile wrapper (the first time only)
@@ -349,10 +370,15 @@
                 echo "##  Apache Makefile (shadow wrapper)" >> Makefile
                 echo "##" >> Makefile
                 echo "" >> Makefile
+                if [ ".$shadow" != . ]; then
+                    echo "SHADOW=$shadow" >> Makefile
+                else
+                    echo "SHADOW=." >> Makefile
+                fi
                 echo "GNUTRIPLE=\`$aux/GuessOS | sed -e 's:/:-:g' | $AWK '{ printf(\"%s\",\$\$1); }'\`" >> Makefile
                 echo "" >> Makefile
                 echo "all build install install-quiet clean distclean:" >> Makefile
-                echo "	@\$(MAKE) -f Makefile.\$(GNUTRIPLE) \$(MFLAGS) \$@" >> Makefile
+                echo "	@cd \$(SHADOW); \$(MAKE) -f Makefile.\$(GNUTRIPLE) \$(MFLAGS) \$@" >> Makefile
                 echo "" >> Makefile
             fi
             #   set shadow paths
@@ -364,7 +390,7 @@
             shadowtplconf="src.$gnutriple/.apaci.tplconf"
             #   (re)create shadow tree
             if [ .$quiet = .no ]; then
-                echo " + create shadow tree ($shadowsrc)"
+                echo " + creating internal platform shadow tree ($shadowsrc)"
             fi
             rm -rf $shadowsrc
             $aux/mkshadow.sh $src $shadowsrc
@@ -1175,5 +1201,21 @@
      sed -e '/^Using config file:.*/d' \
          -e "s:Makefile in :Makefile in $src\\/:" \
          -e "s:Makefile\$:Makefile in $src:")
+fi
+
+##
+##  final hints
+##
+if [ .$quiet = .no ]; then
+    if [ ".$shadow" != . ]; then
+        echo "Hint: You now have to build inside $shadow."
+        echo "This can be done either by running the canonical commands"
+        echo "  \$ cd $shadow"
+        echo "  \$ make"
+        echo "  \$ make install"
+        echo "or by running this alternative commands"
+        echo "  \$ make -f $shadow/Makefile"
+        echo "  \$ make -f $shadow/Makefile install"
+    fi
 fi
 
Index: Makefile.tmpl
===================================================================
RCS file: /e/apache/REPOS/apache-1.3/Makefile.tmpl,v
retrieving revision 1.48
diff -u -r1.48 Makefile.tmpl
--- Makefile.tmpl	1998/09/19 12:41:48	1.48
+++ Makefile.tmpl	1998/10/27 14:24:15
@@ -70,7 +70,7 @@
 SHELL           = /bin/sh
 
 #   paths to the source tree parts
-TOP             = @TOP@
+TOP             = .
 SRC             = @SRC@
 MKF             = @MKF@
 AUX             = @AUX@
@@ -147,7 +147,7 @@
 #   build the package
 build:
 	@echo "===> $(SRC)"
-	@$(MAKE) -f $(MKF) $(MFLAGS) $(MFWD) build-std $(build-support)
+	@$(MAKE) -f $(TOP)/$(MKF) $(MFLAGS) $(MFWD) build-std $(build-support)
 	@touch $(TOP)/$(SRC)/.apaci.build.ok
 	@echo "<=== $(SRC)"
 
@@ -183,11 +183,11 @@
 #   separate parts of the installation process.
 install:
 	@if [ ! -f $(TOP)/$(SRC)/.apaci.build.ok ]; then \
-		$(MAKE) -f $(MKF) $(MFLAGS) $(MFWD) build; \
+		$(MAKE) -f $(TOP)/$(MKF) $(MFLAGS) $(MFWD) build; \
 	else \
 		:; \
 	fi
-	@$(MAKE) -f $(MKF) $(MFLAGS) $(MFWD) \
+	@$(MAKE) -f $(TOP)/$(MKF) $(MFLAGS) $(MFWD) \
 		install-mktree install-programs $(install-support) \
 		install-include install-data install-config
 	-@$(RM) $(SRC)/.apaci.install.tmp
@@ -213,7 +213,7 @@
 
 #   the non-verbose variant for package maintainers
 install-quiet:
-	@$(MAKE) -f $(MKF) $(MFLAGS) $(MFWD) QUIET=1 install
+	@$(MAKE) -f $(TOP)/$(MKF) $(MFLAGS) $(MFWD) QUIET=1 install
 
 #   create the installation tree
 install-mktree:
@@ -344,8 +344,8 @@
 		echo "[PRESERVING EXISTING DATA SUBDIR: $(root)$(datadir)/htdocs/]"; \
 	else \
 		echo "Copying tree $(TOP)/htdocs/ -> $(root)$(datadir)/htdocs/"; \
-		(cd $(TOP)/htdocs/ && $(TAR) cf - *) |\
-		(cd $(root)$(datadir)/htdocs/ && $(TAR) xf -); \
+		(cd $(TOP)/htdocs/ && $(TAR) -hcf - *) |\
+		(cd $(root)$(datadir)/htdocs/ && $(TAR) -xf -); \
 		find $(root)$(datadir)/htdocs/ -type d -exec chmod a+rx {} \; ; \
 		find $(root)$(datadir)/htdocs/ -type f -exec chmod a+r {} \; ; \
 	fi
@@ -361,8 +361,8 @@
 		done; \
 	fi
 	@echo "Copying tree $(TOP)/icons/ -> $(root)$(datadir)/icons/"; \
-	(cd $(TOP)/icons/ && $(TAR) cf - *) |\
-	(cd $(root)$(datadir)/icons/ && $(TAR) xf -); \
+	(cd $(TOP)/icons/ && $(TAR) -hcf - *) |\
+	(cd $(root)$(datadir)/icons/ && $(TAR) -xf -); \
 	find $(root)$(datadir)/icons/ -type d -exec chmod a+rx {} \; ;\
 	find $(root)$(datadir)/icons/ -type f -exec chmod a+r {} \;
 	@echo "<=== [data]"
@@ -427,7 +427,7 @@
 #   created by the build target
 clean:
 	@echo "===> $(SRC)"
-	@$(MAKE) -f $(MKF) $(MFLAGS) $(MFWD) clean-std $(clean-support)
+	@$(MAKE) -f $(TOP)/$(MKF) $(MFLAGS) $(MFWD) clean-std $(clean-support)
 	@echo "<=== $(SRC)"
 	@$(RM) $(TOP)/$(SRC)/.apaci.build.ok
 
@@ -450,14 +450,14 @@
 #   When --shadow is used we just remove the complete shadow tree.
 distclean:
 	@if [ ".$(SRC)" = .src ]; then \
-		$(MAKE) -f $(MKF) $(MFLAGS) $(MFWD) distclean-normal; \
+		$(MAKE) -f $(TOP)/$(MKF) $(MFLAGS) $(MFWD) distclean-normal; \
 	else \
-		$(MAKE) -f $(MKF) $(MFLAGS) $(MFWD) distclean-shadow; \
+		$(MAKE) -f $(TOP)/$(MKF) $(MFLAGS) $(MFWD) distclean-shadow; \
 	fi
 
 distclean-normal:
 	@echo "===> $(SRC)"
-	@$(MAKE) -f $(MKF) $(MFLAGS) $(MFWD) distclean-std $(distclean-support)
+	@$(MAKE) -f $(TOP)/$(MKF) $(MFLAGS) $(MFWD) distclean-std $(distclean-support)
 	@echo "<=== $(SRC)"
 	-$(RM) $(SRC)/Configuration.apaci
 	-$(RM) $(SRC)/apaci
@@ -480,7 +480,7 @@
 
 distclean-shadow:
 	$(RM) -r $(SRC)
-	$(RM) $(MKF)
+	$(RM) $(TOP)/$(MKF)
 	-@if [ ".`ls $(TOP)/src.* 2>/dev/null`" = . ]; then \
 		echo "$(RM) Makefile"; \
 		$(RM) Makefile; \
Index: INSTALL
===================================================================
RCS file: /e/apache/REPOS/apache-1.3/INSTALL,v
retrieving revision 1.45
diff -u -r1.45 INSTALL
--- INSTALL	1998/10/27 10:20:13	1.45
+++ INSTALL	1998/10/27 11:59:50
@@ -141,26 +141,27 @@
        [INCLUDES=...]  [LDFLAGS_SHLIB_EXPORT=...] 
        [LDFLAGS=...]   [RANLIB=...]  
        [LIBS=...] 
-       ./configure [--quiet]   [--prefix=DIR]         [--enable-rule=NAME]    
-                   [--verbose] [--exec-prefix=PREFIX] [--disable-rule=NAME]   
-                   [--shadow]  [--bindir=EPREFIX]     [--add-module=FILE]     
-                   [--help]    [--sbindir=DIR]        [--activate-module=FILE]
-                   [--layout]  [--libexecdir=DIR]     [--enable-module=NAME]  
-                               [--mandir=DIR]         [--disable-module=NAME] 
-                               [--sysconfdir=DIR]     [--enable-shared=NAME]  
-                               [--datadir=DIR]        [--disable-shared=NAME] 
-                               [--includedir=DIR]     [--permute-module=N1:N2]
-                               [--localstatedir=DIR]  
-                               [--runtimedir=DIR]     [--enable-suexec]        
-                               [--logfiledir=DIR]     [--suexec-caller=UID]    
-                               [--proxycachedir=DIR]  [--suexec-userdir=DIR]   
-                               [--compat]             [--suexec-uidmin=UID]    
-                                                      [--suexec-gidmin=GID]    
-                                                      [--suexec-safepath=PATH] 
-                                                                                
-                                                      [--with-perl=FILE]       
-                                                      [--without-support]      
-                                                      [--without-confadjust]   
+       ./configure
+		   [--quiet]         [--prefix=DIR]         [--enable-rule=NAME]    
+		   [--verbose]       [--exec-prefix=PREFIX] [--disable-rule=NAME]   
+		   [--shadow[=DIR]]  [--bindir=EPREFIX]     [--add-module=FILE]     
+		   [--help]          [--sbindir=DIR]        [--activate-module=FILE]
+		   [--layout]        [--libexecdir=DIR]     [--enable-module=NAME]  
+					         [--mandir=DIR]         [--disable-module=NAME] 
+					         [--sysconfdir=DIR]     [--enable-shared=NAME]  
+					         [--datadir=DIR]        [--disable-shared=NAME] 
+					         [--includedir=DIR]     [--permute-module=N1:N2]
+					         [--localstatedir=DIR]  
+					         [--runtimedir=DIR]     [--enable-suexec]        
+					         [--logfiledir=DIR]     [--suexec-caller=UID]    
+					         [--proxycachedir=DIR]  [--suexec-userdir=DIR]   
+					         [--compat]             [--suexec-uidmin=UID]    
+											        [--suexec-gidmin=GID]    
+											        [--suexec-safepath=PATH] 
+																		
+											        [--with-perl=FILE]       
+											        [--without-support]      
+											        [--without-confadjust]   
 
      Use the CC, OPTIM, CFLAGS, INCLUDES, LDFLAGS, LIBS, CFLAGS_SHLIB,
      LD_SHLIB, LDFLAGS_SHLIB, LDFLAGS_SHLIB_EXPORT and RANLIB environment
@@ -389,8 +390,9 @@
 
      Use the --shadow option to let APACI create a shadow source tree of the
      sources for building. This is useful when you want to build for different
-     platforms in parallel (usually through a NFS, AFS or DFS mounted
-     filesystem).
+	 platforms in parallel (usually through a NFS, AFS or DFS mounted
+	 filesystem).  You may specify a directory to the --shadow option into
+	 which the shadow tree will be created.
  
      Use the --quiet option to disable all configuration verbose messages.
  
Index: src/helpers/mkshadow.sh
===================================================================
RCS file: /e/apache/REPOS/apache-1.3/src/helpers/mkshadow.sh,v
retrieving revision 1.3
diff -u -r1.3 mkshadow.sh
--- mkshadow.sh	1998/09/16 20:49:25	1.3
+++ mkshadow.sh	1998/10/27 13:42:34
@@ -19,18 +19,35 @@
 src=`echo $1 | sed -e 's:/$::'`
 dst=`echo $2 | sed -e 's:/$::'`
 
-#   determine if source is an absolute path
+#   check whether source exists
+if [ ! -d $src ]; then
+    echo "mkshadow.sh:Error: source directory not found" 1>&2
+    exit 1
+fi
+
+#   determine if one is an absolute path,
+#   because then we have to use an absolute symlink
+oneisabs=0
 case $src in
-    /* ) srcisabs=1 ;;
-     * ) srcisabs=0 ;;
+    /* ) oneisabs=1 ;;
 esac
-
-#   determine reverse directory to directory
 case $dst in
-    /* ) dstrevdir='' ;;
-     * ) dstrevdir="`$src/helpers/fp2rp $dst`/" ;;
+    /* ) oneisabs=1 ;;
 esac
 
+#   determine reverse directory for destination directory
+dstrevdir=''
+if [ $oneisabs = 0 ]; then
+    #   (inlined fp2rp)
+    OIFS2="$IFS"; IFS='/'
+    for pe in $dst; do
+        dstrevdir="../$dstrevdir"
+    done
+    IFS="$OIFS2"
+else
+    src="`cd $src; pwd`";
+fi
+
 #   create directory tree at destination
 if [ ! -d $dst ]; then
     mkdir $dst
@@ -48,7 +65,7 @@
 
 #   fill directory tree with symlinks to files
 FILES="`cd $src
-        find . -type f -depth -print |\
+        find . -depth -print |\
         sed -e '/\.o$/d' \
             -e '/\.a$/d' \
             -e '/\.so$/d' \
@@ -63,23 +80,29 @@
             -e 's/^\.\///'`"
 OIFS="$IFS" IFS="$DIFS"
 for file in $FILES; do
+     #  don't use `-type f' above for find because of symlinks
+     if [ -d $file ]; then
+         continue
+     fi
      basename=`echo $file | sed -e 's:^.*/::'`
      dir=`echo $file | sed -e 's:[^/]*$::' -e 's:/$::' -e 's:$:/:' -e 's:^/$::'`
      from="$src/$file"
      to="$dst/$dir$basename"
-     if [ $srcisabs = 0 -a ".$dir" != . ]; then
-         subdir=`echo $dir | sed -e 's:/$::'`
-         #   (inlined fp2rp)
-         revdir=''
-         OIFS2="$IFS"; IFS='/'
-         for pe in $subdir; do
-             revdir="../$revdir"
-         done
-         IFS="$OIFS2"
-         #   finalize from
-         from="$revdir$from"
+     if [ $oneisabs = 0 ]; then
+         if [ ".$dir" != . ]; then
+             subdir=`echo $dir | sed -e 's:/$::'`
+             #   (inlined fp2rp)
+             revdir=''
+             OIFS2="$IFS"; IFS='/'
+             for pe in $subdir; do
+                 revdir="../$revdir"
+             done
+             IFS="$OIFS2"
+             #   finalize from
+             from="$revdir$from"
+         fi
+         from="$dstrevdir$from"
      fi
-     from="$dstrevdir$from"
      echo "    $to"
      ln -s $from $to
 done