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
10 CONFIGPARAM="--with-layout=BinaryDistribution --enable-module=most --enable-shared=max"
12 APDIR=`basename $APDIR`
13 VER=`echo $APDIR |sed s/apache_//`
14 OS=`src/helpers/GuessOS`
15 TAR="`src/helpers/PrintPath tar`"
16 GTAR="`src/helpers/PrintPath gtar`"
17 GZIP="`src/helpers/PrintPath gzip`"
23 USER="`src/helpers/buildinfo.sh -n %u@%h%d`"
26 if [ ! -f ./ABOUT_APACHE ]
28 echo "ERROR: The current directory contains no valid Apache distribution."
29 echo "Please change the directory to the top level directory of a freshly"
30 echo "unpacked Apache 1.3 source distribution and re-execute the script"
31 echo "'./src/helpers/bindbuild.sh'."
37 echo "ERROR: The current directory is a CVS checkout of Apache."
38 echo "Only a standard Apache 1.3 source distribution should be used to"
39 echo "create a binary distribution."
43 echo "Building Apache $VER binary distribution..."
44 echo "Platform is \"$OS\"..."
46 ( echo "Build log for Apache binary distribution" && \
47 echo "----------------------------------------------------------------------" && \
48 ./configure $CONFIGPARAM && \
49 echo "----------------------------------------------------------------------" && \
51 rm -rf bindist install-bindist.sh *.bindist
52 echo "----------------------------------------------------------------------" && \
54 echo "----------------------------------------------------------------------" && \
55 make install-quiet root="bindist/" && \
56 echo "----------------------------------------------------------------------" && \
58 echo "----------------------------------------------------------------------" && \
62 if [ ! -f ./bindist/bin/httpd ]
64 echo "ERROR: Failed to build Apache. See \"build.log\" for details."
68 echo "Binary image successfully created..."
70 ./bindist/bin/httpd -v
72 echo "Creating supplementary files..."
75 echo "Apache $VER binary distribution" && \
76 echo "================================" && \
78 echo "This binary distribution is usable on a \"$OS\"" && \
79 echo "system and was built by \"$USER\"." && \
81 echo "The distribution contains all standard Apache modules as shared" && \
82 echo "objects. This allows you to enable or disable particular modules" && \
83 echo "with the LoadModule/AddModule directives in the configuration file" && \
84 echo "without the need to re-compile Apache." && \
86 echo "See \"INSTALL.bindist\" on how to install the distribution." && \
88 echo "NOTE: Please do not send support-related mails to the address mentioned" && \
89 echo " above or to any member of the Apache Group! Support questions" && \
90 echo " should be directed to the \"comp.infosystems.www.servers.unix\"" && \
91 echo " or \"comp.infosystems.www.servers.ms-windows\" newsgroup" && \
92 echo " (as appropriate for the platform you use), where some of the" && \
93 echo " Apache team lurk, in the company of many other Apache gurus" && \
94 echo " who should be able to help." && \
95 echo " If you think you found a bug in Apache or have a suggestion please" && \
96 echo " visit the bug report page at http://www.apache.org/bug_report.html" && \
98 echo "----------------------------------------------------------------------" && \
99 ./bindist/bin/httpd -V && \
100 echo "----------------------------------------------------------------------" \
102 cp README.bindist ../apache_$VER-$OS.README
105 echo "Apache $VER binary installation" && \
106 echo "================================" && \
108 echo "To install this binary distribution you have to execute the installation" && \
109 echo "script \"install-bindist.sh\" in the top-level directory of the distribution." && \
111 echo "The script takes the ServerRoot directory into which you want to install" && \
112 echo "Apache as an option. If you ommit the option the default path" && \
113 echo "\"/usr/local/apache\" is used." && \
114 echo "Make sure you have write permissions in the target directory, e.g. switch" && \
115 echo "to user \"root\" before you execute the script." && \
117 echo "See \"README.bindist\" for further details about this distribution." && \
119 echo "Please note that this distribution includes the complete Apache source code." && \
120 echo "Therefore you may compile Apache yourself at any time if you have a compiler" && \
121 echo "installation on your system." && \
122 echo "See \"INSTALL\" for details on how to accomplish this." && \
126 ( echo "#!/bin/sh" && \
128 echo "# Usage: install-bindist.sh [ServerRoot]" && \
129 echo "# This script installs the Apache binary distribution and" && \
130 echo "# was automatically created by binbuild.sh." && \
134 echo " path=\"\"" && \
135 echo " dirs=\`echo \$1 | sed -e 's%/% %g'\`" && \
136 echo " mode=\$2" && \
138 echo " set -- \${dirs}" && \
140 echo " for d in \${dirs}" && \
142 echo " path=\"\${path}/\$d\"" && \
143 echo " if test ! -d \"\${path}\" ; then" && \
144 echo " mkdir \${path}" && \
145 echo " if test \$? -ne 0 ; then" && \
146 echo " echo \"Failed to create directory: \${path}\"" && \
149 echo " chmod \${mode} \${path}" && \
156 echo " from=\$1" && \
158 echo " dmode=\$3" && \
159 echo " fmode=\$4" && \
161 echo " test -d \${to} || lmkdir \${to} \${dmode}" && \
162 echo " (cd \${from} && tar -cf - *) | (cd \${to} && tar -xf -)" && \
164 echo " if test \"X\${fmode}\" != X ; then" && \
165 echo " find \${to} -type f -print | xargs chmod \${fmode}" && \
167 echo " if test \"X\${dmode}\" != X ; then" && \
168 echo " find \${to} -type d -print | xargs chmod \${dmode}" && \
173 echo "## determine path to (optional) Perl interpreter" && \
175 echo "PERL=no-perl5-on-this-system" && \
176 echo "perls='perl5 perl'" && \
177 echo "path=\`echo \$PATH | sed -e 's/:/ /g'\`" && \
179 echo "for dir in \${path} ; do" && \
180 echo " for pperl in \${perls} ; do" && \
181 echo " if test -f \"\${dir}/\${pperl}\" ; then" && \
182 echo " if \`\${dir}/\${pperl} -v | grep 'version 5\.' >/dev/null 2>&1\` ; then" && \
183 echo " PERL=\"\${dir}/\${pperl}\"" && \
190 echo "if [ .\$1 = . ]" && \
192 echo " SR=/usr/local/apache" && \
196 echo "echo \"Installing binary distribution for platform $OS\"" && \
197 echo "echo \"into directory \$SR ...\"" && \
198 echo "lmkdir \$SR 755" && \
199 echo "lmkdir \$SR/proxy 750" && \
200 echo "lmkdir \$SR/logs 750" && \
201 echo "lcopy bindist/man \$SR/man 755 644" && \
202 echo "lcopy bindist/libexec \$SR/libexec 750 644" && \
203 echo "lcopy bindist/include \$SR/include 755 644" && \
204 echo "lcopy bindist/icons \$SR/icons 755 644" && \
205 echo "lcopy bindist/cgi-bin \$SR/cgi-bin 750 750" && \
206 echo "lcopy bindist/bin \$SR/bin 750 750" && \
207 echo "if [ -d \$SR/conf ]" && \
209 echo " echo \"[Preserving existing configuration files.]\"" && \
210 echo " cp bindist/conf/*.default \$SR/conf/" && \
212 echo " lcopy bindist/conf \$SR/conf 750 640" && \
214 echo "if [ -d \$SR/htdocs ]" && \
216 echo " echo \"[Preserving existing htdocs directory.]\"" && \
218 echo " lcopy bindist/htdocs \$SR/htdocs 755 644" && \
221 echo "sed -e \"s;^#!/.*;#!\$PERL;\" -e \"s;\@prefix\@;\$SR;\" -e \"s;\@sbindir\@;\$SR/bin;\" \\" && \
222 echo " -e \"s;\@libexecdir\@;\$SR/libexec;\" -e \"s;\@includedir\@;\$SR/include;\" \\" && \
223 echo " -e \"s;\@sysconfdir\@;\$SR/conf;\" bindist/bin/apxs > \$SR/bin/apxs" && \
224 echo "sed -e \"s;^#!/.*;#!\$PERL;\" bindist/bin/dbmmanage > \$SR/bin/dbmmanage" && \
225 echo "sed -e \"s%/usr/local/apache%\$SR%\" \$SR/conf/httpd.conf.default > \$SR/conf/httpd.conf" && \
226 echo "sed -e \"s%PIDFILE=%PIDFILE=\$SR/%\" -e \"s%HTTPD=%HTTPD=\\\"\$SR/%\" -e \"s%httpd\$%httpd -d \$SR\\\"%\" bindist/bin/apachectl > \$SR/bin/apachectl" && \
228 echo "echo \"Ready.\"" && \
229 echo "echo \" +--------------------------------------------------------+\"" && \
230 echo "echo \" | You now have successfully installed the Apache $VER |\"" && \
231 echo "echo \" | HTTP server. To verify that Apache actually works |\"" && \
232 echo "echo \" | correctly you should first check the (initially |\"" && \
233 echo "echo \" | created or preserved) configuration files: |\"" && \
234 echo "echo \" | |\"" && \
235 echo "echo \" | \$SR/conf/httpd.conf\"" && \
236 echo "echo \" | |\"" && \
237 echo "echo \" | You should then be able to immediately fire up |\"" && \
238 echo "echo \" | Apache the first time by running: |\"" && \
239 echo "echo \" | |\"" && \
240 echo "echo \" | \$SR/bin/apachectl start \"" &&\
241 echo "echo \" | |\"" && \
242 echo "echo \" | Thanks for using Apache. The Apache Group |\"" && \
243 echo "echo \" | http://www.apache.org/ |\"" && \
244 echo "echo \" +--------------------------------------------------------+\"" && \
246 ) > install-bindist.sh
247 chmod 755 install-bindist.sh
249 sed -e "s%\"htdocs%\"/usr/local/apache/htdocs%" \
250 -e "s%\"icons%\"/usr/local/apache/icons%" \
251 -e "s%\"cgi-bin%\"/usr/local/apache/cgi-bin%" \
252 -e "s%\"proxy%\"/usr/local/apache/proxy%" \
253 -e "s%^ServerAdmin.*%ServerAdmin you@your.address%" \
254 -e "s%#ServerName.*%#ServerName localhost%" \
255 -e "s%Port 8080%Port 80%" \
256 bindist/conf/httpd.conf.default > bindist/conf/httpd.conf
257 cp bindist/conf/httpd.conf bindist/conf/httpd.conf.default
259 echo "Creating distribution archive and readme file..."
261 if [ ".`grep -i error build.log > /dev/null`" != . ]
263 echo "ERROR: Failed to build Apache. See \"build.log\" for details."
266 if [ "x$GTAR" != "x" ]
268 $GTAR -zcf ../apache_$VER-$OS.tar.gz -C .. apache_$VER
270 if [ "x$TAR" != "x" ]
272 $TAR -cf ../apache_$VER-$OS.tar -C .. apache_$VER
273 if [ "x$GZIP" != "x" ]
275 $GZIP ../apache_$VER-$OS.tar
278 echo "ERROR: Could not find a 'tar' program!"
279 echo " Please execute the following commands manually:"
280 echo " tar -cf ../apache_$VER-$OS.tar ."
281 echo " gzip ../apache_$VER-$OS.tar"
285 if [ -f ../apache_$VER-$OS.tar.gz ] && [ -f ../apache_$VER-$OS.README ]
288 echo "You can find the binary archive (apache_$VER-$OS.tar.gz)"
289 echo "and the readme file (apache_$VER-$OS.README) in the"
290 echo "parent directory."