0.6.0-2 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.0], [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 AC_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 # Determine Apache version and find apxs
31
32 AC_MSG_CHECKING([for dynamic Apache module support (via APXS)])
33 AC_ARG_WITH(apxs, 
34             AC_HELP_STRING([--with-apxs=FILE], 
35                            [Build shared Apache module.  FILE is the optional pathname to the Apache apxs tool; defaults to "apxs".]),
36             [
37             if test "$withval" = "yes"; then
38               APXS=apxs
39             else
40               APXS="$withval"
41             fi
42             ])
43
44 if test -z "$APXS"; then
45   APXS=`which apxs`
46 fi
47
48 if test "$BINNAME" = "" -a "$APXS" = "" -a "$FAIL_STATIC" = ""; then
49   for i in /usr/sbin /usr/local/apache/bin ; do
50     if test -f "$i/apxs"; then
51       APXS="$i/apxs"
52     fi
53   done
54 fi
55
56 if test -n "$APXS"; then
57     AC_SUBST(APXS)
58     
59     APACHE_VERSION=`\`$APXS -q SBINDIR\`/\`$APXS -q TARGET\` -v \
60                     | grep "Server version" \
61                     | cut -f2 -d":" \
62                     | cut -f2 -d"/" \
63                     | cut -f1 -d" "`
64     major_version=`echo $APACHE_VERSION|cut -f1,2 -d.`
65     if test "$major_version" = "2.0"; then
66       APACHE_VERSION_2=true
67       APACHE_VERSION_1_3=false
68     else
69       APACHE_VERSION_2=false
70       APACHE_VERSION_1_3=true
71     fi
72     AC_SUBST(APACHE_VERSION_1_3)
73     AC_SUBST(APACHE_VERSION_2)
74     
75     APXS_INCLUDEDIR=`$APXS -q INCLUDEDIR`
76     APXS_LIBEXECDIR=`$APXS -q LIBEXECDIR`
77     if test x"{$APACHE_VERSION_2}" = xtrue ; then \
78       APXS_EXTRA_CFLAGS=`$APXS -q EXTRA_CFLAGS`
79     fi
80     if test x"${APACHE_VERSION_1_3}" = xtrue; then \
81       APXS_EXTRA_CFLAGS=`$APXS -q CFLAGS`
82     fi
83     AC_SUBST([APXS_INCLUDEDIR])
84     AC_SUBST([APXS_LIBEXECDIR])
85     AC_SUBST([APXS_EXTRA_CFLAGS])
86
87     AC_MSG_RESULT(found at $APXS (version $APACHE_VERSION))
88 else
89     APXS="/notfound/"
90     AC_SUBST(APXS)
91     
92     AC_MSG_RESULT(no)
93 fi
94
95
96 # Get uid/gid mode
97
98 AC_MSG_CHECKING([for set-UID/set-GID mode])
99 AC_ARG_WITH(setid-mode, 
100             AC_HELP_STRING([--with-setid-mode=MODE], 
101                            [Mode to use for setting UID/GID.  MODE can be on of "owner", "config" or "paranoid"; defaults to "paranoid".]),
102             [
103             if test "$withval" = "yes"; then
104               SETID_MODE="paranoid"
105             else
106               SETID_MODE="$withval"
107             fi
108             ])
109
110 if test -z "$SETID_MODE" ; then
111   SETID_MODE="paranoid"
112 fi
113
114 if test -n "$SETID_MODE"; then
115     case "$SETID_MODE" in 
116       owner)
117         OPT_APACHEMOD_USERGROUP_DEF=""
118         AC_SUBST(OPT_APACHEMOD_USERGROUP_DEF)
119         AC_DEFINE(OPT_USERGROUP_OWNER, 1,
120                   [Define if you want to set UID/GID to the owner of the script])
121         ;;
122       force)
123         OPT_APACHEMOD_USERGROUP_DEF=-DSUPHP_USE_USERGROUP
124         AC_SUBST(OPT_APACHEMOD_USERGROUP_DEF)
125         AC_DEFINE(OPT_USERGROUP_FORCE, 1,
126                   [Define if you want to set UID/GID to the user/group specified in the Apache configuration])
127         ;;
128       paranoid)
129         OPT_APACHEMOD_USERGROUP_DEF=-DSUPHP_USE_USERGROUP
130         AC_SUBST(OPT_APACHEMOD_USERGROUP_DEF)
131         AC_DEFINE(OPT_USERGROUP_PARANOID, 1,
132                   [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])
133         ;;
134       *)
135         AC_MSG_ERROR([--with-setid-mode has to be set to one of "owner", "force" or "paranoid"])
136         ;;
137     esac
138     AC_MSG_RESULT([ok - using $SETID_MODE])
139 fi
140
141
142 # Checkpath (docroot) option
143
144 checkpath=yes
145 AC_ARG_ENABLE([checkpath], 
146               AC_HELP_STRING([--enable-checkpath],
147                              [Check if script resides in DOCUMENT_ROOT (default is ENABLED)]),
148               [
149               if test "$enableval" = "no"; then
150                 checkpath=no
151                 AC_DEFINE(OPT_DISABLE_CHECKPATH, 1, [Define if you want to disable the check, wether script resides in DOCUMENT_ROOT])
152               fi
153               ])
154
155
156 # Minimum UID
157
158 AC_ARG_WITH([min-uid], 
159             AC_HELP_STRING([--with-min-uid=UID],
160                            [Minimum UID, which is allowed to run scripts
161                             (default=100)]),
162             [
163              if test "$withval" -a ! "$withval" = "yes" ; then
164                AC_DEFINE_UNQUOTED(OPT_MIN_UID, $withval, [Defines the min UID
165                          allowed to run scripts])
166              fi
167             ],
168             [
169               AC_DEFINE(OPT_MIN_UID, 100, [Defines the min UID
170                                        allowed to run scripts])
171             ])
172
173 # Minimum GID
174
175 AC_ARG_WITH([min-gid],
176             AC_HELP_STRING([--with-min-gid=GID],
177                            [Minimum GID, which is allowed to run scripts
178                             (default=100)]),
179             [
180              if test "$withval" -a ! "$withval" = "yes" ; then
181                AC_DEFINE_UNQUOTED(OPT_MIN_GID, $withval, [Defines the min GID
182                          allowed to run scripts])
183              fi
184             ],
185             [
186               AC_DEFINE(OPT_MIN_GID, 100, [Defines the min GID
187                                        allowed to run scripts])
188             ])
189
190
191 # Webserver user
192
193 AC_ARG_WITH([apache-user],
194             AC_HELP_STRING([--with-apache-user=USERNAME],
195                            [Name of the user Apache is running as
196 (default is "wwwrun"]),
197             [
198              if test "$withval" -a ! "$withval" = "yes" ; then
199                AC_DEFINE_UNQUOTED(OPT_APACHE_USER, "$withval", [Defines the username of the Apache user])
200              fi
201             ],
202             [
203              AC_DEFINE_UNQUOTED(OPT_APACHE_USER, "wwwrun", [Defines the username of the Apache user])
204             ])
205
206 # Path to logfile
207
208 AC_ARG_WITH([logfile],
209             AC_HELP_STRING([--with-logfile=FILE],
210                            [Path to suPHP logfile (default is "/var/log/httpd/suphp_log"]),
211             [
212              if test "$withval" -a ! "$withval" = "yes" ; then
213                AC_DEFINE_UNQUOTED(OPT_LOGFILE, "$withval", [Defines
214 path to logfile])
215              fi
216             ],
217             [
218              AC_DEFINE_UNQUOTED(OPT_LOGFILE, "/var/log/httpd/suphp_log", [Defines path to logfile])
219             ])
220
221
222 # Conditional building of Apache module
223 AM_CONDITIONAL([COND_AP13], [test x"$APACHE_VERSION_1_3" = xtrue])
224 AM_CONDITIONAL([COND_AP20], [test x"$APACHE_VERSION_2" = xtrue])
225
226 # Conditionally include UserGroup support
227 AM_CONDITIONAL([COND_APUSERGROUP], [test \( x"$SETID_MODE" = xparanoid \) -o \( x"$SETID_MODE" = xforce \) ])
228
229 AC_CONFIG_FILES([Makefile src/Makefile src/apache/Makefile src/apache2/Makefile])
230 AC_OUTPUT
231
232 if test "$APXS" = "/notfound/"; then
233   AC_MSG_WARN([
234 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
235 !!*** APXS was not found, so mod_suphp will not be built! ***!!
236 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
237   ])
238 fi
239