Skip to content
This repository
Newer
Older
100644 121 lines (102 sloc) 3.934 kb
9c0d10ba » zmoratto
2009-09-18 Massive reorganization. Works this time! A good handful of code has b…
1 dnl __BEGIN_LICENSE__
2 dnl Copyright (C) 2006, 2007 United States Government as represented by
3 dnl the Administrator of the National Aeronautics and Space Administration.
4 dnl All Rights Reserved.
5 dnl __END_LICENSE__
6
7 # Usage: AX_MODULE(<name>, <directory>, <library>, <default>, <prerequisites>, <required dependencies>[, <optional dependencies>])
8 AC_DEFUN([AX_MODULE],
9 [
10 m4_ifdef([_AX_MODULE_PREPARE], [],
11 [
12 realpath() {
13 cd "[$]1" 2>/dev/null 1>&2 && pwd
14 }
15
16 abspath() {
17 if test ${1#/} = [$]1; then
18 echo "$PWD/[$]1"
19 else
20 echo [$]1
21 fi
22 }
23
24 var_uniq() {
25 echo -n "[$]*" | sed 's/ \+/\n/g' | sed -n 'G; s/\n/&&/; /^\(@<:@^\n@:>@*\n\).*\n\1/d; s/\n//; h; P' | tr '\n' ' '
26 }
27
28 get_rpath() {
29 for i in "[$]@"; do
30 case [$i] in
31 -L*) v="`abspath ${i#-L}`"; if test -n "$v"; then echo -n " -R$v"; fi;;
32 esac
33 done
34 echo
35 }
36 m4_define([_AX_MODULE_PREPARE], [1])
37 ])
38
39 # Silently ignore modules that don't exist in this distribution
40 if test -d "$srcdir/$2" ; then
41
42 HAVE_PKG_$1_SRC=yes
43
44 if test -n "$ENABLE_MODULE_$1"; then
45 WANT_MODULE_$1="$ENABLE_MODULE_$1"
46 fi
47
48 AC_ARG_ENABLE([module-]m4_tolower([[$1]]),
49 AC_HELP_STRING([--enable-module-]m4_tolower([[$1]]), [enable the $1 module @<:@$4@:>@]),
50 [ ENABLE_MODULE_$1=$enableval; WANT_MODULE_$1=$enableval; ],
51 [ if test x"$ENABLE_MODULE_$1" = x; then ENABLE_MODULE_$1=`/bin/echo -n $4 | tr [A-Z] [a-z]` ; fi ]
52 )
53
54 AC_MSG_CHECKING([whether to build module $1])
55 ax_module_enable=$ENABLE_MODULE_$1
56
57 # Create a variable to store missing
58 AS_VAR_PUSHDEF([missing], [ax_module_]$1[_missing])
59
60 # Load args 5 and 6 as required deps, and capture missing deps in missing var.
61 # If missing is populated, bail out. Then load the optional deps
62 AS_IF([test x"$ax_module_enable" != "xyes"], [AC_MSG_RESULT([no (disabled)])],
63 [AX_LOAD_DEPS([$1], [$5 $6], [missing]) # Load required deps
64 AS_IF([test -n "$missing"], [AC_MSG_RESULT([no ([missing] $missing)]); ax_module_enable=no],
65 [AX_LOAD_DEPS([$1], [$7]) # Load optional deps
66 MODULE_$1_CPPFLAGS="$PKG_$1_CPPFLAGS"
67 if test x"$ENABLE_RPATH" = "xyes"; then
68 PKG_$1_LIBS="$PKG_$1_LIBS `var_uniq \`get_rpath ${PKG_$1_LIBS}\``"
69 fi
70 MODULE_$1_LIBS="$PKG_$1_LIBS"
71 m4_ifval([$3], [PKG_$1_LIBS="$PKG_$1_LIBS \$(top_builddir)/$2/$3"])
72 AC_MSG_RESULT([yes])])])
73
74 AS_VAR_POPDEF([missing])
75
76 else
77 HAVE_PKG_$1_SRC=no
78 ax_module_enable=no
79 MODULE_$1_LIBS=
80 PKG_$1_LIBS=
81 MODULE_$1_CPPFLAGS=
82 PKG_$1_CPPFLAGS=
83 fi
84
85 AC_SUBST(MODULE_$1_CPPFLAGS)
86 AC_SUBST(PKG_$1_CPPFLAGS)
87 AC_SUBST(MODULE_$1_LIBS)
88 AC_SUBST(PKG_$1_LIBS)
89
90 HAVE_PKG_$1=${ax_module_enable}
91 MAKE_MODULE_$1=${ax_module_enable}
92 AC_SUBST(MAKE_MODULE_$1)
93
94 if test -n "$WANT_MODULE_$1"; then
95 if test x"$MAKE_MODULE_$1" != x"$WANT_MODULE_$1"; then
96 AC_MSG_ERROR([You said ENABLE_MODULE_]$1[=$WANT_MODULE_]$1[, but I decided $MAKE_MODULE_]$1)
97 fi
98 fi
99
100 if test "${HAVE_PKG_$1}" = "yes" ; then
101 ax_have_pkg_bool=1
102 else
103 ax_have_pkg_bool=0
104 fi
105 AC_DEFINE_UNQUOTED(HAVE_PKG_$1,
106 [$ax_have_pkg_bool],
107 [Define to 1 if the $1 module is available.])
108
109 if test "$HAVE_PKG_$1_SRC" = "yes" ; then
110 AX_LOG([MAKE_MODULE_]$1[ = $MAKE_MODULE_]$1)
111 AX_LOG([HAVE_PKG_]$1[ = $HAVE_PKG_]$1)
112 AX_LOG([MODULE_]$1[_CPPFLAGS = $MODULE_]$1[_CPPFLAGS])
113 AX_LOG([PKG_]$1[_CPPFLAGS = $PKG_]$1[_CPPFLAGS])
114 AX_LOG([MODULE_]$1[_LIBS = $MODULE_]$1[_LIBS])
115 AX_LOG([PKG_]$1[_LIBS = $PKG_]$1[_LIBS])
116 fi
117
118 # We're putting these in configure.ac manually by now, for
119 # backwards compatability with older versions of automake.
120 # AM_CONDITIONAL([MAKE_MODULE_$1], [test "$MAKE_MODULE_$1" = "yes"])
121 ])
Something went wrong with that request. Please try again.