starting to work...
[freeside.git] / rt / aclocal.m4
1 dnl aclocal.m4 generated automatically by aclocal 1.4-p6
2
3 dnl Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
7
8 dnl This program is distributed in the hope that it will be useful,
9 dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without
10 dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
11 dnl PARTICULAR PURPOSE.
12
13 dnl
14 dnl @synopsis RT_ENABLE_LAYOUT()
15 dnl
16 dnl Enable a specific directory layout for the installation to use.
17 dnl This configures a command-line parameter that can be specified
18 dnl at ./configure invocation.
19 dnl
20 dnl The use of this feature in this way is a little hackish, but
21 dnl better than a heap of options for every directory.
22 dnl
23 dnl This code is heavily borrowed *cough* from the Apache 2 code.
24 dnl
25
26 AC_DEFUN([RT_ENABLE_LAYOUT],[
27 AC_ARG_ENABLE(layout,
28               AC_HELP_STRING([--enable-layout=LAYOUT],
29                              [Use a specific directory layout (Default: relative)]),
30               LAYOUT=$enableval)
31
32 if test "x$LAYOUT" = "x"; then
33         LAYOUT="relative"
34 fi
35 RT_LAYOUT($srcdir/config.layout, $LAYOUT)
36 AC_MSG_CHECKING(for chosen layout)
37 if test "x$rt_layout_name" = "xno"; then
38         if test "x$LAYOUT" = "xno"; then
39                 AC_MSG_RESULT(none)
40         else
41                 AC_MSG_RESULT($LAYOUT)
42         fi
43         AC_MSG_ERROR([a valid layout must be specified (or the default used)])
44 else
45         AC_SUBST(rt_layout_name)
46         AC_MSG_RESULT($rt_layout_name)
47 fi
48 if test "x$rt_layout_name" != "xinplace" ; then
49         AC_SUBST([COMMENT_INPLACE_LAYOUT], [""])
50 else
51         AC_SUBST([COMMENT_INPLACE_LAYOUT], [# ])
52 fi
53 ])
54
55 dnl
56 dnl @synopsis RT_LAYOUT(configlayout, layoutname)
57 dnl
58 dnl This macro reads an Apache-style layout file (specified as the
59 dnl configlayout parameter), and searches for a specific layout
60 dnl (named using the layoutname parameter).
61 dnl
62 dnl The entries for a given layout are then inserted into the
63 dnl environment such that they become available as substitution
64 dnl variables. In addition, the rt_layout_name variable is set
65 dnl (but not exported) if the layout is valid.
66 dnl
67 dnl This code is heavily borrowed *cough* from the Apache 2 codebase.
68 dnl
69
70 AC_DEFUN([RT_LAYOUT],[
71         if test ! -f $srcdir/config.layout; then
72                 AC_MSG_WARN([Layout file $srcdir/config.layout not found])
73                 rt_layout_name=no
74         else
75                 pldconf=./config.pld
76                 $PERL  -0777 -p -e "\$layout = '$2';"  -e '
77                 s/.*<Layout\s+$layout>//gims; 
78                 s/\<\/Layout\>.*//s; 
79                 s/^#.*$//m;
80                 s/^\s+//gim;
81                 s/\s+$/\n/gim;
82                 s/\+$/\/rt3/gim;
83                 # m4 will not let us just use $1, we need @S|@1
84                 s/^\s*((?:bin|sbin|libexec|data|sysconf|sharedstate|localstate|lib|include|oldinclude|info|man|html)dir)\s*:\s*(.*)$/@S|@1=@S|@2/gim;
85                 s/^\s*(.*?)\s*:\s*(.*)$/\(test "x\@S|@@S|@1" = "xNONE" || test "x\@S|@@S|@1" = "x") && @S|@1=@S|@2/gim;
86                  ' < $1 > $pldconf
87
88                 if test -s $pldconf; then
89                         rt_layout_name=$2
90                         . $pldconf
91                         changequote({,})
92                         for var in prefix exec_prefix bindir sbindir \
93                                  sysconfdir mandir libdir datadir htmldir fontdir\
94                                  lexdir localstatedir logfiledir masonstatedir \
95                                  sessionstatedir customdir custometcdir customhtmldir \
96                                  customlexdir customplugindir customlibdir manualdir; do
97                                 eval "val=\"\$$var\""
98                                 val=`echo $val | sed -e 's:\(.\)/*$:\1:'`
99                                 val=`echo $val | 
100                                         sed -e 's:[\$]\([a-z_]*\):${\1}:g'`
101                                 eval "$var='$val'"
102                         done
103                         changequote([,])
104                 else
105                         rt_layout_name=no
106                 fi
107                 #rm $pldconf
108         fi
109         RT_SUBST_EXPANDED_ARG(prefix)
110         RT_SUBST_EXPANDED_ARG(exec_prefix)
111         RT_SUBST_EXPANDED_ARG(bindir)
112         RT_SUBST_EXPANDED_ARG(sbindir)
113         RT_SUBST_EXPANDED_ARG(sysconfdir)
114         RT_SUBST_EXPANDED_ARG(mandir)
115         RT_SUBST_EXPANDED_ARG(libdir)
116         RT_SUBST_EXPANDED_ARG(lexdir)
117         RT_SUBST_EXPANDED_ARG(datadir)
118         RT_SUBST_EXPANDED_ARG(htmldir)
119         RT_SUBST_EXPANDED_ARG(fontdir)
120         RT_SUBST_EXPANDED_ARG(manualdir)
121         RT_SUBST_EXPANDED_ARG(plugindir)
122         RT_SUBST_EXPANDED_ARG(localstatedir)
123         RT_SUBST_EXPANDED_ARG(logfiledir)
124         RT_SUBST_EXPANDED_ARG(masonstatedir)
125         RT_SUBST_EXPANDED_ARG(sessionstatedir)
126         RT_SUBST_EXPANDED_ARG(customdir)
127         RT_SUBST_EXPANDED_ARG(custometcdir)
128         RT_SUBST_EXPANDED_ARG(customplugindir)
129         RT_SUBST_EXPANDED_ARG(customhtmldir)
130         RT_SUBST_EXPANDED_ARG(customlexdir)
131         RT_SUBST_EXPANDED_ARG(customlibdir)
132 ])dnl
133
134 dnl
135 dnl @synopsis   RT_SUBST_EXPANDED_ARG(var)
136 dnl
137 dnl Export (via AC_SUBST) a given variable, along with an expanded
138 dnl version of the variable (same name, but with exp_ prefix).
139 dnl
140 dnl This code is heavily borrowed *cough* from the Apache 2 source.
141 dnl
142
143 AC_DEFUN([RT_SUBST_EXPANDED_ARG],[
144         RT_EXPAND_VAR(exp_$1, [$]$1)
145         AC_SUBST($1)
146         AC_SUBST(exp_$1)
147 ])
148
149 dnl
150 dnl @synopsis   RT_EXPAND_VAR(baz, $fraz)
151 dnl
152 dnl Iteratively expands the second parameter, until successive iterations
153 dnl yield no change. The result is then assigned to the first parameter.
154 dnl
155 dnl This code is heavily borrowed from the Apache 2 codebase.
156 dnl
157
158 AC_DEFUN([RT_EXPAND_VAR],[
159         ap_last=''
160         ap_cur='$2'
161         while test "x${ap_cur}" != "x${ap_last}"; do
162                 ap_last="${ap_cur}"
163                 ap_cur=`eval "echo ${ap_cur}"`
164         done
165         $1="${ap_cur}"
166 ])
167