| 227 |
dpurdie |
1 |
Defining a tool suite. (out of date)
|
|
|
2 |
=========================
|
|
|
3 |
|
|
|
4 |
The files in this directory defines a tool suite for use within the build
|
|
|
5 |
environment. Here a ``tool suite'' is a complete set of tools for compilation
|
|
|
6 |
/assembly/linking etc etc. The definition takes the form of a fragment of a
|
|
|
7 |
makefile, subsequently included into a user's makefile. This file
|
|
|
8 |
documents what is expected of a definition.
|
|
|
9 |
|
|
|
10 |
Throughout this document the word `target' or phrase `make target'
|
|
|
11 |
refers to a target defined and associated with a list of commands in a
|
|
|
12 |
makefile. The work `platform' and/or phrase `build platform' relates to
|
|
|
13 |
the platform on which the code being compiled/assembled/linked or
|
|
|
14 |
whatever will run.
|
|
|
15 |
|
|
|
16 |
0.1 Trivia.
|
|
|
17 |
==========
|
|
|
18 |
|
|
|
19 |
Each suite MUST define the following macros.
|
|
|
20 |
|
|
|
21 |
$(o) The extension of an object filename.
|
|
|
22 |
$(s) The extension of an assembler source filename.
|
|
|
23 |
$(a) The extension of a archive (library) filename.
|
|
|
24 |
|
|
|
25 |
|
|
|
26 |
1.0 Defining a C compiler.
|
|
|
27 |
|
|
|
28 |
At a minimum only the definition of the make variables $(cc) and $(o)
|
|
|
29 |
must be provided in order to compile a C file. The rule for compilation
|
|
|
30 |
of such a file is as follows...
|
|
|
31 |
|
|
|
32 |
%.$(o): %.c $(cc_build_cmd_file)
|
|
|
33 |
$(cc_pre)
|
|
|
34 |
ifdef cc_error_filter
|
|
|
35 |
ifdef cc_redirect_output
|
|
|
36 |
$(cc) $(cc_flags) $(cc_o_switch) $< > cc.out
|
|
|
37 |
$(cc_error_filter) < cc.out
|
|
|
38 |
$(rm) cc.out
|
|
|
39 |
else
|
|
|
40 |
$(cc) $(cflags) $(cc_o_switch) $< | $(cc_error_filer)
|
|
|
41 |
endif
|
|
|
42 |
else
|
|
|
43 |
$(cc) $(cflags) $(cc_o_switch) $<
|
|
|
44 |
endif
|
|
|
45 |
$(cc_post)
|
|
|
46 |
|
|
|
47 |
If nothing other than $(cc) is defined the above reduces to...
|
|
|
48 |
|
|
|
49 |
%.$(o): %.c
|
|
|
50 |
$(cc) $<
|
|
|
51 |
|
|
|
52 |
If $(cc_build_cmd_file) is defined it names a make TARGET which will
|
|
|
53 |
constructs a command file for the compiler. The suite MUST define this
|
|
|
54 |
target. The commands associated with it will be executed once prior to
|
|
|
55 |
any C compilation. Therefore the command file cannot contain anything
|
|
|
56 |
which is dependent on the file being compiled, like output filenames.
|
|
|
57 |
Only options common to all C compilations for a particular platform may
|
|
|
58 |
be placed into a command file. As build environment invokes make
|
|
|
59 |
seperately for each platform for which a module must be compiled, a
|
|
|
60 |
seperate command file will be constructed on each occasion so platform
|
|
|
61 |
specific flags maybe written to a command file.
|
|
|
62 |
|
|
|
63 |
If $(cc_build_cmd_file) is defined then $(cc_remove_cmd_file) MUST
|
|
|
64 |
also be defined. It is also a make TARGET. The rule for the
|
|
|
65 |
compilation of a module is something like...
|
|
|
66 |
|
|
|
67 |
<module>: <object-files> $(clean_up)
|
|
|
68 |
|
|
|
69 |
where the variable clean_up is defined as...
|
|
|
70 |
|
|
|
71 |
clean_up = $(cc_remove_cmd_file) $(as_remove_cmd_file) \
|
|
|
72 |
$(ar_remove_cmd_file) $(ld_remove_cmd_file)
|
|
|
73 |
|
|
|
74 |
Thus the commands of each of the targets in the list clean_up will be
|
|
|
75 |
executed after all the rules required to generate <object-files> have
|
|
|
76 |
been executed (but before the final commands associated with getting from
|
|
|
77 |
<object-files> to <module>).
|
|
|
78 |
|
|
|
79 |
If $(cc_error_filter) is defined it names a program through which the
|
|
|
80 |
output of the compiler feed before being presented to the user. If
|
|
|
81 |
$(cc_redirect_output) is also defined then the compiler's output will
|
|
|
82 |
be placed into a temporary file prior to being feed to the error file
|
|
|
83 |
otherwise the compiler output is piped directly into the error filter.
|
|
|
84 |
The use of pipes under DOS doesn't really work right... if any program
|
|
|
85 |
in a pipeline exists with an error the error code returned from the
|
|
|
86 |
pipeline is that of the last command in the chain. Unless that is the
|
|
|
87 |
program which detected the error the failure of the compilation will
|
|
|
88 |
not be detected and make will continue on rather than halting.
|
|
|
89 |
|
|
|
90 |
If necessary the variable $(cc_o_switch) maybe defined to include
|
|
|
91 |
whatever is required on the command line to specify the output
|
|
|
92 |
filename. Typical this will make use of the automatic variable $@ to
|
|
|
93 |
reference the full name of the target file, something like...
|
|
|
94 |
|
|
|
95 |
cc_o_switch = -o $@
|
|
|
96 |
|
|
|
97 |
|
|
|
98 |
1.1 Setting include paths, passing in defines and the like.
|
|
|
99 |
|
|
|
100 |
The variable $(include_path) contains a space seperated list of all
|
|
|
101 |
the directories in which the compiler should look for included files.
|
|
|
102 |
The definition of this variable includes a reference to
|
|
|
103 |
$(compiler_include) which maybe set by compiler definition to add
|
|
|
104 |
include directories specific to the compiler.
|
|
|
105 |
|
|
|
106 |
There are a number of mechanisms for passing additional information to
|
|
|
107 |
the compiler from rest of build environment.
|
|
|
108 |
|
|
|
109 |
$(USER_CFLAGS) This maybe defined in the users template PMI file.
|
|
|
110 |
It contains a space seperated list of -D and -I options
|
|
|
111 |
to pass in additional definitions and include directories
|
|
|
112 |
respectively. No other options should be allowed in the
|
|
|
113 |
list as they cannot be made portable.
|
|
|
114 |
|
|
|
115 |
Note that the now obsolete variable USER_FLAGS is treated
|
|
|
116 |
in an identical manner by the current backend definition
|
|
|
117 |
files.
|
|
|
118 |
|
|
|
119 |
$(<tool-suite>_CFLAGS) where <tool-suite> is the name of the
|
|
|
120 |
tool suite currectly being used maybe set in the users
|
|
|
121 |
template PMI file to pass flags to a particular
|
|
|
122 |
compiler. This may contain any options allowed by the
|
|
|
123 |
compiler.
|
|
|
124 |
|
|
|
125 |
$(PLATFORM_CFLAGS) is defined to be $(<platform-name>_CFLAGS)
|
|
|
126 |
where <platform-name> is the current build platform
|
|
|
127 |
name. This is to allow the user to pass build platform
|
|
|
128 |
specific include and preprocessor defines into a
|
|
|
129 |
compilation. See the document on defining a build
|
|
|
130 |
platform for additional information.
|
|
|
131 |
|
|
|
132 |
$(eos_platform_name) is defined by the platform specific make
|
|
|
133 |
rules to be the EOS name for the platform.
|
|
|
134 |
|
|
|
135 |
$(DEBUG) If this make variable is defined the tool suite
|
|
|
136 |
definitions must arrange to define a preprocessor
|
|
|
137 |
symbol of the same name.
|
|
|
138 |
|
|
|
139 |
$(DLVL) Debug level setting. The value of this make variable must
|
|
|
140 |
be used to define the value of a preprocessor symbol of
|
|
|
141 |
the same name, ie, -DDLVL=$(DLVL) must be passed to the
|
|
|
142 |
compiler.
|
|
|
143 |
|
|
|
144 |
$(ALVL) Assert level setting. Must be treated like DLVL.
|
|
|
145 |
|
|
|
146 |
USE_EOS If this variable is defined then the resulting program is
|
|
|
147 |
to run under EOS. This probably only changes the
|
|
|
148 |
arguments passed to the compiler by default.
|
|
|
149 |
|
|
|
150 |
Outside a DOS environment all the above would simply be passed on the
|
|
|
151 |
command line to each compilation. Unfortunately the command line length
|
|
|
152 |
limitation imposed by DOS makes this impossible for all but trivial
|
|
|
153 |
cases. A tool suite must take whatever action necessary to pass all the
|
|
|
154 |
above information into the compiler. Typically this is done by writing a
|
|
|
155 |
command file in the target cc_build_cmd_file or poking something into the
|
|
|
156 |
environment then using the command line $(cflags) to point the compiler
|
|
|
157 |
at this information. For example the definitions for using the watcom
|
|
|
158 |
tools extract all include path information from the above and construct a
|
|
|
159 |
semicolon separated list in the variable INCLUDE which is then exported
|
|
|
160 |
into the environment (the compiler looks for the environment variable by
|
|
|
161 |
default). All other options are then placed into the variable WCFLAGS
|
|
|
162 |
which is also exported into the environment and the variable $(cflags)
|
|
|
163 |
set to `@WCFLAGS' to instruct the compiler to look at the variable in its
|
|
|
164 |
environment.
|
|
|
165 |
|
|
|
166 |
To further assist the command sequences $(cc_pre) and $(cc_post) are
|
|
|
167 |
included in the rules for translating a C file. They may be defined to be
|
|
|
168 |
any sequence of commands using GNU-makes `define ... endef' form.
|
|
|
169 |
|
|
|
170 |
|
|
|
171 |
2.0 Defining an assembler.
|
|
|
172 |
|
|
|
173 |
%.$(o): %.$(s) $(as_init_target)
|
|
|
174 |
$(as_pre)
|
|
|
175 |
$(show_environment)
|
|
|
176 |
ifdef as_error_filter
|
|
|
177 |
ifdef as_redirect_output
|
|
|
178 |
$(as) $(aflags) $(as_o_switch) $< > as.out
|
|
|
179 |
$(as_error_filter) < as.out
|
|
|
180 |
$(rm) as.out
|
|
|
181 |
else
|
|
|
182 |
$(as) $(aflags) $(as_o_switch) $< | $(as_error_filer)
|
|
|
183 |
endif
|
|
|
184 |
else
|
|
|
185 |
$(as) $(aflags) $(as_o_switch) $<
|
|
|
186 |
endif
|
|
|
187 |
$(as_post)
|
|
|
188 |
|
|
|
189 |
|
|
|
190 |
3.0 Defining an archiver.
|
|
|
191 |
|
|
|
192 |
%.$(a): $(ar_init_target)
|
|
|
193 |
$(ar_pre)
|
|
|
194 |
$(show_environment)
|
|
|
195 |
$(ar) $(arflags) $(ar_o_switch)
|
|
|
196 |
$(ar_post)
|