From aa0c1ec1f5919e46a5afb0033f0282625d8bb803 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 12 Jun 2018 12:07:51 +0930 Subject: [PATCH] tools/configurator: add manual page. Signed-off-by: Rusty Russell --- doc/Makefile | 8 +- doc/configurator.1 | 216 ++++++++++++++++++++++++++++++ doc/configurator.1.txt | 152 +++++++++++++++++++++ tools/configurator/configurator.c | 47 ++++--- 4 files changed, 402 insertions(+), 21 deletions(-) create mode 100644 doc/configurator.1 create mode 100644 doc/configurator.1.txt diff --git a/doc/Makefile b/doc/Makefile index 57307923..5aea5606 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -1,5 +1,7 @@ -ccanlint.1: ccanlint.1.txt - a2x --format=manpage ccanlint.1.txt +default: ccanlint.1 configurator.1 + +%.1: %.1.txt + a2x --format=manpage $< distclean: - rm -f ccanlint.1 + rm -f ccanlint.1 configurator.1 diff --git a/doc/configurator.1 b/doc/configurator.1 new file mode 100644 index 00000000..aaa92c52 --- /dev/null +++ b/doc/configurator.1 @@ -0,0 +1,216 @@ +'\" t +.\" Title: configurator +.\" Author: [see the "AUTHOR" section] +.\" Generator: DocBook XSL Stylesheets v1.79.1 +.\" Date: 03/01/2018 +.\" Manual: \ \& +.\" Source: \ \& +.\" Language: English +.\" +.TH "CONFIGURATOR" "1" "03/01/2018" "\ \&" "\ \&" +.\" ----------------------------------------------------------------- +.\" * Define some portability stuff +.\" ----------------------------------------------------------------- +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.\" http://bugs.debian.org/507673 +.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html +.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.ie \n(.g .ds Aq \(aq +.el .ds Aq ' +.\" ----------------------------------------------------------------- +.\" * set default formatting +.\" ----------------------------------------------------------------- +.\" disable hyphenation +.nh +.\" disable justification (adjust text to left margin only) +.ad l +.\" ----------------------------------------------------------------- +.\" * MAIN CONTENT STARTS HERE * +.\" ----------------------------------------------------------------- +.SH "NAME" +configurator \- Generate a simple config\&.h or variable file +.SH "SYNOPSIS" +.sp +\fBconfigurator\fR [\fIOPTIONS\fR] [\fICC\fR] [\fICFLAGS\fR\&...] +.SH "DESCRIPTION" +.sp +\fBconfigurator\fR is a standalone C program which evaluates the C environment using code snippets\&. +.sp +The C compiler (and flags) can be provided on the command\-line, otherwise built\-in defaults are used\&. +.sp +It has a builtin set of tests, to which more can be added\&. By default it produces a C header file to standard output, but it can also produce a file containing simple "key=value" lines suitable for parsing by \fBsh\fR or \fBmake\fR\&. +.SH "OPTIONS" +.PP +\fB\-v\fR +.RS 4 +Print out every test result; specified twice, print out each test too\&. +.RE +.PP +\fB\-vv\fR +.RS 4 +Shortcut for two +\fB\-v\fR +options\&. +.RE +.PP +\fB\-\-var\-file=\fR +.RS 4 +Output results in format +\fI=\fR +to +\fI\fR, or stdout if +\fI\fR +is +\fI\-\fR\&. Default is not to output this\&. +.RE +.PP +\fB\-\-header\-file=\fR +.RS 4 +Output C\-style header to +\fI\fR +instead out stdout\&. +.RE +.PP +\fB\-\-autotools\-style\fR +.RS 4 +Produce output to stdout like autotools\*(Aq configure script\&. This usually means you want to use +\fB\-\-header\-file\fR +so that doesn\(cqt mix with stdout\&. +.RE +.PP +\fB\-O\fR +.RS 4 +Override option to set compiler output file\&. +.RE +.PP +\fB\-\-configurator\-cc=\fR +.RS 4 +This gives the real compiler command to use for tests, instead of the first commandline argument or the default\&. +.RE +.PP +\fB\-\-extra\-tests\fR +.RS 4 +Read additional tests from stdin, see +\fIEXTRA TESTS\fR +below\&. +.RE +.SH "OUTPUT" +.sp +The header output is \fI#ifndef/#define\fR idempotent\-wrapped using \fICCAN_CONFIG_H\fR, and defines \fI_GNU_SOURCE\fR\&. It also defines \fICCAN_COMPILER\fR, \fICCAN_CFLAGS\fR and \fICCAN_OUTPUT_EXE_CFLAG\fR as either the built\-in definitions or those provided on the command line\&. The remainder is \fI#define\fR of the test names followed by a \fI0\fR or \fI1\fR: note that this means you should use \fI#if\fR not \fI#ifdef\fR to test features in your C programs! +.sp +The var\-file output is simply the test names followed by \fI=1\fR or \fI=0\fR\&. +.SH "EXTRA TESTS" +.sp +Extra tests must be formatted as \fI=\fR pairs, with leading whitespace and \fI#\fR lines ignored\&. +.sp +The first three lines are always the same: +.PP +\fBvar=\fR +.RS 4 +Define the variable set by the test, e\&.g\&. +\fIvar=HAVE_FOO\fR\&. +.RE +.PP +\fBdesc=\fR +.RS 4 +The description printed out with +\fB\-\-autotools\-style\fR, e\&.g\&. +\fIfoo support\fR\&. +.RE +.PP +\fBstyle=