$ tar xvf apache1_3_34.tbz
$ cd apache
$ ./configure --prefix=/home/fcwu/apache/working --enable-module=rewrite --enable-module=proxy
$ cat replace_cflags.sh
1 #!/bin/bash
2
3 TMP=`mktemp`
4 REPLACE="-pg -DGPROF -g -DNO_USE_SIGACTION -fno-stack-protector -fno-stack-protector-all"
5 #REPLACE="-pg -DGPROF -g -DNO_USE_SIGACTION -fno-stack-protector"
6 #REPLACE="-pg -DGPROF -g -DNO_USE_SIGACTION "
7
8 for file in `find src/ -name "Makefile"` ; do
9 echo "[Replace file=$file]"
10 grep -nH "^CFLAGS=" $file
11 sed "s/^CFLAGS=/& $REPLACE /" $file > $TMP
12 cp $TMP $file
13 grep -nH "^CFLAGS=" $file
14 done
15
16 rm -f $TMP
$ ./replace_cflags
$ make
$ cd src
$ gcc -static -pg -g -DLINUX=22 -DHAVE_SET_DUMPABLE -DNO_DBM_REWRITEMAP -DUSE_HSREGEX -g -pg `./apaci` -rdynamic -o httpd buildmark.o modules.o modules/standard/mod_env.o modules/standard/mod_log_config.o modules/standard/mod_mime.o modules/standard/mod_negotiation.o modules/standard/mod_status.o modules/standard/mod_include.o modules/standard/mod_autoindex.o modules/standard/mod_dir.o modules/standard/mod_cgi.o modules/standard/mod_asis.o modules/standard/mod_imap.o modules/standard/mod_actions.o modules/standard/mod_userdir.o modules/standard/mod_alias.o modules/standard/mod_access.o modules/standard/mod_auth.o modules/standard/mod_setenvif.o main/alloc.o main/buff.o main/http_config.o main/http_core.o main/http_log.o main/http_main.o main/http_protocol.o main/http_request.o main/http_vhost.o main/util.o main/util_date.o main/util_script.o main/util_uri.o main/util_md5.o main/rfc1413.o os/unix/os.o os/unix/os-inline.o ap/ap_cpystrn.o ap/ap_execve.o ap/ap_fnmatch.o ap/ap_getpass.o ap/ap_md5c.o ap/ap_signal.o ap/ap_slack.o ap/ap_snprintf.o ap/ap_sha1.o ap/ap_checkpass.o ap/ap_base64.o ap/ap_ebcdic.o ap/ap_strtol.o regex/regcomp.o regex/regexec.o regex/regerror.o regex/regfree.o \
modules/proxy/proxy_cache.o modules/proxy/proxy_connect.o modules/proxy/proxy_ftp.o modules/proxy/proxy_http.o modules/proxy/proxy_util.o modules/proxy/mod_proxy.o \
modules/standard/mod_rewrite.o \
-lm -lcrypt -lexpat -ldl -fno-stack-protector
$ make install
$ cd ~/apache/working/bin/
$ ./httpd -X -f /home/fcwu/apache/working/conf/httpd.conf
testing it
$ gprof ./httpd ../logs/gmon.out
其中有個重點是在編譯apache時,要用幾個特別的define值:"-DGPROF -DNO_USE_SIGACTION"。而為了讓gprof能work要加-pg的編譯參數,再為了讓時間的結果跑出來,必需用static的方式把所有的library以靜態的方式將所有想profile的部分編入(這就是我gcc很長長長的那一行)。
另外有些小技巧像是find的使用,我在測時intensively使用,像是:
find ~ -name "gmon.out" -exec ls -al {} \;
find ~ -name "gmon.out" -exec rm -i {} \;
No comments:
Post a Comment