0.6.1.20060928-1 release
[manu/suphp.git] / configure.ac
1 # Process this file with autoconf to produce a configure script.
2
3 # Initialize
4 AC_INIT([suPHP], [0.6.1], [sebastian.marsching@suphp.org], [suphp])
5
6 # Auxiliary tools
7 AC_CONFIG_AUX_DIR([config])
8
9 AM_INIT_AUTOMAKE([suPHP], [0.6.0-pre1])
10 # Check for right directory
11 AC_CONFIG_SRCDIR([src/Application.cpp])
12 # Config headers for automake
13 AM_CONFIG_HEADER([src/config.h])
14
15 # Build time sanity check
16 AM_SANITY_CHECK
17
18 # Look for install program
19 AC_PROG_INSTALL
20
21 # Look for compiler
22 AC_PROG_CC
23 AC_PROG_CXX
24 AM_PROG_LIBTOOL
25
26 # Checks for header files.
27 AC_HEADER_STDC
28 AC_CHECK_HEADERS([fcntl.h stdlib.h string.h unistd.h])
29
30 # Find apr-config
31
32 APR_FIND_APR([], [], [1])
33
34 # Determine Apache version and find apxs
35
36 AC_MSG_CHECKING([for dynamic Apache module support (via APXS)])
37 AC_ARG_WITH(apxs, 
38             AC_HELP_STRING([--with-apxs=FILE], 
39                            [Build shared Apache module.  FILE is the optional pathname to the Apache apxs tool; defaults to "apxs".]),
40             [
41             if test "$withval" = "yes"; then
42               APXS=apxs
43             else
44               APXS="$withval"
45             fi
46             ])
47
48 if test -z "$APXS"; then
49   APXS=`which apxs`
50 fi
51
52 if test "$BINNAME" = "" -a "$APXS" = "" -a "$FAIL_STATIC" = ""; then
53   for i in /usr/sbin /usr/local/apache/bin ; do
54     if test -f "$i/apxs"; then
55       APXS="$i/apxs"
56     fi
57   done
58 fi
59
60 if test -n "$APXS"; then
61     AC_SUBST(APXS)
62     
63     APACHE_VERSION=`\`$APXS -q SBINDIR\`/\`$APXS -q TARGET\` -v \
64                     | grep "Server version" \
65                     | cut -f2 -d":" \
66                     | cut -f2 -d"/" \
67                     | cut -f1 -d" "`
68     major_version=`echo $APACHE_VERSION|cut -f1,2 -d.`
69     if test "$major_version" = "2.0"; then
70       APACHE_VERSION_2=true
71       APACHE_VERSION_1_3=false
72     else
73       APACHE_VERSION_2=false
74       APACHE_VERSION_1_3=true
75     fi
76     AC_SUBST(APACHE_VERSION_1_3)
77     AC_SUBST(APACHE_VERSION_2)
78     
79     APXS_INCLUDEDIR=`$APXS -q INCLUDEDIR`
80     APXS_LIBEXECDIR=`$APXS -q LIBEXECDIR`
81     if test x"${APACHE_VERSION_2}" = xtrue ; then \
82       APXS_EXTRA_CFLAGS=`$APXS -q EXTRA_CFLAGS`
83     fi
84     if test x"${APACHE_VERSION_1_3}" = xtrue; then \
85       APXS_EXTRA_CFLAGS=`$APXS -q CFLAGS`
86     fi
87     AC_SUBST([APXS_INCLUDEDIR])
88     AC_SUBST([APXS_LIBEXECDIR])
89     AC_SUBST([APXS_EXTRA_CFLAGS])
90
91     AC_MSG_RESULT(found at $APXS (version $APACHE_VERSION))
92 else
93     APXS="/notfound/"
94     AC_SUBST(APXS)
95     
96     AC_MSG_RESULT(no)
97 fi
98
99 if test x"${APACHE_VERSION_2}" = xtrue ; then \
100 dnl For Apache 2.x APR is needed
101     if test x"${apr_found}" = xyes ; then \
102         APR_INCLUDEDIR=`${apr_config} --includedir`
103         AC_SUBST([APR_INCLUDEDIR])
104     else
105         AC_MSG_ERROR([APR is needed to build mod_suphp for Apache 2.x but was not found])
106     fi
107 fi
108
109 # Get uid/gid mode
110
111 AC_MSG_CHECKING([for set-UID/set-GID mode])
112 AC_ARG_WITH(setid-mode, 
113             AC_HELP_STRING([--with-setid-mode=MODE], 
114                            [Mode to use for setting UID/GID.  MODE can be on of "owner", "config" or "paranoid"; defaults to "paranoid".]),
115             [
116             if test "$withval" = "yes"; then
117               SETID_MODE="paranoid"
118             else
119               SETID_MODE="$withval"
120             fi
121             ])
122
123 if test -z "$SETID_MODE" ; then
124   SETID_MODE="paranoid"
125 fi
126
127 if test -n "$SETID_MODE"; then
128     case "$SETID_MODE" in 
129       owner)
130         OPT_APACHEMOD_USERGROUP_DEF=""
131         AC_SUBST(OPT_APACHEMOD_USERGROUP_DEF)
132         AC_DEFINE(OPT_USERGROUP_OWNER, 1,
133                   [Define if you want to set UID/GID to the owner of the script])
134         ;;
135       force)
136         OPT_APACHEMOD_USERGROUP_DEF=-DSUPHP_USE_USERGROUP
137         AC_SUBST(OPT_APACHEMOD_USERGROUP_DEF)
138         AC_DEFINE(OPT_USERGROUP_FORCE, 1,
139                   [Define if you want to set UID/GID to the user/group specified in the Apache configuration])
140         ;;
141       paranoid)
142         OPT_APACHEMOD_USERGROUP_DEF=-DSUPHP_USE_USERGROUP
143         AC_SUBST(OPT_APACHEMOD_USERGROUP_DEF)
144         AC_DEFINE(OPT_USERGROUP_PARANOID, 1,
145                   [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])
146         ;;
147       *)
148         AC_MSG_ERROR([--with-setid-mode has to be set to one of "owner", "force" or "paranoid"])
149         ;;
150     esac
151     AC_MSG_RESULT([ok - using $SETID_MODE])
152 fi
153
154
155 # Checkpath (docroot) option
156
157 checkpath=yes
158 AC_ARG_ENABLE([checkpath], 
159               AC_HELP_STRING([--enable-checkpath],
160                              [Check if script resides in DOCUMENT_ROOT (default is ENABLED)]),
161               [
162               if test "$enableval" = "no"; then
163                 checkpath=no
164                 AC_DEFINE(OPT_DISABLE_CHECKPATH, 1, [Define if you want to disable the check, wether script resides in DOCUMENT_ROOT])
165               fi
166               ])
167
168
169 # Minimum UID
170
171 AC_ARG_WITH([min-uid], 
172             AC_HELP_STRING([--with-min-uid=UID],
173                            [Minimum UID, which is allowed to run scripts
174                             (default=100)]),
175             [
176              if test "$withval" -a ! "$withval" = "yes" ; then
177                AC_DEFINE_UNQUOTED(OPT_MIN_UID, $withval, [Defines the min UID
178                          allowed to run scripts])
179              fi
180             ],
181             [
182               AC_DEFINE(OPT_MIN_UID, 100, [Defines the min UID
183                                        allowed to run scripts])
184             ])
185
186 # Minimum GID
187
188 AC_ARG_WITH([min-gid],
189             AC_HELP_STRING([--with-min-gid=GID],
190                            [Minimum GID, which is allowed to run scripts
191                             (default=100)]),
192             [
193              if test "$withval" -a ! "$withval" = "yes" ; then
194                AC_DEFINE_UNQUOTED(OPT_MIN_GID, $withval, [Defines the min GID
195                          allowed to run scripts])
196              fi
197             ],
198             [
199               AC_DEFINE(OPT_MIN_GID, 100, [Defines the min GID
200                                        allowed to run scripts])
201             ])
202
203
204 # Webserver user
205
206 AC_ARG_WITH([apache-user],
207             AC_HELP_STRING([--with-apache-user=USERNAME],
208                            [Name of the user Apache is running as
209 (default is "wwwrun"]),
210             [
211              if test "$withval" -a ! "$withval" = "yes" ; then
212                AC_DEFINE_UNQUOTED(OPT_APACHE_USER, "$withval", [Defines the username of the Apache user])
213              fi
214             ],
215             [
216              AC_DEFINE_UNQUOTED(OPT_APACHE_USER, "wwwrun", [Defines the username of the Apache user])
217             ])
218
219 # Path to logfile
220
221 AC_ARG_WITH([logfile],
222             AC_HELP_STRING([--with-logfile=FILE],
223                            [Path to suPHP logfile (default is "/var/log/httpd/suphp_log"]),
224             [
225              if test "$withval" -a ! "$withval" = "yes" ; then
226                AC_DEFINE_UNQUOTED(OPT_LOGFILE, "$withval", [Defines
227 path to logfile])
228              fi
229             ],
230             [
231              AC_DEFINE_UNQUOTED(OPT_LOGFILE, "/var/log/httpd/suphp_log", [Defines path to logfile])
232             ])
233
234
235 # Conditional building of Apache module
236 AM_CONDITIONAL([COND_AP13], [test x"$APACHE_VERSION_1_3" = xtrue])
237 AM_CONDITIONAL([COND_AP20], [test x"$APACHE_VERSION_2" = xtrue])
238
239 # Conditionally include UserGroup support
240 AM_CONDITIONAL([COND_APUSERGROUP], [test \( x"$SETID_MODE" = xparanoid \) -o \( x"$SETID_MODE" = xforce \) ])
241
242 AC_CONFIG_FILES([Makefile src/Makefile src/apache/Makefile src/apache2/Makefile])
243 AC_OUTPUT
244
245 if test "$APXS" = "/notfound/"; then
246   AC_MSG_WARN([
247 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
248 !!*** APXS was not found, so mod_suphp will not be built! ***!!
249 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
250   ])
251 fi
252