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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
31 echo "+ Creating conf/monkey.conf"
34 echo "+ Creating Makefile"
37 echo "+ Creating src/Makefile"
40 echo "+ Creating src/include/info.h"
43 echo "+ Creating banana script"
46 echo -n "Configuration done, just type 'make"
49 echo -n "+ Checking for Pthreads lib.........."
54 # Create configuration files under 'conf/'
57 cat $INCDIR/config.path lang
/"$*"/mconf lang
/"$*"/sites
/default
> makeconf.sh
61 rm $INCDIR/config.path
70 if [ ! -d $bin ]; then
74 if [ ! -d $logs ]; then
78 if [ ! -d $sites ]; then
90 if [ "$prefix" != "$actual_path" ]; then
94 if [ "$bindir" != "$actual_path/bin" ]; then
98 if [ "$cgibin" != "$actual_path/cgi-bin" ]; then
102 if [ "$sysconfdir" != "$actual_path/conf" ]; then
106 if [ "$datadir" != "$actual_path/htdocs" ]; then
110 if [ "$logdir" != "$actual_path/logs" ]; then
115 echo "Checking dependencies"
116 echo "====================="
122 echo "Creating Makefiles and scripts"
123 echo "=============================="
127 create_conf prefix bindir cgibin sysconfdir datadir logdir
132 if [ "$dir" = 0 ]; then
133 create_makefile1 bindir
135 create_makefile1_install prefix bindir cgibin sysconfdir datadir logdir
139 create_makefile2 mod_libs mod_obj make_script add_obj_mod cheetah_obj
142 create_info sysconfdir SYSNAME VERSION
145 create_banana_script bindir logdir
149 if [ "$dir" = 1 ]; then
150 echo -n " && make install' "
156 create_makefile_plugins
$plugdir
158 echo "#define CC \"${CC}\"" > src
/include
/env.h
166 int main(){ return 0;}
169 libtest
=`gcc check.c -lpthread &>configure.log`
170 libstatus
=`cat configure.log`
171 if test -n "$libstatus" ; then
173 rm -fr check
* configure.log
177 rm -fr check
* configure.log a.out
184 cat > Makefile
<< EOF
185 # Monkey HTTP Daemon: Makefile
186 # ============================
191 @(cd plugins; make all)
194 @(cd src; make clean)
196 @(cd src; make distclean)
200 create_makefile1_install
()
202 # Look for plugins and create list
203 for entry
in plugins
/*
205 if [ -d $entry ]; then
206 echo -e "\tinstall -s -m 644 $entry/*.so \${PLUGINDIR}" >> plugins.list
209 plglist
=`cat plugins.list`
212 # Look for plugins configuration
213 for entry
in conf
/plugins
/*
215 if [ -d $entry ]; then
216 echo -e "\tcp -r $entry \${SYSCONFDIR}/plugins/" >> plugins.conf
219 plgconf
=`cat plugins.conf`
223 # Monkey HTTP Daemon: Makefile
224 # ============================
225 PREFIX=\$(DESTDIR)${prefix}
226 BINDIR=\$(DESTDIR)${bindir}
227 CGIBIN=\$(DESTDIR)${cgibin}
228 SYSCONFDIR=\$(DESTDIR)${sysconfdir}
229 DATADIR=\$(DESTDIR)${datadir}
230 LOGDIR=\$(DESTDIR)${logdir}
231 PLUGINDIR=\$(DESTDIR)${plugdir}
236 @(cd src; make clean)
238 @(cd src; make distclean)
242 install -d \$(BINDIR)
243 install -d \$(CGIBIN)
244 install -d \$(SYSCONFDIR)
245 install -d \${SYSCONFDIR}/sites
246 install -d \${SYSCONFDIR}/plugins
247 install -d \$(DATADIR)
248 install -d \${DATADIR}/imgs
249 install -d \${DATADIR}/php
250 install -d \${DATADIR}/docs
251 install -d \${LOGDIR}
252 install -d \${PLUGINDIR}
253 install -m 755 bin/monkey \$(BINDIR)
254 $STRIP \$(BINDIR)/monkey
255 install -m 755 bin/banana \$(BINDIR)
256 install -m 644 ./conf/*.* \$(SYSCONFDIR)
258 install -m 644 ./conf/sites/* \${SYSCONFDIR}/sites
260 install -m 644 ./htdocs/*.* \$(DATADIR)
261 install -m 644 ./htdocs/imgs/*.* \${DATADIR}/imgs
263 @echo " Running Monkey :"
264 @echo " ----------------"
266 @echo " # $bindir/monkey"
268 @echo " For more help use '-h' option"
274 # Create monkey/src/Makefile
278 cat > src
/Makefile
<<EOF
284 DESTDIR = ../bin/monkey
285 LIBS = -ldl -lpthread $mod_libs $MORE_LIBS
286 OBJ = monkey.o method.o mimetype.o request.o \\
287 header.o config.o logfile.o signals.o \\
288 user.o utils.o chars.o epoll.o scheduler.o \\
289 str.o memory.o connection.o iov.o http.o \\
290 file.o socket.o clock.o cache.o worker.o \\
296 ../bin/monkey: \$(OBJ)
298 @echo "Compiling Monkey"
299 @echo "================"
300 \$(CC) \$(CFLAGS) \$(DEFS) \$(LIBS) \$(LDFLAGS) -o \$@ \$(OBJ) $mod_obj
302 @echo "Compiling Plugins"
303 @echo "================="
304 @(cd ../plugins && make all && cd ..)
311 rm -rf *.o ../bin/* Makefile \\
312 ../Makefile ../conf/monkey.conf \\
313 ../conf/sites/* include/info.h ../logs/*\\
316 \$(CC) -c \$(CFLAGS) \$(DEFS) -I\$(INCDIR) \$<
320 create_makefile_plugins
()
327 plugins_load
="../conf/plugins.load"
328 echo -n > $plugins_load
329 echo "# Monkey Plugins Loader" >> $plugins_load
330 echo "# =====================" >> $plugins_load
331 echo "# Monkey plugins are extended functionalities for Monkey," >> $plugins_load
332 echo "# the main directive to load a plugin is LoadPlugin plus" >> $plugins_load
333 echo "# the absolute path for the desired plugin." >> $plugins_load
334 echo "#" >> $plugins_load
335 echo "# Please check the following list of available plugins:" >> $plugins_load
336 echo "" >> $plugins_load
337 echo "[PLUGINS]" >> $plugins_load
338 echo "" >> $plugins_load
340 for plugin_dir
in `echo */ "" | sed "s/\/ /\n/g"`;
343 if test -e $plugin_dir/DISABLED
; then
347 if test -e $plugin_dir/MANDATORY
; then
351 if test -e $plugin_dir/OPTIONAL
; then
355 echo " @(cd $plugin_dir && make && cd ..)" >> Makefile
;
356 sed -e "s/\$CC/$CC/" -e "s/\$CFLAGS/$CFLAGS/" -e "s/\$DEFS/$DEFS/" $plugin_dir/Makefile.
in > $plugin_dir/Makefile
358 if test -e $plugin_dir/ABOUT
; then
359 cat $plugin_dir/ABOUT |
sed -e 's/^/ # /' >> ..
/conf
/plugins.load
360 echo " #" >> ..
/conf
/plugins.load
362 echo " #" >> ..
/conf
/plugins.load
365 if [ "$plugdir" != "" ]; then
366 echo "${comment}Load $plugdir/monkey-$plugin_dir.so" >> ..
/conf
/plugins.load
368 echo "${comment}Load $dir/$plugin_dir/monkey-$plugin_dir.so" >> ..
/conf
/plugins.load
371 echo "" >> ..
/conf
/plugins.load
374 # Add 'install' option to make file if plugdir was specified
375 if [ "$plugdir" != "" ]; then
376 echo -e "\ninstall:" >> Makefile
377 echo -e "\tinstall -d $plugdir" >> Makefile
379 list
=`echo */ "" | sed "s/\/ /\n/g"`
382 echo -e "\tinstall -m 644 $dir/$i/monkey-$i.so $plugdir/" >> Makefile
388 # Creando include/info.h
391 cat > $INCDIR/info.h
<<EOF
392 #define OS "$SYSNAME"
393 #define VERSION "$VERSION" /* Version de Monkey */
394 #define MONKEY_PATH_CONF "$sysconfdir"
400 cat > $INCDIR/config.path
<<EOF
405 sysconfdir=$sysconfdir
411 create_banana_script
()
413 cat > bin
/banana
<< EOF
416 # Monkey HTTP Daemon - Banana Script
417 # -----------------------------------
418 # This script allow you to control monkey. Written by Eduardo Silva
419 # ----------------------------
421 # ----------------------------
423 # Use: ./banana OPTION
425 # Options available to banana:
427 # start -> start monkey
428 # restart -> restart monkey
429 # stop -> stop monkey if this is running
430 # help -> what do u think ?
432 PIDFILE="$logdir/monkey.pid"
433 BINMONKEY="$bindir/monkey"
437 -*=*) optarg=\`echo "\$arg" | sed 's/[-_a-zA-Z0-9]*=//'\` ;;
441 if ! test -f \$PIDFILE ; then
444 PIDMONKEY=\`cat \$PIDFILE\`
445 if ! kill -0 \$PIDMONKEY 2>/dev/null; then
454 if [ "\$STATUS" = "yes" ] ; then
455 echo "Monkey is running... (PID=\$PIDMONKEY)"
458 if ! test -x \$BINMONKEY ; then
459 echo "Error: I can't run binary file"
462 if \$BINMONKEY -D 2>/dev/null ; then
463 echo "Running Monkey -> OK"
469 if [ "\$STATUS" = "no" ]; then
470 echo "Monkey is not running."
474 rm -rf \$PIDFILE > /dev/null
475 echo "Monkey stopped (\$PIDMONKEY)"
479 if [ "\$STATUS" = "yes" ]; then
480 if ! kill \$PIDMONKEY > /dev/null ; then
483 echo -n "Stopping Monkey... "
486 echo -n "Monkey is not running... "
488 if ! test -x \$BINMONKEY ; then
489 echo "Error: I can't run binary file"
492 \$BINMONKEY -D > /dev/null
493 echo "Restarting -> OK"
498 echo "Use : banana [start|stop|restart|help]"
503 echo "Use : banana [start|stop|restart|help]"
510 #---------------------------#
512 #---------------------------#
515 #---------------------------#
517 #---------------------------#
522 cgibin
="$aux/cgi-bin"
523 sysconfdir
="$aux/conf"
524 datadir
="$aux/htdocs"
531 optarg
=`echo "$arg" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
539 cgibin
="$optarg/cgi-bin"
540 sysconfdir
="$optarg/conf"
541 datadir
="$optarg/htdocs"
542 logdir
="$optarg/logs"
543 plugdir
="$optarg/plugins"
570 echo "Monkey HTTP Daemon v$VERSION"
571 echo "-------------------------"
572 echo "Copyright 2001-2010"
573 echo "Developed by Eduardo Silva Pereira"
574 echo "Monkey Home : http://www.monkey-project.com"
575 echo "Contact Email : edsiper@gmail.com"
580 echo "Usage: configure [--prefix=PREFIXDIR] [ --bindir=BINDIR]"
581 echo " [--sysconfdir=SYSCONFDIR] [--datadir=DATADIR]"
582 echo " [--logdir=LOGDIR] [--plugdir=PLUGDIR]"
585 echo " --help Display this help and exit"
586 echo " --version Display version information and exit"
587 echo " --debug Compile Monkey with debugging symbols"
588 echo " --trace Compile Monkey with trace messages (don't use in production)"
590 echo " --prefix=PREFIX Install Monkey under PREFIX directory"
591 echo " --bindir=BINDIR Install Monkey binaries under BINDIR directory"
592 echo " --sysconfdir=SYSCONFDIR Install Monkey conf files under SYSCONFDIR dir"
593 echo " --datadir=DATADIR Install Monkey data dir files under DATADIR directory"
594 echo " --logdir=LOGDIR Install Monkey log files under LOGDIR directory"
595 echo " --plugdir=PLUGDIR Target directory for Monkey plugins"
602 echo "********************************************"
603 echo " Monkey HTTP Daemon v$VERSION "
604 echo "* http://www.monkey-project.com *"
605 echo "* ---------------------------------------- *"
606 echo "* We need beta testers, developers and *"
607 echo "* translators!, if you want to contribute *"
608 echo "* to this wonderful project contact us ! *"
610 echo "* irc.freenode.net #monkeyd *"
612 echo "* Thanks for use Monkey!!! *"
614 echo "********************************************"
615 echo "System : $SYSINFO"
620 # Configure environment
621 if test -z "$CC" ; then
623 if test -x "$gcc_path" ; then
626 echo "I'm a Monkey not a compiler! how do you suppose to compile me ? Install a compiler"
631 if test -z "$STRIP" ; then
635 if test -z "$debug" ; then
636 CFLAGS
="$CFLAGS -O2 -Wall"
638 CFLAGS
="$CFLAGS -g -Wall"
645 # Starting main function
646 main prefix lang bindir cgibin sysconfdir datadir logdir plugdir modules SYSNAME VERSION