source: trunk/doc/build-system @ 10941

Revision 10941, 9.7 KB checked in by ghudson, 27 years ago (diff)
Document pop and discuss users. We have self-consistent builds now (except for this nit about the man pages), so un-document the requirement about /usr/athena and /usr/afsws.
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
121With these tools, you should be able to set up the build environment
122as documented above.
123
124Generic build system guidelines
125-------------------------------
126
127Here are some desirable properties of a build system for programs or
128libraries, regardless of how it is implemented:
129
130        * It should use feature tests, not platform tests.
131
132        * Once the appropriate configuration steps (e.g. running
133          configure or imake) have been done, "make all" should
134          generate all automatically generated files without ever
135          modifying any source files.  (For example, "make all" should
136          not try to regenerate configure from configure.in, and a
137          build system should not wait until "make install" time to
138          generate a file which is going to be installed.)
139
140        * "make install" should install all files appropriate for the
141          target directories without modifying any files in the build
142          tree.  In particular, it should not depend on the "all"
143          target.
144
145          "make install" should use the install command to install
146          files, not cp or tar or shell redirection.  To install
147          multiple files in the same way, use a single install command
148          rather than a for loop.
149
150        * "make clean" should clean all files generated by "make all."
151          "make distclean" should also delete files generated by the
152          configuration steps.
153
154        * "make check" should run self-tests.  It should not assume
155          that the program has been installed, but it should assume
156          that the program has been built.  It should not modify the
157          build tree in any way; in particular, it should not depend
158          on the "all" target.  If there are no self-tests, "make
159          check" should not generate an error.
160
161        * In a multi-directory source tree, it should be possible to
162          change to a subdirectory of the build tree and run any of
163          the aforementioned make targets with the same results as
164          having descended into that directory from above.  It is okay
165          to assume that previous parts of the build tree have been
166          built, but it is not okay to rely on make command-line
167          parameters passed in from the parent directory.
168
169Using Autoconf
170--------------
171
172For packages in the "athena" hierarchy, we use autoconf.  Autoconf is
173not perfect, but it's the only reasonable package out there for doing
174feature tests as opposed to platform tests.  See the Autoconf info
175pages (available in the default emacs info menu) for information about
176using Autoconf in general.
177
178When we build the program for the Athena environment, we will use a
179config.site file (already written; you don't need to write it or point
180to it) which does the following:
181
182        * Sets the shell variable "athena" to "true".
183
184        * Sets the appropriate compiler (using the CC environment
185          variable) as well as other compilation tools (yacc, lex) for
186          the platform in question.
187
188        * Sets the appropriate X include path and library path for use
189          with AC_PATH_X.
190
191        * Sets the appropriate with_* variables for finding Motif, AFS
192          libraries, Kerberos 4, Kerberos 5, com_err, and ss.  If your
193          package uses any of those libraries, copy the aclocal.m4
194          file from packs/build and use the macros contained within.
195
196        * Sets prefix to /usr/athena, datadir to '${prefix}/lib',
197          sbindir to '${prefix}/etc', and sysconfdir to '/etc/athena'.
198          You do not need to take these into account in configure.in;
199          just put in your Makefile.in:
200
201                prefix=@prefix@
202                exec_prefix=@exec_prefix@
203                datadir=@datadir@
204                sbindir=@sbindir@
205                sysconfdir=@sysconfdir@
206
207        * Sets shell variables lbindir and lsbindir to /bin/athena and
208          /etc/athena respectively.  If your build system needs to
209          install files in /bin/athena or /etc/athena when built for
210          the Athena environment, use the following in your configure.in:
211
212                test -z "$lbindir" && lbindir='${bindir}'
213                test -z "$lsbindir" && lsbindir='${sbindir}'
214                AC_SUBST(lbindir)
215                AC_SUBST(lsbindir)
216
217          And then in your Makefile.in:
218
219                prefix=@prefix@
220                exec_prefix=@exec_prefix@
221                bindir=@bindir@
222                sbindir=@sbindir@
223                lbindir=@lbindir@
224                lsbindir=@lsbindir@
225
226The build environment will ensure that the following things are true:
227
228        * The environment variable ATHENA_SYS is set to the current
229          platform's desired ATHENA_SYS value (e.g. "sun4m_54").
230
231        * The environment variable HOSTTYPE is set to the current
232          platform name (e.g. "sun").
233
234        * The environment variable CONFIG_SITE points to the Athena
235          config.site file.
236
237Using a straight Makefile
238-------------------------
239
240For packages in the "packs" hierarchy, and in some parts of the
241"third" hierarchy where we construct the build system by hand, we use
242a straight Makefile, since feature tests are not necessary for the
243packs hierarchy.
244
245The build system will ensure that the same environment variables are
246set as for using Autoconf.  In addition, the make variable CC will be
247set to the appropriate compiler for the current platform when the
248"all" target is invoked.  You should be sparing in your use of C
249source code in packages using a straight Makefile, but for small,
250portable C programs it's okay.
251
252The subdirectories "platform/$HOSTTYPE" or "arch/$ATHENA_SYS" should
253be used for platform or system-dependent components of a package using
254a straight Makefile.
255
256Start each Makefile with "# $Id: $" and "SHELL=/bin/sh".  The latter
257is to work around a bug in the Irix make where it runs commands under
258${SHELL} rather than /bin/sh.  Also necessary for Irix is using
259"-mkdir -p" instead of "mkdir -p", since mkdir -p under Irix gives an
260error when the directory already exists (in violation of IEEE 1003.2).
Note: See TracBrowser for help on using the repository browser.