~ubuntu-branches/ubuntu/hardy/autoconf-archive/hardy

« back to all changes in this revision

Viewing changes to htmldoc/ac_cond_with.html

  • Committer: Bazaar Package Importer
  • Author(s): Martin A. Godisch
  • Date: 2004-06-26 09:43:57 UTC
  • Revision ID: james.westby@ubuntu.com-20040626094357-3be3jwcz1vcdhpe8
Tags: upstream-20040616
ImportĀ upstreamĀ versionĀ 20040616

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
 
2
"http://www.w3.org/TR/html4/strict.dtd">
 
3
 
 
4
<html lang="en">
 
5
<head>
 
6
  <title>Autoconf Macro: ac_cond_with</title>
 
7
  <link rel="stylesheet" type="text/css" href="ac-archive.css">
 
8
</head>
 
9
 
 
10
<body>
 
11
  <table summary="web navigation" style="width:100%;">
 
12
    <tbody>
 
13
      <tr>
 
14
        <td style="width:50%;" align="center">[<a href="index.html">Macro Index
 
15
        Page</a>]</td>
 
16
 
 
17
        <td style="width:50%;" align="center">[<a href=
 
18
        "../m4source/ac_cond_with.m4">Download M4 Source</a>]</td>
 
19
      </tr>
 
20
    </tbody>
 
21
  </table>
 
22
  <hr>
 
23
 
 
24
  <h1>ac_cond_with</h1>
 
25
 
 
26
  <h2>Synopsis</h2>
 
27
 
 
28
  <div class="indent">
 
29
    <p style="text-align:left; white-space:nowrap;"><code>AC_COND_WITH(PACKAGE
 
30
    [,DEFAULT])</code></p>
 
31
  </div>
 
32
 
 
33
  <h2>Description</h2>
 
34
 
 
35
  <div class="indent">
 
36
    <p>obsoleted - do not use this macro, use AX_SUBST_WITH or
 
37
    AM_CONDITIONAL</p>
 
38
 
 
39
    <p>actually used after an AC_ARG_WITH(PKG,...) option-directive, where
 
40
    AC_ARG_WITH is a part of the standard autoconf to define a `configure`
 
41
    --with-PKG option.</p>
 
42
 
 
43
    <p>the AC_COND_WITH(PKG) will use the $with_PKG var to define WITH_PKG and
 
44
    WITHOUT_PKG substitutions (AC_SUBST), that are either '' or '#' - depending
 
45
    whether the var was "no" or not (probably 'yes', or a value); it will also
 
46
    declare WITHVAL_PKG for use when someone wanted to set a val other than
 
47
    just "yes". And there is a WITHDEF_PKG that expands to a C-precompiler
 
48
    definition of the form -DWITH_PKG or -DWITH_PKG=\"value\" (n.b.: the PKG
 
49
    *is* uppercased if in lowercase and "-" translit to "_")</p>
 
50
 
 
51
    <p>this macro is most handily in making Makefile.in/Makefile.am that have a
 
52
    set of if-with declarations that can be defined as follows:</p>
 
53
    <pre>
 
54
 CFLAGS = -Wall @WITHOUT_FLOAT@ -msoft-float # --without-float
 
55
 @WITH_FLOAT@ LIBS += -lm              # --with-float
 
56
 DEFS += -DNDEBUG @WITHDEF_MY_PKG@     # --with-my-pkg="/usr/lib"
 
57
 DEFS += @WITHVAL_DEFS@                # --with-defs="-DLOGLEVEL=6"
 
58
</pre>
 
59
 
 
60
    <p>Example configure.in:</p>
 
61
    <pre>
 
62
 AC_ARG_WITH(float,
 
63
 [ --with-float,       with float words support])
 
64
 AC_COND_WITH(float,no)
 
65
</pre>
 
66
 
 
67
    <p>Extened notes:</p>
 
68
 
 
69
    <p>1. the idea comes from AM_CONDITIONAL but it is much easier to use, and
 
70
    unlike automake's ifcond, the Makefile.am will work as a normal $(MAKE) -f
 
71
    Makefile.am makefile.</p>
 
72
 
 
73
    <p>2. the @VALS@ are parsed over by automake so automake will see all the
 
74
    filenames and definitions that follow @WITH_FLOAT@, so that the
 
75
    AC_COND_WITH user can see additional message if they apply.</p>
 
76
 
 
77
    <p>3. in this m4-part, there's a AC_ARG_COND_WITH with the synopsis of
 
78
    AC_ARG_WITH and an implicit following AC_COND_WITH =:-)</p>
 
79
 
 
80
    <p>4. and there is an AC_ARG_COND_WITH_DEFINE that will emit an implicit
 
81
    AC_DEFINE that is actually seen by autoheader, even generated with the
 
82
    correct name and comment, for config.h.in</p>
 
83
 
 
84
    <p>some non-autoconf coders tend to create "editable" Makefile where they
 
85
    have out-commented lines with an example (additional) definition. Each of
 
86
    these can be replaced with a three-liner in configure.in as shown above.
 
87
    Starting to use AC_COND_WITH will soon lead you to provide a dozen
 
88
    --with-option rules for the `configure` user. Do it!</p>
 
89
  </div>
 
90
 
 
91
  <h2>Version</h2>
 
92
 
 
93
  <div class="indent">
 
94
    <p>1.4 (last modified: 2003-05-21)</p>
 
95
  </div>
 
96
 
 
97
  <h2>Author</h2>
 
98
 
 
99
  <div class="indent">
 
100
    <p>Guido Draheim &lt;guidod@gmx.de&gt;</p>
 
101
  </div>
 
102
 
 
103
  <h2>M4 Source Code</h2>
 
104
 
 
105
  <div class="indent">
 
106
    <pre class="m4source">
 
107
AC_DEFUN([AC_COND_WITH],
 
108
[dnl the names to be defined...
 
109
pushdef([WITH_VAR],    patsubst([with_$1], -, _))dnl
 
110
pushdef([VAR_WITH],    patsubst(translit([with_$1], [a-z], [A-Z]), -, _))dnl
 
111
pushdef([VAR_WITHOUT], patsubst(translit([without_$1], [a-z], [A-Z]), -, _))dnl
 
112
pushdef([VAR_WITHVAL], patsubst(translit([withval_$1], [a-z], [A-Z]), -, _))dnl
 
113
pushdef([VAR_WITHDEF], patsubst(translit([withdef_$1], [a-z], [A-Z]), -, _))dnl
 
114
AC_SUBST(VAR_WITH)
 
115
AC_SUBST(VAR_WITHOUT)
 
116
AC_SUBST(VAR_WITHVAL)
 
117
AC_SUBST(VAR_WITHDEF)
 
118
if test -z "$WITH_VAR" ; then WITH_VAR=`echo ifelse([$2], , no, [$2])` ; fi
 
119
if test "$WITH_VAR" != "no"; then
 
120
  VAR_WITH=    ; VAR_WITHOUT='#'
 
121
  case "$WITH_VAR" in
 
122
    [yes)]    VAR_WITHVAL=""
 
123
              VAR_WITHDEF="-D""VAR_WITH" ;;
 
124
    [*)]      VAR_WITHVAL=WITH_VAR
 
125
              VAR_WITHDEF="-D""VAR_WITH="'"'$WITH_VAR'"' ;;
 
126
  esac
 
127
else
 
128
  VAR_WITH='#' ;  VAR_WITHOUT=
 
129
  VAR_WITHVAL= ;  VAR_WITHDEF=
 
130
fi
 
131
popdef([VAR_WITH])dnl
 
132
popdef([VAR_WITHOUT])dnl
 
133
popdef([VAR_WITHVAL])dnl
 
134
popdef([VAR_WITHDEF])dnl
 
135
popdef([WITH_VAR])dnl
 
136
])
 
137
 
 
138
AC_DEFUN([AC_ARG_COND_WITH],
 
139
[dnl
 
140
AC_ARG_WITH([$1],[$2],[$3],[$4],[$5])
 
141
# done with AC_ARG_WITH, now do AC_COND_WITH (rather than AM_CONDITIONAL)
 
142
AC_COND_WITH([$1])
 
143
])
 
144
 
 
145
dnl and the same version as AC_COND_WITH but including the
 
146
dnl AC_DEFINE for WITH_PACKAGE
 
147
 
 
148
AC_DEFUN([AC_COND_WITH_DEFINE],
 
149
[dnl the names to be defined...
 
150
pushdef([WITH_VAR],    patsubst([with_$1], -, _))dnl
 
151
pushdef([VAR_WITH],    patsubst(translit([with_$1], [a-z], [A-Z]), -, _))dnl
 
152
pushdef([VAR_WITHOUT], patsubst(translit([without_$1], [a-z], [A-Z]), -, _))dnl
 
153
pushdef([VAR_WITHVAL], patsubst(translit([withval_$1], [a-z], [A-Z]), -, _))dnl
 
154
pushdef([VAR_WITHDEF], patsubst(translit([withdef_$1], [a-z], [A-Z]), -, _))dnl
 
155
AC_SUBST(VAR_WITH)
 
156
AC_SUBST(VAR_WITHOUT)
 
157
AC_SUBST(VAR_WITHVAL)
 
158
AC_SUBST(VAR_WITHDEF)
 
159
if test -z "$WITH_VAR" ; then WITH_VAR=`echo ifelse([$2], , no, [$2])` ; fi
 
160
if test "$WITH_VAR" != "no"; then
 
161
  VAR_WITH=    ; VAR_WITHOUT='#'
 
162
  case "$WITH_VAR" in
 
163
    [yes)]    VAR_WITHVAL=""
 
164
              VAR_WITHDEF="-D""VAR_WITH" ;;
 
165
    [*)]      VAR_WITHVAL=WITH_VAR
 
166
              VAR_WITHDEF="-D""VAR_WITH="'"'$WITH_VAR'"' ;;
 
167
  esac
 
168
else
 
169
  VAR_WITH='#' ;  VAR_WITHOUT=
 
170
  VAR_WITHVAL= ;  VAR_WITHDEF=
 
171
fi
 
172
if test "_$WITH_VAR" != "_no" ; then
 
173
      AC_DEFINE_UNQUOTED(VAR_WITH, "$WITH_VAR", "--with-$1")
 
174
fi dnl
 
175
popdef([VAR_WITH])dnl
 
176
popdef([VAR_WITHOUT])dnl
 
177
popdef([VAR_WITHVAL])dnl
 
178
popdef([VAR_WITHDEF])dnl
 
179
popdef([WITH_VAR])dnl
 
180
])
 
181
 
 
182
</pre>
 
183
  </div>
 
184
 
 
185
  <h2>Copyright</h2>
 
186
 
 
187
  <div class="indent">
 
188
    <a href="COPYING.html">GNU General Public License</a> with this special
 
189
    <a href="COPYING-Exception.html">exception</a>.
 
190
  </div>
 
191
</body>
 
192
</html>