1
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
2
"http://www.w3.org/TR/html4/strict.dtd">
6
<title>Autoconf Macro: ac_cond_with</title>
7
<link rel="stylesheet" type="text/css" href="ac-archive.css">
11
<table summary="web navigation" style="width:100%;">
14
<td style="width:50%;" align="center">[<a href="index.html">Macro Index
17
<td style="width:50%;" align="center">[<a href=
18
"../m4source/ac_cond_with.m4">Download M4 Source</a>]</td>
29
<p style="text-align:left; white-space:nowrap;"><code>AC_COND_WITH(PACKAGE
30
[,DEFAULT])</code></p>
36
<p>obsoleted - do not use this macro, use AX_SUBST_WITH or
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>
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>
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>
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"
60
<p>Example configure.in:</p>
63
[ --with-float, with float words support])
64
AC_COND_WITH(float,no)
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>
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>
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>
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>
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>
94
<p>1.4 (last modified: 2003-05-21)</p>
100
<p>Guido Draheim <guidod@gmx.de></p>
103
<h2>M4 Source Code</h2>
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
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='#'
122
[yes)] VAR_WITHVAL=""
123
VAR_WITHDEF="-D""VAR_WITH" ;;
124
[*)] VAR_WITHVAL=WITH_VAR
125
VAR_WITHDEF="-D""VAR_WITH="'"'$WITH_VAR'"' ;;
128
VAR_WITH='#' ; VAR_WITHOUT=
129
VAR_WITHVAL= ; VAR_WITHDEF=
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
138
AC_DEFUN([AC_ARG_COND_WITH],
140
AC_ARG_WITH([$1],[$2],[$3],[$4],[$5])
141
# done with AC_ARG_WITH, now do AC_COND_WITH (rather than AM_CONDITIONAL)
145
dnl and the same version as AC_COND_WITH but including the
146
dnl AC_DEFINE for WITH_PACKAGE
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
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='#'
163
[yes)] VAR_WITHVAL=""
164
VAR_WITHDEF="-D""VAR_WITH" ;;
165
[*)] VAR_WITHVAL=WITH_VAR
166
VAR_WITHDEF="-D""VAR_WITH="'"'$WITH_VAR'"' ;;
169
VAR_WITH='#' ; VAR_WITHOUT=
170
VAR_WITHVAL= ; VAR_WITHDEF=
172
if test "_$WITH_VAR" != "_no" ; then
173
AC_DEFINE_UNQUOTED(VAR_WITH, "$WITH_VAR", "--with-$1")
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
188
<a href="COPYING.html">GNU General Public License</a> with this special
189
<a href="COPYING-Exception.html">exception</a>.