今天在linux下開發php擴展,發現修改源代碼從新編譯安裝後,.so文件仍是原來的,並無更新。最後清理了全部編譯後產生的文件,從新編譯安裝才更新了.so文件。估計是編譯後產生了緩存,爲了方便清理,能夠在ext_skel文件後面加入下面代碼。php
$ECHO_N " remake$ECHO_C" cat >remake <<eof #!/bin/sh keepfiles="php_${extname}.h ${extname}.c ${extname}.php config.m4 config.w32 CREDITS EXPERIMENTAL remake" allfiles=\$(ls .) for f in \$allfiles do echo "\$keepfiles" | grep -q "\$f" if [ \$? -ne 0 ] then rm -rf \$f fi done #phpize路徑 /usr/local/webserver/php/bin/phpize #php-config路徑 ./configure --with-php-config=/usr/local/webserver/php/bin/php-config #編譯 make eof chmod 755 ./remake
測試運行linux
在擴展目錄裏新生成了remake文件,remake源碼以下:nginx
#!/bin/sh keepfiles="php_abc.h abc.c abc.php config.m4 config.w32 CREDITS EXPERIMENTAL remake" allfiles=$(ls .) for f in $allfiles do echo "$keepfiles" | grep -q "$f" if [ $? -ne 0 ] then rm -rf $f fi done /www/wdlinux/nginx_php-5.3.17/bin/phpize ./configure --with-php-config=/www/wdlinux/nginx_php-5.3.17/bin/php-config make
之後從新編譯擴展的時候用 ./remake 替代make命令編譯便可。web
若是您要轉載此文章請註明出處:http://my.oschina.net/u/554660/blog/169006 shell