79004bfe902464f8f3da6946a5206318bf8345d7
[manu/suphp.git] / configure.ac
1 # Process this file with autoconf to produce a configure script.
2 AC_INIT([suphp], [0.5.2], [sebastian.marsching@suphp.org])
3 AC_CONFIG_SRCDIR([src/suphp.c])
4 AC_CONFIG_AUX_DIR([config])
5 AC_CONFIG_HEADER([src/config.h])
6
7 # Checks for programs.
8 AC_PROG_CC
9 AC_PROG_INSTALL
10
11 AC_MSG_CHECKING([for dynamic Apache module support (via APXS)])
12 AC_ARG_WITH(apxs, 
13             AC_HELP_STRING([--with-apxs=FILE], 
14                            [Build shared Apache module.  FILE is the optional pathname to the Apache apxs tool; defaults to "apxs".]),
15             [
16             if test "$withval" = "yes"; then
17               APXS=apxs
18             else
19               APXS="$withval"
20             fi
21             ])
22
23 if test -z "$APXS"; then
24   APXS=`which apxs`
25 fi
26
27 if test "$BINNAME" = "" -a "$APXS" = "" -a "$FAIL_STATIC" = ""; then
28   for i in /usr/sbin /usr/local/apache/bin ; do
29     if test -f "$i/apxs"; then
30       APXS="$i/apxs"
31     fi
32   done
33 fi
34
35 if test -n "$APXS"; then
36     AC_SUBST(APXS)
37     
38     APACHE_VERSION=`\`$APXS -q SBINDIR\`/\`$APXS -q TARGET\` -v \
39                     | grep "Server version" \
40                     | cut -f2 -d":" \
41                     | cut -f2 -d"/" \
42                     | cut -f1 -d" "`
43     major_version=`echo $APACHE_VERSION|cut -f1,2 -d.`
44     if test "$major_version" = "2.0"; then
45       APACHE_VERSION_2=true
46       APACHE_VERSION_1_3=false
47     else
48       APACHE_VERSION_2=false
49       APACHE_VERSION_1_3=true
50     fi
51     AC_SUBST(APACHE_VERSION_1_3)
52     AC_SUBST(APACHE_VERSION_2)
53
54     AC_MSG_RESULT(found at $APXS (version $APACHE_VERSION))
55 else
56     APXS="/notfound/"
57     AC_SUBST(APXS)
58     
59     AC_MSG_RESULT(no)
60 fi
61
62 AC_MSG_CHECKING([for set-UID/set-GID mode])
63 AC_ARG_WITH(setid-mode, 
64             AC_HELP_STRING([--with-setid-mode=MODE], 
65                            [Mode to use for setting UID/GID.  MODE can be on of "owner", "config" or "paranoid"; defaults to "owner".]),
66             [
67             if test "$withval" = "yes"; then
68               SETID_MODE="owner"
69             else
70               SETID_MODE="$withval"
71             fi
72             ])
73
74 if test -z "$SETID_MODE" ; then
75   SETID_MODE="owner"
76 fi
77
78 if test -n "$SETID_MODE"; then
79     case "$SETID_MODE" in 
80       owner)
81         OPT_APACHEMOD_USERGROUP_DEF=""
82         AC_SUBST(OPT_APACHEMOD_USERGROUP_DEF)
83         AC_DEFINE(OPT_USERGROUP_OWNER, 1,
84                   [Define if you want to set UID/GID to the owner of the script])
85         ;;
86       force)
87         OPT_APACHEMOD_USERGROUP_DEF=-DSUPHP_USE_USERGROUP
88         AC_SUBST(OPT_APACHEMOD_USERGROUP_DEF)
89         AC_DEFINE(OPT_USERGROUP_FORCE, 1,
90                   [Define if you want to set UID/GID to the user/group specified in the Apache configuration])
91         ;;
92       paranoid)
93         OPT_APACHEMOD_USERGROUP_DEF=-DSUPHP_USE_USERGROUP
94         AC_SUBST(OPT_APACHEMOD_USERGROUP_DEF)
95         AC_DEFINE(OPT_USERGROUP_PARANOID, 1,
96                   [Define if you want to set UID/GID to the user/group specified in the Apache configuration AND check if these settings match the UID/GID of the script])
97         ;;
98       *)
99         AC_MSG_ERROR([--with-setid-mode has to be set to one of "owner", "force" or "paranoid"])
100         ;;
101     esac
102     AC_MSG_RESULT([ok - using $SETID_MODE])
103 fi
104
105 checkpath=yes
106 AC_ARG_ENABLE([checkpath], 
107               AC_HELP_STRING([--enable-checkpath],
108                              [Check if script resides in DOCUMENT_ROOT (default is ENABLED)]),
109               [
110               if test "$enableval" = "no"; then
111                 checkpath=no
112                 AC_DEFINE(OPT_DISABLE_CHECKPATH, 1, [Define if you want to disable the check, wether script resides in DOCUMENT_ROOT])
113               fi
114               ])
115
116 checkuid=yes
117 AC_ARG_ENABLE([checkuid],
118               AC_HELP_STRING([--enable-checkuid],
119                              [Do not accept UIDs that are not listed in /etc/passwd (default is ENABLED)]),
120               [
121               if test "$enableval" = "no"; then
122                 checkuid=no
123                 AC_DEFINE(OPT_NO_PASSWD, 1, 
124                           [Define if you want to proceed even if UID of the script is not listed in /etc/passwd])
125               fi
126               ])
127
128 checkgid=yes
129 AC_ARG_ENABLE([checkgid],
130               AC_HELP_STRING([--enable-checkgid],
131                              [Do not accept GIDs that are not listed in /etc/group (default is ENABLED)]),
132               [
133               if test "$enableval" = "no"; then
134                 checkgid=no
135                 AC_DEFINE(OPT_NO_GROUP, 1, 
136                           [Define if you want to proceed even if GID of the script is not listed in /etc/group])
137               fi
138               ])
139
140 AC_ARG_WITH([min-uid], 
141             AC_HELP_STRING([--with-min-uid=UID],
142                            [Minimum UID, which is allowed to run scripts
143                             (default=100)]),
144             [
145              if test "$withval" -a ! "$withval" = "yes" ; then
146                AC_DEFINE_UNQUOTED(OPT_MIN_UID, $withval, [Defines the min UID
147                          allowed to run scripts])
148              fi
149             ],
150             [
151               AC_DEFINE(OPT_MIN_UID, 100, [Defines the min UID
152                                        allowed to run scripts])
153             ])
154
155 AC_ARG_WITH([min-gid],
156             AC_HELP_STRING([--with-min-gid=GID],
157                            [Minimum GID, which is allowed to run scripts
158                             (default=100)]),
159             [
160              if test "$withval" -a ! "$withval" = "yes" ; then
161                AC_DEFINE_UNQUOTED(OPT_MIN_GID, $withval, [Defines the min GID
162                          allowed to run scripts])
163              fi
164             ],
165             [
166               AC_DEFINE(OPT_MIN_GID, 100, [Defines the min GID
167                                        allowed to run scripts])
168             ])
169
170 AC_ARG_WITH([apache-user],
171             AC_HELP_STRING([--with-apache-user=USERNAME],
172                            [Name of the user Apache is running as
173 (default is "wwwrun"]),
174             [
175              if test "$withval" -a ! "$withval" = "yes" ; then
176                AC_DEFINE_UNQUOTED(OPT_APACHE_USER, "$withval", [Defines the username of the Apache user])
177              fi
178             ],
179             [
180              AC_DEFINE_UNQUOTED(OPT_APACHE_USER, "wwwrun", [Defines the username of the Apache user])
181             ])
182
183 AC_ARG_WITH([php],
184             AC_HELP_STRING([--with-php=FILE],
185                            [Path to PHP interpreter (default is "/usr/bin/php"]),
186             [ 
187              if test "$withval" -a ! "$withval" = "yes" ; then 
188                AC_DEFINE_UNQUOTED(OPT_PATH_TO_PHP, "$withval", [Defines path to PHP interpreter])
189              fi
190             ],
191             [
192              AC_DEFINE_UNQUOTED(OPT_PATH_TO_PHP, "/usr/bin/php", [Defines path to PHP interpreter])
193             ])
194
195 AC_ARG_WITH([logfile],
196             AC_HELP_STRING([--with-logfile=FILE],
197                            [Path to suPHP logfile (default is "/var/log/httpd/suphp_log"]),
198             [
199              if test "$withval" -a ! "$withval" = "yes" ; then
200                AC_DEFINE_UNQUOTED(OPT_LOGFILE, "$withval", [Defines
201 path to logfile])
202              fi
203             ],
204             [
205              AC_DEFINE_UNQUOTED(OPT_LOGFILE, "/var/log/httpd/suphp_log", [Defines path to logfile])
206             ])
207
208
209 # Checks for libraries.
210
211 # Checks for header files.
212 AC_HEADER_STDC
213 AC_CHECK_HEADERS([fcntl.h stdlib.h string.h unistd.h])
214
215 # Checks for typedefs, structures, and compiler characteristics.
216 AC_C_CONST
217 AC_TYPE_UID_T
218 AC_STRUCT_TM
219
220 # Checks for library functions.
221 AC_FUNC_LSTAT
222 AC_FUNC_MALLOC
223 AC_FUNC_STAT
224 AC_FUNC_STRFTIME
225 AC_CHECK_FUNCS([setenv strcasecmp strdup strrchr])
226
227 AC_CONFIG_FILES([Makefile src/Makefile src/apache/Makefile src/apache2/Makefile])
228 AC_OUTPUT
229
230 if test -n "$OPT_APACHEMOD_USERGROUP_DEF" -a "$APACHE_VERSION_1_3" = "true"; then
231   AC_MSG_WARN([
232 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
233 !!*** The suPHP module for Apache 1.3 only works with     ***!!
234 !!*** set-ID mode "owner", other modes are only supported ***!!
235 !!*** by the Apache 2.x module                            ***!!
236 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
237   ])
238 fi
239
240 if test "$APXS" = "/notfound/"; then
241   AC_MSG_WARN([
242 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
243 !!*** APXS was not found, so mod_suphp will not be built! ***!!
244 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
245   ])
246 fi
247