Skip to content

Commit

Permalink
General Configuration improvements. Support bin_dir and exec-prefix v…
Browse files Browse the repository at this point in the history
…ariables
  • Loading branch information
dreamcat4 committed Sep 24, 2009
1 parent 53346d9 commit 9bb2305
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 51 deletions.
1 change: 1 addition & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

SUBDIRS = cgi fpm

bindir = $(php_fpm_bin_dir)
bin_PROGRAMS = $(php_fpm_bin)

$(php_fpm_bin): php_fpm
Expand Down
35 changes: 27 additions & 8 deletions ac/fpm_conf.m4
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
AC_DEFUN([AC_FPM_ARGS],
[
PHP_ARG_WITH(fpm-bin,,
[ --with-fpm-bin[=PATH] Set the path for the php-fpm binary [/usr/local/bin/php-fpm]], /usr/local/bin/php-fpm, no)
[ --with-fpm-bin[=PATH] Set the path for the php-fpm binary [/usr/local/bin/php-fpm]], yes, no)
PHP_ARG_WITH(fpm-conf,,
[ --with-fpm-conf[=PATH] Set the path for php-fpm configuration file [/etc/php-fpm.conf]], /etc/php-fpm.conf, no)
[ --with-fpm-conf[=PATH] Set the path for php-fpm configuration file [/etc/php-fpm.conf]], yes, no)
PHP_ARG_WITH(fpm-log,,
[ --with-fpm-log[=PATH] Set the path for php-fpm log file [var/log/php-fpm.log]], var/log/php-fpm.log, no)
[ --with-fpm-log[=PATH] Set the path for php-fpm log file [/var/log/php-fpm.log]], yes, no)
PHP_ARG_WITH(fpm-pid,,
[ --with-fpm-pid[=PATH] Set the path for php-fpm pid file [var/run/php-fpm.pid]], var/run/php-fpm.pid, no)
[ --with-fpm-pid[=PATH] Set the path for php-fpm pid file [/var/run/php-fpm.pid]], yes, no)
PHP_ARG_WITH(fpm-user,,
[ --with-fpm-user[=USER] Set the user for php-fpm to run as [nobody]], nobody, no)
[ --with-fpm-user[=USER] Set the user for php-fpm to run as [nobody]], yes, no)
PHP_ARG_WITH(fpm-group,,
[ --with-fpm-group[=GRP] Set the group for php-fpm to run as. For a system user, this
should usually be set to match the fpm username [nobody]], nobody, no)
[ --with-fpm-group[=GRP] Set the group for php-fpm to run as. For a system user,
this should be set to match the fpm username [nobody]], yes, no)
])

AC_DEFUN([AC_FPM_VARS],
Expand All @@ -28,31 +28,40 @@ AC_DEFUN([AC_FPM_VARS],
fpm_prefix=$prefix
fi
fpm_bin_prefix=$fpm_prefix/bin
if test $bindir != "NONE" -a $bindir != "" -a $bindir != "no" ; then
fpm_bin_prefix=$bindir
fi
if test -z "$PHP_FPM_BIN" -o "$PHP_FPM_BIN" = "yes" -o "$PHP_FPM_BIN" = "no"; then
php_fpm_bin_path="$fpm_prefix/bin/php-fpm"
php_fpm_bin_path="$fpm_bin_prefix/php-fpm"
else
php_fpm_bin_path="$PHP_FPM_BIN"
fi
php_fpm_bin=`basename $php_fpm_bin_path`
php_fpm_bin_dir=`dirname $php_fpm_bin_path`
if test -z "$PHP_FPM_CONF" -o "$PHP_FPM_CONF" = "yes" -o "$PHP_FPM_CONF" = "no"; then
php_fpm_conf_path="/etc/php-fpm.conf"
else
php_fpm_conf_path="$PHP_FPM_CONF"
fi
php_fpm_conf=`basename $php_fpm_conf_path`
php_fpm_conf_dir=`dirname $php_fpm_conf_path`
if test -z "$PHP_FPM_LOG" -o "$PHP_FPM_LOG" = "yes" -o "$PHP_FPM_LOG" = "no"; then
php_fpm_log_path="/var/log/php-fpm.log"
else
php_fpm_log_path="$PHP_FPM_LOG"
fi
php_fpm_log_dir=`dirname $php_fpm_log_path`
if test -z "$PHP_FPM_PID" -o "$PHP_FPM_PID" = "yes" -o "$PHP_FPM_PID" = "no"; then
php_fpm_pid_path="/var/run/php-fpm.pid"
else
php_fpm_pid_path="$PHP_FPM_PID"
fi
php_fpm_pid_dir=`dirname $php_fpm_pid_path`
if test -z "$PHP_FPM_USER" -o "$PHP_FPM_USER" = "yes" -o "$PHP_FPM_USER" = "no"; then
php_fpm_user="nobody"
Expand All @@ -69,19 +78,29 @@ AC_DEFUN([AC_FPM_VARS],
PHP_SUBST_OLD(fpm_version)
PHP_SUBST_OLD(php_fpm_bin)
PHP_SUBST_OLD(php_fpm_bin_dir)
PHP_SUBST_OLD(php_fpm_bin_path)
PHP_SUBST_OLD(php_fpm_conf)
PHP_SUBST_OLD(php_fpm_conf_dir)
PHP_SUBST_OLD(php_fpm_conf_path)
PHP_SUBST_OLD(php_fpm_log_dir)
PHP_SUBST_OLD(php_fpm_log_path)
PHP_SUBST_OLD(php_fpm_pid_dir)
PHP_SUBST_OLD(php_fpm_pid_path)
PHP_SUBST_OLD(php_fpm_user)
PHP_SUBST_OLD(php_fpm_group)
AC_DEFINE_UNQUOTED(PHP_FPM_VERSION, "$fpm_version", [fpm version])
AC_DEFINE_UNQUOTED(PHP_FPM_BIN, "$php_fpm_bin", [fpm binary executable])
AC_DEFINE_UNQUOTED(PHP_FPM_BIN_DIR, "$php_fpm_bin_dir", [fpm binary dir])
AC_DEFINE_UNQUOTED(PHP_FPM_BIN_PATH, "$php_fpm_bin_path", [fpm bin file path])
AC_DEFINE_UNQUOTED(PHP_FPM_CONF, "$php_fpm_conf", [fpm conf file])
AC_DEFINE_UNQUOTED(PHP_FPM_CONF_DIR, "$php_fpm_conf_dir", [fpm conf dir])
AC_DEFINE_UNQUOTED(PHP_FPM_CONF_PATH, "$php_fpm_conf_path", [fpm conf file path])
AC_DEFINE_UNQUOTED(PHP_FPM_LOG_DIR, "$php_fpm_log_dir", [fpm log dir])
AC_DEFINE_UNQUOTED(PHP_FPM_LOG_PATH, "$php_fpm_log_path", [fpm log file path])
AC_DEFINE_UNQUOTED(PHP_FPM_PID_DIR, "$php_fpm_pid_dir", [fpm pid dir])
AC_DEFINE_UNQUOTED(PHP_FPM_PID_PATH, "$php_fpm_pid_path", [fpm pid file path])
AC_DEFINE_UNQUOTED(PHP_FPM_USER, "$php_fpm_user", [fpm user name])
AC_DEFINE_UNQUOTED(PHP_FPM_GROUP, "$php_fpm_group", [fpm group name])
Expand Down
23 changes: 16 additions & 7 deletions acinclude.m4
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,9 @@ AC_DEFUN([AC_FPM_PRCTL],
])
])

m4_include([m4/ac_php_frag.m4])
m4_include([m4/ac_lib_event.m4])

AC_DEFUN([AC_FPM_PHP],
[
AC_ARG_WITH([php-src], AC_HELP_STRING([--with-php-src=DIR], [full path to php source dir]))
Expand Down Expand Up @@ -357,24 +360,21 @@ AC_DEFUN([AC_FPM_PHP],
AC_MSG_ERROR([Cannot find expected makefile variables])
fi
AC_MSG_RESULT([$PHP_VERSION])
# sanity check
if test "$PHP_SAPI" != "cgi" ; then
AC_MSG_ERROR([Please re-configure php with no sapi-related switches])
AC_MSG_WARN([PHP was built as sapi \"$PHP_SAPI\". Its recommended to buid php without any sapi-related switches.])
fi
PHP_OBJS="$PHP_GLOBAL_OBJS main/internal_functions.lo"
AC_MSG_RESULT([$PHP_VERSION])
AC_SUBST(PHP_OBJS)
AC_SUBST(PHP_SRCDIR)
AC_SUBST(PHP_BUILDDIR)
AC_SUBST(PHP_VERSION)
])

m4_include([m4/ac_php_frag.m4])
m4_include([m4/ac_lib_event.m4])

AC_DEFUN([AC_FPM_PATHS],
[
Expand All @@ -401,31 +401,40 @@ AC_DEFUN([AC_FPM_PATHS],
fpm_prefix=$prefix
fi
fpm_bin_prefix=$fpm_prefix/bin
if test $bindir != "NONE" -a $bindir != "" -a $bindir != "no" ; then
fpm_bin_prefix=$bindir
fi
if test -z "$with_fpm_bin" -o "$with_fpm_bin" = "yes" -o "$with_fpm_bin" = "no"; then
php_fpm_bin_path="$fpm_prefix/bin/php-fpm"
php_fpm_bin_path="$fpm_bin_prefix/php-fpm"
else
php_fpm_bin_path="$with_fpm_bin"
fi
php_fpm_bin=`basename $php_fpm_bin_path`
php_fpm_bin_dir=`dirname $php_fpm_bin_path`
if test -z "$with_fpm_conf" -o "$with_fpm_conf" = "yes" -o "$with_fpm_conf" = "no"; then
php_fpm_conf_path="/etc/php-fpm.conf"
else
php_fpm_conf_path="$with_fpm_conf"
fi
php_fpm_conf=`basename $php_fpm_conf_path`
php_fpm_conf_dir=`dirname $php_fpm_conf_path`
if test -z "$with_fpm_log" -o "$with_fpm_log" = "yes" -o "$with_fpm_log" = "no"; then
php_fpm_log_path="/var/log/php-fpm.log"
else
php_fpm_log_path="$with_fpm_log"
fi
php_fpm_log_dir=`dirname $php_fpm_log_path`
if test -z "$with_fpm_pid" -o "$with_fpm_pid" = "yes" -o "$with_fpm_pid" = "no"; then
php_fpm_pid_path="/var/run/php-fpm.pid"
else
php_fpm_pid_path="$with_fpm_pid"
fi
php_fpm_pid_dir=`dirname $php_fpm_pid_path`
if test -z "$with_fpm_user" -o "$with_fpm_user" = "yes" -o "$with_fpm_user" = "no"; then
php_fpm_user="nobody"
Expand Down
38 changes: 16 additions & 22 deletions config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,25 @@ dnl
dnl $Id$
dnl

PHP_ARG_ENABLE(fpm,,
[ --with-fpm EXPERIMENTAL: Enable building of the fpm SAPI executable], yes, no)
PHP_ARG_WITH(fpm,,
[ --with-fpm Build PHP FastCGI - FPM executable], no)

# if test "$PHP_SAPI" = "default"; then
# AC_MSG_CHECKING(whether to build FPM binary)
if test "$PHP_FPM" != "no"; then

if test "$PHP_FPM" != "no"; then
# AC_MSG_RESULT(yes)
PHP_CONFIGURE_PART(Configuring fpm)

PHP_CONFIGURE_PART(Configuring fpm)

sinclude(sapi/fpm/ac/fpm_libevent.m4)
AC_LIB_EVENT([1.4.11])

sinclude(sapi/fpm/ac/fpm_checks.m4)
AC_FPM_CHECKS

sinclude(sapi/fpm/ac/fpm_conf.m4)
fpm_version="0.6.5"
AC_FPM_CONF
sinclude(sapi/fpm/ac/fpm_libevent.m4)
AC_LIB_EVENT([1.4.11])

sinclude(sapi/fpm/ac/fpm_build.m4)
AC_FPM_BUILD_SAPI
sinclude(sapi/fpm/ac/fpm_checks.m4)
AC_FPM_CHECKS

AC_MSG_RESULT()
fi
sinclude(sapi/fpm/ac/fpm_conf.m4)
fpm_version="0.6.5"
AC_FPM_CONF

# fi
sinclude(sapi/fpm/ac/fpm_build.m4)
AC_FPM_BUILD_SAPI

AC_MSG_RESULT()
fi
32 changes: 18 additions & 14 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,31 @@ AC_SUBST(php_fpm_ADD_CFLAGS)
AC_SUBST(php_fpm_ADD_LIBS)

AC_SUBST(fpm_version)
AC_DEFINE_UNQUOTED(PHP_FPM_VERSION, "$fpm_version", [fpm version])

AC_SUBST(php_fpm_bin)
AC_DEFINE_UNQUOTED(PHP_FPM_BIN, "$php_fpm_bin", [fpm binary executable])

AC_SUBST(php_fpm_bin_dir)
AC_SUBST(php_fpm_bin_path)
AC_DEFINE_UNQUOTED(PHP_FPM_BIN_PATH, "$php_fpm_bin_path", [fpm bin file path])

AC_SUBST(php_fpm_conf)
AC_SUBST(php_fpm_conf_dir)
AC_SUBST(php_fpm_conf_path)
AC_DEFINE_UNQUOTED(PHP_FPM_CONF_PATH, "$php_fpm_conf_path", [fpm conf file path])

AC_SUBST(php_fpm_log_dir)
AC_SUBST(php_fpm_log_path)
AC_DEFINE_UNQUOTED(PHP_FPM_LOG_PATH, "$php_fpm_log_path", [fpm log file path])

AC_SUBST(php_fpm_pid_dir)
AC_SUBST(php_fpm_pid_path)
AC_DEFINE_UNQUOTED(PHP_FPM_PID_PATH, "$php_fpm_pid_path", [fpm pid file path])

AC_SUBST(php_fpm_user)
AC_DEFINE_UNQUOTED(PHP_FPM_USER, "$php_fpm_user", [fpm user name])

AC_SUBST(php_fpm_group)

AC_DEFINE_UNQUOTED(PHP_FPM_VERSION, "$fpm_version", [fpm version])
AC_DEFINE_UNQUOTED(PHP_FPM_BIN, "$php_fpm_bin", [fpm binary executable])
AC_DEFINE_UNQUOTED(PHP_FPM_BIN_DIR, "$php_fpm_bin_dir", [fpm binary dir])
AC_DEFINE_UNQUOTED(PHP_FPM_BIN_PATH, "$php_fpm_bin_path", [fpm bin file path])
AC_DEFINE_UNQUOTED(PHP_FPM_CONF, "$php_fpm_conf", [fpm conf file])
AC_DEFINE_UNQUOTED(PHP_FPM_CONF_DIR, "$php_fpm_conf_dir", [fpm conf dir])
AC_DEFINE_UNQUOTED(PHP_FPM_CONF_PATH, "$php_fpm_conf_path", [fpm conf file path])
AC_DEFINE_UNQUOTED(PHP_FPM_LOG_DIR, "$php_fpm_log_dir", [fpm log dir])
AC_DEFINE_UNQUOTED(PHP_FPM_LOG_PATH, "$php_fpm_log_path", [fpm log file path])
AC_DEFINE_UNQUOTED(PHP_FPM_PID_DIR, "$php_fpm_pid_dir", [fpm pid dir])
AC_DEFINE_UNQUOTED(PHP_FPM_PID_PATH, "$php_fpm_pid_path", [fpm pid file path])
AC_DEFINE_UNQUOTED(PHP_FPM_USER, "$php_fpm_user", [fpm user name])
AC_DEFINE_UNQUOTED(PHP_FPM_GROUP, "$php_fpm_group", [fpm group name])


Expand Down

0 comments on commit 9bb2305

Please sign in to comment.