blob: 42988bcb30f1058b5e7b066f98b3a166ee85cca0 [file] [log] [blame]
Charmonizer - Use C to configure C.
Charmonizer is a tool for probing, normalizing, and testing the build
environment provided by a C compiler and an operating system. It works by
attempting to compile lots of little programs and analyzing the output
from those that build successfully. `
Charmonizer modules are ordinary ANSI C files, and the configuration
application that you write is an ordinary C executable.
Charmonizer's only prerequisite is an ISO C90-compliant compiler which can
be invoked from C via the system() command. The build system assumes you
have a corresponding make or nmake executable. Folks hacking on the Charmonizer
source need to be aware of ../devel/bin/ which
generates the makefiles from the src tree.
#include "Charmonizer/Probe.h"
#include "Charmonizer/Probe/Integers.h"
#include "Charmonizer/Probe/LargeFiles.h"
int main()
/* Tell Charmonizer about your OS and compiler. */
chaz_Probe_init("cc", "-I/usr/local/include", NULL);
/* Run desired Charmonizer modules. */
/* Tear down. */
return 0;
The purpose of Charmonizer's probing toolset is to generate a single C
header file called "charmony.h", gathering together information that is
ordinarily only available at runtime and assigning predictable names to
functionality which may go by many different aliases on different systems.
One header file, "Charmonizer/Probe.h", provides the primary interface and
a suite of topically oriented modules -- e.g.
"Charmonizer/Probe/LargeFiles.h", "Charmonizer/Probe/Integers.h" -- do the
heavy lifting. Each topical module exports 1 main function,
ModuleName_run(), which runs all the relevant compiler probes and appends
output to charmony.h. As you run each module in turn, "charmony.h" gets
built up incrementally; it can be further customized by writing your own
content to it at any point.
#include "Charmonizer/Test.h"
#include "Charmonizer/Test/Integers.h"
#include "Charmonizer/Test/Largefile.h"
#include "MyTest.h"
int main() {
int all_tests_pass = 0;
/* Set up. */
/* Run all the tests */
all_tests_pass = chaz_Test_run_all_tests();
/* Tear down. */
return all_tests_pass;
Charmonizer provides both a general test harness for writing your own
tests, and a corresponding test module for each probing module. The stock
tests can be found within "Charmonizer/Test" -- e.g. at
The stock tests require access to "charmony.h". Not all tests will pass
in every environment, and the expectation is that you will append
charmony.h with ifdef tests as necessary to draw in supplementary code:
#ifndef HAS_DIRENT_H
#include "my/dirent.h"
Charmonizer restricts itself to working with what it finds, and
does not supply a library of compatibility functions.
The "charmony.h" header prepends a prefix onto most of the symbols it
exports: either "chy_" or "CHY_". For public code, such as header files,
this helps avoid namespace collisions. For private code, the prefixes can
be stripped via the CHY_USE_SHORT_NAMES symbol.
#ifdef HAS_LONG_LONG /* alias for CHY_HAS_LONG_LONG */
Charmonizer creates a number of temporary files within the current working
directory while it runs. These files all begin with "_charm".