[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
There are actually several levels of using
autoopts.
Which you choose depends upon how you plan to distribute
(or not) your application.
7.9.1 local-only use | ||
7.9.2 binary distro, AutoOpts not installed | ||
7.9.3 binary distro, AutoOpts pre-installed | ||
7.9.4 source distro, AutoOpts pre-installed | ||
7.9.5 source distro, AutoOpts not installed |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
To use AutoOpts in your application where you do not have to worry about distribution issues, your issues are simple and few.
myopts.h
)
and the option descriptor code (myopts.c
):
autogen myopts.def |
#include "myopts.h"
.
#define ARGC_MIN some-lower-limit #define ARGC_MAX some-upper-limit main( int argc, char** argv ) { { int arg_ct = optionProcess( &myprogOptions, argc, argv ); argc -= arg_ct; if ((argc < ARGC_MIN) || (argc > ARGC_MAX)) { fprintf( stderr, "%s ERROR: remaining args (%d) " "out of range\n", myprogOptions.pzProgName, argc ); USAGE( EXIT_FAILURE ); } argv += arg_ct; } if (HAVE_OPT(OPTN_NAME)) respond_to_optn_name(); ... } |
`autoopts-config cflags ldflags` myopts.c |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
If you will be distributing (or copying) your project to a system that
does not have AutoOpts installed, you will need to statically link the
AutoOpts library, libopts
into your program. Get the link information
with static-libs
instead of ldflags
:
`autoopts-config static-libs` |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
If you will be distributing (or copying) your project to a system that does
have AutoOpts (or only libopts
) installed, you will still need to
ensure that the library is findable at program load time, or you will still
have to statically link. The former can be accomplished by linking your
project with ‘--rpath’ or by setting the LD_LIBRARY_PATH
appropriately. Otherwise, See section binary distro, AutoOpts not installed.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
If you will be distributing your project to a system that will build your product but it may not be pre-installed with AutoOpts, you will need to do some configuration checking before you start the build. Assuming you are willing to fail the build if AutoOpts has not been installed, you will still need to do a little work.
AutoOpts is distributed with a configuration check M4 script,
‘autoopts.m4’. It will add an autoconf
macro named,
AG_PATH_AUTOOPTS
. Add this to your ‘configure.ac’ script
and use the following substitution values:
AUTOGEN
the name of the autogen executable
AUTOGEN_TPLIB
the directory where AutoGen template library is stored
AUTOOPTS_CFLAGS
the compile time options needed to find the AutoOpts headers
AUTOOPTS_LIBS
the link options required to access the libopts
library
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
If you will be distributing your project to a system that will build
your product but it may not be pre-installed with AutoOpts, you may
wish to incorporate the sources for libopts
in your project.
To do this, I recommend reading the tear-off libopts library
‘README’ that you can find in the ‘pkg/libopts’ directory.
You can also examine an example package (blocksort) that incorporates
this tear off library in the autogen distribution directory. There is
also a web page that describes what you need to do:
http://autogen.sourceforge.net/blocksort.html |
Alternatively, you can pull the libopts
library sources into
a build directory and build it for installation along with your package.
This can be done approximately as follows:
tar -xzvf `autoopts-config libsrc` cd libopts-* ./bootstrap configure make make install |
That will install the library, but not the headers or anything else.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] |
This document was generated by Bruce Korb on August 21, 2015 using texi2html 1.82.