Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…
Cannot retrieve contributors at this time
87 lines (70 sloc) 3.05 KB
dnl Copyright (C) 2006-2010 United States Government as represented by
dnl the Administrator of the National Aeronautics and Space Administration.
dnl All Rights Reserved.
m4_ifdef([_AX_FIXUPS], [], [m4_include([m4/fixups.m4])])
dnl AX_ARG_(ENABLE|WITH)(<arg>, <default>, <tags>, <description>)
dnl possible tags are:
dnl always -> set autoconf macro to value
dnl mk -> set Makefile variable to value
dnl cpp-int -> set config.h value to value
dnl cpp-bool -> set config.h value to int(bool(value == yes))
dnl am-yes -> set automake conditional to bool(value == yes)
dnl am-set -> set automake conditional to bool(-n value)
dnl variable in question is ether ENABLE_ARG or ARG (the "with" is dropped)
dnl AX_ARG(<type>, <arg>, <default>, <tags>, <description>)
m4_pushdef([lower], my_tolower([$2]))dnl lower-case arg name
m4_pushdef([type], my_toupper([$1]))dnl WITH or ENABLE
AS_VAR_PUSHDEF([value], m4_if(type, [WITH], [], type[_])[]m4_toupper([[$2]]))dnl
m4_divert_once([INIT_PREPARE], [dnl
dnl switch between AC_ARG_(WITH|ENABLE), since I don't think you can indirect
m4_if(type, [WITH],
dnl WITH case.
AS_HELP_STRING([--with]-lower, [$5][ ]m4_ifval([$3],[@<:@$3@:>@])), dnl append default value to the desc
[ value=[$withval] ], dnl if passed in, set value
[ AS_VAR_SET_IF([value], [], [value="[$3]"]) ])], dnl else set to default if not already set
dnl ENABLE case. same as above except if default is yes, change enable -> disable
AS_HELP_STRING([--][]m4_if(yes, [$3], disable, enable)-lower, [$5][ ]m4_ifval([$3],[@<:@$3@:>@])),
[ value=[$enableval] ],
[ AS_VAR_SET_IF([value], [], [value="[$3]"]) ])])])
dnl if the tag is none, generate no configure code here
m4_bmatch([$4], [none], [], [dnl
dnl check for am-yes tag. var name is shell-escaped
m4_bmatch([$4], [am-yes], [dnl
AM_CONDITIONAL(AS_TR_SH(value), [test x"$value" = x"yes"])dnl
dnl check for am-set tag. var name is shell-escaped
m4_bmatch([$4], [am-set], [dnl
AM_CONDITIONAL(AS_TR_SH(value), [test ! -z "$value"])dnl
dnl check for cpp-bool tag.
m4_bmatch([$4], [cpp-bool], [dnl
AS_VAR_PUSHDEF([int], my_tolower(value))
AS_IF([test x"$value" = x"yes"], int=1, int=0)
AC_DEFINE_UNQUOTED(AS_TR_CPP(value), [$int], [$5])
dnl check for cpp-int tag.
m4_bmatch([$4], [cpp-int], [dnl
AS_VAR_PUSHDEF([int], my_tolower(value))dnl
int=$value dnl
AC_DEFINE_UNQUOTED(AS_TR_CPP(value), [$int], [$5])dnl
m4_bmatch([$4], [mk], [dnl
dnl clean up after myself
AC_DEFUN([AX_ARG_ENABLE], [AX_ARG([enable], [$1], [$2], [$3], [$4])])
AC_DEFUN([AX_ARG_WITH], [AX_ARG([with], [$1], [$2], [$3], [$4])])
Jump to Line
Something went wrong with that request. Please try again.