File: simple-enable-flag.m4

package info (click to toggle)
libalberta2 2.0.1-3
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 6,260 kB
  • ctags: 4,829
  • sloc: ansic: 62,180; sh: 9,256; makefile: 446; cpp: 225; fortran: 148
file content (43 lines) | stat: -rw-r--r-- 1,089 bytes parent folder | download | duplicates (2)
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
#
# $1: name of the enable-switch (e.g. el-index)
# $2: help string
# $3: one of {0,1}, default value
#
# _OR_
#
# $1: name of the enable/disable option
# $2: help string
# $3: default value
# $4: name of the preprocessor/Makefile/shell variable
#
# Results: declare proper AC_ARG_ENABLE(), define make-file
# subsitution (e.g. EL_INDEX), define automake conditional
# (e.g. EL_INDEX).
#
AC_DEFUN([ALBERTA_ENABLE_FLAG],
[m4_if($#,3,
       [m4_define([FLAGNAME], [m4_bpatsubst(m4_toupper([$1]),-,_)])],
       [m4_define([FLAGNAME], [m4_bpatsubst(m4_toupper([$4]),-,_)])])
m4_if([$3],[1],
      [m4_define([NEGDEFAULT],[disable])
       m4_define([DEFAULT],[enabled])],
      [m4_define([NEGDEFAULT],[enable])
       m4_define([DEFAULT],[disabled])])
AC_ARG_ENABLE($1,
	AC_HELP_STRING(--[]NEGDEFAULT[]-$1,
			[$2 (default: DEFAULT)]),
	[case "$enableval" in
		yes)
			FLAGNAME=1
			;;
		no)
			FLAGNAME=0
			;;
		*)
			AC_MSG_ERROR(["--[]NEGDEFAULT[]-$1" does not take an argument.])
			;;
	esac],
	[FLAGNAME=$3])
AC_SUBST(FLAGNAME)
AM_CONDITIONAL(FLAGNAME, [test "$[]FLAGNAME" -eq 1])
])