]> granicus.if.org Git - apache/blob - build/binbuild.sh
Allow statically linked support binaries with the new
[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=`./srclib/apr/build/config.guess`
10 BUILD_DIR="`pwd`/bindist"
11 DEFAULT_DIR="/usr/local/apache2"
12 APDIR=`pwd`
13 APDIR=`basename $APDIR`
14 APFULLDIR=`pwd`
15 CONFIGPARAM="--with-layout=BinaryDistribution --prefix=$BUILD_DIR --enable-mods-shared=most --with-expat=$APFULLDIR/srclib/apr-util/xml/expat --enable-static-support"
16 VER=`echo $APDIR |sed s/httpd-//`
17 TAR="`srclib/apr/build/PrintPath tar`"
18 GTAR="`srclib/apr/build/PrintPath gtar`"
19 GZIP="`srclib/apr/build/PrintPath gzip`"
20
21 if [ x$1 != x ]; then
22   USER=$1
23 else
24   USER="`build/buildinfo.sh -n %u@%h%d`"
25 fi
26
27 if [ ! -f ./ABOUT_APACHE ]
28 then
29   echo "ERROR: The current directory contains no valid Apache distribution."
30   echo "Please change the directory to the top level directory of a freshly"
31   echo "unpacked Apache 2.0 source distribution and re-execute the script"
32   echo "'./build/binbuild.sh'." 
33   exit 1;
34 fi
35
36 if [ -d ./CVS ]
37 then
38   echo "ERROR: The current directory is a CVS checkout of Apache."
39   echo "Only a standard Apache 2.0 source distribution should be used to"
40   echo "create a binary distribution."
41   exit 1;
42 fi
43
44 echo "Building Apache $VER binary distribution..."
45 echo "Platform is \"$OS\"..."
46
47 ( echo "Build log for Apache binary distribution" && \
48   echo "----------------------------------------------------------------------" && \
49   ./configure $CONFIGPARAM && \
50   echo "----------------------------------------------------------------------" && \
51   make clean && \
52   rm -rf bindist install-bindist.sh *.bindist
53   echo "----------------------------------------------------------------------" && \
54   make && \
55   echo "----------------------------------------------------------------------" && \
56   make install root="bindist/" && \
57   echo "----------------------------------------------------------------------" && \
58   make clean && \
59   echo "----------------------------------------------------------------------" && \
60   echo "[EOF]" \
61 ) 2>&1 | tee build.log
62
63 if [ ! -f ./bindist/bin/httpd ]
64 then
65   echo "ERROR: Failed to build Apache. See \"build.log\" for details."
66   exit 1;
67 fi
68
69 echo "Binary image successfully created..."
70
71 ./bindist/bin/httpd -v
72
73 echo "Creating supplementary files..."
74
75 ( echo " " && \
76   echo "Apache $VER binary distribution" && \
77   echo "================================" && \
78   echo " " && \
79   echo "This binary distribution is usable on a \"$OS\"" && \
80   echo "system and was built by \"$USER\"." && \
81   echo "" && \
82   echo "The distribution contains all standard Apache modules as shared" && \
83   echo "objects. This allows you to enable or disable particular modules" && \
84   echo "with the LoadModule/AddModule directives in the configuration file" && \
85   echo "without the need to re-compile Apache." && \
86   echo "" && \
87   echo "See \"INSTALL.bindist\" on how to install the distribution." && \
88   echo " " && \
89   echo "NOTE: Please do not send support-related mails to the address mentioned" && \
90   echo "      above or to any member of the Apache Group! Support questions" && \
91   echo "      should be directed to the \"comp.infosystems.www.servers.unix\"" && \
92   echo "      or \"comp.infosystems.www.servers.ms-windows\" newsgroup" && \
93   echo "      (as appropriate for the platform you use), where some of the" && \
94   echo "      Apache team lurk, in the company of many other Apache gurus" && \
95   echo "      who should be able to help." && \
96   echo "      If you think you found a bug in Apache or have a suggestion please" && \
97   echo "      visit the bug report page at http://www.apache.org/bug_report.html" && \
98   echo " " && \
99   echo "----------------------------------------------------------------------" && \
100   ./bindist/bin/httpd -V && \
101   echo "----------------------------------------------------------------------" \
102 ) > README.bindist
103 cp README.bindist ../httpd-$VER-$OS.README
104
105 ( echo " " && \
106   echo "Apache $VER binary installation" && \
107   echo "================================" && \
108   echo " " && \
109   echo "To install this binary distribution you have to execute the installation" && \
110   echo "script \"install-bindist.sh\" in the top-level directory of the distribution." && \
111   echo " " && \
112   echo "The script takes the ServerRoot directory into which you want to install" && \
113   echo "Apache as an option. If you omit the option the default path" && \
114   echo "\"$DEFAULT_DIR\" is used." && \
115   echo "Make sure you have write permissions in the target directory, e.g. switch" && \
116   echo "to user \"root\" before you execute the script." && \
117   echo " " && \
118   echo "See \"README.bindist\" for further details about this distribution." && \
119   echo " " && \
120   echo "Please note that this distribution includes the complete Apache source code." && \
121   echo "Therefore you may compile Apache yourself at any time if you have a compiler" && \
122   echo "installation on your system." && \
123   echo "See \"INSTALL\" for details on how to accomplish this." && \
124   echo " " \
125 ) > INSTALL.bindist
126
127 sed -e "s%\@default_dir\@%$DEFAULT_DIR%" \
128     -e "s%\@ver\@%$VER%" \
129     -e "s%\@os\@%$OS%" \
130     build/install-bindist.sh.in > install-bindist.sh
131     
132 chmod 755 install-bindist.sh
133
134 sed -e "s%$BUILD_DIR%$DEFAULT_DIR%" \
135     -e "s%^ServerAdmin.*%ServerAdmin you@your.address%" \
136     -e "s%#ServerName.*%#ServerName localhost%" \
137     bindist/conf/httpd-std.conf > bindist/conf/httpd.conf
138 cp bindist/conf/httpd.conf bindist/conf/httpd-std.conf
139
140 for one_file in apachectl envvars envvars-std; do
141     sed -e "s%$BUILD_DIR%$DEFAULT_DIR%" \
142         -e "s%^#binbuild %%" \
143         bindist/bin/$one_file > bindist/bin/$one_file.tmp
144     mv bindist/bin/$one_file.tmp bindist/bin/$one_file
145 done
146
147 echo "Creating distribution archive and readme file..."
148  
149 if [ ".`grep -i error build.log > /dev/null`" != . ]
150 then
151   echo "ERROR: Failed to build Apache. See \"build.log\" for details."
152   exit 1;
153 else
154   if [ "x$GTAR" != "x" ]
155   then
156     $GTAR -zcf ../httpd-$VER-$OS.tar.gz -C .. httpd-$VER
157   else
158     if [ "x$TAR" != "x" ]
159     then
160       case "x$OS" in
161         x*390*) $TAR -cfU ../httpd-$VER-$OS.tar -C .. httpd-$VER;;
162             *) (cd .. && $TAR -cf httpd-$VER-$OS.tar httpd-$VER);;
163       esac
164       if [ "x$GZIP" != "x" ]
165       then
166         $GZIP ../httpd-$VER-$OS.tar
167       fi
168     else
169       echo "ERROR: Could not find a 'tar' program!"
170       echo "       Please execute the following commands manually:"
171       echo "         tar -cf ../httpd-$VER-$OS.tar ."
172       echo "         gzip ../httpd-$VER-$OS.tar"
173     fi
174   fi
175
176   if [ -f ../httpd-$VER-$OS.tar.gz ] && [ -f ../httpd-$VER-$OS.README ]
177   then
178     echo "Ready."
179     echo "You can find the binary archive (httpd-$VER-$OS.tar.gz)"
180     echo "and the readme file (httpd-$VER-$OS.README) in the"
181     echo "parent directory."
182     exit 0;
183   else
184     exit 1;
185   fi
186 fi