This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
Re: Re: Determine target/template at compile time
>>>>> "Grant" == Grant Edwards <grante@visi.com> writes:
Grant> In gmane.os.ecos.general, you wrote:
>> On Tue, Aug 01, 2006 at 09:32:22AM -0500, Grant Edwards wrote:
>>>
>>> Is there a standard way to determine the target/template at
>>> compile time?
>>
>> Don't think so.
Grant> Is there any documentation on the commands allowed in
Grant> ecos.db or on the sytax for a "target" statement in
Grant> ecos.db? The only thing I can find in the documentation
Grant> regarding the "target" command is a paragraph that says
Grant> Currently the ecos.db database also holds information
Grant> about the various targets. When porting to a new target
Grant> it will be necessary to add information about the
Grant> target to the database, as well as the details of the
Grant> new platform HAL package and any related packages.
Grant> Do I have to create a whole new package with its own
Grant> directory and .cdl file just to define a pre-processor
Grant> symbol to tell me a particular target has been selected?
ecos.db is documented @
http://ecos.sourceware.org/docs-latest/cdl-guide/language.database.html
There is no mechanism for determining the current template at compile
time because that does not actually make sense. A template is only the
starting point for a configuration. Subsequently you can add/remove
packages and change configuration options to your heart's content, so
if you really wanted to you could start with the default template and
end up building RedBoot.
Detecting the current target is normally done by #include'ing
<pkgconf/system.h> and looking for specific platform HAL packages,
e.g.:
#include <pkgconf/system.h>
#if defined(HAL_M68K_M5272EVB)
... do one thing ...
#elif defined(HAL_M68K_M5282LITE)
... do something else ...
#else
# error This code is not supported on the current platform.
#endif
The approach assumes a one-one correspondence between target and
platform HAL. Usually that is a safe assumption, but it breaks down if
a single platform HAL can support several similar boards. Often in
such cases there will be a config option within the platform HAL to
select the exact target which you can then test at compile-time.
I did write a spec once for a CDL extension to handle such cases
better, but that has not yet been implemented.
Bart
--
Bart Veer eCos Configuration Architect
http://www.ecoscentric.com/ The eCos and RedBoot experts
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss