您应该做的第一件事是找到 apache 扩展工具 apxs 或 apxs2(取决于您正在构建的 apache 版本和/或平台)。在您知道您的工具所在的位置后,您可以运行查询以获取某些 apache 配置参数。例如,要获取系统配置目录,您可以运行:
apxs2 -q SYSCONFDIR
以下是如何找到 apache 扩展工具的片段:(注意它可能包含语法错误)
dnl Note: AC_DEFUN goes here plus other stuff
AC_MSG_CHECKING(for apache APXS)
AC_ARG_WITH(apxs,
[AS_HELP_STRING([[--with-apxs[=FILE]]],
[path to the apxs, defaults to "apxs".])],
[
if test "$withval" = "yes"; then
APXS=apxs
else
APXS="$withval"
fi
])
if test -z "$APXS"; then
for i in /usr/sbin /usr/local/apache/bin /usr/bin ; do
if test -f "$i/apxs2"; then
APXS="$i/apxs2"
break
fi
if test -f "$i/apxs"; then
APXS="$i/apxs"
break
fi
done
fi
AC_SUBST(APXS)
在您的 automake Makefile.am 中使用 APXS 的方式如下所示:
## Find apache sys config dir
APACHE2_SYSCONFDIR = `@APXS@ -q SYSCONFDIR`
## Misc automake stuff goes here
install: install-am
cp my.conf $(DESTDIR)${APACHE2_SYSCONFDIR}/conf.d/my.conf
我假设您熟悉 automake 和 autoconf 工具。