1 On Configuring Development Tools
6 Last Mod Tue Oct 1 21:20:21 PDT 1991, by rich@cygnus.com
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. Eventually, FIXME, there
14 will also be a man page for "configure", an "info" tree, etc.
22 There are a lot of terms that are frequently used when discussing
23 development tools. Most of the common terms have been used for
24 several different concepts such that their meanings have become
25 ambiguous to the point of being confusing. Typically, we only
26 guess at their meanings from context and we frequently guess
29 This document uses very few terms by comparison. The intent is to
30 make the concepts as clear as possible in order to convey the
31 usage and intent of these tools.
33 "Programs" run on "machines". Programs are very nearly always
34 written in "source". Programs are "built" from source.
35 "Compilation" is a process that is frequently, but not always,
36 used when building programs.
41 In this document, the word "host" refers to the environment in
42 which this source will be compiled. "host" and "host name" have
43 nothing to do with the proper name of your host, like "ucbvax",
44 "prep.ai.mit.edu" or "att.com". Instead they refer to things like
47 Forget for a moment that this particular directory of source is
48 the source for a development environment. Instead, pretend that
49 it is the source for a simpler, more mundane, application, say, a
52 Source that can be compiled in more than one environment,
53 generally needs to be set up for each environment explicitly.
54 Here we refer to that process as configuration. That is, we
55 configure the source for a host.
57 For example, if we wanted to configure our mythical desk
58 calculator to compile on a SparcStation, we might configure for
59 host sun4. With our configuration system:
61 cd desk-calculator ; ./configure sun4
63 does the trick. "configure" is a shell script that sets up
64 Makefiles, subdirectories, and symbolic links appropriate for
65 compiling the source on a sun4.
67 The "host" environment does not necessarily refer to the machine
68 on which the tools are built. It is possible to provide a sun3
69 development environment on a sun4. If we wanted to use a cross
70 compiler on the sun4 to build a program intended to be run on a
71 sun3, we would configure the source for sun3.
73 cd desk-calculator ; ./configure sun3
75 The fact that we are actually building the program on a sun4 makes
76 no difference if the sun3 cross compiler presents an environment
77 that looks like a sun3 from the point of view of the desk
78 calculator source code. Specifically, the environment is a sun3
79 environment if the header files, predefined symbols, and libraries
80 appear as they do on a sun3.
82 Nor does the host environment refer to the the machine on which
83 the program to be built will run. It is possible to provide a
84 sun3 emulation environment on a sun4 such that programs built in a
85 sun3 development environment actually run on the sun4.
87 Host environment simply refers to the environment in which the
88 program will be built from the source.
91 Configuration Time Options:
93 Many programs have compile time options. That is, features of the
94 program that are either compiled into the program or not based on a
95 choice made by the person who builds the program. We refer to these
96 as "configuration options". For example, our desk calculator might be
97 capable of being compiled into a program that either uses infix
98 notation or postfix as a configuration option. For a sun3, chosing
101 ./configure sun3 +notation=infix
103 while a sun4 with postfix might be:
105 ./configure sun4 +notation=postfix
107 If we wanted to build both at the same time, in the same directory
108 structure, the intermediate pieces used in the build process must
111 ./configure sun4 +subdirs +notation=postfix
112 ./configure sun3 +subdirs +notation=infix
114 will create subdirectories for the intermediate pieces of the sun4
115 and sun3 configurations. This is necessary as previous systems
116 were only capable of one configuration at a time. A second
117 configuration overwrote the first. We've chosen to retain this
118 behaviour so the "+subdirs" configuration option is necessary
119 to get the new behaviour. The order of the arguments doesn't
120 matter. There should be exactly one argument without a leading
121 '+' sign and that argument will be assumed to be the host name.
123 From here on the examples will assume that you want to build the
124 tools "in place" and won't show the "+subdirs" option, but
125 remember that it is available.
127 In order to actually install the program, the configuration system
128 needs to know where you would like the program installed. The
129 default location is /usr/local. We refer to this location as
130 $(destdir). All user visible programs will be installed in
131 $(destdir)/bin. All other programs and files will be installed in
132 a subdirectory of $(destdir)/lib.
134 You can elect to change $(destdir) only as a configuration time
137 ./configure sun4 +notation=postfix +destdir=/local
139 Will configure the source such that:
143 will put it's programs in /local/bin and /local/lib/gcc. If you
144 change $(destdir) after building the source, you will need to:
148 before the change will be propogated properly. This is because
149 some tools need to know the locations of other tools.
151 With these concepts in mind, we can drop the desk calculator and
152 move on to the application that resides in these directories,
153 namely, the source to a development environment.
159 The GNU Development Tools can be built on a wide variety of hosts.
160 So, of course, they must be configured. Like the last example,
162 ./configure sun4 +destdir=/local
163 ./configure sun3 +destdir=/local
165 will configure the source to be built in subdirectories, in order
166 to keep the intermediate pieces separate, and to be installed in
169 When built with suitable development environments, these will be
170 native tools. We'll explain the term "native" later.
173 BUILDING DEVELOPMENT ENVIRONMENTS
174 ---------------------------------
176 The Cygnus Support GNU development tools can not only be built
177 with a number of host development environments, they can also be
178 configured to create a number of different development
179 environments on each of those hosts. We refer to a specific
180 development environment created as a "target". That is, the word
181 "target" refers to the development environment produced by
182 compiling this source and installing the resulting programs.
184 For the Cygnus Support GNU development tools, the default target
185 is the same as the host. That is, the development environment
186 produced is intended to be compatible with the environment used to
189 In the example above, we created two configurations, one for sun4
190 and one for sun3. The first configuration is expecting to be
191 built in a sun4 development environment, to create a sun4
192 development environment. It doesn't necessarily need to be built
193 on a sun4 if a sun4 development environment is available
194 elsewhere. Likewise, if the available sun4 development
195 environment produces executables intended for something other than
196 sun4, then the development environment built from this sun4
197 configuration will run on something other than a sun4. From the
198 point of view of the configuration system and the GNU development
199 tools source, this doesn't matter. What matters is that they will
200 be built in a sun4 environment.
202 Similarly, the second configuration given above is expecting to be
203 built in a sun3 development environment, to create a sun3
204 development environment.
206 The development environment produced, is a configuration time
207 option, just like $(destdir).
209 ./configure sun4 +destdir=/local +target=sun3
210 ./configure sun3 +destdir=/local +target=sun4
212 In this example, like before, we create two configurations. The
213 first is intended to be built in a sun4 environment, in
214 subdirectories, to be installed in /local. The second is intended
215 to be built in a sun3 environment, in subdirectories, to be
218 Unlike the previous example, the first configuration will produce
219 a sun3 development environment, perhaps even suitable for building
220 the second configuration. Likewise, the second configuration will
221 produce a sun4 development environment, perhaps even suitable for
222 building the first configuration.
224 The development environment used to build these configurations
225 will determine the machines on which the resulting development
226 environments can be used.
232 Native Development Environments:
234 Let us assume for a moment that you have a sun4 and that with your
235 sun4 you received a development environment. This development
236 environment is intended to be run on your sun4 to build programs
237 that can be run on your sun4. You could, for instance, run this
238 development environment on your sun4 to build our example desk
239 calculator program. You could then run the desk calculator
240 program on your sun4.
242 The resulting desk calculator program is referred to as a "native"
243 program. The development environment itself is composed of native
244 programs that, when run, build other native programs. Any other
245 program is referred to as "foreign". Programs intended for other
246 machines are foreign programs.
248 This type of development environment, which is by far the most
249 common, is refered to as "native". That is, a native development
250 environment runs on some machine to build programs for that same
251 machine. The process of using a native development environment to
252 build native programs is called a "native" build.
256 Will configure this source such that when built in a sun4
257 development environment, with a development environment that
258 builds programs intended to be run on sun4 machines, the programs
259 built will be native programs and the resulting development
260 environment will be a native development environment.
262 The development system that came with your sun4 is one such
263 environment. Using it to build the GNU Development Tools is a
264 very common activity and the resulting development environment is
269 will build the tools as configured and will assume that you want
270 to use the native development environment that came with your
273 Using a development environment to build a development environment
274 is called "bootstrapping". The Cygnus Support release of the GNU
275 Development Tools is capable of bootstrapping itself. This is a
276 very powerful feature that we'll return to later. For now, let's
277 pretend that you used the native development environment that came
278 with your sun4 to bootstrap the Cygnus Support release and let's
279 call the new development environment stage1.
281 Why bother? Well, most people find that the Cygnus Support
282 release builds programs that run faster and take up less space
283 than the native development environments that came with their
284 machines. Some people didn't get development environments with
285 their machines and some people just like using the GNU tools
286 better than using other tools.
288 While you're at it, if the GNU tools produce better programs, maybe
289 you should use them to build the GNU tools. It's a good idea, so
290 let's pretend that you do. Let's call the new development
293 So far you've built a development environment, stage1, and you've
294 used stage1 to build a new, faster and smaller development
295 environment, stage2, but you haven't run any of the programs that
296 the GNU tools have built. You really don't yet know if these
297 tools work. Do you have any programs built with the GNU tools?
298 Yes, you do. stage2. What does that program do? It builds
299 programs. Ok, do you have any source handy to build into a
300 program? Yes, you do. The GNU tools themselves. In fact, if you
301 use stage2 to build the GNU tools again the resulting programs
302 should be identical to stage2. Let's pretend that you do and call
303 the new development environment stage3.
305 You've just completed what's called a "three stage boot". You now
306 have a small, fast, somewhat tested, development environment.
310 will do a three stage boot across all tools and will compare
311 stage2 to stage3 and complain if they are not identical.
317 will install the development environment in the default location
318 or in $(destdir) if you specified an alternate when you
319 configured. In fact, you can skip the "make all" part and just
320 "make install" which will make sure that the development
321 environment is built before attempting to install anything. Even
322 better, for configurations where host is the same as target, like
323 this one, "make install" will make sure that a "make bootstrap" is
324 done before installing anything.
326 Any development environment that is not a native development
327 environment is refered to as a "cross" development environment.
328 There are many different types of cross development environments
329 but most fall into one of FIXME basic categories.
332 Emulation Environments:
334 The first category of cross development environment is called
335 "emulation". There are two primary types of emulation, but both
336 types result in programs that run on the native host.
338 The first type is "software emulation". This form of cross
339 development environment involves a native program that when run on
340 the native host, is capable of interpreting, and in most aspects
341 running, a program intended for some other machine. This
342 technique is typically used when the other machine is either too
343 expensive, too slow, too fast, or not available, perhaps because
344 it hasn't yet been built. The native, interpreting program is
345 called a "software emulator".
347 The GNU Development Tools do not currently include any software
348 emulators. Some do exist and the GNU Development Tools can be
349 configured to create simple cross development environments for
350 with these emulators. More on this later.
352 The second type of emulation is when source intended for some
353 other development environment is built into a program intended for
354 the native host. The concept of universes in operating systems
355 and hosted operating systems are two such development
358 The Cygnus Support Release of the GNU Development Tools can be
359 configured for one such emulation at this time.
361 ./configure sun4 +ansi
363 will configure the source such that when built in a sun4
364 development environment the resulting development environment is
365 capable of building sun4 programs from strictly conforming ANSI
366 X3J11 C source. Remember that the environment used to build the
367 tools determines the machine on which this tools will run, so the
368 resulting programs aren't necessarily intended to run on a sun4,
369 although they usually are. Also note that the source for the GNU
370 tools is not strictly conforming ANSI source so this configuration
371 cannot be used to bootstrap the GNU tools.
374 Simple Cross Environments:
376 ./configure sun4 +target=a29k
378 will configure the tools such that when compiled in a sun4
379 development environment the resulting development environment can
380 be used to create programs intended for an a29k. Again, this does
381 not necessarily mean that the new development environment can be
382 run on a sun4. That would depend on the development environment
383 used to build these tools.
385 Earlier you saw how to configure the tools to build a native
386 development environment, that is, a development environment that
387 runs on your sun4 and builds programs for your sun4. Let's
388 pretend that you use stage3 to build this simple cross
389 configuration and let's call the new development environment
390 gcc-a29k. Remember that this is a native build. Gcc-a29k is a
391 collection of native programs intended to run on your sun4.
392 That's what stage3 builds, programs for your sun4. Gcc-a29k
393 represents an a29k development environment that builds programs
394 intended to run on an a29k. But, remember, gcc-a29k runs on your
395 sun4. Programs built with gcc-a29k will run on your sun4 only
396 with the help of an appropriate software emulator.
398 Building gcc-a29k is also a bootstrap but of a slightly different
399 sort. We call gcc-a29k a simple cross environment and using
400 gcc-a29k to build a program intended for a29k is called "crossing
401 to" a29k. Simple cross environments are the second category of
402 cross development environments.
405 Crossing Into Targets:
407 ./configure a29k +target=a29k
409 will configure the tools such that when compiled in an a29k
410 development environment, the resulting development environment can
411 be used to create programs intended for an a29k. Again, this does
412 not necessarily mean that the new development environment can be
413 run on an a29k. That would depend on the development environment
414 used to build these tools.
416 If you've been following along this walk through, then you've
417 already built an a29k environment, namely gcc-a29k. Let's pretend
418 you use gcc-a29k to build the current configuration.
420 Gcc-a29k builds programs intended for the a29k so the new
421 development environment will be intended for use on an a29k. That
422 is, this new gcc consists of programs that are foreign to your
423 sun4. They cannot be run on your sun4.
425 The process of building this configuration is another a bootstrap.
426 This bootstrap is also a cross to a29k. Because this type of
427 build is both a bootstrap and a cross to a29k, it is sometimes
428 referred to as a "cross into" a29k. This new development
429 environment isn't really a cross development environment at all.
430 It is intended to run on an a29k to produce programs for an a29k.
431 You'll remember that this makes it, by definition, an a29k native
432 compiler. "Crossing into" has been introduced here not because it
433 is a type of cross development environment, but because it is
434 frequently confused one. The process is "a cross" but the
435 resulting development environment is a native development
438 You could not have built this configuration with stage3, because
439 stage3 doesn't provide an a29k environment. Instead it provides a
442 If you happen to have an a29k lying around, you could now use
443 this fresh development environment on the a29k to three-stage
444 these tools all over again. This process would look just like it
445 did when we built the native sun4 development environment because
446 we would be building another native development environment, this
450 The Three Party Cross:
452 So far you've seen that our development environment source must be
453 configured for a specific host and for a specific target. You've
454 also seen that the resulting development environment depends on
455 the development environment used in the build process.
457 When all four match identically, that is, the configured host, the
458 configured target, the environment presented by the development
459 environment used in the build, and the machine on which the
460 resulting development environment is intended to run, then the new
461 development environment will be a native development environment.
463 When all four match except the configured host, then we can assume
464 that the development environment used in the build is some form of
467 When all four match except for the configured target, then the
468 resulting development environment will be a simple cross
469 development environment.
471 When all four match except for the host on which the development
472 environment used in the build runs, the build process is a "cross
473 into" and the resulting development environment will be native to
476 Most of the other permutations do exist in some form, but only one
477 more is interesting to the current discussion.
479 ./configure a29k +target=sun3
481 will configure the tools such that when compiled in an a29k
482 development environment, the resulting development environment can
483 be used to create programs intended for a sun3. Again, this does
484 not necessarily mean that the new development environment can be
485 run on an a29k. That would depend on the development environment
486 used to build these tools.
488 If you are still following along, then you have two a29k
489 development environments, the native development environment that
490 runs on a29k, and the simple cross that runs on your sun4. If you
491 use the a29k native development environment on the a29k, you will
492 be doing the same thing we did a while back, namely building a
493 simple cross from a29k to sun3. Let's pretend that instead, you
494 use gcc-a29k, the simple cross development environment that runs
495 on sun4 but produces programs for a29k.
497 The resulting development environment will run on a29k because
498 that's what gcc-a29k builds, a29k programs. This development
499 environment will produce programs for a sun3 because that is how
500 it was configured. This means that the resulting development
501 environment is a simple cross.
503 There really isn't a common name for this process because very few
504 development environments are capable of being configured this
505 extensively. For the sake of discussion, let's call this process
506 a "three party cross".
512 By "configures", I mean that links, Makefile, .gdbinit, and
513 config.status are built. Configuration is always done from the source
516 * "./configure name" configures this directory, perhaps recursively,
517 for a single host+target pair where the host and target are both
518 "name". If a previous configuration existed, it will be
521 * "./configure hostname +target=targetname" configures this directory,
522 perhaps recursively, for a single host+target pair where the host is
523 hostname and target is targetname. If a previous configuration
524 existed, it will be overwritten.
526 * "./configure +subdirs hostname +target=targetname" creates a
527 subdirectories H-hostname and H-hostname/T-targetname and
528 configures H-hostname/T-targetname. For now, makes should
529 be done from H-hostname/T-targetname. "./configure +sub name"
530 works as expected. That is, it creates H-name and
531 H-name/T-name and configures the latter.
534 Hacking configurations:
536 The configure scripts essentially do three things, create
537 subdirectories if appropriate, build a Makefile, and create links to
538 files, all based on and tailored to, a specific host+target pair. The
539 scripts also create a .gdbinit if appropriate but this is not
542 The Makefile is created by prepending some variable definitions to a
543 Makefile template called Makefile.in and then inserting host and
544 target specific Makefile fragments. The variables are set based on
545 the chosen host+target pair and build style, that is, if you use
546 subdirectories or not. The host and target specific Makefile may or
547 may not exist. If fragments
549 * Makefiles can be edited directly, but those changes will eventually
550 be lost. Changes intended to be permanent for a specific host
551 should be made to the host specific Makefile fragment. This should
552 be in ./config/hmake-host if it exists. Changes intended to be
553 permanent for a specific target should be made to the target
554 specific Makefile fragment. This should be in ./config/tmake-target
555 if it exists. Changes intended to be permanent for the directory
556 should be made in Makefile.in. To propogate changes to any of
557 these, either use "make Makefile" or re-configure from the source
560 * configure can be edited directly, but those changes will eventually
561 be lost. Changes intended to be permanent for a specific directory
562 should be made to configure.in. Changes intended to be permanent
563 for all configure scripts should be made to configure.template.
564 Propogating changes to configure.in requires the presence of
565 configure.template which normally resides in the uppermost directory
566 you received. To propogate changes to either configure.template or
567 a configure.in, use "configure +template=pathtothetemplate".
568 This will configure the configure scripts themselves, recursively if
571 * "./configure -srcdir=foo" is not supported yet. At the moment, things
572 will probably be configured correctly only for leaf directories, and
573 even they will not have paths to libraries set properly.