<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
  <META NAME="GENERATOR" CONTENT="GtkHTML/3.3.2">
</HEAD>
<BODY>
Hi Tanya,<BR>
<BR>
The first thing you need to understand is that there are multiple make targets to support this feature. I'll briefly describe each here so you have an overview and then delve into the details later. 
<UL>
    <LI><B>distdir</B> - builds the distribution directory from which the distribution will be packaged 
    <LI><B>dist</B> - builds each of the distribution tarballs (tar.gz, tar.bzip2, .zip). These can be built individually as well, with separate targets. 
    <LI><B>dist-check</B> - this is identical to "dist" but includes a check on the distribution that ensures the tarball can: be unpacked, compiles correctly, passes 'make check', passes 'make clean'. 
    <LI><B>dist-clean </B>- this just does a normal clean but also cleans up the stuff generated by the other three "dist" targets (above).
</UL>
Okay, that's the basic functionality. When making a release, we want to ensure that the tree you build the distribution from passes "dist-check".  Beyond fixing the usual bugs, there is generally one impediment to making the release in this fashion: missing files.  The "dist-check" process guards against that possibility. It will either fail and that failure will indicate what's missing, or it will succeed meaning that it has proved that the tarballs can actually succeed in building LLVM correctly and that it passes "make check".  <BR>
<BR>
<BR>
<H3>
<B><FONT SIZE="4">distdir</FONT></B>
</H3>
This target builds the distribution directory which is the directory from which the tarballs are generated. The distribution directory has the same name as the release, e.g. LLVM-1.7).  This target goes through he following process: 
<OL TYPE=1>
    <LI TYPE=1 VALUE=1>First, if there was an old distribution directory (for the current release), it is removed in its entirety and you see "<TT>Removing old LLVM-1.7"</TT> 
    <LI TYPE=1 VALUE=2>Second, it issues a "<TT>make all ENABLE_OPTIMIZED=1</TT>" to ensure that the everything in your tree can be built in release mode. Often times there are discrepancies in building between debug and release modes so it enforces release mode first.  If that fails, the <TT>distdir</TT> target fails too. This is preceded by the message "<TT>Making 'all' to verify build</TT>". 
    <LI TYPE=1 VALUE=3>Next, it traverses your source tree and copies it to a new directory that has the name of the release (<TT>LLVM-1.7</TT> in our current case). This is the directory that will get tar'd. It contains all the software that needs to be in the distribution.  During the copying process, it omits generated files, CVS directories, and any other "cruft" that's in your build tree. This is done to eliminate the possibility of huge distribution tarballs that include useless or irrelevant stuff in them.  This is the trickiest part of making the distribution. Done manually you will either include stuff that shouldn't be in the distribution or exclude stuff that should. This step is preceded by the message "<TT>Building Distribution Directory LLVM-1.7</TT>" 
    <LI TYPE=1 VALUE=4>The distribution directory is then traversed and all <TT>CVS</TT> or .svn directories are removed. You see: "<TT>Eliminating CVS/.svn directories from distribution</TT>" 
    <LI TYPE=1 VALUE=5>The recursive <TT>dist-hook</TT> target is executed. This gives each directory a chance to modify the distribution in some way (more on this below). 
    <LI TYPE=1 VALUE=6>The distribution directory is traversed and the correct file permissions and modes are set based on the type of file. 
</OL>
To control the process of making the distribution directory correctly, each Makefile can utilize two features: 
<OL TYPE=1>
    <LI TYPE=1 VALUE=1><B><TT>EXTRA_DIST</TT></B> - this make variable specifies which files it should distribute. By default, all source files are automatically included for distribution as well as certain "well known" files (see DistAlways variable in Makefile.rules for details).  Each Makefile specifies, via the <TT>EXTRA_DIST</TT> variable, which additional files need to be distributed.  Only those files that are needed to build LLVM should be added to <TT>EXTRA_DIST</TT>.  <TT>EXTRA_DIST</TT> contains a list of file or directory names that should be distributed. For example, the top level Makefile contains "<TT>EXTRA_DIST := test llvm.spec include</TT>". This means that in addition to regular things that are distributed at the top level (<TT>CREDITS.txt, LICENSE.txt</TT>, etc.) the distribution should contain the entire <TT>test</TT> and <TT>include</TT> directories as well as the <TT>llvm.spec</TT> file. 
    <LI TYPE=1 VALUE=2><B><TT>dist-hook</TT></B> - this make target can be used to alter the content of the distribution directory.  For example, in the top level Makefile there is some logic to eliminate files in the <TT>include</TT> subtree that are generated by the configure script. These should not be distributed. Similarly, any <TT>dist-hook</TT> target found in any directory can add or remove or modify things just before it gets packaged. Any transformation is permitted. Generally, not much is needed.
</OL>
You will see various messages if things go wrong: 
<OL TYPE=1>
    <LI TYPE=1 VALUE=1>During the copying process, any files that are missing will be flagged with: "<TT>===== WARNING: Distribution Source 'dir/file' Not Found!</TT>" These must be corrected by either adding the file or removing it from EXTRA_DIST.
    <LI TYPE=1 VALUE=2>If you build the distribution with VERBOSE=1, then you might also see: "<TT>Skipping non-existent</TT><TT> </TT><TT>'dir/file'</TT>" in certain cases where its okay to skip the file. 
    <LI TYPE=1 VALUE=3>The target can fail if any of the things it does fail .. error messages should indicate what went wrong.
</OL>
<H3>
<B><FONT SIZE="4">dist</FONT></B>
</H3>
This target does exactly what <TT>distdir</TT> target does, but also includes assembling the tarballs. There are actually four related targets here: 
<UL>
    <LI><B><TT>dist-gzip</TT></B>: package the gzipped distribution tar file. The distribution directory is packaged into a single file ending in <TT>.tar.gz</TT> which is gzip compressed. 
    <LI><B><TT>dist-bzip2</TT></B>: package the bzip2 distribution tar file. The distribution directory is packaged into a single file ending in <TT>.tar.bzip2</TT> which is bzip2 compressed. 
    <LI><B><TT>dist-zip</TT></B>: package the zip distribution file. The distribution directory is packaged into a single file ending in <TT>.zip</TT> which is zip compressed. 
    <LI><B><TT>dist</TT></B>: does all three, dist-gzip, dist-bzip2, dist-zip
</UL>
<H3>
<B><FONT SIZE="4">dist-check</FONT></B>
</H3>
This target checks the distribution. The basic idea is that it unpacks the distribution tarball and ensures that it can build. It takes the following actions: 
<OL TYPE=1>
    <LI TYPE=1 VALUE=1>It depends on the <TT>dist-gzip</TT> target which, if it hasn't already been built, builds the gzip tar bundle (see dist and distdir above)
    <LI TYPE=1 VALUE=2>removes any pre-existing <TT>_distcheckdir</TT> at the top level. 
    <LI TYPE=1 VALUE=3>creates a new <TT>_distcheckdir</TT> directory at the top level 
    <LI TYPE=1 VALUE=4>creates a <TT>build</TT> subdirectory and an <TT>install</TT> subdirectory under <TT>_distcheckdir</TT> 
    <LI TYPE=1 VALUE=5>unzips and untars the release tarball into <TT>_distcheckdir</TT> , creating <TT>LLVM-1.7</TT> directory (from the tarball)
    <LI TYPE=1 VALUE=6>in the build subdirectory, it configures with appropriate options to build from the unpacked source tarball into the <TT>build</TT> directory with installation in the <TT>install</TT> directory 
    <LI TYPE=1 VALUE=7>runs <TT>make all</TT> 
    <LI TYPE=1 VALUE=8>runs <TT>make </TT><TT>check</TT> 
    <LI TYPE=1 VALUE=9>runs <TT>make install</TT> 
    <LI TYPE=1 VALUE=10>runs <TT>make uninstall</TT> 
    <LI TYPE=1 VALUE=11>runs <TT>make dist</TT> 
    <LI TYPE=1 VALUE=12>runs <TT>make clean</TT> 
    <LI TYPE=1 VALUE=13>runs <TT>make dist-clean</TT>
</OL>
If it can pass all that, the distribution will be deemed distribution worthy and you will see:<BR>
<TT>===== LLVM-1.7.tar.gz Ready For Distribution =====</TT><BR>
<BR>
This means the tarball should then be tested on other platforms and have the nightly test run against it. If those all pass, THEN its ready for distribution.<BR>
<BR>
A note about disk space: using "<TT>dist-check</TT>" will easily triple the amount of disk space your build tree is using. Might want to check available space before you being :)<BR>
<BR>
<H3>
<B><FONT SIZE="4">dist-clean</FONT></B>
</H3>
In addition to doing a normal "clean", this target will clean up the files and directories created by the distribution targets. In particular the distribution directory <TT>(LLVM-X.X</TT>), check directory (<TT>_distcheckdir</TT>), and the various tarballs will be removed.  You do this after the release has shipped and you no longer need this stuff in your build tree. <BR>
<BR>
<BR>
I hope this brief tutorial has helped.  Feel free to ask questions.  Further details can be found in Makefile.rules. <BR>
<BR>
Reid.<BR>
<BR>
On Tue, 2006-04-11 at 13:07 -0500, Tanya Lattner wrote: 
<BLOCKQUOTE TYPE=CITE>
<PRE>
<FONT COLOR="#000000">Reid,</FONT>

<FONT COLOR="#000000">Could you explain in detail what make dist does? :) I'd like to see how it </FONT>
<FONT COLOR="#000000">can be integrated into the release process.</FONT>

<FONT COLOR="#000000">Thanks,</FONT>
<FONT COLOR="#000000">Tanya</FONT>

<FONT COLOR="#000000">_______________________________________________</FONT>
<FONT COLOR="#000000">LLVM Developers mailing list</FONT>
<FONT COLOR="#000000"><A HREF="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</A>         <A HREF="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</A></FONT>
<FONT COLOR="#000000"><A HREF="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</A></FONT>
</PRE>
</BLOCKQUOTE>
</BODY>
</HTML>