📄 build.headers.html
字号:
CLASS="PROGRAMLISTING"> define FOPEN_MAX</PRE></TD></TR></TABLE><P>This will result in something like:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">#define FOPEN_MAX 8#define FOPEN_MAX_8</PRE></TD></TR></TABLE><P>The specified symbol must be a valid C preprocessor symbol. Normallythe <TTCLASS="LITERAL">#define</TT> will end up in the same header file asthe default one, in other words <TTCLASS="FILENAME">pkgconf/system.h</TT> in the case of a<TTCLASS="LITERAL">cdl_package</TT>, or the package's own header file for any other option.The <TTCLASS="LITERAL">-file</TT> option can be used to change this. Atpresent the only legal value is <TTCLASS="LITERAL">system.h</TT>, forexample:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING"> define -file=system.h <symbol></PRE></TD></TR></TABLE><P>This will cause the <TTCLASS="LITERAL">#define</TT> to end up in the globalconfiguration header rather than in the package's own header. Use ofthis facility should be avoided since it is very rarely necessary tomake options globally visible.</P><P>The <SPANCLASS="PROPERTY">define</SPAN> property takes another option,<TTCLASS="LITERAL">-format</TT>, to provide a format string.</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING"> define -format=%08x <symbol></PRE></TD></TR></TABLE><P>This should only be used for options with the <TTCLASS="LITERAL">data</TT>or <TTCLASS="LITERAL">booldata</TT> flavor, and has the same effect as the<SPANCLASS="PROPERTY">define_format</SPAN> property has on the default<TTCLASS="LITERAL">#define</TT>.</P><P><SPANCLASS="PROPERTY">define</SPAN> properties are processed in the same way the default<TTCLASS="LITERAL">#define</TT>. For options with the<TTCLASS="LITERAL">bool</TT> or <TTCLASS="LITERAL">none</TT> flavors a single<TTCLASS="LITERAL">#define</TT> will be generated using the value<TTCLASS="LITERAL">1</TT>. For options with the <TTCLASS="LITERAL">data</TT> or<TTCLASS="LITERAL">booldata</TT> flavors either one or two<TTCLASS="LITERAL">#define's</TT> will be generated.</P></LI><LI><P>After processing all <SPANCLASS="PROPERTY">define</SPAN> properties, the component framework willlook for any <SPANCLASS="PROPERTY">if_define</SPAN> properties. These take the following form:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING"> if_define [-file=<filename>] <symbol1> <symbol2></PRE></TD></TR></TABLE><P>For example:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING"> if_define CYGSRC_KERNEL CYGDBG_USE_ASSERTS</PRE></TD></TR></TABLE><P>The following will be generated in the configuration header file:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">#ifdef CYGSRC_KERNEL# define CYGDBG_USE_ASSERTS#endif</PRE></TD></TR></TABLE><P>Typical kernel source code would begin with the following construct:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">#define CYGSRC_KERNEL 1#include <pkgconf/kernel.h>#include <cyg/infra/cyg_ass.h></PRE></TD></TR></TABLE><P>The infrastructure header file <TTCLASS="FILENAME">cyg/infra/cyg_ass.h</TT> only checks for symbolssuch as <TTCLASS="LITERAL">CYGDBG_USE_ASSERTS</TT>, and has no specialknowledge of the kernel or any other package. The <SPANCLASS="PROPERTY">if_define</SPAN> propertywill only affect code that defines the symbol<TTCLASS="LITERAL">CYGSRC_KERNEL</TT>, so typically only kernel sourcecode. If the option is enabled then assertion support will be enabledfor the kernel source code only. If the option is inactive or disabledthen kernel assertions will be disabled. Assertions in other packagesare not affected. Thus the <SPANCLASS="PROPERTY">if_define</SPAN> property allows control overassertions, tracing, and similar facilities at the level of individualpackages, or at finer levels such as components or even single sourcefiles if desired.</P><DIVCLASS="NOTE"><BLOCKQUOTECLASS="NOTE"><P><B>Note: </B>Current <SPANCLASS="APPLICATION">eCos</SPAN> packages do not yet make use of this facility. Insteadthere is a single global configuration option<TTCLASS="VARNAME">CYGDBG_USE_ASSERTS</TT> which is used to enable ordisable assertions for all packages. This issue should be addressed ina future release of the system.</P></BLOCKQUOTE></DIV><P>As with the <SPANCLASS="PROPERTY">define</SPAN> property, the <SPANCLASS="PROPERTY">if_define</SPAN> property takes anoption <TTCLASS="LITERAL">-file</TT> with a single legal value<TTCLASS="LITERAL">system.h</TT>. This allows the output to be redirectedto <TTCLASS="FILENAME">pkgconf/system.h</TT> if and whennecessary. </P></LI><LI><P>The final property that is relevant to configuration header filegeneration is <SPANCLASS="PROPERTY">define_proc</SPAN>. This takes a single argument, a <SPANCLASS="APPLICATION">Tcl</SPAN>fragment that can add arbitrary data to the global header <TTCLASS="FILENAME">pkgconf/system.h</TT> and to the package's ownheader. When the <SPANCLASS="PROPERTY">define_proc</SPAN> script is invoked two variables will beset up to allow access to these headers: <TTCLASS="LITERAL">cdl_header</TT>will be a channel to the package's own header file, for example<TTCLASS="FILENAME">pkgconf/kernel.h</TT>;<TTCLASS="LITERAL">cdl_system_header</TT> will be a channel to <TTCLASS="FILENAME">pkgconf/system.h</TT>. A typical <SPANCLASS="PROPERTY">define_proc</SPAN>script will use the <SPANCLASS="APPLICATION">Tcl</SPAN> <TTCLASS="LITERAL">puts</TT> command to outputdata to one of these channels, for example:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">cdl_option <name> { … define_proc { puts $::cdl_header "#define XXX 1" }}</PRE></TD></TR></TABLE><DIVCLASS="NOTE"><BLOCKQUOTECLASS="NOTE"><P><B>Note: </B>In the current implementation the use of <SPANCLASS="PROPERTY">define_proc</SPAN> is limitedbecause the <SPANCLASS="APPLICATION">Tcl</SPAN> script cannot access any of the configuration data.Therefore the script is limited to writing constant data to theconfiguration headers. This is a major limitation which will beaddressed in a future release of the component framework.</P></BLOCKQUOTE></DIV></LI></OL><DIVCLASS="NOTE"><BLOCKQUOTECLASS="NOTE"><P><B>Note: </B>Generating C header files with <TTCLASS="LITERAL">#define's</TT> for theconfiguration data suffices for existing packages written in somecombination of C, C++ and assembler. It can also be used inconjunction with some other languages, for example by first passingthe source code through the C preprocessor and feeding the result intothe appropriate compiler. In future versions of the componentframework additional programming languages such as Java may besupported, and the configuration data may also be written to files insome format other than C preprocessor directives. </P></BLOCKQUOTE></DIV><DIVCLASS="NOTE"><BLOCKQUOTECLASS="NOTE"><P><B>Note: </B>At present there is no way for application or package source code toget hold of all the configuration details related to the currenthardware. Instead that information is spread over various differentconfiguration headers for the HAL and device driver packages, withsome of the information going into <TTCLASS="FILENAME">pkgconf/system.h</TT>. It is possible that insome future release of the system there will be another globalconfiguration header file <TTCLASS="FILENAME">pkgconf/hardware.h</TT> which either contains theconfiguration details for the various hardware-specific packages orwhich <TTCLASS="LITERAL">#include's</TT> all the hardware-specificconfiguration headers. The desirability and feasibility of such ascheme are still to be determined. To avoid future incompatibilityproblems as a result of any such changes, it is recommended that allhardware packages (in other packages containing the <SPANCLASS="PROPERTY">hardware</SPAN>property) use the <SPANCLASS="PROPERTY">define_header</SPAN> property to specify explicitly whichconfiguration header should be generated.</P></BLOCKQUOTE></DIV><DIVCLASS="SECT2"><H2CLASS="SECT2"><ANAME="BUILD.HEADERS.SYSTEM.H">The <TTCLASS="FILENAME">system.h</TT> Header</H2><P>Typically configuration header files are <TTCLASS="LITERAL">#include'd</TT>only by the package's source code at build time, or by a package'sexported header files if the interface provided by the package may beaffected by a configuration option. There should be no need forapplication code to know the details of individual configurationoptions, instead the configuration should specifically meet the needsof the application.</P><P>There are always exceptions. Application code may want to adapt toconfiguration options, for example to do different things for ROM andRAM booting systems, or when it is necessary to support severaldifferent target boards. This is especially true if the code in questionis really re-usable library code which has not been converted to aneCos package, and hence cannot use any CDL facilities.</P><P>A major problem here is determining which packages are in theconfiguration: attempting to <TTCLASS="LITERAL">#include</TT> a header filesuch as <TTCLASS="FILENAME">pkgconf/net.h</TT>when it is not known for certain that that particular package is partof the configuration will result in compilation errors. The globalheader file <TTCLASS="FILENAME">pkgconf/system.h</TT>serves to provide such information, so application code can usetechniques like the following:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">#include <pkgconf/system.h>#ifdef CYGPKG_NET# include <pkgconf/net.h>#endif</PRE></TD></TR></TABLE><P>This will compile correctly irrespective of the eCos configuration,and subsequent code can use <TTCLASS="LITERAL">#ifdef</TT> or similardirectives on <TTCLASS="LITERAL">CYGPKG_NET</TT> or any of theconfiguration options in that package. </P><P>In addition to determining whether or not a package is present, theglobal configuration header file can also be used to find out thespecific version of a package that is being used. This can be usefulif a more recent version exports additional functionality. It may alsobe necessary to adapt to incompatible changes in the exportedinterface or to changes in behaviour. For each package theconfiguration system will typically <TTCLASS="LITERAL">#define</TT> threesymbols, for example for a V1.3.1 release:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">#define CYGNUM_NET_VERSION_MAJOR 1#define CYGNUM_NET_VERSION_MINOR 3#define CYGNUM_NET_VERSION_RELEASE 1</PRE></TD></TR></TABLE><P>There are a number of problems associated with such version<TTCLASS="LITERAL">#define's</TT>. The first restriction is that thepackage must follow the standard naming conventions, so the packagename must be of the form <TTCLASS="LITERAL">xxxPKG_yyy</TT>. The threecharacters immediately preceding the first underscore must be<TTCLASS="LITERAL">PKG</TT>, and will be replaced with<TTCLASS="LITERAL">NUM</TT> when generating the version<TTCLASS="LITERAL">#define's</TT>. If a package does not follow the namingconvention then no version <TTCLASS="LITERAL">#define's</TT> will begenerated. </P><P>Assuming the package does follow the naming conventions, theconfiguration tools will always generate three version<TTCLASS="LITERAL">#define's</TT> for the major, minor, and releasenumbers. The symbol names are obtained from the package name byreplacing <TTCLASS="LITERAL">PKG</TT> with <TTCLASS="LITERAL">NUM</TT> andappending <TTCLASS="LITERAL">_VERSION_MAJOR</TT>,<TTCLASS="LITERAL">_VERSION_MINOR</TT> and<TTCLASS="LITERAL">_VERSION_RELEASE</TT>. It is assumed that the resultingsymbols will not clash with any configuration option names. The valuesfor the <TTCLASS="LITERAL">#define's</TT> are determined by searching theversion string for sequences of digits, optionally preceded by a minussign. It is possible that some or all of the numbers are absent in anygiven version string, in which case <TTCLASS="LITERAL">-1</TT> will be usedin the <TTCLASS="LITERAL">#define</TT>. For example, given a version stringof <TTCLASS="LITERAL">V1.12beta</TT>, the major version number is<TTCLASS="LITERAL">1</TT>, the minor number is <TTCLASS="LITERAL">12</TT>, andthe release number is <TTCLASS="LITERAL">-1</TT>. Given a version string of<TTCLASS="LITERAL">beta</TT> all three numbers would be set to<TTCLASS="LITERAL">-1</TT>.</P><P>There is special case code for the version <TTCLASS="LITERAL">current</TT>,which typically corresponds to a development version obtained viaanonymous CVS or similar means. The configuration system has specialbuilt-in knowledge of this version, and will assume it is more recentthan any specific release number. The global configuration headerdefines a special symbol <TTCLASS="LITERAL">CYGNUM_VERSION_CURRENT</TT>,and this will be used as the major version number when version<TTCLASS="LITERAL">current</TT> of a package is used:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">#define CYGNUM_VERSION_CURRENT 0x7fffff00...#define CYGNUM_INFRA_VERSION_MAJOR CYGNUM_VERSION_CURRENT#define CYGNUM_INFRA_VERSION_MINOR -1#define CYGNUM_INFRA_VERSION_RELEASE -1</PRE></TD></TR></TABLE><P>The large number used for <TTCLASS="LITERAL">CYGNUM_VERSION_CURRENT</TT>should ensure that major version comparisons work as expected, whilestill allowing for a small amount of arithmetic in case that provesuseful. </P><P>It should be noted that this implementation of version<TTCLASS="LITERAL">#define's</TT> will not cope with all version numberschemes. However for many cases it should suffice.</P></DIV></DIV><DIVCLASS="NAVFOOTER"><HRALIGN="LEFT"WIDTH="100%"><TABLESUMMARY="Footer navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top"><AHREF="build.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="cdl-guide.html"ACCESSKEY="H">Home</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top"><AHREF="build.make.html"ACCESSKEY="N">Next</A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top">The Build Process</TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="build.html"ACCESSKEY="U">Up</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top">Building eCos</TD></TR></TABLE></DIV></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -