source: trunk/doc/build-system @ 14489

Revision 14489, 10.6 KB checked in by ghudson, 24 years ago (diff)
Document "do dist" operation.
Line 
1This document explains how to build packages from the Athena source
2tree, and then describes guidelines for designing the build system for
3code we maintain in the Athena source tree.  A discussion of building
4packages we get from third parties is in the file "third-party" in
5this directory.
6
7This file contains the following sections:
8
9        Building packages from the source tree
10        Building the tree
11        Generic build system guidelines
12        Using Autoconf
13        Using a straight Makefile
14
15Building packages from the source tree
16--------------------------------------
17
18To build a package from the Athena source tree, you should generally
19first attach the source tree that you want.  You can either attach a
20locker like "source-8.0" or "source-8.1" to get the sources for a
21particular release, or you can attach "source" to get the current
22development sources.  Releases prior to 8.1 will not build using the
23procedure below.  Note that you can only build whole packages, not
24arbitrary subdirectories; package names are listed in
25packs/build/packages.
26
27After attaching the correct locker, you can build a package by doing:
28
29        set src = /mit/source           # or /mit/source-8.1, etc.
30        mkdir /var/tmp/PACKAGE-NAME
31        cd /var/tmp/PACKAGE-NAME
32        synctree -s $src/PATH-TO-PACKAGE -d . -a $src/.rconf
33        sh $src/packs/build/do.sh dist
34        sh $src/packs/build/do.sh prepare
35        sh $src/packs/build/do.sh all
36
37If you are building the from the current sources (that is, $src is
38/mit/source), the package may have dependencies on changes which have
39been made since the last release.  In this case, use the "-c" flag to
40do.sh to make the build use a recent build for tools and libraries.
41The last three commands are then:
42
43        sh $src/packs/build/do.sh -c dist
44        sh $src/packs/build/do.sh -c prepare
45        sh $src/packs/build/do.sh -c all
46
47"do" accepts the following options (-c and -t are mutually exclusive):
48
49        -s SRCDIR       Specifies the source hierarchy, if not default
50        -d DESTDIR      Specifies the install hierarchy, if not
51                        /afs/dev.mit.edu/system/$ATHENA_SYS/srvd-current
52        -t TOOLDIR      Specifies the tool hierarchy
53        -c              Sets the tool hierarchy to the install
54                        hierarchy
55        -n              Show what build steps would be done, but don't
56                        do them
57
58The default location for SRCDIR is the source locker you attached
59(/mit/source, /mit/source-8.1, etc.).  "do" supports the following
60build operations:
61
62        dist            Copy in or create any materials necessary to
63                        make source tree suitable for distribution
64        prepare         Set up the source tree for building
65        clean           Clean any files generated by the "all" operation
66        all             Create automatically generated files
67        check           Perform automated tests, if any
68        install         Install in DESTDIR specified by -d (or default)
69
70Building the tree
71-----------------
72
73To build the entire tree by hand, attach an appropriate source locker
74and do something like the following:
75
76        set src = /mit/source
77        mkdir /var/tmp/build
78        cd /var/tmp/build
79        synctree -s $src -d .
80        sh $src/packs/build/build.sh -b `pwd` -d /var/tmp/inst
81
82"build" accepts the following options:
83
84        -s SRCDIR       Specifies the source hierarchy, if not default
85        -b BUILDDIR     Specifies the build hierarchy, if not /build
86        -d DESTDIR      Specifies the install hierarchy, if not /.srvd
87        -k              Keep going if a package fails to build
88        -n              Only display a list of packages to be built
89        -l              Log build output to a file.
90
91As with "do", the default location for SRCDIR is the source locker you
92attached.
93
94Building the tree has the following requirements right now:
95
96        * The system passwd file must have "pop" and "discuss" users.
97          Athena machines should typically have these lines in them
98          already, but you may have to add them on non-Athena systems.
99
100        * You must have write access to the destination hierarchy, and
101          be able to chown files and make setuid root files in that
102          tree.
103
104        * On Solaris, you need system:authuser access to the Athena
105          cell in order to build third/gcc (since it is bootstrapped
106          with the sunsoft compiler).
107
108Therefore, if you have a machine newly installed with the vendor
109operating system and AFS, and you want to build the Athena source tree
110for the first time, you have to do a little work beforehand:
111
112        * Make a temporary directory to put binaries in:
113
114                mkdir /var/tmp/bin
115                set path = ($path /var/tmp/bin)
116
117        * You need a functioning synctree.  The sources are in
118          athena/etc/synctree; because they are not world-readable,
119          you may need to copy the sources somewhere temporary from
120          another workstation in order to get them onto the machine
121          you're building on.  Once you have a copy of the sources,
122          building them is relatively easy:
123
124                set src = /afs/dev.mit.edu/source/src-current
125                ./configure
126                make
127                cp synctree /var/tmp/bin
128                rehash
129
130        * You need a functioning kinit.  In the worst case, you may
131          need to do a partial build of third/krb5.
132
133                cd /var/tmp; mkdir krb5; cd krb5
134                synctree -s $src/third/krb5 -d . -a $src/.rconf
135                make -f Makefile.athena prepare
136                make -f Makefile.athena all
137
138                cp src/clients/kinit/kinit /var/tmp/bin
139                cp $src/packs/config/krb5.conf /etc
140                mkdir /etc/athena
141                cp $src/packs/config/krb.conf /etc/athena
142                cp $src/packs/config/krb.realms /etc/athena
143
144        * For Solaris, you need a functioning aklog.
145
146                cd /var/tmp; mkdir aklog; cd aklog
147                synctree -s $src/athena/bin/aklog -d . -a $src/.rconf
148                ./configure --with-afs=/usr/afsws # or wherever
149                make
150                cp aklog /var/tmp/bin
151
152        * For a few packages (third/perl and some things under packs),
153          /os must point to an image of the operating system.  A
154          symlink from /os to / will usually service if a pristine
155          operating system image is unavailable.
156
157With these tools, you should be able to set up the build environment
158as documented above.
159
160Generic build system guidelines
161-------------------------------
162
163Here are some desirable properties of a build system for programs or
164libraries, regardless of how it is implemented:
165
166        * It should use feature tests, not platform tests.
167
168        * Once the appropriate configuration steps (e.g. running
169          configure or imake) have been done, "make all" should
170          generate all automatically generated files without ever
171          modifying any source files.  (For example, "make all" should
172          not try to regenerate configure from configure.in, and a
173          build system should not wait until "make install" time to
174          generate a file which is going to be installed.)
175
176        * "make install" should install all files appropriate for the
177          target directories without modifying any files in the build
178          tree.  In particular, it should not depend on the "all"
179          target.
180
181          "make install" should use the install command to install
182          files, not cp or tar or shell redirection.  To install
183          multiple files in the same way, use a single install command
184          rather than a for loop.
185
186        * "make clean" should clean all files generated by "make all."
187          "make distclean" should also delete files generated by the
188          configuration steps.
189
190        * "make check" should run self-tests.  It should not assume
191          that the program has been installed, but it should assume
192          that the program has been built.  It should not modify the
193          build tree in any way; in particular, it should not depend
194          on the "all" target.  If there are no self-tests, "make
195          check" should not generate an error.
196
197        * In a multi-directory source tree, it should be possible to
198          change to a subdirectory of the build tree and run any of
199          the aforementioned make targets with the same results as
200          having descended into that directory from above.  It is okay
201          to assume that previous parts of the build tree have been
202          built, but it is not okay to rely on make command-line
203          parameters passed in from the parent directory.
204
205Using Autoconf
206--------------
207
208For packages in the "athena" hierarchy, we use autoconf.  Autoconf is
209not perfect, but it's the only reasonable package out there for doing
210feature tests as opposed to platform tests.  See the Autoconf info
211pages (available in the default emacs info menu) for information about
212using Autoconf in general.
213
214When we build the program for the Athena environment, we will use a
215config.site file (already written; you don't need to write it or point
216to it) which does the following:
217
218        * Sets the shell variable "athena" to "true".
219
220        * Sets the appropriate compiler (using the CC environment
221          variable) as well as other compilation tools (yacc, lex) for
222          the platform in question.
223
224        * Sets the appropriate X include path and library path for use
225          with AC_PATH_X.
226
227        * Sets the appropriate with_* variables for finding Motif, AFS
228          libraries, Kerberos 4, Kerberos 5, com_err, and ss.  If your
229          package uses any of those libraries, copy the aclocal.m4
230          file from packs/build and use the macros contained within.
231
232        * Sets prefix to /usr/athena, datadir to '${prefix}/lib',
233          sbindir to '${prefix}/etc', and sysconfdir to '/etc/athena'.
234          You do not need to take these into account in configure.in;
235          just put in your Makefile.in:
236
237                prefix=@prefix@
238                exec_prefix=@exec_prefix@
239                datadir=@datadir@
240                sbindir=@sbindir@
241                sysconfdir=@sysconfdir@
242
243        * Sets shell variables lbindir and lsbindir to /bin/athena and
244          /etc/athena respectively.  If your build system needs to
245          install files in /bin/athena or /etc/athena when built for
246          the Athena environment, use the following in your configure.in:
247
248                test -z "$lbindir" && lbindir='${bindir}'
249                test -z "$lsbindir" && lsbindir='${sbindir}'
250                AC_SUBST(lbindir)
251                AC_SUBST(lsbindir)
252
253          And then in your Makefile.in:
254
255                prefix=@prefix@
256                exec_prefix=@exec_prefix@
257                bindir=@bindir@
258                sbindir=@sbindir@
259                lbindir=@lbindir@
260                lsbindir=@lsbindir@
261
262The build environment will ensure that the following things are true:
263
264        * The environment variable ATHENA_SYS is set to the current
265          platform's desired ATHENA_SYS value (e.g. "sun4m_54").
266
267        * The environment variable HOSTTYPE is set to the current
268          platform name (e.g. "sun").
269
270        * The environment variable CONFIG_SITE points to the Athena
271          config.site file.
272
273Using a straight Makefile
274-------------------------
275
276For packages in the "packs" hierarchy, and in some parts of the
277"third" hierarchy where we construct the build system by hand, we use
278a straight Makefile, since feature tests are not necessary for the
279packs hierarchy.
280
281The build system will ensure that the same environment variables are
282set as for using Autoconf.  In addition, the make variable CC will be
283set to the appropriate compiler for the current platform when the
284"all" target is invoked.  You should be sparing in your use of C
285source code in packages using a straight Makefile, but for small,
286portable C programs it's okay.
287
288The subdirectories "platform/$HOSTTYPE" or "arch/$ATHENA_SYS" should
289be used for platform or system-dependent components of a package using
290a straight Makefile.
291
292Start each Makefile with "# $Id: $" and "SHELL=/bin/sh".  The latter
293is to work around a bug in the Irix make where it runs commands under
294${SHELL} rather than /bin/sh.
Note: See TracBrowser for help on using the repository browser.