
| Jump to: | OMake Home • Guide Home • Guide (single-page) • Contents (short) • Contents (long) | |
| Index: | All • Variables • Functions • Objects • Targets • Options |
autoconf scripts
OMake standard library provides a number of functions and variables intended to help one write build specifications that need to be capable of autoconfiguring itself to adjust to different build environments.
The following general-purpose functions can be used to discover the properties of your build
environment in a fashion similar to the one used by GNU autoconf tool you may be familiar with.
It is recommended that these function be used from an appropriate static. block (see
Section 4.15 for more information).
In order to use the following general-purpose functions, you need to have the line
open configure/Configure
included in your OMakefile or OMakeroot.
ConfMsgChecking(<msg>) ... ConfMsgResult(<msg>)
The ConfMsgChecking function output message of the form --- Checking <msg>...
without any trailing newline. After the test advertized by ConfMsgChecking is
performed, the ConfMsgResult function should be used to output the result.
In certain cases users may want to redefine these function — for example, to use a different output formatting and/or to copy the messages to a log file.
Example:
static. = ConfMsgChecking(which foo to use) foo = ... ConfMsgResult($(foo))
ConfMsgWarn(<msg>) ConfMsgError(<msg>)
Print a warning or an error message respectively. ConfMsgError would then abort OMake.
flag = $(ConfMsgYesNo <bool expr> flag = $(ConfMsgFound <bool expr>
The ConfMsgFound function expects to receive a boolean flag describing whether a test
previously announced using the ConfMsgChecking function found what it
was looking for. ConfMsgFound will output the appropriate result (“found” or “NOT found”)
using the ConfMsgResult function and return its argument back.
The ConfMsgYesNo function is similar, outputting a simple (“yes” or “NO”).
success = $(TryCompileC <prog_text>) success = $(TryLinkC <prog_text>) success = $(TryRunC <prog_text>)
Given the text of a C program, the TryCompileC, TryLinkC, and TryRunC
functions would try to compile / compile and link / compile, link, and run, the given program and return a boolean flag
indicating whether the attempt was successful.
TryCompileC will use the CC, CFLAGS and INCLUDES variables
to run the C compiler. TryLinkC and TryRunC will also use the LDFLAGS variable
to run the C compiler and linker. However, the flags like /WX, -Werror and -warn-error
will be not be passed to the compiler, even if they occur in CFLAGS.
These functions are silent and should normally be used with an appropriate
ConfMsgChecking … ConfMsgResult.
output = $(RunCProg <prog>)
RunCProg is similar to the RunCProg function, except that it
returns the output of the function (will return false if the program fails to compile
or run).
success = $(CheckCHeader <files>) success = $(VerboseCheckCHeader <files>)
Use the TryCompileC function to check whether your C compiler can locate
and process the specified headers files.
Will incude <stdio.h> before including the header files.
Both functions return a boolean value. The CheckCHeader function is silent; the
VerboseCheckCHeader function will use the ConfMsgChecking and
ConfMsgResult functions to describe the test and the outcome.
Example:
static. = NCURSES_H_AVAILABLE = $(VerboseCheckCHeader ncurses.h)
success = $(CheckCLib <libs>, <functions>) success = $(VerboseCheckCLib <libs>, <functions>)
Use the TryLinkC function to check whether your C compiler and linker can
find the named functions when linking with the named libraries. Will pass the <libs> to
the compiler using the -l flag.
Both functions return a boolean value. The CheckCLib function is silent; the
VerboseCheckCHeader function will use the ConfMsgChecking and
ConfMsgResult functions to describe the test and the outcome.
Example:
static. =
NCURSES_LIB_AVAILABLE = $(VerboseCheckCLib ncurses, initscr setupterm tigetstr)
Checks whether the program <prog> exists in your path. Will use the
ConfMsgChecking and
ConfMsgResult functions to describe the test and the outcome.
autoconf scripts
Some of the functions described above are very similar to the ones present in autoconf.
Below is a brief translation table for such functions.
AC_MSG_CHECKING is very similar to ConfMsgChecking function.
AC_MSG_RESULT is very similar to ConfMsgResult function.
AC_MSG_WARN is very similar to ConfMsgWarn function.
AC_MSG_ERROR is very similar to ConfMsgError function.
AC_TRY_COMPILE is somewhat similar to TryCompileC function,
except the TryCompileC function returns a boolean value and only works for C. Similarly,
AC_TRY_LINK is approximated by TryLinkC function, and
AC_TRY_RUN is approximated by TryRunC function.
A number of configuration tests are already included in the standard library.
In order to use them in your project, simply open (see Section 4.8) the
corresponding build file in your OMakefile and the tests will run the first time OMake
is executed. Note that it is not a problem to open these files from more than one place in
your project — if you do that, the test will still run only once.
Add open configure/ncurses line to your OMakefile to get access to the following
autoconfiguration variables.
A boolean flag that would be set when both
the curses.h header, the term.h header, and the ncurses library very found.
A boolean flag that would be set
when term.h has to be included as <ncurses/term.h> instead of <term.h>.
The CFLAGS to use when compiling ncurses code.
Will include -DNCURSES and -DTERMH_IN_NCURSES, respectively
when NCURSES_AVAILABLE and NCURSES_TERMH_IN_NCURSES are true.
The LDFLAGS to use when linking ncurses code.
Will normally contain -lncurses when ncurses is found and remain empty otherwise.
Add open configure/readline line to your OMakefile to get access to the following
autoconfiguration variables.
A boolean flag that would be set when both
the readline/readline.h header, the readline/history.h header, and the readline
library very found.
A boolean flag that would be set when the GNU version of the readline library is found (as opposed to the BSD one).
The CFLAGS to use when compiling readline code.
Will include -DREADLINE_ENABLED and -DREADLINE_GNU, respectively
when READLINE_AVAILABLE and READLINE_GNU are true.
The LDFLAGS to use when linking readline code.
Will normally contain -lncurses -lreadline when readline is found and remain empty otherwise.
Add open configure/snprintf line to your OMakefile to get access to the following
autoconfiguration variables.
A boolean flag telling whether the snprintf function is available in the standard C library.
| Jump to: | OMake Home • Guide Home • Guide (single-page) • Contents (short) • Contents (long) | |
| Index: | All • Variables • Functions • Objects • Targets • Options |