]> granicus.if.org Git - apache/blob - build/binbuild.sh
Remove a trailing slash from library.mk. This slash was causing problems
[apache] / build / binbuild.sh
1 #!/bin/sh
2 #
3 # binbuild.sh - Builds an Apache binary distribution.
4 # Initially written by Lars Eilebrecht <lars@apache.org>.
5 #
6 # This script falls under the Apache License.
7 # See http://www.apache.org/docs/LICENSE
8
9 OS=`src/helpers/GuessOS`
10 case "x$OS" in
11   x*390*) CONFIGPARAM="--with-layout=BinaryDistribution --enable-module=most";;
12       *) CONFIGPARAM="--with-layout=BinaryDistribution --enable-module=most --enable-shared=max";;
13 esac
14 APDIR=`pwd`
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`"
20
21 if [ x$1 != x ]
22 then
23   USER=$1
24 else
25   USER="`src/helpers/buildinfo.sh -n %u@%h%d`"
26 fi
27
28 if [ ! -f ./ABOUT_APACHE ]
29 then
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'." 
34   exit 1;
35 fi
36
37 if [ -d ./CVS ]
38 then
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."
42   exit 1;
43 fi
44
45 echo "Building Apache $VER binary distribution..."
46 echo "Platform is \"$OS\"..."
47
48 ( echo "Build log for Apache binary distribution" && \
49   echo "----------------------------------------------------------------------" && \
50   ./configure $CONFIGPARAM && \
51   echo "----------------------------------------------------------------------" && \
52   make clean && \
53   rm -rf bindist install-bindist.sh *.bindist
54   echo "----------------------------------------------------------------------" && \
55   make && \
56   echo "----------------------------------------------------------------------" && \
57   make install-quiet root="bindist/" && \
58   echo "----------------------------------------------------------------------" && \
59   make clean && \
60   echo "----------------------------------------------------------------------" && \
61   echo "[EOF]" \
62 ) > build.log 2>&1
63
64 if [ ! -f ./bindist/bin/httpd ]
65 then
66   echo "ERROR: Failed to build Apache. See \"build.log\" for details."
67   exit 1;
68 fi
69
70 echo "Binary image successfully created..."
71
72 ./bindist/bin/httpd -v
73
74 echo "Creating supplementary files..."
75
76 ( echo " " && \
77   echo "Apache $VER binary distribution" && \
78   echo "================================" && \
79   echo " " && \
80   echo "This binary distribution is usable on a \"$OS\"" && \
81   echo "system and was built by \"$USER\"." && \
82   echo "" && \
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." && \
87   echo "" && \
88   echo "See \"INSTALL.bindist\" on how to install the distribution." && \
89   echo " " && \
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" && \
99   echo " " && \
100   echo "----------------------------------------------------------------------" && \
101   ./bindist/bin/httpd -V && \
102   echo "----------------------------------------------------------------------" \
103 ) > README.bindist
104 cp README.bindist ../apache_$VER-$OS.README
105
106 ( echo " " && \
107   echo "Apache $VER binary installation" && \
108   echo "================================" && \
109   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." && \
112   echo " " && \
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." && \
118   echo " " && \
119   echo "See \"README.bindist\" for further details about this distribution." && \
120   echo " " && \
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." && \
125   echo " " \
126 ) > INSTALL.bindist
127
128 ( echo "#!/bin/sh" && \
129   echo "#" && \
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." && \
133   echo " " && \
134   echo "lmkdir()" && \
135   echo "{" && \
136   echo "  path=\"\"" && \
137   echo "  dirs=\`echo \$1 | sed -e 's%/% %g'\`" && \
138   echo "  mode=\$2" && \
139   echo " " && \
140   echo "  set -- \${dirs}" && \
141   echo " " && \
142   echo "  for d in \${dirs}" && \
143   echo "  do" && \
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}\"" && \
149   echo "        exit 1" && \
150   echo "      fi" && \
151   echo "      chmod \${mode} \${path}" && \
152   echo "    fi" && \
153   echo "  done" && \
154   echo "}" && \
155   echo " " && \
156   echo "lcopy()" && \
157   echo "{" && \
158   echo "  from=\$1" && \
159   echo "  to=\$2" && \
160   echo "  dmode=\$3" && \
161   echo "  fmode=\$4" && \
162   echo " " && \
163   echo "  test -d \${to} || lmkdir \${to} \${dmode}" && \
164   echo "  (cd \${from} && tar -cf - *) | (cd \${to} && tar -xf -)" && \
165   echo " " && \
166   echo "  if test \"X\${fmode}\" != X ; then" && \
167   echo "    find \${to} -type f -print | xargs chmod \${fmode}" && \
168   echo "  fi" && \
169   echo "  if test \"X\${dmode}\" != X ; then" && \
170   echo "    find \${to} -type d -print | xargs chmod \${dmode}" && \
171   echo "  fi" && \
172   echo "}" && \
173   echo " " && \
174   echo "##" && \
175   echo "##  determine path to (optional) Perl interpreter" && \
176   echo "##" && \
177   echo "PERL=no-perl5-on-this-system" && \
178   echo "perls='perl5 perl'" && \
179   echo "path=\`echo \$PATH | sed -e 's/:/ /g'\`" && \
180   echo " " && \
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}\"" && \
186   echo "        break" && \
187   echo "      fi" && \
188   echo "    fi" && \
189   echo "  done" && \
190   echo "done" && \
191   echo " " && \
192   echo "if [ .\$1 = . ]" && \
193   echo "then" && \
194   echo "  SR=/usr/local/apache" && \
195   echo "else" && \
196   echo "  SR=\$1" && \
197   echo "fi" && \
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 ]" && \
210   echo "then" && \
211   echo "  echo \"[Preserving existing configuration files.]\"" && \
212   echo "  cp bindist/conf/*.default \$SR/conf/" && \
213   echo "else" && \
214   echo "  lcopy bindist/conf \$SR/conf 750 640" && \
215   echo "fi" && \
216   echo "if [ -d \$SR/htdocs ]" && \
217   echo "then" && \
218   echo "  echo \"[Preserving existing htdocs directory.]\"" && \
219   echo "else" && \
220   echo "  lcopy bindist/htdocs \$SR/htdocs 755 644" && \
221   echo "fi" && \
222   echo " " && \
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" && \
229   echo " " && \
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 \" +--------------------------------------------------------+\"" && \
247   echo "echo \" \"" \
248 ) > install-bindist.sh
249 chmod 755 install-bindist.sh
250
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
260
261 echo "Creating distribution archive and readme file..."
262  
263 if [ ".`grep -i error build.log > /dev/null`" != . ]
264 then
265   echo "ERROR: Failed to build Apache. See \"build.log\" for details."
266   exit 1;
267 else
268   if [ "x$GTAR" != "x" ]
269   then
270     $GTAR -zcf ../apache_$VER-$OS.tar.gz -C .. apache_$VER
271   else
272     if [ "x$TAR" != "x" ]
273     then
274       case "x$OS" in
275         x*390*) $TAR -cfU ../apache_$VER-$OS.tar -C .. apache_$VER;;
276             *) $TAR -cf ../apache_$VER-$OS.tar -C .. apache_$VER;;
277       esac
278       if [ "x$GZIP" != "x" ]
279       then
280         $GZIP ../apache_$VER-$OS.tar
281       fi
282     else
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"
287     fi
288   fi
289
290   if [ -f ../apache_$VER-$OS.tar.gz ] && [ -f ../apache_$VER-$OS.README ]
291   then
292     echo "Ready."
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."
296     exit 0;
297   else
298     exit 1;
299   fi
300 fi