Free client request log->size_p
[MonkeyD.git] / configure
blob311e39c48b1035f0c75d12472da54dfa2fb98839
1 #!/bin/sh
3 # Monkey HTTP Daemon
4 # ------------------
5 # Copyright (C) 2001-2009, Eduardo Silva P.
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU Library General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 VERSION="0.10.0-git"
22 SYSNAME=`uname -s`
23 SYSINFO=`uname -sr`
25 INFOMODS="extras/inf/"
26 INCDIR="src/include/"
28 messages_en()
30 case "$*" in
31 "1")
32 echo "+ Creating conf/monkey.conf"
34 "2")
35 echo "+ Creating Makefile"
37 "3")
38 echo "+ Creating src/Makefile"
40 "4")
41 echo "+ Creating src/include/info.h"
43 "5")
44 echo "+ Creating banana script"
46 "6")
47 echo -n "Configuration done, just type 'make"
49 "7")
50 echo -n "+ Checking for Pthreads lib.........."
52 esac
55 # Create configuration files under 'conf/'
56 make_conf()
58 cat $INCDIR/config.path lang/"$*"/mconf lang/"$*"/sites/default > makeconf.sh
59 chmod 755 makeconf.sh
60 ./makeconf.sh
61 rm makeconf.sh
62 rm $INCDIR/config.path
63 cp lang/"$*"/monkey.deny conf/
64 cp lang/"$*"/INSTALL ./
65 cp lang/"$*"/README ./
68 local_dirs()
70 bin="bin"
71 logs="logs"
72 sites="conf/sites"
74 if [ ! -d $bin ]; then
75 mkdir $bin
78 if [ ! -d $logs ]; then
79 mkdir $logs
82 if [ ! -d $sites ]; then
83 mkdir $sites
88 main()
90 local_dirs
91 dir=0
92 actual_path=`pwd`
93 rm -rf src/extras/inf/*
96 if [ "$prefix" != "$actual_path" ]; then
97 dir=1
100 if [ "$bindir" != "$actual_path/bin" ]; then
101 dir=1
104 if [ "$cgibin" != "$actual_path/cgi-bin" ]; then
105 dir=1
108 if [ "$sysconfdir" != "$actual_path/conf" ]; then
109 dir=1
112 if [ "$datadir" != "$actual_path/htdocs" ]; then
113 dir=1
116 if [ "$logdir" != "$actual_path/logs" ]; then
117 dir=1
120 echo
121 echo "Checking dependencies"
122 echo "====================="
123 echo
124 messages_$lang "7"
125 check_lib lang
127 echo
128 echo "Creating Makefiles and scripts"
129 echo "=============================="
130 echo
132 messages_$lang "1"
133 create_conf prefix bindir cgibin sysconfdir datadir logdir
135 make_conf $lang
136 messages_$lang "2"
138 if [ "$dir" = 0 ]; then
139 create_makefile1 bindir
140 else
141 create_makefile1_install prefix bindir cgibin sysconfdir datadir logdir
144 messages_$lang "3"
145 create_makefile2 mod_libs mod_defs mod_obj make_script add_obj_mod cheetah_obj
147 messages_$lang "4"
148 create_info sysconfdir SYSNAME VERSION
150 messages_$lang "5"
151 create_banana_script bindir logdir
152 echo
153 messages_$lang "6"
155 if [ "$dir" = 1 ]; then
156 echo -n " && make install' "
157 else
158 echo "' "
160 echo
162 create_makefile_plugins
165 # Check pthreads lib
166 check_lib()
168 cat > check.c <<EOF
169 #include <pthread.h>
170 int main(){ return 0;}
173 libtest=`gcc check.c -lpthread &>configure.log`
174 libstatus=`cat configure.log`
175 if test -n "$libstatus" ; then
176 echo "no"
177 rm -fr check* configure.log
178 exit 1
180 echo "yes"
181 rm -fr check* configure.log a.out
185 # Create Makefile
186 create_makefile1()
188 cat > Makefile << EOF
189 # Monkey HTTP Daemon: Makefile
190 # ============================
191 default:
192 @(cd src; make all)
193 @echo
194 @echo " Running Monkey :"
195 @echo " ----------------"
196 @echo
197 @echo " # $bindir/monkey"
198 @echo
199 @echo " For more help use '-h' option."
200 @echo
202 plugins:
203 @(cd src/plugins; make all)
205 clean:
206 @(cd src; make clean)
207 distclean:
208 @(cd src; make distclean)
212 create_makefile1_install()
214 cat > Makefile <<EOF
215 # Monkey HTTP Daemon: Makefile
216 # ============================
217 PREFIX=${prefix}
218 BINDIR=${bindir}
219 CGIBIN=${cgibin}
220 SYSCONFDIR=${sysconfdir}
221 DATADIR=${datadir}
222 LOGDIR=${logdir}
224 default:
225 @(cd src; make all)
226 clean:
227 @(cd src; make clean)
228 distclean:
229 @(cd src; make distclean)
231 install:
232 make -C src all
233 install -d \$(BINDIR)
234 install -d \$(CGIBIN)
235 install -d \$(SYSCONFDIR)
236 install -d \$(DATADIR)
237 install -d \${DATADIR}/imgs
238 install -d \${DATADIR}/php
239 install -d \${DATADIR}/docs
240 install -d \${LOGDIR}
241 install -s -m 755 bin/monkey \$(BINDIR)
242 install -m 755 bin/banana \$(BINDIR)
243 install -m 755 ./cgi-bin/* \$(CGIBIN)
244 install -m 600 ./conf/*.* \$(SYSCONFDIR)
245 install -m 644 ./htdocs/*.* \$(DATADIR)
246 install -m 644 ./htdocs/imgs/*.* \${DATADIR}/imgs
247 install -m 644 ./htdocs/php/*.* \${DATADIR}/php
248 install -m 644 ./htdocs/docs/*.* \${DATADIR}/docs
249 @echo
250 @echo " Running Monkey :"
251 @echo " ----------------"
252 @echo
253 @echo " # $bindir/monkey"
254 @echo
255 @echo " For more help use '-h' option"
256 @echo
261 # Create monkey/src/Makefile
262 create_makefile2()
265 if test -z $CC ; then
266 CC="gcc"
268 if test -z $STRIP ; then
269 STRIP="strip "
272 ##### Internal options ####
273 # just for remember that one time we support this :_(
274 # ---------------------------------------------------
275 #if [ "$disable_sendfile" = "on" ]; then
276 # internal_options="-DDISABLE_SENDFILE_SYSCALL"
279 cat > src/Makefile<<EOF
280 CC = $CC
281 DEFS = $mod_defs $internal_options
282 CFLAGS = \$(DEFS) -g -O2 -Wall
283 INCDIR = ./include
284 LDFLAGS =
285 DESTDIR = ../bin/monkey
286 LIBS = -ldl -lpthread $mod_libs $MORE_LIBS
287 OBJ = monkey.o method.o mimetype.o request.o \\
288 header.o config.o logfile.o signals.o \\
289 dir_html.o deny.o cgi.o user.o utils.o \\
290 chars.o epoll.o scheduler.o str.o memory.o \\
291 conn_switch.o iov.o http.o file.o socket.o \\
292 clock.o cache.o worker.o server.o plugin.o \\
293 $add_obj_mod
295 all: ../bin/monkey
297 ../bin/monkey: \$(OBJ)
298 @echo "Compiling Monkey"
299 @echo "================"
300 \$(CC) \$(CFLAGS) \$(LIBS) \$(LDFLAGS) -o \$@ \$(OBJ) $mod_obj
301 $STRIP ../bin/monkey
302 @echo
303 @echo "Compiling Plugins"
304 @echo "================="
305 @(cd plugins && make all && cd ..)
307 clean:
308 rm -rf *.o
309 rm -rf ../bin/monkey
311 distclean:
312 rm -rf *.o ../bin/* Makefile \\
313 ../Makefile ../conf/monkey.conf \\
314 ../conf/monkey.deny ../conf/sites/* include/info.h ../logs/*\\
315 extras/inf/*
316 @(cd extras && ./cleanmods.sh && cd ..)
318 .c.o:
319 \$(CC) -c \$(CFLAGS) -I\$(INCDIR) \$<
323 create_makefile_plugins()
325 cd src/plugins
326 list=`echo */ "" | sed "s/\/ /\n/g"`
327 cat > Makefile <<EOF
328 all:
330 dir=`pwd`
331 echo -n > ../../conf/plugins.load;
332 for i in $list;
334 echo "\t@(cd $i && make && cd ..)" >> Makefile;
335 echo "LoadPlugin $dir/$i/monkey-$i.so" >> ../../conf/plugins.load;
336 done
339 # Creando include/info.h
340 create_info()
342 cat > $INCDIR/info.h <<EOF
343 #define OS "$SYSNAME"
344 #define VERSION "$VERSION" /* Version de Monkey */
345 #define MONKEY_PATH_CONF "$sysconfdir"
349 create_conf()
351 cat > $INCDIR/config.path <<EOF
352 #!/bin/sh
353 prefix=$prefix
354 bindir=$bindir
355 cgibin=$cgibin
356 sysconfdir=$sysconfdir
357 datadir=$datadir
358 logdir=$logdir
362 create_banana_script()
364 cat > bin/banana << EOF
365 #!/bin/sh
367 # Monkey HTTP Daemon - Banana Script
368 # -----------------------------------
369 # This script allow you to control monkey. Written by Eduardo Silva
370 # ----------------------------
371 # Date : 2002/09/01.
372 # ----------------------------
374 # Use: ./banana OPTION
376 # Options available to banana:
378 # start -> start monkey
379 # restart -> restart monkey
380 # stop -> stop monkey if this is running
381 # help -> what do u think ?
383 PIDFILE="$logdir/monkey.pid"
384 BINMONKEY="$bindir/monkey"
386 for arg in \$*; do
387 case "\$arg" in
388 -*=*) optarg=\`echo "\$arg" | sed 's/[-_a-zA-Z0-9]*=//'\` ;;
389 *) optarg= ;;
390 esac
392 if ! test -f \$PIDFILE ; then
393 STATUS="no"
394 else
395 PIDMONKEY=\`cat \$PIDFILE\`
396 if ! kill -0 \$PIDMONKEY 2>/dev/null; then
397 STATUS="no"
398 else
399 STATUS="yes"
403 case "\$arg" in
404 start)
405 if [ "\$STATUS" = "yes" ] ; then
406 echo "Monkey is running... (PID=\$PIDMONKEY)"
407 exit 1
409 if ! test -x \$BINMONKEY ; then
410 echo "Error: I can't run binary file"
411 exit 1
412 else
413 if \$BINMONKEY -D 2>/dev/null ; then
414 echo "Running Monkey -> OK"
415 exit 0
419 stop)
420 if [ "\$STATUS" = "no" ]; then
421 echo "Monkey is not running."
422 exit 1
424 kill -9 \$PIDMONKEY
425 rm -rf \$PIDFILE > /dev/null
426 echo "Monkey stopped (\$PIDMONKEY)"
427 exit 0
429 restart)
430 if [ "\$STATUS" = "yes" ]; then
431 if ! kill \$PIDMONKEY > /dev/null ; then
432 killall -9 monkey
433 else
434 echo -n "Stopping Monkey... "
436 else
437 echo -n "Monkey is not running... "
439 if ! test -x \$BINMONKEY ; then
440 echo "Error: I can't run binary file"
441 exit 1
442 else
443 \$BINMONKEY -D > /dev/null
444 echo "Restarting -> OK"
445 exit 0
449 echo "Use : banana [start|stop|restart|help]"
450 exit 1
452 esac
453 done
454 echo "Use : banana [start|stop|restart|help]"
456 exit 0
458 chmod 755 bin/banana
461 #---------------------------#
462 # End Functions
463 #---------------------------#
466 #---------------------------#
467 # Starting configure
468 #---------------------------#
469 aux=`pwd`
471 prefix="$aux"
472 bindir="$aux/bin"
473 cgibin="$aux/cgi-bin"
474 sysconfdir="$aux/conf"
475 datadir="$aux/htdocs"
476 logdir="$aux/logs"
478 rm -rf src/extras/*.info
479 touch $INCDIR/modules.h
481 for arg in $*; do
482 case "$arg" in
483 -*=*)
484 optarg=`echo "$arg" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
485 *) optarg= ;;
486 esac
488 case "$arg" in
489 --prefix*)
490 prefix=$optarg
491 bindir="$optarg/bin"
492 cgibin="$optarg/cgi-bin"
493 sysconfdir="$optarg/conf"
494 datadir="$optarg/htdocs"
495 logdir="$optarg/logs"
497 --bindir*)
498 bindir=$optarg
500 --cgibin*)
501 cgibin=$optarg
503 --sysconfdir*)
504 sysconfdir=$optarg
506 --datadir*)
507 datadir=$optarg
509 --logdir*)
510 logdir=$optarg
512 --lang*)
513 lang=$optarg
515 --load-mod_mysql*)
516 modules="on"
517 mod_mysql="on"
519 --with-cheetah-shell*)
520 cheetah="on"
522 --version*)
523 echo "Monkey HTTP Daemon v$VERSION"
524 echo "-------------------------"
525 echo "Copyright 2001-2009"
526 echo "Developed by Eduardo Silva"
527 echo "Monkey Home : http://monkeyd.sf.net"
528 echo "Contact Email : edsiper@users.sf.net"
529 echo
530 exit 1
533 echo "Usage: configure [--prefix=PREFIXDIR] [--lang=LANGUAGE] [ --bindir=BINDIR]"
534 echo " [--cgibin=CGIBINDIR] [--sysconfdir=SYSCONFDIR]"
535 echo " [--datadir=DATADIR] [--logdir=LOGDIR]"
536 echo
537 echo "Options : "
538 echo " --help Display this help and exit"
539 echo " --version Display version information and exit"
540 echo
541 echo " --prefix=PREFIX Install Monkey under PREFIX directory"
542 echo " --bindir=BINDIR Install Monkey binaries under BINDIR directory"
543 echo " --cgibin=CGIBINDIR Install Monkey cgi-bin under CGIBIN directory"
544 echo " --sysconfdir=SYSCONFDIR Install Monkey conf files under SYSCONFDIR dir"
545 echo " --datadir=DATADIR Install Monkey data dir files under DATADIR directory"
546 echo " --logdir=LOGDIR Install Monkey log files under LOGDIR directory"
547 echo " --lang=[en|es] Language to configuration files (default English)"
548 echo
549 echo "Extra features :"
550 echo " All modules are optional features, neither of them are loaded by default,"
551 echo " the available modules are:"
552 echo
553 echo " --load-mod_mysql Load MySQL Support (read MODULES file for details)."
554 echo " --with-cheetah-shell Include Cheetah Shell!!!"
555 echo
556 exit 1
558 esac
559 done
561 echo "********************************************"
562 echo " Monkey HTTP Daemon v$VERSION "
563 echo "* (http://monkeyd.sf.net) *"
564 echo "* ---------------------------------------- *"
565 echo "* We need beta testers, developers and *"
566 echo "* translators!, if u want help to this *"
567 echo "* project, email me : *"
568 echo "* *"
569 echo "* edsiper@users.sourceforge.net *"
570 echo "* *"
571 echo "* Thanks for use Monkey!!! *"
572 echo "* *"
573 echo "********************************************"
574 echo "System : $SYSINFO"
576 lang="en"
578 # starting main function
579 main prefix lang bindir cgibin sysconfdir datadir logdir modules SYSNAME VERSION
580 exit 0