3 # binbuild.sh - Builds an Apache binary distribution.
4 # Initially written by Lars Eilebrecht <lars@apache.org>.
6 # This script falls under the Apache License.
7 # See http://www.apache.org/docs/LICENSE
9 OS=`src/helpers/GuessOS`
11 x*390) CONFIGPARAM="--with-layout=BinaryDistribution --enable-module=most --enable-module=log_agent --enable-module=log_referer --enable-module=example --enable-module=mmap_static";;
12 *) CONFIGPARAM="--with-layout=BinaryDistribution --enable-module=most --enable-shared=max";;
15 APDIR=`basename $APDIR`
16 VER=`echo $APDIR |sed s/apache_//`
17 TAR="`src/helpers/PrintPath tar`"
18 GTAR="`src/helpers/PrintPath gtar`"
19 GZIP="`src/helpers/PrintPath gzip`"
25 USER="`src/helpers/buildinfo.sh -n %u@%h%d`"
28 if [ ! -f ./ABOUT_APACHE ]
30 echo "ERROR: The current directory contains no valid Apache distribution."
31 echo "Please change the directory to the top level directory of a freshly"
32 echo "unpacked Apache 1.3 source distribution and re-execute the script"
33 echo "'./src/helpers/bindbuild.sh'."
39 echo "ERROR: The current directory is a CVS checkout of Apache."
40 echo "Only a standard Apache 1.3 source distribution should be used to"
41 echo "create a binary distribution."
45 echo "Building Apache $VER binary distribution..."
46 echo "Platform is \"$OS\"..."
48 ( echo "Build log for Apache binary distribution" && \
49 echo "----------------------------------------------------------------------" && \
50 ./configure $CONFIGPARAM && \
51 echo "----------------------------------------------------------------------" && \
53 rm -rf bindist install-bindist.sh *.bindist
54 echo "----------------------------------------------------------------------" && \
56 echo "----------------------------------------------------------------------" && \
57 make install-quiet root="bindist/" && \
58 echo "----------------------------------------------------------------------" && \
60 echo "----------------------------------------------------------------------" && \
64 if [ ! -f ./bindist/bin/httpd ]
66 echo "ERROR: Failed to build Apache. See \"build.log\" for details."
70 echo "Binary image successfully created..."
72 ./bindist/bin/httpd -v
74 echo "Creating supplementary files..."
77 echo "Apache $VER binary distribution" && \
78 echo "================================" && \
80 echo "This binary distribution is usable on a \"$OS\"" && \
81 echo "system and was built by \"$USER\"." && \
83 echo "The distribution contains all standard Apache modules as shared" && \
84 echo "objects. This allows you to enable or disable particular modules" && \
85 echo "with the LoadModule/AddModule directives in the configuration file" && \
86 echo "without the need to re-compile Apache." && \
88 echo "See \"INSTALL.bindist\" on how to install the distribution." && \
90 echo "NOTE: Please do not send support-related mails to the address mentioned" && \
91 echo " above or to any member of the Apache Group! Support questions" && \
92 echo " should be directed to the \"comp.infosystems.www.servers.unix\"" && \
93 echo " or \"comp.infosystems.www.servers.ms-windows\" newsgroup" && \
94 echo " (as appropriate for the platform you use), where some of the" && \
95 echo " Apache team lurk, in the company of many other Apache gurus" && \
96 echo " who should be able to help." && \
97 echo " If you think you found a bug in Apache or have a suggestion please" && \
98 echo " visit the bug report page at http://www.apache.org/bug_report.html" && \
100 echo "----------------------------------------------------------------------" && \
101 ./bindist/bin/httpd -V && \
102 echo "----------------------------------------------------------------------" \
104 cp README.bindist ../apache_$VER-$OS.README
107 echo "Apache $VER binary installation" && \
108 echo "================================" && \
110 echo "To install this binary distribution you have to execute the installation" && \
111 echo "script \"install-bindist.sh\" in the top-level directory of the distribution." && \
113 echo "The script takes the ServerRoot directory into which you want to install" && \
114 echo "Apache as an option. If you ommit the option the default path" && \
115 echo "\"/usr/local/apache\" is used." && \
116 echo "Make sure you have write permissions in the target directory, e.g. switch" && \
117 echo "to user \"root\" before you execute the script." && \
119 echo "See \"README.bindist\" for further details about this distribution." && \
121 echo "Please note that this distribution includes the complete Apache source code." && \
122 echo "Therefore you may compile Apache yourself at any time if you have a compiler" && \
123 echo "installation on your system." && \
124 echo "See \"INSTALL\" for details on how to accomplish this." && \
128 ( echo "#!/bin/sh" && \
130 echo "# Usage: install-bindist.sh [ServerRoot]" && \
131 echo "# This script installs the Apache binary distribution and" && \
132 echo "# was automatically created by binbuild.sh." && \
136 echo " path=\"\"" && \
137 echo " dirs=\`echo \$1 | sed -e 's%/% %g'\`" && \
138 echo " mode=\$2" && \
140 echo " set -- \${dirs}" && \
142 echo " for d in \${dirs}" && \
144 echo " path=\"\${path}/\$d\"" && \
145 echo " if test ! -d \"\${path}\" ; then" && \
146 echo " mkdir \${path}" && \
147 echo " if test \$? -ne 0 ; then" && \
148 echo " echo \"Failed to create directory: \${path}\"" && \
151 echo " chmod \${mode} \${path}" && \
158 echo " from=\$1" && \
160 echo " dmode=\$3" && \
161 echo " fmode=\$4" && \
163 echo " test -d \${to} || lmkdir \${to} \${dmode}" && \
164 echo " (cd \${from} && tar -cf - *) | (cd \${to} && tar -xf -)" && \
166 echo " if test \"X\${fmode}\" != X ; then" && \
167 echo " find \${to} -type f -print | xargs chmod \${fmode}" && \
169 echo " if test \"X\${dmode}\" != X ; then" && \
170 echo " find \${to} -type d -print | xargs chmod \${dmode}" && \
175 echo "## determine path to (optional) Perl interpreter" && \
177 echo "PERL=no-perl5-on-this-system" && \
178 echo "perls='perl5 perl'" && \
179 echo "path=\`echo \$PATH | sed -e 's/:/ /g'\`" && \
181 echo "for dir in \${path} ; do" && \
182 echo " for pperl in \${perls} ; do" && \
183 echo " if test -f \"\${dir}/\${pperl}\" ; then" && \
184 echo " if \`\${dir}/\${pperl} -v | grep 'version 5\.' >/dev/null 2>&1\` ; then" && \
185 echo " PERL=\"\${dir}/\${pperl}\"" && \
192 echo "if [ .\$1 = . ]" && \
194 echo " SR=/usr/local/apache" && \
198 echo "echo \"Installing binary distribution for platform $OS\"" && \
199 echo "echo \"into directory \$SR ...\"" && \
200 echo "lmkdir \$SR 755" && \
201 echo "lmkdir \$SR/proxy 750" && \
202 echo "lmkdir \$SR/logs 750" && \
203 echo "lcopy bindist/man \$SR/man 755 644" && \
204 echo "lcopy bindist/libexec \$SR/libexec 750 644" && \
205 echo "lcopy bindist/include \$SR/include 755 644" && \
206 echo "lcopy bindist/icons \$SR/icons 755 644" && \
207 echo "lcopy bindist/cgi-bin \$SR/cgi-bin 750 750" && \
208 echo "lcopy bindist/bin \$SR/bin 750 750" && \
209 echo "if [ -d \$SR/conf ]" && \
211 echo " echo \"[Preserving existing configuration files.]\"" && \
212 echo " cp bindist/conf/*.default \$SR/conf/" && \
214 echo " lcopy bindist/conf \$SR/conf 750 640" && \
216 echo "if [ -d \$SR/htdocs ]" && \
218 echo " echo \"[Preserving existing htdocs directory.]\"" && \
220 echo " lcopy bindist/htdocs \$SR/htdocs 755 644" && \
223 echo "sed -e \"s;^#!/.*;#!\$PERL;\" -e \"s;\@prefix\@;\$SR;\" -e \"s;\@sbindir\@;\$SR/bin;\" \\" && \
224 echo " -e \"s;\@libexecdir\@;\$SR/libexec;\" -e \"s;\@includedir\@;\$SR/include;\" \\" && \
225 echo " -e \"s;\@sysconfdir\@;\$SR/conf;\" bindist/bin/apxs > \$SR/bin/apxs" && \
226 echo "sed -e \"s;^#!/.*;#!\$PERL;\" bindist/bin/dbmmanage > \$SR/bin/dbmmanage" && \
227 echo "sed -e \"s%/usr/local/apache%\$SR%\" \$SR/conf/httpd.conf.default > \$SR/conf/httpd.conf" && \
228 echo "sed -e \"s%PIDFILE=%PIDFILE=\$SR/%\" -e \"s%HTTPD=%HTTPD=\\\"\$SR/%\" -e \"s%httpd\$%httpd -d \$SR -R \$SR/libexec\\\"%\" bindist/bin/apachectl > \$SR/bin/apachectl" && \
230 echo "echo \"Ready.\"" && \
231 echo "echo \" +--------------------------------------------------------+\"" && \
232 echo "echo \" | You now have successfully installed the Apache $VER |\"" && \
233 echo "echo \" | HTTP server. To verify that Apache actually works |\"" && \
234 echo "echo \" | correctly you should first check the (initially |\"" && \
235 echo "echo \" | created or preserved) configuration files: |\"" && \
236 echo "echo \" | |\"" && \
237 echo "echo \" | \$SR/conf/httpd.conf\"" && \
238 echo "echo \" | |\"" && \
239 echo "echo \" | You should then be able to immediately fire up |\"" && \
240 echo "echo \" | Apache the first time by running: |\"" && \
241 echo "echo \" | |\"" && \
242 echo "echo \" | \$SR/bin/apachectl start \"" &&\
243 echo "echo \" | |\"" && \
244 echo "echo \" | Thanks for using Apache. The Apache Group |\"" && \
245 echo "echo \" | http://www.apache.org/ |\"" && \
246 echo "echo \" +--------------------------------------------------------+\"" && \
248 ) > install-bindist.sh
249 chmod 755 install-bindist.sh
251 sed -e "s%\"htdocs%\"/usr/local/apache/htdocs%" \
252 -e "s%\"icons%\"/usr/local/apache/icons%" \
253 -e "s%\"cgi-bin%\"/usr/local/apache/cgi-bin%" \
254 -e "s%\"proxy%\"/usr/local/apache/proxy%" \
255 -e "s%^ServerAdmin.*%ServerAdmin you@your.address%" \
256 -e "s%#ServerName.*%#ServerName localhost%" \
257 -e "s%Port 8080%Port 80%" \
258 bindist/conf/httpd.conf.default > bindist/conf/httpd.conf
259 cp bindist/conf/httpd.conf bindist/conf/httpd.conf.default
261 echo "Creating distribution archive and readme file..."
263 if [ ".`grep -i error build.log > /dev/null`" != . ]
265 echo "ERROR: Failed to build Apache. See \"build.log\" for details."
268 if [ "x$GTAR" != "x" ]
270 $GTAR -zcf ../apache_$VER-$OS.tar.gz -C .. apache_$VER
272 if [ "x$TAR" != "x" ]
275 x*390) $TAR -cfU ../apache_$VER-$OS.tar -C .. apache_$VER;;
276 *) $TAR -cf ../apache_$VER-$OS.tar -C .. apache_$VER;;
278 if [ "x$GZIP" != "x" ]
280 $GZIP ../apache_$VER-$OS.tar
283 echo "ERROR: Could not find a 'tar' program!"
284 echo " Please execute the following commands manually:"
285 echo " tar -cf ../apache_$VER-$OS.tar ."
286 echo " gzip ../apache_$VER-$OS.tar"
290 if [ -f ../apache_$VER-$OS.tar.gz ] && [ -f ../apache_$VER-$OS.README ]
293 echo "You can find the binary archive (apache_$VER-$OS.tar.gz)"
294 echo "and the readme file (apache_$VER-$OS.README) in the"
295 echo "parent directory."