1214571Sdim# Helper functions for option handling.                    -*- Autoconf -*-
2214571Sdim
3214571Sdim# Copyright (C) 2004, 2005 Free Software Foundation, Inc.
4214571Sdim# Written by Gary V. Vaughan <gary@gnu.org>
5214571Sdim#
6214571Sdim# This file is free software; the Free Software Foundation gives
7214571Sdim# unlimited permission to copy and/or distribute it, with or without
8214571Sdim# modifications, as long as this notice is preserved.
9214571Sdim
10214571Sdim# serial 3 ltoptions.m4
11214571Sdim
12214571Sdim# This is to help aclocal find these macros, as it can't see m4_define.
13214571SdimAC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])])
14214571Sdim
15214571Sdim
16214571Sdim# _LT_MANGLE_OPTION(NAME)
17214571Sdim# -----------------------
18214571Sdimm4_define([_LT_MANGLE_OPTION],
19214571Sdim[[_LT_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
20214571Sdim
21214571Sdim
22214571Sdim# _LT_SET_OPTION(NAME)
23214571Sdim# --------------------
24214571Sdim# Set option NAME, and if there is a matching handler defined,
25214571Sdim# dispatch to it.  Other NAMEs are saved as a flag.
26214571Sdimm4_define([_LT_SET_OPTION],
27214571Sdim[m4_define(_LT_MANGLE_OPTION([$1]))dnl
28214571Sdimm4_ifdef(_LT_MANGLE_DEFUN([$1]),
29214571Sdim        _LT_MANGLE_DEFUN([$1]),
30214571Sdim    [m4_warning([Unknown Libtool option `$1'])])[]dnl
31214571Sdim])
32214571Sdim
33214571Sdim
34214571Sdim# _LT_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
35214571Sdim# -------------------------------------------
36214571Sdim# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
37214571Sdimm4_define([_LT_IF_OPTION],
38214571Sdim[m4_ifdef(_LT_MANGLE_OPTION([$1]), [$2], [$3])])
39214571Sdim
40214571Sdim
41214571Sdim# _LT_UNLESS_OPTIONS(OPTIONS, IF-NOT-SET)
42214571Sdim# ---------------------------------------
43214571Sdim# Execute IF-NOT-SET if all OPTIONS are not set.
44214571Sdimm4_define([_LT_UNLESS_OPTIONS],
45214571Sdim[m4_foreach([_LT_Option], m4_split(m4_normalize([$1])),
46214571Sdim	    [m4_ifdef(_LT_MANGLE_OPTION(_LT_Option),
47214571Sdim		      [m4_define([$0_found])])])[]dnl
48214571Sdimm4_ifdef([$0_found], [m4_undefine([$0_found])], [$2
49214571Sdim])[]dnl
50214571Sdim])
51214571Sdim
52214571Sdim
53214571Sdim# _LT_SET_OPTIONS(OPTIONS)
54214571Sdim# ------------------------
55214571Sdim# OPTIONS is a space-separated list of Libtool options.
56214571Sdim# If any OPTION has a handler macro declared with LT_OPTION_DEFINE,
57214571Sdim# dispatch to that macro; otherwise complain about the unknown option
58214571Sdim# and exit.
59214571Sdimm4_defun([_LT_SET_OPTIONS],
60214571Sdim[# Set options
61214571Sdimm4_foreach([_LT_Option], m4_split(m4_normalize([$1])),
62214571Sdim    [_LT_SET_OPTION(_LT_Option)])
63214571Sdimdnl
64214571Sdimdnl Simply set some default values (i.e off) if boolean options were not
65214571Sdimdnl specified:
66214571Sdim_LT_UNLESS_OPTIONS([dlopen], [enable_dlopen=no
67214571Sdim])
68214571Sdim_LT_UNLESS_OPTIONS([win32-dll], [enable_win32_dll=no
69214571Sdim])
70214571Sdimdnl
71214571Sdimdnl If no reference was made to various pairs of opposing options, then
72214571Sdimdnl we run the default mode handler for the pair.  For example, if neither
73214571Sdimdnl `shared' nor `disable-shared' was passed, we enable building of shared
74214571Sdimdnl archives by default:
75214571Sdim_LT_UNLESS_OPTIONS([shared disable-shared], [_LT_ENABLE_SHARED])
76214571Sdim_LT_UNLESS_OPTIONS([static disable-static], [_LT_ENABLE_STATIC])
77214571Sdim_LT_UNLESS_OPTIONS([pic-only no-pic], [_LT_WITH_PIC])
78214571Sdim_LT_UNLESS_OPTIONS([fast-install disable-fast-install],
79214571Sdim		   [_LT_ENABLE_FAST_INSTALL])
80214571Sdim])# _LT_SET_OPTIONS
81214571Sdim
82214571Sdim
83214571Sdim## --------------------------------- ##
84214571Sdim## Macros to handle LT_INIT options. ##
85214571Sdim## --------------------------------- ##
86214571Sdim
87214571Sdimm4_define([_LT_MANGLE_DEFUN],
88214571Sdim[[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1]), [[^A-Z0-9_]], [_])])
89214571Sdim
90214571Sdim
91214571Sdim# LT_OPTION_DEFINE(NAME, CODE)
92214571Sdim# ----------------------------
93214571Sdimm4_define([LT_OPTION_DEFINE],
94214571Sdim[m4_define(_LT_MANGLE_DEFUN([$1]), [$2])[]dnl
95214571Sdim])# LT_OPTION_DEFINE
96214571Sdim
97214571Sdim
98214571Sdim# dlopen
99214571Sdim# ------
100214571SdimLT_OPTION_DEFINE([dlopen], [enable_dlopen=yes
101214571Sdim])
102214571Sdim
103214571SdimAU_DEFUN([AC_LIBTOOL_DLOPEN],
104214571Sdim[_LT_SET_OPTION([dlopen])
105214571SdimAC_DIAGNOSE([obsolete],
106214571Sdim[$0: Remove this warning and the call to _LT_SET_OPTION when you
107214571Sdimput the `dlopen' option into LT_INIT's first parameter.])
108214571Sdim])
109214571Sdim
110214571Sdimdnl aclocal-1.4 backwards compatibility:
111214571Sdimdnl AC_DEFUN([AC_LIBTOOL_DLOPEN], [])
112214571Sdim
113214571Sdim
114214571Sdim# win32-dll
115214571Sdim# ---------
116214571Sdim# Declare package support for building win32 dll's.
117214571SdimLT_OPTION_DEFINE([win32-dll],
118214571Sdim[enable_win32_dll=yes
119214571Sdim
120214571Sdimcase $host in
121214571Sdim*-*-cygwin* | *-*-mingw* | *-*-pw32*)
122214571Sdim  AC_CHECK_TOOL(AS, as, false)
123214571Sdim  AC_CHECK_TOOL(DLLTOOL, dlltool, false)
124214571Sdim  AC_CHECK_TOOL(OBJDUMP, objdump, false)
125214571Sdim  ;;
126214571Sdimesac
127214571Sdim
128214571Sdimtest -z "$AS" && AS=as
129214571Sdim_LT_DECL([], [AS],      [0], [Assembler program])dnl
130214571Sdim
131214571Sdimtest -z "$DLLTOOL" && DLLTOOL=dlltool
132214571Sdim_LT_DECL([], [DLLTOOL], [0], [DLL creation program])dnl
133214571Sdim
134214571Sdimtest -z "$OBJDUMP" && OBJDUMP=objdump
135214571Sdim_LT_DECL([], [OBJDUMP], [0], [Object dumper program])dnl
136214571Sdim])# win32-dll
137214571Sdim
138214571SdimAU_DEFUN([AC_LIBTOOL_WIN32_DLL],
139214571Sdim[_LT_SET_OPTION([win32-dll])
140214571SdimAC_DIAGNOSE([obsolete],
141214571Sdim[$0: Remove this warning and the call to _LT_SET_OPTION when you
142214571Sdimput the `win32-dll' option into LT_INIT's first parameter.])
143214571Sdim])
144214571Sdim
145214571Sdimdnl aclocal-1.4 backwards compatibility:
146214571Sdimdnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [])
147214571Sdim
148214571Sdim
149214571Sdim# _LT_ENABLE_SHARED([DEFAULT])
150214571Sdim# ----------------------------
151214571Sdim# implement the --enable-shared flag, and supports the `shared' and
152214571Sdim# `disable-shared' LT_INIT options.
153214571Sdim# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
154214571Sdimm4_define([_LT_ENABLE_SHARED],
155214571Sdim[m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl
156214571SdimAC_ARG_ENABLE([shared],
157214571Sdim    [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@],
158214571Sdim	[build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])],
159214571Sdim    [p=${PACKAGE-default}
160214571Sdim    case $enableval in
161214571Sdim    yes) enable_shared=yes ;;
162214571Sdim    no) enable_shared=no ;;
163214571Sdim    *)
164214571Sdim      enable_shared=no
165214571Sdim      # Look at the argument we got.  We use all the common list separators.
166214571Sdim      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
167214571Sdim      for pkg in $enableval; do
168214571Sdim	IFS="$lt_save_ifs"
169214571Sdim	if test "X$pkg" = "X$p"; then
170214571Sdim	  enable_shared=yes
171214571Sdim	fi
172214571Sdim      done
173214571Sdim      IFS="$lt_save_ifs"
174214571Sdim      ;;
175214571Sdim    esac],
176214571Sdim    [enable_shared=]_LT_ENABLE_SHARED_DEFAULT)
177214571Sdim
178214571Sdim    _LT_DECL([build_libtool_libs], [enable_shared], [0],
179214571Sdim	[Whether or not to build shared libraries])
180214571Sdim])# _LT_ENABLE_SHARED
181214571Sdim
182214571SdimLT_OPTION_DEFINE([shared], [_LT_ENABLE_SHARED([yes])])
183214571SdimLT_OPTION_DEFINE([disable-shared], [_LT_ENABLE_SHARED([no])])
184214571Sdim
185214571Sdim# Old names:
186214571SdimAC_DEFUN([AC_ENABLE_SHARED],
187214571Sdim[_LT_SET_OPTION([shared])
188214571Sdim])
189214571Sdim
190214571SdimAC_DEFUN([AC_DISABLE_SHARED],
191214571Sdim[_LT_SET_OPTION([disable-shared])
192214571Sdim])
193214571Sdim
194214571SdimAU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)])
195214571SdimAU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)])
196214571Sdim
197214571Sdimdnl aclocal-1.4 backwards compatibility:
198214571Sdimdnl AC_DEFUN([AM_ENABLE_SHARED], [])
199214571Sdimdnl AC_DEFUN([AM_DISABLE_SHARED], [])
200214571Sdim
201214571Sdim
202214571Sdim
203214571Sdim# _LT_ENABLE_STATIC([DEFAULT])
204214571Sdim# ----------------------------
205214571Sdim# implement the --enable-static flag, and support the `static' and
206214571Sdim# `disable-static' LT_INIT options.
207214571Sdim# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
208214571Sdimm4_define([_LT_ENABLE_STATIC],
209214571Sdim[m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl
210214571SdimAC_ARG_ENABLE([static],
211214571Sdim    [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@],
212214571Sdim	[build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])],
213214571Sdim    [p=${PACKAGE-default}
214214571Sdim    case $enableval in
215214571Sdim    yes) enable_static=yes ;;
216214571Sdim    no) enable_static=no ;;
217214571Sdim    *)
218214571Sdim     enable_static=no
219214571Sdim      # Look at the argument we got.  We use all the common list separators.
220214571Sdim      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
221214571Sdim      for pkg in $enableval; do
222214571Sdim	IFS="$lt_save_ifs"
223214571Sdim	if test "X$pkg" = "X$p"; then
224214571Sdim	  enable_static=yes
225214571Sdim	fi
226214571Sdim      done
227214571Sdim      IFS="$lt_save_ifs"
228214571Sdim      ;;
229214571Sdim    esac],
230214571Sdim    [enable_static=]_LT_ENABLE_STATIC_DEFAULT)
231214571Sdim
232214571Sdim    _LT_DECL([build_old_libs], [enable_static], [0],
233214571Sdim	[Whether or not to build static libraries])
234214571Sdim])# _LT_ENABLE_STATIC
235214571Sdim
236214571SdimLT_OPTION_DEFINE([static], [_LT_ENABLE_STATIC([yes])])
237214571SdimLT_OPTION_DEFINE([disable-static], [_LT_ENABLE_STATIC([no])])
238214571Sdim
239214571Sdim# Old names:
240214571SdimAC_DEFUN([AC_ENABLE_STATIC],
241214571Sdim[_LT_SET_OPTION([static])
242214571Sdim])
243214571Sdim
244214571SdimAC_DEFUN([AC_DISABLE_STATIC],
245214571Sdim[_LT_SET_OPTION([disable-static])
246214571Sdim])
247214571Sdim
248214571SdimAU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)])
249214571SdimAU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)])
250214571Sdim
251214571Sdimdnl aclocal-1.4 backwards compatibility:
252214571Sdimdnl AC_DEFUN([AM_ENABLE_STATIC], [])
253214571Sdimdnl AC_DEFUN([AM_DISABLE_STATIC], [])
254214571Sdim
255214571Sdim
256214571Sdim
257214571Sdim# _LT_ENABLE_FAST_INSTALL([DEFAULT])
258214571Sdim# ----------------------------------
259214571Sdim# implement the --enable-fast-install flag, and support the `fast-install'
260214571Sdim# and `disable-fast-install' LT_INIT options.
261214571Sdim# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
262214571Sdimm4_define([_LT_ENABLE_FAST_INSTALL],
263214571Sdim[m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl
264214571SdimAC_ARG_ENABLE([fast-install],
265214571Sdim    [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@],
266214571Sdim    [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])],
267214571Sdim    [p=${PACKAGE-default}
268214571Sdim    case $enableval in
269214571Sdim    yes) enable_fast_install=yes ;;
270214571Sdim    no) enable_fast_install=no ;;
271214571Sdim    *)
272214571Sdim      enable_fast_install=no
273214571Sdim      # Look at the argument we got.  We use all the common list separators.
274214571Sdim      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
275214571Sdim      for pkg in $enableval; do
276214571Sdim	IFS="$lt_save_ifs"
277214571Sdim	if test "X$pkg" = "X$p"; then
278214571Sdim	  enable_fast_install=yes
279214571Sdim	fi
280214571Sdim      done
281214571Sdim      IFS="$lt_save_ifs"
282214571Sdim      ;;
283214571Sdim    esac],
284214571Sdim    [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT)
285214571Sdim
286214571Sdim_LT_DECL([fast_install], [enable_fast_install], [0],
287214571Sdim	 [Whether or not to optimize for fast installation])dnl
288214571Sdim])# _LT_ENABLE_FAST_INSTALL
289214571Sdim
290214571SdimLT_OPTION_DEFINE([fast-install], [_LT_ENABLE_FAST_INSTALL([yes])])
291214571SdimLT_OPTION_DEFINE([disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])])
292214571Sdim
293214571Sdim# Old names:
294214571SdimAU_DEFUN([AC_ENABLE_FAST_INSTALL],
295214571Sdim[_LT_SET_OPTION([fast-install])
296214571SdimAC_DIAGNOSE([obsolete],
297214571Sdim[$0: Remove this warning and the call to _LT_SET_OPTION when you put
298214571Sdimthe `fast-install' option into LT_INIT's first parameter.])
299214571Sdim])
300214571Sdim
301214571SdimAU_DEFUN([AC_DISABLE_FAST_INSTALL],
302214571Sdim[_LT_SET_OPTION([disable-fast-install])
303214571SdimAC_DIAGNOSE([obsolete],
304214571Sdim[$0: Remove this warning and the call to _LT_SET_OPTION when you put
305214571Sdimthe `disable-fast-install' option into LT_INIT's first parameter.])
306214571Sdim])
307214571Sdim
308214571Sdimdnl aclocal-1.4 backwards compatibility:
309214571Sdimdnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], [])
310214571Sdimdnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], [])
311214571Sdim
312214571Sdim
313214571Sdim# _LT_WITH_PIC([MODE])
314214571Sdim# --------------------
315214571Sdim# implement the --with-pic flag, and support the `pic-only' and `no-pic'
316214571Sdim# LT_INIT options.
317214571Sdim# MODE is either `yes' or `no'.  If omitted, it defaults to `both'.
318214571Sdimm4_define([_LT_WITH_PIC],
319214571Sdim[AC_ARG_WITH([pic],
320214571Sdim    [AS_HELP_STRING([--with-pic],
321214571Sdim	[try to use only PIC/non-PIC objects @<:@default=use both@:>@])],
322214571Sdim    [pic_mode="$withval"],
323214571Sdim    [pic_mode=default])
324214571Sdim
325214571Sdimtest -z "$pic_mode" && pic_mode=m4_default([$1], [default])
326214571Sdim
327214571Sdim_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl
328214571Sdim])# _LT_WITH_PIC
329214571Sdim
330214571SdimLT_OPTION_DEFINE([pic-only], [_LT_WITH_PIC([yes])])
331214571SdimLT_OPTION_DEFINE([no-pic], [_LT_WITH_PIC([no])])
332214571Sdim
333214571Sdim# Old name:
334214571SdimAU_DEFUN([AC_LIBTOOL_PICMODE],
335214571Sdim[_LT_SET_OPTION([pic-only])
336214571SdimAC_DIAGNOSE([obsolete],
337214571Sdim[$0: Remove this warning and the call to _LT_SET_OPTION when you
338214571Sdimput the `pic-only' option into LT_INIT's first parameter.])
339214571Sdim])
340214571Sdim
341214571Sdimdnl aclocal-1.4 backwards compatibility:
342214571Sdimdnl AC_DEFUN([AC_LIBTOOL_PICMODE], [])
343