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=`./srclib/apr/build/config.guess`
10 CONFIGPARAM="--with-layout=BinaryDistribution --prefix=`pwd`/bindist"
12 APDIR=`basename $APDIR`
13 VER=`echo $APDIR |sed s/httpd-//`
14 TAR="`srclib/apr/build/PrintPath tar`"
15 GTAR="`srclib/apr/build/PrintPath gtar`"
16 GZIP="`srclib/apr/build/PrintPath gzip`"
21 USER="`build/buildinfo.sh -n %u@%h%d`"
24 if [ ! -f ./ABOUT_APACHE ]
26 echo "ERROR: The current directory contains no valid Apache distribution."
27 echo "Please change the directory to the top level directory of a freshly"
28 echo "unpacked Apache 2.0 source distribution and re-execute the script"
29 echo "'./build/bindbuild.sh'."
35 echo "ERROR: The current directory is a CVS checkout of Apache."
36 echo "Only a standard Apache 2.0 source distribution should be used to"
37 echo "create a binary distribution."
41 echo "Building Apache $VER binary distribution..."
42 echo "Platform is \"$OS\"..."
44 ( echo "Build log for Apache binary distribution" && \
45 echo "----------------------------------------------------------------------" && \
46 ./configure $CONFIGPARAM && \
47 echo "----------------------------------------------------------------------" && \
49 rm -rf bindist install-bindist.sh *.bindist
50 echo "----------------------------------------------------------------------" && \
52 echo "----------------------------------------------------------------------" && \
53 make install root="bindist/" && \
54 echo "----------------------------------------------------------------------" && \
56 echo "----------------------------------------------------------------------" && \
58 ) 2>&1 | tee build.log
60 if [ ! -f ./bindist/bin/httpd ]
62 echo "ERROR: Failed to build Apache. See \"build.log\" for details."
66 echo "Binary image successfully created..."
68 ./bindist/bin/httpd -v
70 echo "Creating supplementary files..."
73 echo "Apache $VER binary distribution" && \
74 echo "================================" && \
76 echo "This binary distribution is usable on a \"$OS\"" && \
77 echo "system and was built by \"$USER\"." && \
79 echo "The distribution contains all standard Apache modules as shared" && \
80 echo "objects. This allows you to enable or disable particular modules" && \
81 echo "with the LoadModule/AddModule directives in the configuration file" && \
82 echo "without the need to re-compile Apache." && \
84 echo "See \"INSTALL.bindist\" on how to install the distribution." && \
86 echo "NOTE: Please do not send support-related mails to the address mentioned" && \
87 echo " above or to any member of the Apache Group! Support questions" && \
88 echo " should be directed to the \"comp.infosystems.www.servers.unix\"" && \
89 echo " or \"comp.infosystems.www.servers.ms-windows\" newsgroup" && \
90 echo " (as appropriate for the platform you use), where some of the" && \
91 echo " Apache team lurk, in the company of many other Apache gurus" && \
92 echo " who should be able to help." && \
93 echo " If you think you found a bug in Apache or have a suggestion please" && \
94 echo " visit the bug report page at http://www.apache.org/bug_report.html" && \
96 echo "----------------------------------------------------------------------" && \
97 ./bindist/bin/httpd -V && \
98 echo "----------------------------------------------------------------------" \
100 cp README.bindist ../httpd-$VER-$OS.README
103 echo "Apache $VER binary installation" && \
104 echo "================================" && \
106 echo "To install this binary distribution you have to execute the installation" && \
107 echo "script \"install-bindist.sh\" in the top-level directory of the distribution." && \
109 echo "The script takes the ServerRoot directory into which you want to install" && \
110 echo "Apache as an option. If you ommit the option the default path" && \
111 echo "\"/usr/local/apache\" is used." && \
112 echo "Make sure you have write permissions in the target directory, e.g. switch" && \
113 echo "to user \"root\" before you execute the script." && \
115 echo "See \"README.bindist\" for further details about this distribution." && \
117 echo "Please note that this distribution includes the complete Apache source code." && \
118 echo "Therefore you may compile Apache yourself at any time if you have a compiler" && \
119 echo "installation on your system." && \
120 echo "See \"INSTALL\" for details on how to accomplish this." && \
124 ( echo "#!/bin/sh" && \
126 echo "# Usage: install-bindist.sh [ServerRoot]" && \
127 echo "# This script installs the Apache binary distribution and" && \
128 echo "# was automatically created by binbuild.sh." && \
132 echo " path=\"\"" && \
133 echo " dirs=\`echo \$1 | sed -e 's%/% %g'\`" && \
134 echo " mode=\$2" && \
136 echo " set -- \${dirs}" && \
138 echo " for d in \${dirs}" && \
140 echo " path=\"\${path}/\$d\"" && \
141 echo " if test ! -d \"\${path}\" ; then" && \
142 echo " mkdir \${path}" && \
143 echo " if test \$? -ne 0 ; then" && \
144 echo " echo \"Failed to create directory: \${path}\"" && \
147 echo " chmod \${mode} \${path}" && \
154 echo " from=\$1" && \
156 echo " dmode=\$3" && \
157 echo " fmode=\$4" && \
159 echo " test -d \${to} || lmkdir \${to} \${dmode}" && \
160 echo " (cd \${from} && tar -cf - *) | (cd \${to} && tar -xf -)" && \
162 echo " if test \"X\${fmode}\" != X ; then" && \
163 echo " find \${to} -type f -print | xargs chmod \${fmode}" && \
165 echo " if test \"X\${dmode}\" != X ; then" && \
166 echo " find \${to} -type d -print | xargs chmod \${dmode}" && \
171 echo "## determine path to (optional) Perl interpreter" && \
173 echo "PERL=no-perl5-on-this-system" && \
174 echo "perls='perl5 perl'" && \
175 echo "path=\`echo \$PATH | sed -e 's/:/ /g'\`" && \
177 echo "for dir in \${path} ; do" && \
178 echo " for pperl in \${perls} ; do" && \
179 echo " if test -f \"\${dir}/\${pperl}\" ; then" && \
180 echo " if \`\${dir}/\${pperl} -v | grep 'version 5\.' >/dev/null 2>&1\` ; then" && \
181 echo " PERL=\"\${dir}/\${pperl}\"" && \
188 echo "if [ .\$1 = . ]" && \
190 echo " SR=/usr/local/apache" && \
194 echo "echo \"Installing binary distribution for platform $OS\"" && \
195 echo "echo \"into directory \$SR ...\"" && \
196 echo "lmkdir \$SR 755" && \
197 echo "lmkdir \$SR/proxy 750" && \
198 echo "lmkdir \$SR/logs 750" && \
199 echo "lcopy bindist/man \$SR/man 755 644" && \
200 echo "if [ -d bindist/modules ]" && \
202 echo " lcopy bindist/modules \$SR/modules 750 750" && \
204 echo "lcopy bindist/include \$SR/include 755 644" && \
205 echo "lcopy bindist/icons \$SR/icons 755 644" && \
206 echo "lcopy bindist/cgi-bin \$SR/cgi-bin 750 750" && \
207 echo "lcopy bindist/bin \$SR/bin 750 750" && \
208 echo "if [ -d \$SR/conf ]" && \
210 echo " echo \"[Preserving existing configuration files.]\"" && \
211 echo " cp bindist/conf/*.default \$SR/conf/" && \
213 echo " lcopy bindist/conf \$SR/conf 750 640" && \
215 echo "if [ -d \$SR/htdocs ]" && \
217 echo " echo \"[Preserving existing htdocs directory.]\"" && \
219 echo " lcopy bindist/htdocs \$SR/htdocs 755 644" && \
221 echo "if [ -d \$SR/error ]" && \
223 echo " echo \"[Preserving existing error documents directory.]\"" && \
225 echo " lcopy bindist/error \$SR/error 755 644" && \
228 echo "sed -e \"s;^#!/.*;#!\$PERL;\" -e \"s;\@prefix\@;\$SR;\" -e \"s;\@sbindir\@;\$SR/bin;\" \\" && \
229 echo " -e \"s;\@libexecdir\@;\$SR/libexec;\" -e \"s;\@includedir\@;\$SR/include;\" \\" && \
230 echo " -e \"s;\@sysconfdir\@;\$SR/conf;\" bindist/bin/apxs > \$SR/bin/apxs" && \
231 echo "sed -e \"s;^#!/.*;#!\$PERL;\" bindist/bin/dbmmanage > \$SR/bin/dbmmanage" && \
232 echo "sed -e \"s%/usr/local/apache%\$SR%\" \$SR/conf/httpd-std.conf > \$SR/conf/httpd.conf" && \
233 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" && \
235 echo "echo \"Ready.\"" && \
236 echo "echo \" +--------------------------------------------------------+\"" && \
237 echo "echo \" | You now have successfully installed the Apache $VER |\"" && \
238 echo "echo \" | HTTP server. To verify that Apache actually works |\"" && \
239 echo "echo \" | correctly you should first check the (initially |\"" && \
240 echo "echo \" | created or preserved) configuration files: |\"" && \
241 echo "echo \" | |\"" && \
242 echo "echo \" | \$SR/conf/httpd.conf\"" && \
243 echo "echo \" | |\"" && \
244 echo "echo \" | You should then be able to immediately fire up |\"" && \
245 echo "echo \" | Apache the first time by running: |\"" && \
246 echo "echo \" | |\"" && \
247 echo "echo \" | \$SR/bin/apachectl start \"" &&\
248 echo "echo \" | |\"" && \
249 echo "echo \" | Thanks for using Apache. The Apache Group |\"" && \
250 echo "echo \" | http://www.apache.org/ |\"" && \
251 echo "echo \" +--------------------------------------------------------+\"" && \
253 ) > install-bindist.sh
254 chmod 755 install-bindist.sh
256 sed -e "s%\"htdocs%\"/usr/local/apache/htdocs%" \
257 -e "s%\"icons%\"/usr/local/apache/icons%" \
258 -e "s%\"cgi-bin%\"/usr/local/apache/cgi-bin%" \
259 -e "s%\"proxy%\"/usr/local/apache/proxy%" \
260 -e "s%^ServerAdmin.*%ServerAdmin you@your.address%" \
261 -e "s%#ServerName.*%#ServerName localhost%" \
262 -e "s%Port 8080%Port 80%" \
263 bindist/conf/httpd-std.conf > bindist/conf/httpd.conf
264 cp bindist/conf/httpd.conf bindist/conf/httpd.conf.default
266 echo "Creating distribution archive and readme file..."
268 if [ ".`grep -i error build.log > /dev/null`" != . ]
270 echo "ERROR: Failed to build Apache. See \"build.log\" for details."
273 if [ "x$GTAR" != "x" ]
275 $GTAR -zcf ../httpd-$VER-$OS.tar.gz -C .. httpd-$VER
277 if [ "x$TAR" != "x" ]
280 x*390*) $TAR -cfU ../httpd-$VER-$OS.tar -C .. httpd-$VER;;
281 *) (cd .. && $TAR -cf httpd-$VER-$OS.tar httpd-$VER);;
283 if [ "x$GZIP" != "x" ]
285 $GZIP ../httpd-$VER-$OS.tar
288 echo "ERROR: Could not find a 'tar' program!"
289 echo " Please execute the following commands manually:"
290 echo " tar -cf ../httpd-$VER-$OS.tar ."
291 echo " gzip ../httpd-$VER-$OS.tar"
295 if [ -f ../httpd-$VER-$OS.tar.gz ] && [ -f ../httpd-$VER-$OS.README ]
298 echo "You can find the binary archive (httpd-$VER-$OS.tar.gz)"
299 echo "and the readme file (httpd-$VER-$OS.README) in the"
300 echo "parent directory."