3 On Configuring Development Tools
5 Last Mod Mon Apr 15 10:25:59 PDT 1991, by rich@sendai
11 This document attempts to describe the general concepts behind
12 configuration of the Cygnus Support release of the GNU Development
13 Tools. It also discusses common usage. For a more in succint
14 description, please refer to the man page on "configure" which you
15 should have received {FIXME: ALONG WITH LOTS OF OTHER VERY PRETTY
16 HARD COPY OR IN A DIFFERENT DISTRIBUTION OR ON THIS TAPE OR SHRINK
25 There are a lot of terms that are frequently used when discussing
26 development tools. Most of the common terms have been used for
27 several different concepts such that their meanings have become
28 ambiguous to the point of being confusing. Typically, we only
29 guess at their meanings from context and we frequently guess
32 This document uses very few terms by comparison. The intent is to
33 make the concepts as clear as possible in order to convey the
34 usage and intent of these tools.
36 "Programs" run on "machines". Programs are very nearly always
37 written in "source". Programs are "built" from source.
38 "Compilation" is a process that is frequently, but not always,
39 used when building programs.
44 In this document, the word "host" refers to the environment in
45 which this source will be compiled. "host" and "host name" have
46 nothing to do with the proper name of your host, like "ucbvax",
47 "prep.ai.mit.edu" or "att.com". Instead they refer to things like
50 Forget for a moment that this particular directory of source is
51 the source for a development environment. Instead, pretend that
52 it is the source for a simpler, more mundane, application, say, a
55 Source that can be compiled in more than one environment,
56 generally needs to be set up for each environment explicitly.
57 Here we refer to that process as configuration. That is, we
58 configure the source for a host.
60 For example, if we wanted to configure our mythical desk
61 calculator to compile on a SparcStation, we might configure for
62 host sun4. With our configuration system:
64 cd desk-calculator ; configure sun4
66 does the trick. "configure" is a shell script that sets up
67 Makefiles, subdirectories, and symbolic links appropriate for
68 compiling the source on a sun4.
70 The "host" environment does not necessarily refer to the machine
71 on which the tools are built. It is possible to provide a sun3
72 development environment on a sun4. If we wanted to use a cross
73 compiler on the sun4 to build a program intended to be run on a
74 sun3, we would configure the source for sun3.
76 cd desk-calculator ; configure sun3
78 The fact that we are actually building the program on a sun4 makes
79 no difference if the sun3 cross compiler presents an environment
80 that looks like a sun3 from the point of view of the desk
81 calculator source code. Specifically, the environment is a sun3
82 environment if the header files, predefined symbols, and libraries
83 appear as they do on a sun3.
85 Nor does the host environment refer to the the machine on which
86 the program to be built will run. It is possible to provide a
87 sun3 emulation environment on a sun4 such that programs built in a
88 sun3 development environment actually run on the sun4.
90 Host environment simply refers to the environment in which the
91 program will be built from the source.
94 Configuration Time Options:
96 Many programs have compile time options. That is, features of the
97 program that are either compiled into the program or not based on a
98 choice made by the person who builds the program. We refer to these
99 as "configuration options". For example, our desk calculator might be
100 capable of being compiled into a program that either uses infix
101 notation or postfix as a configuration option. For a sun3, chosing
104 configure sun3 +notation=infix
106 while a sun4 with postfix might be:
108 configure sun4 +notation=postfix
110 If we wanted to build both at the same time, in the same directory
111 structure, the intermediate pieces used in the build process must
114 configure sun4 +forcesubdirs +notation=postfix
115 configure sun3 +forcesubdirs +notation=infix
117 will create subdirectories for the intermediate pieces of the sun4
118 and sun3 configurations. This is necessary as previous systems
119 were only capable of one configuration at a time. A second
120 configuration overwrote the first. We've chosen to retain this
121 behaviour so the "+forcesubdirs" configuration option is necessary
122 to get the new behaviour. The order of the arguments doesn't
123 matter. There should be exactly one argument without a leading
124 '+' sign and that argument will be assumed to be the host name.
126 From here on the examples will assume that you want to build the
127 tools "in place" and won't show the "+forcesubdirs" option, but
128 remember that it is available.
130 In order to actually install the program, the configuration system
131 needs to know where you would like the program installed. The
132 default location is /usr/local. We refer to this location as
133 $(destdir). All user visible programs will be installed in
134 $(destdir)/bin. All other programs and files will be installed in
135 a subdirectory of $(destdir)/lib. For the tools in this
136 directory, the files not normally user visible will be installed
137 in $(destdir)/lib/gcc.
139 You can elect to change $(destdir) only as a configuration time
142 configure sun4 +notation=postfix +destdir=/local
144 Will configure the source such that:
148 will put it's programs in /local/bin and /local/lib/gcc. If you
149 change $(destdir) after building the source, you will need to:
153 before the change will be propogated properly. This is because
154 some tools need to know the locations of other tools.
156 With these concepts in mind, we can drop the desk calculator and
157 move on to the application that resides in these directories,
158 namely, the source to a development environment.
164 The GNU Development Tools can be built on a wide variety of hosts.
165 So, of course, they must be configured. Like the last example,
167 configure sun4 +destdir=/local
168 configure sun3 +destdir=/local
170 will configure the source to be built in subdirectories, in order
171 to keep the intermediate pieces separate, and to be installed in
174 When built with suitable development environments, these will be
175 native tools. We'll explain the term "native" later.
178 BUILDING DEVELOPMENT ENVIRONMENTS
179 ---------------------------------
181 The Cygnus Support GNU development tools can not only be built
182 with a number of host development environments, they can also be
183 configured to create a number of different development
184 environments on each of those hosts. We refer to a specific
185 development environment created as a "target". That is, the word
186 "target" refers to the development environment produced by
187 compiling this source and installing the resulting programs.
189 For the Cygnus Support GNU development tools, the default target
190 is the same as the host. That is, the development environment
191 produced is intended to be compatible with the environment used to
194 In the example above, we created two configurations, one for sun4
195 and one for sun3. The first configuration is expecting to be
196 built in a sun4 development environment, to create a sun4
197 development environment. It doesn't necessarily need to be built
198 on a sun4 if a sun4 development environment is available
199 elsewhere. Likewise, if the available sun4 development
200 environment produces executables intended for something other than
201 sun4, then the development environment built from this sun4
202 configuration will run on something other than a sun4. From the
203 point of view of the configuration system and the GNU development
204 tools source, this doesn't matter. What matters is that they will
205 be built in a sun4 environment.
207 Similarly, the second configuration given above is expecting to be
208 built in a sun3 development environment, to create a sun3
209 development environment.
211 The development environment produced, is a configuration time
212 option, just like $(destdir).
214 configure sun4 +destdir=/local +target=sun3
215 configure sun3 +destdir=/local +target=sun4
217 In this example, like before, we create two configurations. The
218 first is intended to be built in a sun4 environment, in
219 subdirectories, to be installed in /local. The second is also
220 intended to be build in a sun4 environment, in subdirectories, to
221 be installed in /local.
223 Unlike the previous example, the first configuration will produce
224 a sun3 development environment, perhaps even suitable for building
225 the second configuration. Likewise, the second configuration will
226 produce a sun4 development environment, perhaps even suitable for
227 building the first configuration.
229 The development environment used to build these configurations
230 will determine the machines on which the resulting development
231 environments can be used.
237 Native Development Environments:
239 Let us assume for a moment that you have a sun4 and that with your
240 sun4 you received a development environment. This development
241 environment is intended to be run on your sun4 to build programs
242 that can be run on your sun4. You could, for instance, run this
243 development environment on your sun4 to build our example desk
244 calculator program. You could then run the desk calculator
245 program on your sun4.
247 The resulting desk calculator program is referred to as a "native"
248 program. The development environment itself is composed of native
249 programs that, when run, build other native programs. Any other
250 program is referred to as "foreign". Programs intended for other
251 machines are foreign programs.
253 This type of development environment, which is by far the most
254 common, is refered to as "native". That is, a native development
255 environment runs on some machine to build programs for that same
256 machine. The process of using a native development environment to
257 build native programs is called a "native" build.
261 Will configure this source such that when built in a sun4
262 development environment, with a development environment that
263 builds programs intended to be run on sun4 machines, the programs
264 built will be native programs and the resulting development
265 environment will be a native development environment.
267 The development system that came with your sun4 is one such
268 environment. Using it to build the GNU Development Tools is a
269 very common activity and the resulting development environment is
274 will build the tools as configured and will assume that you want
275 to use the native development environment that came with your
278 Using a development environment to build a development environment
279 is called "bootstrapping". The Cygnus Support release of the GNU
280 Development Tools is capable of bootstrapping itself. This is a
281 very powerful feature that we'll return to later. For now, let's
282 pretend that you used the native development environment that came
283 with your sun4 to bootstrap the Cygnus Support release and let's
284 call the new development environment stage1.
286 Why bother? Well, most people find that the Cygnus Support
287 release builds programs that run faster and take up less space
288 than the native development environments that came with their
289 machines. Some people didn't get development environments with
290 their machines and some people just like using the GNU tools
291 better than using other tools.
293 While you're at it, if the GNU tools produce better programs, maybe
294 you should use them to build the GNU tools. It's a good idea, so
295 let's pretend that you do. Let's call the new development
298 So far you've built a development environment, stage1, and you've
299 used stage1 to build a new, faster and smaller development
300 environment, stage2, but you haven't run any of the programs that
301 the GNU tools have built. You really don't yet know if these
302 tools work. Do you have any programs built with the GNU tools?
303 Yes, you do. stage2. What does that program do? It builds
304 programs. Ok, do you have any source handy to build into a
305 program? Yes, you do. The GNU tools themselves. In fact, if you
306 use stage2 to build the GNU tools again the resulting programs
307 should be identical to stage2. Let's pretend that you do and call
308 the new development environment stage3.
310 You've just completed what's called a "three stage boot". You now
311 have a small, fast, somewhat tested, development environment.
315 will do a three stage boot across all tools and will compare
316 stage2 to stage3 and complain if they are not identical.
322 will install the development environment in the default location
323 or in $(destdir) if you specified an alternate when you
324 configured. In fact, you can skip the "make all" part and just
325 "make install" which will make sure that the development
326 environment is built before attempting to install anything. Even
327 better, for configurations where host is the same as target, like
328 this one, "make install" will make sure that a "make bootstrap" is
329 done before installing anything.
331 Any development environment that is not a native development
332 environment is refered to as a "cross" development environment.
333 There are many different types of cross development environments
334 but most fall into one of FIXME basic categories.
337 Emulation Environments:
339 The first category of cross development environment is called
340 "emulation". There are two primary types of emulation, but both
341 types result in programs that run on the native host.
343 The first type is "software emulation". This form of cross
344 development environment involves a native program that when run on
345 the native host, is capable of interpreting, and in most aspects
346 running, a program intended for some other machine. This
347 technique is typically used when the other machine is either too
348 expensive, too slow, too fast, or not available, perhaps because
349 it hasn't yet been built. The native, interpreting program is
350 called a "software emulator".
352 The GNU Development Tools do not currently include any software
353 emulators. Some do exist and the GNU Development Tools can be
354 configured to create simple cross development environments for
355 with these emulators. More on this later.
357 The second type of emulation is when source intended for some
358 other development environment is built into a program intended for
359 the native host. The concept of universes in operating systems
360 and hosted operating systems are two such development
363 The Cygnus Support Release of the GNU Development Tools can be
364 configured for one such emulation at this time.
368 will configure the source such that when built in a sun4
369 development environment the resulting development environment is
370 capable of building sun4 programs from strictly conforming ANSI
371 X3J11 C source. Remember that the environment used to build the
372 tools determines the machine on which this tools will run, so the
373 resulting programs aren't necessarily intended to run on a sun4,
374 although they usually are. Also note that the source for the GNU
375 tools is not strictly conforming ANSI source so this configuration
376 cannot be used to bootstrap the GNU tools.
379 Simple Cross Environments:
381 configure sun4 +target=a29k
383 will configure the tools such that when compiled in a sun4
384 development environment the resulting development environment can
385 be used to create programs intended for a sun3. Again, this does
386 not necessarily mean that the new development environment can be
387 run on a sun4. That would depend on the development environment
388 used to build these tools.
390 Earlier you saw how to configure the tools to build a native
391 development environment, that is, a development environment that
392 runs on your sun4 and builds programs for your sun4. Let's
393 pretend that you use stage3 to build this simple cross
394 configuration and let's call the new development environment
395 gcc-a29k. Remember that this is a native build. Gcc-a29k is a
396 collection of native programs intended to run on your sun4.
397 That's what stage3 builds, programs for your sun4. Gcc-a29k
398 represents an a29k development environment that builds programs
399 intended to run on an a29k. But, remember, gcc-a29k runs on your
400 sun4. Programs built with gcc-a29k will run on your sun4 only
401 with the help of an appropriate software emulator.
403 Building gcc-a29k is also a bootstrap but of a slightly different
404 sort. We call gcc-a29k a simple cross environment and using
405 gcc-a29k to build a program intended for a29k is called "crossing
406 to" a29k. Simple cross environments are the second category of
407 cross development environments.
410 Crossing Into Targets:
412 configure a29k +target=a29k
414 will configure the tools such that when compiled in an a29k
415 development environment, the resulting development environment can
416 be used to create programs intended for an a29k. Again, this does
417 not necessarily mean that the new development environment can be
418 run on an a29k. That would depend on the development environment
419 used to build these tools.
421 If you've been following along this walk through, then you've
422 already built an a29k environment, namely gcc-a29k. Let's pretend
423 you use gcc-a29k to build the current configuration.
425 Gcc-a29k builds programs intended for the a29k so the new
426 development environment will be intended for use on an a29k. That
427 is, this new gcc consists of programs that are foreign to your
428 sun4. They cannot be run on your sun4.
430 The process of building this configuration is another a bootstrap.
431 This bootstrap is also a cross to a29k. Because this type of
432 build is both a bootstrap and a cross to a29k, it is sometimes
433 referred to as a "cross into" a29k. This new development
434 environment isn't really a cross development environment at all.
435 It is intended to run on an a29k to produce programs for an a29k.
436 You'll remember that this makes it, by definition, an a29k native
437 compiler. "Crossing into" has been introduced here not because it
438 is a type of cross development environment, but because it is
439 frequently confused one. The process is "a cross" but the
440 resulting development environment is a native development
443 You could not have built this configuration with stage3, because
444 stage3 doesn't provide an a29k environment. Instead it provides a
447 If you happen to have an a29k lying around, you could now use
448 this fresh development environment on the a29k to three stage
449 these tools all over again. This process would look just like it
450 did when we built the native sun4 development environment because
451 we would be building another native development environment, this
455 The Three Party Cross:
457 So far you've seen that our development environment source must be
458 configured for a specific host and for a specific target. You've
459 also seen that the resulting development environment depends on
460 the development environment used in the build process.
462 When all four match identically, that is, the configured host, the
463 configured target, the environment presented by the development
464 environment used in the build, and the machine on which the
465 resulting development environment is intended to run, then the new
466 development environment will be a native development environment.
468 When all four match except the configured host, then we can assume
469 that the development environment used in the build is some form of
472 When all four match except for the configured target, then the
473 resulting development environment will be a simple cross
474 development environment.
476 When all four match except for the host on which the development
477 environment used in the build runs, the build process is a "cross
478 into" and the resulting development environment will be native to
481 Most of the other permutations do exist in some form, but only one
482 more is interesting to the current discussion.
484 configure a29k +target=sun3
486 will configure the tools such that when compiled in an a29k
487 development environment, the resulting development environment can
488 be used to create programs intended for a sun3. Again, this does
489 not necessarily mean that the new development environment can be
490 run on an a29k. That would depend on the development environment
491 used to build these tools.
493 If you are still following along, then you have two a29k
494 development environments, the native development environment that
495 runs on a29k, and the simple cross that runs on your sun4. If you
496 use the a29k native development environment on the a29k, you will
497 be doing the same thing we did a while back, namely building a
498 simple cross from a29k to sun3. Let's pretend that instead, you
499 use gcc-a29k, the simple cross development environment that runs
500 on sun4 but produces programs for a29k.
502 The resulting development environment will run on a29k because
503 that's what gcc-a29k builds, a29k programs. This development
504 environment will produce programs for a sun3 because that is how
505 it was configured. This means that the resulting development
506 environment is a simple cross.
508 There really isn't a common name for this process because very few
509 development environments are capable of being configured this
510 extensively. For the sake of discussion, let's call this process
511 a "three party cross".
517 Gdb's config has features not yet present in the uniform configuration
518 scheme described here. For this reason, configuration of gdb must
519 currently be done separately from that of the rest of this package.
520 This will be corrected soon. For more information on the
521 configuration of gdb, please refer to the documents in gdb.{your
522 target} if it exists, otherwise gdb.
524 By "configures", I mean that links, Makefile, .gdbinit, and
525 config.status are built. Configuration is always done from the source
528 * "./configure name" configures this directory, perhaps recursively,
529 for a single host+target pair where the host and target are both
530 "name". If a previous configuration existed, it will be
533 * "./configure hostname +target=targetname" configures this directory,
534 perhaps recursively, for a single host+target pair where the host is
535 hostname and target is targetname. If a previous configuration
536 existed, it will be overwritten.
538 * "./configure +forcesubdirs hostname +target=targetname" creates a
539 subdirectories Host-hostname and Host-hostname/Target-targetname and
540 configures Host-hostname/Target-targetname. For now, makes should
541 be done from Host-hostname/Target-targetname. "./configure +f name"
542 works as expected. That is, it creates Host-name and
543 Host-name/Target-name and configures the latter.
546 Hacking configurations:
548 The configure scripts essentially do three things, create
549 subdirectories if appropriate, build a Makefile, and create links to
550 files, all based on and tailored to, a specific host+target pair. The
551 scripts also create a .gdbinit if appropriate but this is not
554 The Makefile is created by prepending some variable definitions to a
555 Makefile template called Makefile.in and then inserting host and
556 target specific Makefile fragments. The variables are set based on
557 the chosen host+target pair and build style, that is, if you use
558 subdirectories or not. The host and target specific Makefile may or
559 may not exist. If fragments
561 * Makefiles can be editted directly, but those changes will eventually
562 be lost. Changes intended to be permanent for a specific host
563 should be made to the host specific Makefile fragment. This should
564 be in ./config/hmake-host if it exists. Changes intended to be
565 permanent for a specific target should be made to the target
566 specific Makefile fragment. This should be in ./config/tmake-target
567 if it exists. Changes intended to be permanent for the directory
568 should be made in Makefile.in. To propogate changes to any of
569 these, either use "make Makefile" or re-configure from the source
572 * configure can be editted directly, but those changes will eventually
573 be lost. Changes intended to be permanent for a specific directory
574 should be made to configure.in. Changes intended to be permanent
575 for all configure scripts should be made to configure.template.
576 Propogating changes to configure.in requires the presence of
577 configure.template which normally resides in the uppermost directory
578 you received. To propogate changes to either configure.template or
579 a configure.in, use "configure +template=absolutepathtothetemplate".
580 This will configure the configure scripts themselves, recursively if
583 * "configure -srcdir=foo" is not supported yet. At the moment, things
584 will probably be configured correctly only for leaf directories, and
585 even they will not have paths to libraries set properly.