Add old entries to Changelog
[MonkeyD.git] / configure
blob91be6bffc681eed3587e26282b90bda2794090cf
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/"$*"/INSTALL ./
64 cp lang/"$*"/README ./
67 local_dirs()
69 bin="bin"
70 logs="logs"
71 sites="conf/sites"
73 if [ ! -d $bin ]; then
74 mkdir $bin
77 if [ ! -d $logs ]; then
78 mkdir $logs
81 if [ ! -d $sites ]; then
82 mkdir $sites
87 main()
89 local_dirs
90 dir=0
91 actual_path=`pwd`
93 if [ "$prefix" != "$actual_path" ]; then
94 dir=1
97 if [ "$bindir" != "$actual_path/bin" ]; then
98 dir=1
101 if [ "$cgibin" != "$actual_path/cgi-bin" ]; then
102 dir=1
105 if [ "$sysconfdir" != "$actual_path/conf" ]; then
106 dir=1
109 if [ "$datadir" != "$actual_path/htdocs" ]; then
110 dir=1
113 if [ "$logdir" != "$actual_path/logs" ]; then
114 dir=1
117 echo
118 echo "Checking dependencies"
119 echo "====================="
120 echo
121 messages_$lang "7"
122 check_lib lang
124 echo
125 echo "Creating Makefiles and scripts"
126 echo "=============================="
127 echo
129 messages_$lang "1"
130 create_conf prefix bindir cgibin sysconfdir datadir logdir
132 make_conf $lang
133 messages_$lang "2"
135 if [ "$dir" = 0 ]; then
136 create_makefile1 bindir
137 else
138 create_makefile1_install prefix bindir cgibin sysconfdir datadir logdir
141 messages_$lang "3"
142 create_makefile2 mod_libs mod_defs mod_obj make_script add_obj_mod cheetah_obj
144 messages_$lang "4"
145 create_info sysconfdir SYSNAME VERSION
147 messages_$lang "5"
148 create_banana_script bindir logdir
149 echo
150 messages_$lang "6"
152 if [ "$dir" = 1 ]; then
153 echo -n " && make install' "
154 else
155 echo "' "
157 echo
159 create_makefile_plugins
162 # Check pthreads lib
163 check_lib()
165 cat > check.c <<EOF
166 #include <pthread.h>
167 int main(){ return 0;}
170 libtest=`gcc check.c -lpthread &>configure.log`
171 libstatus=`cat configure.log`
172 if test -n "$libstatus" ; then
173 echo "no"
174 rm -fr check* configure.log
175 exit 1
177 echo "yes"
178 rm -fr check* configure.log a.out
182 # Create Makefile
183 create_makefile1()
185 cat > Makefile << EOF
186 # Monkey HTTP Daemon: Makefile
187 # ============================
188 default:
189 @(cd src; make all)
190 @echo
191 @echo " Running Monkey :"
192 @echo " ----------------"
193 @echo
194 @echo " # $bindir/monkey"
195 @echo
196 @echo " For more help use '-h' option."
197 @echo
199 plugins:
200 @(cd plugins; make all)
202 clean:
203 @(cd src; make clean)
204 distclean:
205 @(cd src; make distclean)
209 create_makefile1_install()
211 cat > Makefile <<EOF
212 # Monkey HTTP Daemon: Makefile
213 # ============================
214 PREFIX=${prefix}
215 BINDIR=${bindir}
216 CGIBIN=${cgibin}
217 SYSCONFDIR=${sysconfdir}
218 DATADIR=${datadir}
219 LOGDIR=${logdir}
221 default:
222 @(cd src; make all)
223 clean:
224 @(cd src; make clean)
225 distclean:
226 @(cd src; make distclean)
228 install:
229 make -C src all
230 install -d \$(BINDIR)
231 install -d \$(CGIBIN)
232 install -d \$(SYSCONFDIR)
233 install -d \${SYSCONFDIR}/sites
234 install -d \${SYSCONFDIR}/plugins
235 install -d \$(DATADIR)
236 install -d \${DATADIR}/imgs
237 install -d \${DATADIR}/php
238 install -d \${DATADIR}/docs
239 install -d \${LOGDIR}
240 install -s -m 755 bin/monkey \$(BINDIR)
241 install -m 755 bin/banana \$(BINDIR)
242 install -m 755 ./cgi-bin/* \$(CGIBIN)
243 install -m 600 ./conf/*.* \$(SYSCONFDIR)
244 install -m 600 ./conf/sites/* \${SYSCONFDIR}/sites
245 install -m 600 ./conf/plugins/* \${SYSCONFDIR}/plugins
246 install -m 644 ./htdocs/*.* \$(DATADIR)
247 install -m 644 ./htdocs/imgs/*.* \${DATADIR}/imgs
248 install -m 644 ./htdocs/php/*.* \${DATADIR}/php
249 install -m 644 ./htdocs/docs/*.* \${DATADIR}/docs
250 @echo
251 @echo " Running Monkey :"
252 @echo " ----------------"
253 @echo
254 @echo " # $bindir/monkey"
255 @echo
256 @echo " For more help use '-h' option"
257 @echo
262 # Create monkey/src/Makefile
263 create_makefile2()
266 if test -z $CC ; then
267 CC="gcc"
269 if test -z $STRIP ; then
270 STRIP="strip "
273 ##### Internal options ####
274 # just for remember that one time we support this :_(
275 # ---------------------------------------------------
276 #if [ "$disable_sendfile" = "on" ]; then
277 # internal_options="-DDISABLE_SENDFILE_SYSCALL"
280 cat > src/Makefile<<EOF
281 CC = $CC
282 DEFS = $mod_defs $internal_options
283 CFLAGS = $CFLAGS \$(DEFS) -g -O2 -Wall
284 INCDIR = ./include
285 LDFLAGS =
286 DESTDIR = ../bin/monkey
287 LIBS = -ldl -lpthread $mod_libs $MORE_LIBS
288 OBJ = monkey.o method.o mimetype.o request.o \\
289 header.o config.o logfile.o signals.o \\
290 user.o utils.o chars.o epoll.o scheduler.o \\
291 str.o memory.o connection.o iov.o http.o \\
292 file.o socket.o clock.o cache.o worker.o \\
293 server.o plugin.o \\
294 $add_obj_mod
296 all: ../bin/monkey
298 ../bin/monkey: \$(OBJ)
299 @echo "Compiling Monkey"
300 @echo "================"
301 \$(CC) \$(CFLAGS) \$(LIBS) \$(LDFLAGS) -o \$@ \$(OBJ) $mod_obj
302 $STRIP ../bin/monkey
303 @echo
304 @echo "Compiling Plugins"
305 @echo "================="
306 @(cd ../plugins && make all && cd ..)
308 clean:
309 rm -rf *.o
310 rm -rf ../bin/monkey
312 distclean:
313 rm -rf *.o ../bin/* Makefile \\
314 ../Makefile ../conf/monkey.conf \\
315 ../conf/sites/* include/info.h ../logs/*\\
316 @(cd extras && ./cleanmods.sh && cd ..)
318 .c.o:
319 \$(CC) -c \$(CFLAGS) -I\$(INCDIR) \$<
323 create_makefile_plugins()
325 cd plugins
326 list=`echo */ "" | sed "s/\/ /\n/g"`
327 cat > Makefile <<EOF
328 all:
330 dir=`pwd`
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" >> $plugins_load
336 echo "" >> $plugins_load
338 for i in $list;
340 echo " @(cd $i && make && cd ..)" >> Makefile;
341 echo "#LoadPlugin $dir/$i/monkey-$i.so" >> ../conf/plugins.load;
342 done
345 # Creando include/info.h
346 create_info()
348 cat > $INCDIR/info.h <<EOF
349 #define OS "$SYSNAME"
350 #define VERSION "$VERSION" /* Version de Monkey */
351 #define MONKEY_PATH_CONF "$sysconfdir"
355 create_conf()
357 cat > $INCDIR/config.path <<EOF
358 #!/bin/sh
359 prefix=$prefix
360 bindir=$bindir
361 cgibin=$cgibin
362 sysconfdir=$sysconfdir
363 datadir=$datadir
364 logdir=$logdir
368 create_banana_script()
370 cat > bin/banana << EOF
371 #!/bin/sh
373 # Monkey HTTP Daemon - Banana Script
374 # -----------------------------------
375 # This script allow you to control monkey. Written by Eduardo Silva
376 # ----------------------------
377 # Date : 2002/09/01.
378 # ----------------------------
380 # Use: ./banana OPTION
382 # Options available to banana:
384 # start -> start monkey
385 # restart -> restart monkey
386 # stop -> stop monkey if this is running
387 # help -> what do u think ?
389 PIDFILE="$logdir/monkey.pid"
390 BINMONKEY="$bindir/monkey"
392 for arg in \$*; do
393 case "\$arg" in
394 -*=*) optarg=\`echo "\$arg" | sed 's/[-_a-zA-Z0-9]*=//'\` ;;
395 *) optarg= ;;
396 esac
398 if ! test -f \$PIDFILE ; then
399 STATUS="no"
400 else
401 PIDMONKEY=\`cat \$PIDFILE\`
402 if ! kill -0 \$PIDMONKEY 2>/dev/null; then
403 STATUS="no"
404 else
405 STATUS="yes"
409 case "\$arg" in
410 start)
411 if [ "\$STATUS" = "yes" ] ; then
412 echo "Monkey is running... (PID=\$PIDMONKEY)"
413 exit 1
415 if ! test -x \$BINMONKEY ; then
416 echo "Error: I can't run binary file"
417 exit 1
418 else
419 if \$BINMONKEY -D 2>/dev/null ; then
420 echo "Running Monkey -> OK"
421 exit 0
425 stop)
426 if [ "\$STATUS" = "no" ]; then
427 echo "Monkey is not running."
428 exit 1
430 kill -9 \$PIDMONKEY
431 rm -rf \$PIDFILE > /dev/null
432 echo "Monkey stopped (\$PIDMONKEY)"
433 exit 0
435 restart)
436 if [ "\$STATUS" = "yes" ]; then
437 if ! kill \$PIDMONKEY > /dev/null ; then
438 killall -9 monkey
439 else
440 echo -n "Stopping Monkey... "
442 else
443 echo -n "Monkey is not running... "
445 if ! test -x \$BINMONKEY ; then
446 echo "Error: I can't run binary file"
447 exit 1
448 else
449 \$BINMONKEY -D > /dev/null
450 echo "Restarting -> OK"
451 exit 0
455 echo "Use : banana [start|stop|restart|help]"
456 exit 1
458 esac
459 done
460 echo "Use : banana [start|stop|restart|help]"
462 exit 0
464 chmod 755 bin/banana
467 #---------------------------#
468 # End Functions
469 #---------------------------#
472 #---------------------------#
473 # Starting configure
474 #---------------------------#
475 aux=`pwd`
477 prefix="$aux"
478 bindir="$aux/bin"
479 cgibin="$aux/cgi-bin"
480 sysconfdir="$aux/conf"
481 datadir="$aux/htdocs"
482 logdir="$aux/logs"
484 for arg in $*; do
485 case "$arg" in
486 -*=*)
487 optarg=`echo "$arg" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
488 *) optarg= ;;
489 esac
491 case "$arg" in
492 --prefix*)
493 prefix=$optarg
494 bindir="$optarg/bin"
495 cgibin="$optarg/cgi-bin"
496 sysconfdir="$optarg/conf"
497 datadir="$optarg/htdocs"
498 logdir="$optarg/logs"
500 --bindir*)
501 bindir=$optarg
503 --cgibin*)
504 cgibin=$optarg
506 --sysconfdir*)
507 sysconfdir=$optarg
509 --datadir*)
510 datadir=$optarg
512 --logdir*)
513 logdir=$optarg
515 --lang*)
516 lang=$optarg
518 --load-mod_mysql*)
519 modules="on"
520 mod_mysql="on"
522 --with-cheetah-shell*)
523 cheetah="on"
525 --version*)
526 echo "Monkey HTTP Daemon v$VERSION"
527 echo "-------------------------"
528 echo "Copyright 2001-2010"
529 echo "Developed by Eduardo Silva Pereira"
530 echo "Monkey Home : http://www.monkey-project.com"
531 echo "Contact Email : edsiper@gmail.com"
532 echo
533 exit 1
536 echo "Usage: configure [--prefix=PREFIXDIR] [--lang=LANGUAGE] [ --bindir=BINDIR]"
537 echo " [--cgibin=CGIBINDIR] [--sysconfdir=SYSCONFDIR]"
538 echo " [--datadir=DATADIR] [--logdir=LOGDIR]"
539 echo
540 echo "Options : "
541 echo " --help Display this help and exit"
542 echo " --version Display version information and exit"
543 echo
544 echo " --prefix=PREFIX Install Monkey under PREFIX directory"
545 echo " --bindir=BINDIR Install Monkey binaries under BINDIR directory"
546 echo " --cgibin=CGIBINDIR Install Monkey cgi-bin under CGIBIN directory"
547 echo " --sysconfdir=SYSCONFDIR Install Monkey conf files under SYSCONFDIR dir"
548 echo " --datadir=DATADIR Install Monkey data dir files under DATADIR directory"
549 echo " --logdir=LOGDIR Install Monkey log files under LOGDIR directory"
550 echo " --lang=[en] Language to configuration files (default English)"
551 echo
552 exit 1
554 esac
555 done
557 echo "********************************************"
558 echo " Monkey HTTP Daemon v$VERSION "
559 echo "* http://www.monkey-project.com *"
560 echo "* ---------------------------------------- *"
561 echo "* We need beta testers, developers and *"
562 echo "* translators!, if u want help to this *"
563 echo "* project, email me : *"
564 echo "* *"
565 echo "* edsiper@gmail.com *"
566 echo "* *"
567 echo "* Thanks for use Monkey!!! *"
568 echo "* *"
569 echo "********************************************"
570 echo "System : $SYSINFO"
572 lang="en"
574 # starting main function
575 main prefix lang bindir cgibin sysconfdir datadir logdir modules SYSNAME VERSION
576 exit 0