1AC_DEFUN([AX_XEN_EXPAND_CONFIG], [
2dnl expand these early so we can use this for substitutions
3test "x$prefix" = "xNONE" && prefix=$ac_default_prefix
4test "x$exec_prefix" = "xNONE" && exec_prefix=${prefix}
5
6dnl Use /var instead of /usr/local/var because there can be only one
7dnl xenstored active at a time. All tools have to share this dir, even
8dnl if they come from a different --prefix=.
9if test "$localstatedir" = '${prefix}/var' ; then
10    localstatedir=/var
11fi
12
13dnl expand exec_prefix or it will endup in substituted variables
14bindir=`eval echo $bindir`
15sbindir=`eval echo $sbindir`
16libdir=`eval echo $libdir`
17
18dnl
19if test "x$sysconfdir" = 'x${prefix}/etc' ; then
20    case "$host_os" in
21         *freebsd*)
22         sysconfdir=$prefix/etc
23         ;;
24         *solaris*)
25         if test "$prefix" = "/usr" ; then
26             sysconfdir=/etc
27         else
28             sysconfdir=$prefix/etc
29         fi
30         ;;
31         *)
32         sysconfdir=/etc
33         ;;
34    esac
35fi
36
37CONFIG_DIR=$sysconfdir
38AC_SUBST(CONFIG_DIR)
39
40XEN_CONFIG_DIR=$CONFIG_DIR/xen
41AC_SUBST(XEN_CONFIG_DIR)
42AC_DEFINE_UNQUOTED([XEN_CONFIG_DIR], ["$XEN_CONFIG_DIR"], [Xen's config dir])
43
44AC_ARG_WITH([initddir],
45    AS_HELP_STRING([--with-initddir=DIR],
46    [Path to directory with sysv runlevel scripts. [SYSCONFDIR/init.d]]),
47    [initddir_path=$withval],
48    [case "$host_os" in
49         *linux*)
50         if test -d $sysconfdir/rc.d/init.d ; then
51             initddir_path=$sysconfdir/rc.d/init.d
52         else
53             initddir_path=$sysconfdir/init.d
54         fi
55         ;;
56         *)
57         initddir_path=$sysconfdir/rc.d
58         ;;
59     esac])
60
61AC_ARG_WITH([sysconfig-leaf-dir],
62    AS_HELP_STRING([--with-sysconfig-leaf-dir=SUBDIR],
63    [Name of subdirectory in /etc to store runtime options for runlevel
64    scripts and daemons such as xenstored.
65    This should be either "sysconfig" or "default". [sysconfig]]),
66    [config_leaf_dir=$withval],
67    [config_leaf_dir=sysconfig
68    if test ! -d /etc/sysconfig ; then config_leaf_dir=default ; fi])
69CONFIG_LEAF_DIR=$config_leaf_dir
70AC_SUBST(CONFIG_LEAF_DIR)
71
72dnl autoconf docs suggest to use a "package name" subdir. We make it
73dnl configurable for the benefit of those who want e.g. xen-X.Y instead.
74AC_ARG_WITH([libexec-leaf-dir],
75    AS_HELP_STRING([--with-libexec-leaf-dir=SUBDIR],
76    [Name of subdirectory in libexecdir to use.]),
77    [libexec_subdir=$withval],
78    [libexec_subdir=$PACKAGE_TARNAME])
79
80AC_ARG_WITH([xen-scriptdir],
81    AS_HELP_STRING([--with-xen-scriptdir=DIR],
82    [Path to directory for dom0 hotplug scripts. [SYSCONFDIR/xen/scripts]]),
83    [xen_scriptdir_path=$withval],
84    [xen_scriptdir_path=$XEN_CONFIG_DIR/scripts])
85XEN_SCRIPT_DIR=$xen_scriptdir_path
86AC_SUBST(XEN_SCRIPT_DIR)
87AC_DEFINE_UNQUOTED([XEN_SCRIPT_DIR], ["$XEN_SCRIPT_DIR"], [Xen's script dir])
88
89AC_ARG_WITH([xen-dumpdir],
90    AS_HELP_STRING([--with-xen-dumpdir=DIR],
91    [Path to directory for domU crash dumps. [LOCALSTATEDIR/lib/xen/dump]]),
92    [xen_dumpdir_path=$withval],
93    [xen_dumpdir_path=$localstatedir/lib/xen/dump])
94
95AC_ARG_WITH([rundir],
96    AS_HELP_STRING([--with-rundir=DIR],
97    [Path to directory for runtime data. [LOCALSTATEDIR/run]]),
98    [rundir_path=$withval],
99    [rundir_path=$localstatedir/run])
100
101AC_ARG_WITH([debugdir],
102    AS_HELP_STRING([--with-debugdir=DIR],
103    [Path to directory for debug symbols. [PREFIX/lib/debug]]),
104    [debugdir_path=$withval],
105    [debugdir_path=$prefix/lib/debug])
106
107if test "$libexecdir" = '${exec_prefix}/libexec' ; then
108    case "$host_os" in
109         *netbsd*) ;;
110         *)
111         libexecdir='${exec_prefix}/lib'
112         ;;
113    esac
114fi
115dnl expand exec_prefix or it will endup in substituted variables
116LIBEXEC=`eval echo $libexecdir/$libexec_subdir`
117AC_SUBST(LIBEXEC)
118
119dnl These variables will be substituted in various .in files
120LIBEXEC_BIN=${LIBEXEC}/bin
121AC_SUBST(LIBEXEC_BIN)
122AC_DEFINE_UNQUOTED([LIBEXEC_BIN], ["$LIBEXEC_BIN"], [Xen's libexec path])
123LIBEXEC_LIB=${LIBEXEC}/lib
124AC_SUBST(LIBEXEC_LIB)
125LIBEXEC_INC=${LIBEXEC}/include
126AC_SUBST(LIBEXEC_INC)
127XENFIRMWAREDIR=${LIBEXEC}/boot
128AC_SUBST(XENFIRMWAREDIR)
129AC_DEFINE_UNQUOTED([XENFIRMWAREDIR], ["$XENFIRMWAREDIR"], [Xen's firmware dir])
130
131XEN_RUN_DIR=$rundir_path/xen
132AC_SUBST(XEN_RUN_DIR)
133AC_DEFINE_UNQUOTED([XEN_RUN_DIR], ["$XEN_RUN_DIR"], [Xen's runstate path])
134
135XEN_LOG_DIR=$localstatedir/log/xen
136AC_SUBST(XEN_LOG_DIR)
137AC_DEFINE_UNQUOTED([XEN_LOG_DIR], ["$XEN_LOG_DIR"], [Xen's log dir])
138
139XEN_RUN_STORED=$rundir_path/xenstored
140AC_SUBST(XEN_RUN_STORED)
141AC_DEFINE_UNQUOTED([XEN_RUN_STORED], ["$XEN_RUN_STORED"], [Xenstore's runstate path])
142
143XEN_LIB_DIR=$localstatedir/lib/xen
144AC_SUBST(XEN_LIB_DIR)
145AC_DEFINE_UNQUOTED([XEN_LIB_DIR], ["$XEN_LIB_DIR"], [Xen's lib dir])
146
147SHAREDIR=$prefix/share
148AC_SUBST(SHAREDIR)
149
150INITD_DIR=$initddir_path
151AC_SUBST(INITD_DIR)
152
153case "$host_os" in
154*freebsd*) XEN_LOCK_DIR=$localstatedir/lib ;;
155*netbsd*) XEN_LOCK_DIR=$rundir_path ;;
156*) XEN_LOCK_DIR=$localstatedir/lock ;;
157esac
158AC_SUBST(XEN_LOCK_DIR)
159AC_DEFINE_UNQUOTED([XEN_LOCK_DIR], ["$XEN_LOCK_DIR"], [Xen's lock dir])
160
161XEN_PAGING_DIR=$localstatedir/lib/xen/xenpaging
162AC_SUBST(XEN_PAGING_DIR)
163
164XEN_DUMP_DIR=$xen_dumpdir_path
165AC_SUBST(XEN_DUMP_DIR)
166AC_DEFINE_UNQUOTED([XEN_DUMP_DIR], ["$XEN_DUMP_DIR"], [Xen's dump directory])
167
168DEBUG_DIR=$debugdir_path
169AC_SUBST(DEBUG_DIR)
170])
171
172case "$host_os" in
173*freebsd*) XENSTORED_KVA=/dev/xen/xenstored ;;
174*) XENSTORED_KVA=/proc/xen/xsd_kva ;;
175esac
176AC_SUBST(XENSTORED_KVA)
177
178case "$host_os" in
179*freebsd*) XENSTORED_PORT=/dev/xen/xenstored ;;
180*) XENSTORED_PORT=/proc/xen/xsd_port ;;
181esac
182AC_SUBST(XENSTORED_PORT)
183