File: ac_cond_with.html

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

AC_DEFUN([AC_ARG_COND_WITH],
[dnl
AC_ARG_WITH([$1],[$2],[$3],[$4],[$5])
# done with AC_ARG_WITH, now do AC_COND_WITH (rather than AM_CONDITIONAL)
AC_COND_WITH([$1])
])

dnl and the same version as AC_COND_WITH but including the
dnl AC_DEFINE for WITH_PACKAGE

AC_DEFUN([AC_COND_WITH_DEFINE],
[dnl the names to be defined...
pushdef([WITH_VAR],    patsubst([with_$1], -, _))dnl
pushdef([VAR_WITH],    patsubst(translit([with_$1], [a-z], [A-Z]), -, _))dnl
pushdef([VAR_WITHOUT], patsubst(translit([without_$1], [a-z], [A-Z]), -, _))dnl
pushdef([VAR_WITHVAL], patsubst(translit([withval_$1], [a-z], [A-Z]), -, _))dnl
pushdef([VAR_WITHDEF], patsubst(translit([withdef_$1], [a-z], [A-Z]), -, _))dnl
AC_SUBST(VAR_WITH)
AC_SUBST(VAR_WITHOUT)
AC_SUBST(VAR_WITHVAL)
AC_SUBST(VAR_WITHDEF)
if test -z "$WITH_VAR" ; then WITH_VAR=`echo ifelse([$2], , no, [$2])` ; fi
if test "$WITH_VAR" != "no"; then
  VAR_WITH=    ; VAR_WITHOUT='#'
  case "$WITH_VAR" in
    [yes)]    VAR_WITHVAL=""
              VAR_WITHDEF="-D""VAR_WITH" ;;
    [*)]      VAR_WITHVAL=WITH_VAR
              VAR_WITHDEF="-D""VAR_WITH="'"'$WITH_VAR'"' ;;
  esac
else
  VAR_WITH='#' ;  VAR_WITHOUT=
  VAR_WITHVAL= ;  VAR_WITHDEF=
fi
if test "_$WITH_VAR" != "_no" ; then
      AC_DEFINE_UNQUOTED(VAR_WITH, "$WITH_VAR", "--with-$1")
fi dnl
popdef([VAR_WITH])dnl
popdef([VAR_WITHOUT])dnl
popdef([VAR_WITHVAL])dnl
popdef([VAR_WITHDEF])dnl
popdef([WITH_VAR])dnl
])
</pre>
  </div>
 </body>
</html>