]> granicus.if.org Git - apache/blob - build/binbuild.sh
c323e532181b8dc8040af868ffce7cef4c2be8ed
[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
10 APDIR=$(basename $(pwd))
11 VER=$(echo $APDIR |sed s/apache-//)
12 OS=$(src/helpers/GuessOS)
13 USER="$(src/helpers/buildinfo.sh -n %u@%h%d)"
14 TAR="$(src/helpers/PrintPath tar)"
15 GTAR="$(src/helpers/PrintPath gtar)"
16 GZIP="$(src/helpers/PrintPath gzip)"
17 CONFIGPARAM="--with-layout=BinaryDistribution --enable-module=most --enable-shared=max"
18
19 if [ ! -f ./ABOUT_APACHE ]
20 then
21   echo "ERROR: The current directory contains no valid Apache distribution."
22   echo "Please change the directory to the top level directory of a freshly"
23   echo "unpacked Apache 1.3 source distribution and re-execute the script"
24   echo "'./src/helpers/bindbuild.sh'." 
25   exit 1;
26 fi
27
28 if [ -d ./CVS ]
29 then
30   echo "ERROR: The current directory is a CVS checkout of Apache."
31   echo "Only a standard Apache 1.3 source distribution should be used to"
32   echo "create a binary distribution."
33   exit 1;
34 fi
35
36 echo "Building Apache $VER binary distribution..."
37 echo "Platform is \"$OS\"..."
38
39 ( echo "Build log for Apache binary distribution" && \
40   echo "----------------------------------------------------------------------" && \
41   ./configure $CONFIGPARAM && \
42   echo "----------------------------------------------------------------------" && \
43   make clean && \
44   rm -rf bindist install-bindist.sh *.bindist
45   echo "----------------------------------------------------------------------" && \
46   make && \
47   echo "----------------------------------------------------------------------" && \
48   make install-quiet root="bindist/" && \
49   echo "----------------------------------------------------------------------" && \
50   make clean && \
51   echo "----------------------------------------------------------------------" && \
52   echo "[EOF]" \
53 ) > build.log 2>&1
54
55 if [ ! -f ./bindist/bin/httpd ]
56 then
57   echo "ERROR: Failed to build Apache. See \"build.log\" for details."
58   exit 1;
59 fi
60
61 echo "Binary images successfully created..."
62 echo "Creating supplementary files..."
63
64 ( echo " " && \
65   echo "Apache $VER binary distribution" && \
66   echo "================================" && \
67   echo " " && \
68   echo "This binary distribution is usable on a \"$OS\"" && \
69   echo "system and was built by \"$USER\"." && \
70   echo "" && \
71   echo "The distribution contains all standard Apache modules as shared" && \
72   echo "objects. This allows you to enable or disable particular modules" && \
73   echo "with the LoadModule/AddModule directives in the configuration file" && \
74   echo "without the need to re-compile Apache." && \
75   echo "" && \
76   echo "See \"INSTALL.bindist\" on how to install the distribution." && \
77   echo " " && \
78   echo "NOTE: Please do not send support-related mails to the address mentioned" && \
79   echo "      above or to any member of the Apache Group! Support questions" && \
80   echo "      should be directed to the \"comp.infosystems.www.servers.unix\"" && \
81   echo "      or \"comp.infosystems.www.servers.ms-windows\" newsgroup" && \
82   echo "      (as appropriate for the platform you use), where some of the" && \
83   echo "      Apache team lurk, in the company of many other Apache gurus" && \
84   echo "      who should be able to help." && \
85   echo "      If you think you found a bug in Apache or have a suggestion please" && \
86   echo "      visit the bug report page at http://www.apache.org/bug_report.html" && \
87   echo " " && \
88   echo "----------------------------------------------------------------------" && \
89   ./bindist/bin/httpd -V && \
90   echo "----------------------------------------------------------------------" \
91 ) > README.bindist
92 cp README.bindist ../apache-$VER-$OS.README
93
94 ( echo " " && \
95   echo "Apache $VER binary installation" && \
96   echo "================================" && \
97   echo " " && \
98   echo "To install this binary distribution you have to execute the installation" && \
99   echo "script \"install-bindist.sh\" in the top-level directory of the distribution." && \
100   echo " " && \
101   echo "The script takes the ServerRoot directory into which you want to install" && \
102   echo "Apache as an option. If you ommit the option the default path" && \
103   echo "\"/usr/local/apache\" is used." && \
104   echo "Make sure you have write permissions in the target directory, e.g. switch" && \
105   echo "to user \"root\" before you execute the script." && \
106   echo " " && \
107   echo "See \"README.bindist\" for further details about this distribution." && \
108   echo " " && \
109   echo "Please note that this distribution includes the complete Apache source code." && \
110   echo "Therefore you may compile Apache yourself at any time if you have a compiler" && \
111   echo "installation on your system." && \
112   echo "See \"INSTALL\" for details on how to accomplish this." && \
113   echo " " \
114 ) > INSTALL.bindist
115
116 ( echo "#!/bin/sh" && \
117   echo "#" && \
118   echo "# Usage: install-bindist.sh [ServerRoot]" && \
119   echo "# This script installs the Apache binary distribution and" && \
120   echo "# was automatically created by binbuild.sh." && \
121   echo " " && \
122   echo "if [ .\$1 = . ]" && \
123   echo "then" && \
124   echo "  SR=/usr/local/apache" && \
125   echo "else" && \
126   echo "  SR=\$1" && \
127   echo "fi" && \
128   echo "echo \"Installing binary distribution for platform $OS\"" && \
129   echo "echo \"into directory \$SR ...\"" && \
130   echo "./src/helpers/mkdir.sh \$SR" && \
131   echo "cp -r bindist/proxy \$SR/proxy" && \
132   echo "cp -r bindist/man \$SR/man" && \
133   echo "cp -r bindist/logs \$SR/logs" && \
134   echo "cp -r bindist/libexec \$SR/libexec" && \
135   echo "cp -r bindist/include \$SR/include" && \
136   echo "cp -r bindist/icons \$SR/icons" && \
137   echo "cp -r bindist/cgi-bin \$SR/cgi-bin" && \
138   echo "cp -r bindist/bin \$SR/bin" && \
139   echo "if [ -d \$SR/conf ]" && \
140   echo "then" && \
141   echo "  echo \"[Preserving existing configuration files.]\"" && \
142   echo "  cp -r bindist/conf/*.default \$SR/conf/" && \
143   echo "else" && \
144   echo "  cp -r bindist/conf \$SR/conf" && \
145   echo "fi" && \
146   echo "if [ -d \$SR/htdocs ]" && \
147   echo "then" && \
148   echo "  echo \"[Preserving existing htdocs directory.]\"" && \
149   echo "else" && \
150   echo "  cp -r bindist/htdocs \$SR/htdocs" && \
151   echo "fi" && \
152   echo "sed -e s%/usr/local/apache%\$SR/% \$SR/conf/httpd.conf.default > \$SR/conf/httpd.conf" && \
153   echo "sed -e s%PIDFILE=%PIDFILE=\$SR/% -e s%HTTPD=%HTTPD=\\\"\$SR/% -e \"s%/httpd$%/httpd -d \$SR\\\"%\" bindist/bin/apachectl > \$SR/bin/apachectl" && \
154   echo " " && \
155   echo "echo \"Ready.\"" && \
156   echo "echo \" +--------------------------------------------------------+\"" && \
157   echo "echo \" | You now have successfully installed the Apache $VER   |\"" && \
158   echo "echo \" | HTTP server. To verify that Apache actually works      |\"" && \
159   echo "echo \" | correctly you now should first check the (initially    |\"" && \
160   echo "echo \" | created or preserved) configuration files              |\"" && \
161   echo "echo \" |                                                        |\"" && \
162   echo "echo \" |   \$SR/conf/httpd.conf\"" && \
163   echo "echo \" |                                                        |\"" && \
164   echo "echo \" | and then you should be able to immediately fire up     |\"" && \
165   echo "echo \" | Apache the first time by running:                      |\"" && \
166   echo "echo \" |                                                        |\"" && \
167   echo "echo \" |   \$SR/bin/apachectl start \"" &&\
168   echo "echo \" |                                                        |\"" && \
169   echo "echo \" | Thanks for using Apache.       The Apache Group        |\"" && \
170   echo "echo \" |                                http://www.apache.org/  |\"" && \
171   echo "echo \" +--------------------------------------------------------+\"" && \
172   echo "echo \" \"" \
173 ) > install-bindist.sh
174 chmod 755 install-bindist.sh
175
176 sed -e "s%\"/htdocs%\"/usr/local/apache/htdocs%" \
177     -e "s%\"/icons%\"/usr/local/apache/icons%" \
178     -e "s%\"/cgi-bin%\"/usr/local/apache/cgi-bin%" \
179     -e "s%^ServerAdmin.*%ServerAdmin you@your.address%" \
180     -e "s%#ServerName.*%#ServerName localhost%" \
181     -e "s%Port 8080%Port 80%" \
182     bindist/conf/httpd.conf.default > bindist/conf/httpd.conf
183 cp bindist/conf/httpd.conf bindist/conf/httpd.conf.default
184
185 echo "Creating distribution archive and readme file..."
186  
187 if [ ".`grep -i error build.log > /dev/null`" != . ]
188 then
189   echo "ERROR: Failed to build Apache. See \"build.log\" for details."
190   exit 1;
191 else
192   if [ ".$GTAR" != . ]
193   then
194     $GTAR -zcf ../apache-$VER-$OS.tar.gz -C .. --owner=root --group=root apache-$VER
195   else
196     if [ ".$TAR" != . ]
197     then
198       $TAR -cf ../apache-$VER-$OS.tar -C .. apache-$VER
199       if [ ".$GZIP" != . ]
200       then
201         $GZIP ../apache-$VER-$OS.tar
202       fi
203     else
204       echo "ERROR: Could not find a 'tar' program!"
205       echo "       Please execute the following commands manually:"
206       echo "         tar -cf ../apache-$VER-$OS.tar ."
207       echo "         gzip ../apache-$VER-$OS.tar"
208     fi
209   fi
210
211   if [ -f ../apache-$VER-$OS.tar.gz ] && [ -f ../apache-$VER-$OS.README ]
212   then
213     echo "Ready."
214     echo "You can find the binary archive (apache-$VER-$OS.tar.gz)"
215     echo "and the readme file (apache-$VER-$OS.README) in the"
216     echo "parent directory."
217     exit 0;
218   else
219     exit 1;
220   fi
221 fi