1240116Smarcel        THIS TARBALL IS NOT A FULL DISTRIBUTION.
2240116Smarcel
3240116SmarcelThe contents of this tarball is designed to be incorporated into
4240116Smarcelsoftware packages that utilize the AutoOpts option automation package
5240116Smarceland are intended to be installed on systems that may not have libopts
6240116Smarcelinstalled.  It is redistributable under the terms of either the LGPL
7240116Smarcel(see COPYING.lgpl) or under the terms of the advertising clause free BSD
8240116Smarcellicense (see COPYING.mbsd).
9240116Smarcel
10240116SmarcelUsage Instructions for autoconf/automake/libtoolized projects:
11240116Smarcel
12240116Smarcel1. Install the unrolled tarball into your package source tree,
13240116Smarcel   copying ``libopts.m4'' to your autoconf macro directory.
14240116Smarcel
15240116Smarcel   In your bootstrap (pre-configure) script, you can do this:
16240116Smarcel
17240116Smarcel      rm -rf libopts libopts-*
18240116Smarcel      gunzip -c `autoopts-config libsrc` | tar -xvf -
19240116Smarcel      mv -f libopts-*.*.* libopts
20240116Smarcel      cp -fp libopts/m4/*.m4 m4/.
21240116Smarcel
22240116Smarcel   I tend to put my configure auxiliary files in "m4".
23240116Smarcel   Whatever directory you choose, if it is not ".", then
24240116Smarcel   be sure to tell autoconf about it with:
25240116Smarcel
26240116Smarcel      AC_CONFIG_AUX_DIR(m4)
27240116Smarcel
28240116Smarcel   This is one macro where you *MUST* remember to *NOT* quote
29240116Smarcel   the argument.  If you do, automake will get lost.
30240116Smarcel
31240116Smarcel2. Add an invocation of either LIBOPTS_CHECK or LIBOPTS_CHECK_NOBUILD
32240116Smarcel   to your configure.ac file.  See LIBOPTS_CHECK: below for details.
33240116Smarcel
34240116Smarcel3. Add the following to your top level ``Makefile.am'' file:
35240116Smarcel
36240116Smarcel      if NEED_LIBOPTS
37240116Smarcel         SUBDIRS += $(LIBOPTS_DIR)
38240116Smarcel      endif
39240116Smarcel
40240116Smarcel   where ``<...>'' can be whatever other files or directories you may
41240116Smarcel   need.  The SUBDIRS must be properly ordered.  *PLEASE NOTE* it is
42240116Smarcel   crucial that the SUBDIRS be set under the control of an automake
43240116Smarcel   conditional.  To work correctly, automake has to know the range of
44240116Smarcel   possible values of SUBDIRS.  It's a magical name with magical
45240116Smarcel   properties.  ``NEED_LIBOPTS'' will be correctly set by the
46262855Sjmmv   ``LIBOPTS_CHECK'' macro, above.
47262855Sjmmv
48240116Smarcel4. Add ``$(LIBOPTS_CFLAGS)'' to relevant compiler flags and
49240116Smarcel   ``$(LIBOPTS_LDADD)'' to relevant link options whereever
50240116Smarcel   you need them in your build tree.
51240116Smarcel
52240116Smarcel5. Make sure your object files explicitly depend upon the
53240116Smarcel   generated options header file.  e.g.:
54240116Smarcel
55240116Smarcel     $(prog_OBJECTS) : prog-opts.h
56240116Smarcel     prog-opts.h : prog-opts.c
57240116Smarcel     prog-opts.c : prog-opts.def
58240116Smarcel         autogen prog-opts.def
59240116Smarcel
60262855Sjmmv6. *OPTIONAL* --
61240116Smarcel   If you are creating man pages and texi documentation from
62240116Smarcel   the program options, you will need these rules somewhere, too:
63240116Smarcel
64240116Smarcel     man_MANS = prog.1
65240116Smarcel     prog.1 : prog-opts.def
66240116Smarcel         autogen -Tagman-cmd.tpl -bprog prog-opts.def
67240116Smarcel
68240116Smarcel     invoke-prog.texi : prog-opts.def
69240116Smarcel         autogen -Tagtexi-cmd.tpl prog-opts.def
70240116Smarcel
71240116SmarcelIf your package does not utilize the auto* tools, then you
72240116Smarcelwill need to hand craft the rules for building the library.
73240116Smarcel
74240116SmarcelLIBOPTS_CHECK:
75240116Smarcel
76240116SmarcelThe arguments to both macro are a relative path to the directory with
77240116Smarcelthe libopts source code.  It is optional and defaults to "libopts".
78240116SmarcelThese macros work as follows:
79240116Smarcel
80240116Smarcel1.  LIBOPTS_CHECK([libopts/rel/path/optional])
81240116Smarcel
82240116Smarcel    Adds two command-line options to the generated configure script,
83240116Smarcel    --enable-local-libopts and --disable-libopts-install.  AC_SUBST's
84240116Smarcel    LIBOPTS_CFLAGS, LIBOPTS_LDADD, and LIBOPTS_DIR for use in
85240116Smarcel    Makefile.am files.  Adds Automake conditional NEED_LIBOPTS which
86240116Smarcel    will be true when the local copy of libopts should be built.  Uses
87240116Smarcel    AC_CONFIG_FILES([$libopts-dir/Makefile]) to cause the local libopts
88240116Smarcel    into the package build.  If the optional relative path to libopts is
89240116Smarcel    not provided, it defaults to simply "libopts".
90240116Smarcel
91240116Smarcel2.  LIBOPTS_CHECK_NOBUILD([libopts/rel/path/optional])
92240116Smarcel
93240116Smarcel    This variant of LIBOPTS_CHECK is useful when multiple configure.ac
94240116Smarcel    files in a package make use of a single libopts tearoff.  In that
95240116Smarcel    case, only one of the configure.ac files should build libopts and
96240116Smarcel    others should simply use it.  Consider this package arrangment:
97240116Smarcel
98240116Smarcel    all-tools/
99240116Smarcel      configure.ac
100240116Smarcel      common-tools/
101240116Smarcel        configure.ac
102240116Smarcel        libopts/
103240116Smarcel
104240116Smarcel    The parent package all-tools contains a subpackage common-tools
105240116Smarcel    which can be torn off and used independently.  Programs configured
106240116Smarcel    by both configure.ac files link against the common-tools/libopts
107240116Smarcel    tearoff, when not using the system's libopts.  The top-level
108240116Smarcel    configure.ac uses LIBOPTS_CHECK_NOBUILD([common-tools/libopts]),
109240116Smarcel    while common-tools/configure.ac uses LIBOPTS_CHECK.  The difference
110240116Smarcel    is LIBOPTS_CHECK_NOBUILD will never build the libopts tearoff,
111240116Smarcel    leaving that to the subpackage configure.ac's LIBOPTS_CHECK.
112240116Smarcel    Specifically, LIBOPTS_CHECK_NOBUILD always results in the
113240116Smarcel    NEED_LIBOPTS Automake conditional being false, and does not invoke
114240116Smarcel    AC_CONFIG_FILES(path-to-libopts/Makefile).
115240116Smarcel
116240116SmarcelLICENSING:
117240116Smarcel
118240116SmarcelThis material is Copyright (C) 1992-2015 by Bruce Korb.  You are
119240116Smarcellicensed to use this under the terms of either the GNU Lesser General
120240116SmarcelPublic License (see: COPYING.lgpl), or, at your option, the modified
121240116SmarcelBerkeley Software Distribution License (see: COPYING.mbsd).  Both of
122240116Smarcelthese files should be included with this tarball.
123240116Smarcel