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.
25 INFOMODS
="extras/inf/"
32 echo "+ Creating conf/monkey.conf"
35 echo "+ Creating Makefile"
38 echo "+ Creating src/Makefile"
41 echo "+ Creating src/include/info.h"
44 echo "+ Creating banana script"
47 echo -n "Configuration done, just type 'make"
50 echo -n "+ Checking for Pthreads lib.........."
55 # Create configuration files under 'conf/'
58 cat $INCDIR/config.path lang
/"$*"/mconf lang
/"$*"/sites
/default
> makeconf.sh
62 rm $INCDIR/config.path
63 cp lang
/"$*"/monkey.deny conf
/
64 cp lang
/"$*"/INSTALL .
/
65 cp lang
/"$*"/README .
/
74 if [ ! -d $bin ]; then
78 if [ ! -d $logs ]; then
82 if [ ! -d $sites ]; then
93 rm -rf src
/extras
/inf
/*
96 if [ "$prefix" != "$actual_path" ]; then
100 if [ "$bindir" != "$actual_path/bin" ]; then
104 if [ "$cgibin" != "$actual_path/cgi-bin" ]; then
108 if [ "$sysconfdir" != "$actual_path/conf" ]; then
112 if [ "$datadir" != "$actual_path/htdocs" ]; then
116 if [ "$logdir" != "$actual_path/logs" ]; then
121 echo "Checking dependencies"
122 echo "====================="
128 echo "Creating Makefiles and scripts"
129 echo "=============================="
133 create_conf prefix bindir cgibin sysconfdir datadir logdir
138 if [ "$dir" = 0 ]; then
139 create_makefile1 bindir
141 create_makefile1_install prefix bindir cgibin sysconfdir datadir logdir
145 create_makefile2 mod_libs mod_defs mod_obj make_script add_obj_mod cheetah_obj
148 create_info sysconfdir SYSNAME VERSION
151 create_banana_script bindir logdir
155 if [ "$dir" = 1 ]; then
156 echo -n " && make install' "
162 create_makefile_plugins
170 int main(){ return 0;}
173 libtest
=`gcc check.c -lpthread &>configure.log`
174 libstatus
=`cat configure.log`
175 if test -n "$libstatus" ; then
177 rm -fr check
* configure.log
181 rm -fr check
* configure.log a.out
188 cat > Makefile
<< EOF
189 # Monkey HTTP Daemon: Makefile
190 # ============================
194 @echo " Running Monkey :"
195 @echo " ----------------"
197 @echo " # $bindir/monkey"
199 @echo " For more help use '-h' option."
203 @(cd src/plugins; make all)
206 @(cd src; make clean)
208 @(cd src; make distclean)
212 create_makefile1_install
()
215 # Monkey HTTP Daemon: Makefile
216 # ============================
220 SYSCONFDIR=${sysconfdir}
227 @(cd src; make clean)
229 @(cd src; make distclean)
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
250 @echo " Running Monkey :"
251 @echo " ----------------"
253 @echo " # $bindir/monkey"
255 @echo " For more help use '-h' option"
261 # Create monkey/src/Makefile
265 if test -z $CC ; then
268 if test -z $STRIP ; then
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
281 DEFS = $mod_defs $internal_options
282 CFLAGS = \$(DEFS) -g -O2 -Wall
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 deny.o cgi.o user.o utils.o \\
290 chars.o epoll.o scheduler.o str.o memory.o \\
291 connection.o iov.o http.o file.o socket.o \\
292 clock.o cache.o worker.o server.o plugin.o \\
297 ../bin/monkey: \$(OBJ)
298 @echo "Compiling Monkey"
299 @echo "================"
300 \$(CC) \$(CFLAGS) \$(LIBS) \$(LDFLAGS) -o \$@ \$(OBJ) $mod_obj
303 @echo "Compiling Plugins"
304 @echo "================="
305 @(cd plugins && make all && cd ..)
312 rm -rf *.o ../bin/* Makefile \\
313 ../Makefile ../conf/monkey.conf \\
314 ../conf/monkey.deny ../conf/sites/* include/info.h ../logs/*\\
316 @(cd extras && ./cleanmods.sh && cd ..)
319 \$(CC) -c \$(CFLAGS) -I\$(INCDIR) \$<
323 create_makefile_plugins
()
326 list
=`echo */ "" | sed "s/\/ /\n/g"`
331 plugins_load
="../../conf/plugins.load"
332 echo -n > $plugins_load
333 echo "# Monkey plugins are loaded on run, by default all " >> $plugins_load
334 echo "# plugins are disabled, if you want to enable" >> $plugins_load
335 echo "# one, just remove the comment character for each line\n" >> $plugins_load
339 echo "\t@(cd $i && make && cd ..)" >> Makefile
;
340 echo "#LoadPlugin $dir/$i/monkey-$i.so" >> ..
/..
/conf
/plugins.load
;
344 # Creando include/info.h
347 cat > $INCDIR/info.h
<<EOF
348 #define OS "$SYSNAME"
349 #define VERSION "$VERSION" /* Version de Monkey */
350 #define MONKEY_PATH_CONF "$sysconfdir"
356 cat > $INCDIR/config.path
<<EOF
361 sysconfdir=$sysconfdir
367 create_banana_script
()
369 cat > bin
/banana
<< EOF
372 # Monkey HTTP Daemon - Banana Script
373 # -----------------------------------
374 # This script allow you to control monkey. Written by Eduardo Silva
375 # ----------------------------
377 # ----------------------------
379 # Use: ./banana OPTION
381 # Options available to banana:
383 # start -> start monkey
384 # restart -> restart monkey
385 # stop -> stop monkey if this is running
386 # help -> what do u think ?
388 PIDFILE="$logdir/monkey.pid"
389 BINMONKEY="$bindir/monkey"
393 -*=*) optarg=\`echo "\$arg" | sed 's/[-_a-zA-Z0-9]*=//'\` ;;
397 if ! test -f \$PIDFILE ; then
400 PIDMONKEY=\`cat \$PIDFILE\`
401 if ! kill -0 \$PIDMONKEY 2>/dev/null; then
410 if [ "\$STATUS" = "yes" ] ; then
411 echo "Monkey is running... (PID=\$PIDMONKEY)"
414 if ! test -x \$BINMONKEY ; then
415 echo "Error: I can't run binary file"
418 if \$BINMONKEY -D 2>/dev/null ; then
419 echo "Running Monkey -> OK"
425 if [ "\$STATUS" = "no" ]; then
426 echo "Monkey is not running."
430 rm -rf \$PIDFILE > /dev/null
431 echo "Monkey stopped (\$PIDMONKEY)"
435 if [ "\$STATUS" = "yes" ]; then
436 if ! kill \$PIDMONKEY > /dev/null ; then
439 echo -n "Stopping Monkey... "
442 echo -n "Monkey is not running... "
444 if ! test -x \$BINMONKEY ; then
445 echo "Error: I can't run binary file"
448 \$BINMONKEY -D > /dev/null
449 echo "Restarting -> OK"
454 echo "Use : banana [start|stop|restart|help]"
459 echo "Use : banana [start|stop|restart|help]"
466 #---------------------------#
468 #---------------------------#
471 #---------------------------#
473 #---------------------------#
478 cgibin
="$aux/cgi-bin"
479 sysconfdir
="$aux/conf"
480 datadir
="$aux/htdocs"
483 rm -rf src
/extras
/*.info
484 touch $INCDIR/modules.h
489 optarg
=`echo "$arg" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
497 cgibin
="$optarg/cgi-bin"
498 sysconfdir
="$optarg/conf"
499 datadir
="$optarg/htdocs"
500 logdir
="$optarg/logs"
524 --with-cheetah-shell*)
528 echo "Monkey HTTP Daemon v$VERSION"
529 echo "-------------------------"
530 echo "Copyright 2001-2009"
531 echo "Developed by Eduardo Silva"
532 echo "Monkey Home : http://monkeyd.sf.net"
533 echo "Contact Email : edsiper@users.sf.net"
538 echo "Usage: configure [--prefix=PREFIXDIR] [--lang=LANGUAGE] [ --bindir=BINDIR]"
539 echo " [--cgibin=CGIBINDIR] [--sysconfdir=SYSCONFDIR]"
540 echo " [--datadir=DATADIR] [--logdir=LOGDIR]"
543 echo " --help Display this help and exit"
544 echo " --version Display version information and exit"
546 echo " --prefix=PREFIX Install Monkey under PREFIX directory"
547 echo " --bindir=BINDIR Install Monkey binaries under BINDIR directory"
548 echo " --cgibin=CGIBINDIR Install Monkey cgi-bin under CGIBIN directory"
549 echo " --sysconfdir=SYSCONFDIR Install Monkey conf files under SYSCONFDIR dir"
550 echo " --datadir=DATADIR Install Monkey data dir files under DATADIR directory"
551 echo " --logdir=LOGDIR Install Monkey log files under LOGDIR directory"
552 echo " --lang=[en|es] Language to configuration files (default English)"
554 echo "Extra features :"
555 echo " All modules are optional features, neither of them are loaded by default,"
556 echo " the available modules are:"
558 echo " --load-mod_mysql Load MySQL Support (read MODULES file for details)."
559 echo " --with-cheetah-shell Include Cheetah Shell!!!"
566 echo "********************************************"
567 echo " Monkey HTTP Daemon v$VERSION "
568 echo "* (http://monkeyd.sf.net) *"
569 echo "* ---------------------------------------- *"
570 echo "* We need beta testers, developers and *"
571 echo "* translators!, if u want help to this *"
572 echo "* project, email me : *"
574 echo "* edsiper@users.sourceforge.net *"
576 echo "* Thanks for use Monkey!!! *"
578 echo "********************************************"
579 echo "System : $SYSINFO"
583 # starting main function
584 main prefix lang bindir cgibin sysconfdir datadir logdir modules SYSNAME VERSION