623e7ab4 |
1 | # Process this file with autoconf to produce a configure script. |
2 | |
3 | # Initialize |
4 | AC_INIT([suPHP], [0.7.1], [sebastian.marsching@suphp.org], [suphp]) |
5 | |
6 | # Auxiliary tools |
7 | AC_CONFIG_AUX_DIR([config]) |
8 | |
9 | AM_INIT_AUTOMAKE([suPHP], [0.7.1]) |
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" -o "$major_version" = "2.2"; 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 | APR_CPPFLAGS=`${apr_config} --cppflags` |
105 | AC_SUBST([APR_CPPFLAGS]) |
106 | else |
107 | AC_MSG_ERROR([APR is needed to build mod_suphp for Apache 2.x but was not found]) |
108 | fi |
109 | fi |
110 | |
111 | # Get uid/gid mode |
112 | |
113 | AC_MSG_CHECKING([for set-UID/set-GID mode]) |
114 | AC_ARG_WITH(setid-mode, |
115 | AC_HELP_STRING([--with-setid-mode=MODE], |
116 | [Mode to use for setting UID/GID. MODE can be on of "owner", "config" or "paranoid"; defaults to "paranoid".]), |
117 | [ |
118 | if test "$withval" = "yes"; then |
119 | SETID_MODE="paranoid" |
120 | else |
121 | SETID_MODE="$withval" |
122 | fi |
123 | ]) |
124 | |
125 | if test -z "$SETID_MODE" ; then |
126 | SETID_MODE="paranoid" |
127 | fi |
128 | |
129 | if test -n "$SETID_MODE"; then |
130 | case "$SETID_MODE" in |
131 | owner) |
132 | OPT_APACHEMOD_USERGROUP_DEF="" |
133 | AC_SUBST(OPT_APACHEMOD_USERGROUP_DEF) |
134 | AC_DEFINE(OPT_USERGROUP_OWNER, 1, |
135 | [Define if you want to set UID/GID to the owner of the script]) |
136 | ;; |
137 | force) |
138 | OPT_APACHEMOD_USERGROUP_DEF=-DSUPHP_USE_USERGROUP |
139 | AC_SUBST(OPT_APACHEMOD_USERGROUP_DEF) |
140 | AC_DEFINE(OPT_USERGROUP_FORCE, 1, |
141 | [Define if you want to set UID/GID to the user/group specified in the Apache configuration]) |
142 | ;; |
143 | paranoid) |
144 | OPT_APACHEMOD_USERGROUP_DEF=-DSUPHP_USE_USERGROUP |
145 | AC_SUBST(OPT_APACHEMOD_USERGROUP_DEF) |
146 | AC_DEFINE(OPT_USERGROUP_PARANOID, 1, |
147 | [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]) |
148 | ;; |
149 | *) |
150 | AC_MSG_ERROR([--with-setid-mode has to be set to one of "owner", "force" or "paranoid"]) |
151 | ;; |
152 | esac |
153 | AC_MSG_RESULT([ok - using $SETID_MODE]) |
154 | fi |
155 | |
156 | |
157 | # Checkpath (docroot) option |
158 | |
159 | checkpath=yes |
160 | AC_ARG_ENABLE([checkpath], |
161 | AC_HELP_STRING([--enable-checkpath], |
162 | [Check if script resides in DOCUMENT_ROOT (default is ENABLED)]), |
163 | [ |
164 | if test "$enableval" = "no"; then |
165 | checkpath=no |
166 | AC_DEFINE(OPT_DISABLE_CHECKPATH, 1, [Define if you want to disable the check, wether script resides in DOCUMENT_ROOT]) |
167 | fi |
168 | ]) |
169 | |
170 | |
171 | # Minimum UID |
172 | |
173 | AC_ARG_WITH([min-uid], |
174 | AC_HELP_STRING([--with-min-uid=UID], |
175 | [Minimum UID, which is allowed to run scripts |
176 | (default=100)]), |
177 | [ |
178 | if test "$withval" -a ! "$withval" = "yes" ; then |
179 | AC_DEFINE_UNQUOTED(OPT_MIN_UID, $withval, [Defines the min UID |
180 | allowed to run scripts]) |
181 | fi |
182 | ], |
183 | [ |
184 | AC_DEFINE(OPT_MIN_UID, 100, [Defines the min UID |
185 | allowed to run scripts]) |
186 | ]) |
187 | |
188 | # Minimum GID |
189 | |
190 | AC_ARG_WITH([min-gid], |
191 | AC_HELP_STRING([--with-min-gid=GID], |
192 | [Minimum GID, which is allowed to run scripts |
193 | (default=100)]), |
194 | [ |
195 | if test "$withval" -a ! "$withval" = "yes" ; then |
196 | AC_DEFINE_UNQUOTED(OPT_MIN_GID, $withval, [Defines the min GID |
197 | allowed to run scripts]) |
198 | fi |
199 | ], |
200 | [ |
201 | AC_DEFINE(OPT_MIN_GID, 100, [Defines the min GID |
202 | allowed to run scripts]) |
203 | ]) |
204 | |
205 | |
206 | # Webserver user |
207 | |
208 | AC_ARG_WITH([apache-user], |
209 | AC_HELP_STRING([--with-apache-user=USERNAME], |
210 | [Name of the user Apache is running as |
211 | (default is "wwwrun"]), |
212 | [ |
213 | if test "$withval" -a ! "$withval" = "yes" ; then |
214 | AC_DEFINE_UNQUOTED(OPT_APACHE_USER, "$withval", [Defines the username of the Apache user]) |
215 | fi |
216 | ], |
217 | [ |
218 | AC_DEFINE_UNQUOTED(OPT_APACHE_USER, "wwwrun", [Defines the username of the Apache user]) |
219 | ]) |
220 | |
221 | # Path to logfile |
222 | |
223 | AC_ARG_WITH([logfile], |
224 | AC_HELP_STRING([--with-logfile=FILE], |
225 | [Path to suPHP logfile (default is "/var/log/httpd/suphp_log"]), |
226 | [ |
227 | if test "$withval" -a ! "$withval" = "yes" ; then |
228 | AC_DEFINE_UNQUOTED(OPT_LOGFILE, "$withval", [Defines |
229 | path to logfile]) |
230 | fi |
231 | ], |
232 | [ |
233 | AC_DEFINE_UNQUOTED(OPT_LOGFILE, "/var/log/httpd/suphp_log", [Defines path to logfile]) |
234 | ]) |
235 | |
236 | |
237 | # Conditional building of Apache module |
238 | AM_CONDITIONAL([COND_AP13], [test x"$APACHE_VERSION_1_3" = xtrue]) |
239 | AM_CONDITIONAL([COND_AP20], [test x"$APACHE_VERSION_2" = xtrue]) |
240 | |
241 | # Conditionally include UserGroup support |
242 | AM_CONDITIONAL([COND_APUSERGROUP], [test \( x"$SETID_MODE" = xparanoid \) -o \( x"$SETID_MODE" = xforce \) ]) |
243 | |
244 | AC_CONFIG_FILES([Makefile src/Makefile src/apache/Makefile src/apache2/Makefile]) |
245 | AC_OUTPUT |
246 | |
247 | if test "$APXS" = "/notfound/"; then |
248 | AC_MSG_WARN([ |
249 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
250 | !!*** APXS was not found, so mod_suphp will not be built! ***!! |
251 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
252 | ]) |
253 | fi |
254 | |