source: trunk/doc/build-system @ 11199

Revision 11199, 9.9 KB checked in by ghudson, 26 years ago (diff)
Add a note about the /os dependency of the build system.
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/PACKGAGE-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 prepare
34        sh $src/packs/build/do.sh all
35
36"do" accepts the following options:
37
38        -s SRCDIR       Specifies the source hierarchy, if not default
39        -d DESTDIR      Specifies the install hierarchy, if not /srvd
40
41The default location for SRCDIR is the source locker you attached
42(/mit/source, /mit/source-8.1, etc.).  "do" recognizes supports the
43following build operations:
44
45        prepare         Set up the source tree for building
46        clean           Clean any files generated by the "all" operation
47        all             Create automatically generated files
48        check           Perform automated tests, if any
49        install         Install in /srvd (or dir given by -d option)
50
51Building the tree
52-----------------
53
54To build the entire tree by hand, you run packs/build/build.sh from
55the source directory.  Building the tree has the following
56requirements right now:
57
58        * The system passwd file must have "pop" and "discuss" users.
59          Athena machines should typically have these lines in them
60          already, but you may have to add them on non-Athena systems.
61
62        * The source tree must be findable in the default location
63          (/mit/source for the current sources), or you must tell
64          build.sh where to find the source tree using the -s option.
65
66        * You must have a link farm of the source tree generated by
67          synctree.  The default location is /build; you can specify
68          an alternative location with the -b option.
69
70        * You must have write access to a destination tree, and be
71          able to chown files and make setuid root files in that tree.
72          The default location is /srvd; you can specify an
73          alternative location with the -d option.
74
75        * On Solaris, you need system:authuser access to the Athena
76          cell in order to build third/gcc (since it is bootstrapped
77          with the sunsoft compiler).
78
79Therefore, if you have a machine newly installed with the vendor
80operating system and AFS, and you want to build the Athena source tree
81for the first time, you have to do a little work beforehand:
82
83        * Make a temporary directory to put binaries in:
84
85                mkdir /var/tmp/bin
86                set path = ($path /var/tmp/bin)
87
88        * You need a functioning synctree.  The sources are in
89          athena/etc/synctree; because they are not world-readable,
90          you may need to copy the sources somewhere temporary from
91          another workstation in order to get them onto the machine
92          you're building on.  Once you have a copy of the sources,
93          building them is relatively easy:
94
95                set src = /afs/dev.mit.edu/source/src-current
96                imake -I$src/packs/build/config -DUseInstalled
97                make
98                cp synctree /var/tmp/bin
99                rehash
100
101        * You need a functioning kinit.  In the worst case, you may
102          need to do a complete build of third/cns.
103
104                cd /var/tmp; mkdir cns; cd cns
105                synctree -s $src/third/cns -d . -a $src/.rconf
106                ./configure --site=athena
107                make
108                cp kuser/kinit /var/tmp/bin
109                mkdir /etc/athena
110                cp $src/packs/config/krb.conf /etc/athena
111                cp $src/packs/config/krb.realms /etc/athena
112
113        * You need a functioning aklog.
114
115                cd /var/tmp; mkdir aklog; cd aklog
116                synctree -s $src/athena/bin/aklog -d . -a $src/.rconf
117                imake -I$src/packs/build/config -DUseInstalled
118                make # or "make AFSDIR=/wherever" if AFS libs not in /usr/afsws
119                cp aklog /var/tmp/bin
120
121        * For a few packages (third/perl and some things under packs),
122          /os must point to an image of the operating system.  A
123          symlink from /os to / will usually service if a pristine
124          operating system image is unavailable.
125
126With these tools, you should be able to set up the build environment
127as documented above.
128
129Generic build system guidelines
130-------------------------------
131
132Here are some desirable properties of a build system for programs or
133libraries, regardless of how it is implemented:
134
135        * It should use feature tests, not platform tests.
136
137        * Once the appropriate configuration steps (e.g. running
138          configure or imake) have been done, "make all" should
139          generate all automatically generated files without ever
140          modifying any source files.  (For example, "make all" should
141          not try to regenerate configure from configure.in, and a
142          build system should not wait until "make install" time to
143          generate a file which is going to be installed.)
144
145        * "make install" should install all files appropriate for the
146          target directories without modifying any files in the build
147          tree.  In particular, it should not depend on the "all"
148          target.
149
150          "make install" should use the install command to install
151          files, not cp or tar or shell redirection.  To install
152          multiple files in the same way, use a single install command
153          rather than a for loop.
154
155        * "make clean" should clean all files generated by "make all."
156          "make distclean" should also delete files generated by the
157          configuration steps.
158
159        * "make check" should run self-tests.  It should not assume
160          that the program has been installed, but it should assume
161          that the program has been built.  It should not modify the
162          build tree in any way; in particular, it should not depend
163          on the "all" target.  If there are no self-tests, "make
164          check" should not generate an error.
165
166        * In a multi-directory source tree, it should be possible to
167          change to a subdirectory of the build tree and run any of
168          the aforementioned make targets with the same results as
169          having descended into that directory from above.  It is okay
170          to assume that previous parts of the build tree have been
171          built, but it is not okay to rely on make command-line
172          parameters passed in from the parent directory.
173
174Using Autoconf
175--------------
176
177For packages in the "athena" hierarchy, we use autoconf.  Autoconf is
178not perfect, but it's the only reasonable package out there for doing
179feature tests as opposed to platform tests.  See the Autoconf info
180pages (available in the default emacs info menu) for information about
181using Autoconf in general.
182
183When we build the program for the Athena environment, we will use a
184config.site file (already written; you don't need to write it or point
185to it) which does the following:
186
187        * Sets the shell variable "athena" to "true".
188
189        * Sets the appropriate compiler (using the CC environment
190          variable) as well as other compilation tools (yacc, lex) for
191          the platform in question.
192
193        * Sets the appropriate X include path and library path for use
194          with AC_PATH_X.
195
196        * Sets the appropriate with_* variables for finding Motif, AFS
197          libraries, Kerberos 4, Kerberos 5, com_err, and ss.  If your
198          package uses any of those libraries, copy the aclocal.m4
199          file from packs/build and use the macros contained within.
200
201        * Sets prefix to /usr/athena, datadir to '${prefix}/lib',
202          sbindir to '${prefix}/etc', and sysconfdir to '/etc/athena'.
203          You do not need to take these into account in configure.in;
204          just put in your Makefile.in:
205
206                prefix=@prefix@
207                exec_prefix=@exec_prefix@
208                datadir=@datadir@
209                sbindir=@sbindir@
210                sysconfdir=@sysconfdir@
211
212        * Sets shell variables lbindir and lsbindir to /bin/athena and
213          /etc/athena respectively.  If your build system needs to
214          install files in /bin/athena or /etc/athena when built for
215          the Athena environment, use the following in your configure.in:
216
217                test -z "$lbindir" && lbindir='${bindir}'
218                test -z "$lsbindir" && lsbindir='${sbindir}'
219                AC_SUBST(lbindir)
220                AC_SUBST(lsbindir)
221
222          And then in your Makefile.in:
223
224                prefix=@prefix@
225                exec_prefix=@exec_prefix@
226                bindir=@bindir@
227                sbindir=@sbindir@
228                lbindir=@lbindir@
229                lsbindir=@lsbindir@
230
231The build environment will ensure that the following things are true:
232
233        * The environment variable ATHENA_SYS is set to the current
234          platform's desired ATHENA_SYS value (e.g. "sun4m_54").
235
236        * The environment variable HOSTTYPE is set to the current
237          platform name (e.g. "sun").
238
239        * The environment variable CONFIG_SITE points to the Athena
240          config.site file.
241
242Using a straight Makefile
243-------------------------
244
245For packages in the "packs" hierarchy, and in some parts of the
246"third" hierarchy where we construct the build system by hand, we use
247a straight Makefile, since feature tests are not necessary for the
248packs hierarchy.
249
250The build system will ensure that the same environment variables are
251set as for using Autoconf.  In addition, the make variable CC will be
252set to the appropriate compiler for the current platform when the
253"all" target is invoked.  You should be sparing in your use of C
254source code in packages using a straight Makefile, but for small,
255portable C programs it's okay.
256
257The subdirectories "platform/$HOSTTYPE" or "arch/$ATHENA_SYS" should
258be used for platform or system-dependent components of a package using
259a straight Makefile.
260
261Start each Makefile with "# $Id: $" and "SHELL=/bin/sh".  The latter
262is to work around a bug in the Irix make where it runs commands under
263${SHELL} rather than /bin/sh.  Also necessary for Irix is using
264"-mkdir -p" instead of "mkdir -p", since mkdir -p under Irix gives an
265error when the directory already exists (in violation of IEEE 1003.2).
Note: See TracBrowser for help on using the repository browser.