mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / scripts / make_binary_distribution.sh
blob8c86c179bcddbc617200fe552c9706e274564328
1 #!/bin/sh
2 # Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; version 2 of the License.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 ##############################################################################
19 # This is a script to create a TAR or ZIP binary distribution out of a
20 # built source tree. The output file will be put at the top level of
21 # the source tree, as "mysql-<vsn>....{tar.gz,zip}"
23 # Note that the structure created by this script is slightly different from
24 # what a normal "make install" would produce. No extra "mysql" sub directory
25 # will be created, i.e. no "$prefix/include/mysql", "$prefix/lib/mysql" or
26 # "$prefix/share/mysql". This is because the build system explicitly calls
27 # make with pkgdatadir=<datadir>, etc.
29 # In GNU make/automake terms
31 # "pkglibdir" is set to the same as "libdir"
32 # "pkgincludedir" is set to the same as "includedir"
33 # "pkgdatadir" is set to the same as "datadir"
34 # "pkgplugindir" is set to "$pkglibdir/plugin"
35 # "pkgsuppdir" is set to "@prefix@/support-files",
36 # normally the same as "datadir"
38 # The temporary directory path given to "--tmp=<path>" has to be
39 # absolute and with no spaces.
41 # Note that for best result, the original "make" should be done with
42 # the same arguments as used for "make install" below, especially the
43 # 'pkglibdir', as the RPATH should to be set correctly.
45 ##############################################################################
47 ##############################################################################
49 # Read the command line arguments that control this script
51 ##############################################################################
53 machine=@MACHINE_TYPE@
54 system=@SYSTEM_TYPE@
55 SOURCE=`pwd`
56 CP="cp -p"
57 MV="mv"
59 # There are platforms, notably OS X on Intel (x86 + x86_64),
60 # for which "uname" does not provide sufficient information.
61 # The value of CFLAGS as used during compilation is the most exact info
62 # we can get - after all, we care about _what_ we built, not _where_ we did it.
63 cflags="@CFLAGS@"
65 STRIP=1 # Option ignored
66 SILENT=0
67 PLATFORM=""
68 TMP=/tmp
69 NEW_NAME="" # Final top directory and TAR package name
70 SUFFIX=""
71 SHORT_PRODUCT_TAG="" # If don't want server suffix in package name
72 NDBCLUSTER="" # Option ignored
74 for arg do
75 case "$arg" in
76 --tmp=*) TMP=`echo "$arg" | sed -e "s;--tmp=;;"` ;;
77 --suffix=*) SUFFIX=`echo "$arg" | sed -e "s;--suffix=;;"` ;;
78 --short-product-tag=*) SHORT_PRODUCT_TAG=`echo "$arg" | sed -e "s;--short-product-tag=;;"` ;;
79 --no-strip) STRIP=0 ;;
80 --machine=*) machine=`echo "$arg" | sed -e "s;--machine=;;"` ;;
81 --platform=*) PLATFORM=`echo "$arg" | sed -e "s;--platform=;;"` ;;
82 --silent) SILENT=1 ;;
83 --with-ndbcluster) NDBCLUSTER=1 ;;
85 echo "Unknown argument '$arg'"
86 exit 1
88 esac
89 done
91 # ----------------------------------------------------------------------
92 # Adjust "system" output from "uname" to be more human readable
93 # ----------------------------------------------------------------------
95 if [ x"$PLATFORM" = x"" ] ; then
96 # FIXME move this to the build tools
97 # Remove vendor from $system
98 system=`echo $system | sed -e 's/[a-z]*-\(.*\)/\1/g'`
100 # Map OS names to "our" OS names (eg. darwin6.8 -> osx10.2)
101 system=`echo $system | sed -e 's/darwin6.*/osx10.2/g'`
102 system=`echo $system | sed -e 's/darwin7.*/osx10.3/g'`
103 system=`echo $system | sed -e 's/darwin8.*/osx10.4/g'`
104 system=`echo $system | sed -e 's/darwin9.*/osx10.5/g'`
105 system=`echo $system | sed -e 's/\(aix4.3\).*/\1/g'`
106 system=`echo $system | sed -e 's/\(aix5.1\).*/\1/g'`
107 system=`echo $system | sed -e 's/\(aix5.2\).*/\1/g'`
108 system=`echo $system | sed -e 's/\(aix5.3\).*/\1/g'`
109 system=`echo $system | sed -e 's/osf5.1b/tru64/g'`
110 system=`echo $system | sed -e 's/linux-gnu/linux/g'`
111 system=`echo $system | sed -e 's/solaris2.\([0-9]*\)/solaris\1/g'`
112 system=`echo $system | sed -e 's/sco3.2v\(.*\)/openserver\1/g'`
115 # Get the "machine", which really is the CPU architecture (including the size).
116 # The precedence is:
117 # 1) use an explicit argument, if given;
118 # 2) use platform-specific fixes, if there are any (see bug#37808);
119 # 3) stay with the default (determined during "configure", using predefined macros).
121 if [ x"$MACHINE" != x"" ] ; then
122 machine=$MACHINE
123 else
124 case $system in
125 osx* )
126 # Extract "XYZ" from CFLAGS "... -arch XYZ ...", or empty!
127 cflag_arch=`echo "$cflags" | sed -n -e 's=.* -arch \([^ ]*\) .*=\1=p'`
128 case "$cflag_arch" in
129 i386 ) case $system in
130 osx10.4 ) machine=i686 ;; # Used a different naming
131 * ) machine=x86 ;;
132 esac ;;
133 x86_64 ) machine=x86_64 ;;
134 ppc ) ;; # No treatment needed with PPC
135 ppc64 ) ;;
136 * ) # No matching compiler flag? "--platform" is needed
137 if [ x"$PLATFORM" != x"" ] ; then
138 : # See below: "$PLATFORM" will take precedence anyway
139 elif [ "$system" = "osx10.3" -a -z "$cflag_arch" ] ; then
140 : # Special case of OS X 10.3, which is PPC-32 only and doesn't use "-arch"
141 else
142 echo "On system '$system' only specific '-arch' values are expected."
143 echo "It is taken from the 'CFLAGS' whose value is:"
144 echo "$cflags"
145 echo "'-arch $cflag_arch' is unexpected, and no '--platform' was given: ABORT"
146 exit 1
147 fi ;;
148 esac # "$cflag_arch"
150 esac # $system
153 # Combine OS and CPU to the "platform". Again, an explicit argument takes precedence.
154 if [ x"$PLATFORM" != x"" ] ; then
156 else
157 PLATFORM="$system-$machine"
160 # Print the platform name for build logs
161 echo "PLATFORM NAME: $PLATFORM"
163 case $PLATFORM in
164 *netware*) BASE_SYSTEM="netware" ;;
165 esac
167 # Change the distribution to a long descriptive name
168 # For the cluster product, concentrate on the second part
169 VERSION_NAME=@VERSION@
170 case $VERSION_NAME in
171 *-ndb-* ) VERSION_NAME=`echo $VERSION_NAME | sed -e 's/[.0-9]*-ndb-//'` ;;
172 esac
173 if [ x"$SHORT_PRODUCT_TAG" != x"" ] ; then
174 NEW_NAME=mysql-$SHORT_PRODUCT_TAG-$VERSION_NAME-$PLATFORM$SUFFIX
175 else
176 NEW_NAME=mysql@MYSQL_SERVER_SUFFIX@-$VERSION_NAME-$PLATFORM$SUFFIX
179 # ----------------------------------------------------------------------
180 # Define BASE, and remove the old BASE directory if any
181 # ----------------------------------------------------------------------
182 BASE=$TMP/my_dist$SUFFIX
183 if [ -d $BASE ] ; then
184 rm -rf $BASE
187 # ----------------------------------------------------------------------
188 # Find the TAR to use
189 # ----------------------------------------------------------------------
191 # This is needed to prefer GNU tar over platform tar because that can't
192 # always handle long filenames
194 PATH_DIRS=`echo $PATH | \
195 sed -e 's/^:/. /' -e 's/:$/ ./' -e 's/::/ . /g' -e 's/:/ /g' `
197 which_1 ()
199 for cmd
201 for d in $PATH_DIRS
203 for file in $d/$cmd
205 if [ -x $file -a ! -d $file ] ; then
206 echo $file
207 exit 0
209 done
210 done
211 done
212 exit 1
215 tar=`which_1 gnutar gtar`
216 if [ $? -ne 0 -o x"$tar" = x"" ] ; then
217 tar=tar
221 ##############################################################################
223 # Handle the Unix/Linux packaging using "make install"
225 ##############################################################################
227 if [ x"$BASE_SYSTEM" != x"netware" ] ; then
229 # ----------------------------------------------------------------------
230 # Terminate on any base level error
231 # ----------------------------------------------------------------------
232 set -e
234 # ----------------------------------------------------------------------
235 # Really ugly, one script, "mysql_install_db", needs prefix set to ".",
236 # i.e. makes access relative the current directory. This matches
237 # the documentation, so better not change this. And for another script,
238 # "mysql.server", we make some relative, others not.
239 # ----------------------------------------------------------------------
241 cd scripts
242 rm -f mysql_install_db
243 @MAKE@ mysql_install_db \
244 prefix=. \
245 bindir=./bin \
246 sbindir=./bin \
247 scriptdir=./bin \
248 libexecdir=./bin \
249 pkgdatadir=./share \
250 localstatedir=./data
251 cd ..
253 cd support-files
254 rm -f mysql.server
255 @MAKE@ mysql.server \
256 bindir=./bin \
257 sbindir=./bin \
258 scriptdir=./bin \
259 libexecdir=./bin \
260 pkgdatadir=@pkgdatadir@
261 cd ..
263 # ----------------------------------------------------------------------
264 # Do a install that we later are to pack. Use the same paths as in
265 # the build for the relevant directories.
266 # ----------------------------------------------------------------------
267 @MAKE@ DESTDIR=$BASE install \
268 pkglibdir=@pkglibdir@ \
269 pkgincludedir=@pkgincludedir@ \
270 pkgdatadir=@pkgdatadir@ \
271 pkgplugindir=@pkgplugindir@ \
272 pkgsuppdir=@pkgsuppdir@ \
273 mandir=@mandir@ \
274 infodir=@infodir@
276 # ----------------------------------------------------------------------
277 # Rename top directory, and set DEST to the new directory
278 # ----------------------------------------------------------------------
279 mv $BASE@prefix@ $BASE/$NEW_NAME
280 DEST=$BASE/$NEW_NAME
282 # ----------------------------------------------------------------------
283 # If we compiled with gcc, copy libgcc.a to the dist as libmygcc.a
284 # ----------------------------------------------------------------------
285 if [ x"@GXX@" = x"yes" ] ; then
286 gcclib=`@CC@ @CFLAGS@ --print-libgcc-file 2>/dev/null` || true
287 if [ -z "$gcclib" ] ; then
288 echo "Warning: Compiler doesn't tell libgcc.a!"
289 elif [ -f "$gcclib" ] ; then
290 $CP $gcclib $DEST/lib/libmygcc.a
291 else
292 echo "Warning: Compiler result '$gcclib' not found / no file!"
296 # FIXME let this script be in "bin/", where it is in the RPMs?
297 # http://dev.mysql.com/doc/refman/5.1/en/mysql-install-db-problems.html
298 mkdir $DEST/scripts
299 mv $DEST/bin/mysql_install_db $DEST/scripts/
301 # Note, no legacy "safe_mysqld" link to "mysqld_safe" in 5.1
303 # Copy readme and license files
304 cp README Docs/INSTALL-BINARY $DEST/
305 if [ -f COPYING ] ; then
306 cp COPYING $DEST/
307 elif [ -f LICENSE.mysql ] ; then
308 cp LICENSE.mysql $DEST/
309 else
310 echo "ERROR: no license files found"
311 exit 1
314 # FIXME should be handled by make file, and to other dir
315 mkdir -p $DEST/bin $DEST/support-files
316 cp scripts/mysqlaccess.conf $DEST/bin/
317 cp support-files/magic $DEST/support-files/
319 # Create empty data directories, set permission (FIXME why?)
320 mkdir $DEST/data $DEST/data/mysql $DEST/data/test
321 chmod o-rwx $DEST/data $DEST/data/mysql $DEST/data/test
323 # ----------------------------------------------------------------------
324 # Create the result tar file
325 # ----------------------------------------------------------------------
327 echo "Using $tar to create archive"
328 OPT=cvf
329 if [ x$SILENT = x1 ] ; then
330 OPT=cf
333 echo "Creating and compressing archive"
334 rm -f $NEW_NAME.tar.gz
335 (cd $BASE ; $tar $OPT - $NEW_NAME) | gzip -9 > $NEW_NAME.tar.gz
336 echo "$NEW_NAME.tar.gz created"
338 echo "Removing temporary directory"
339 rm -rf $BASE
340 exit 0
344 ##############################################################################
346 # Handle the Netware case, until integrated above
348 ##############################################################################
350 BS=".nlm"
351 MYSQL_SHARE=$BASE/share
353 mkdir $BASE $BASE/bin $BASE/docs \
354 $BASE/include $BASE/lib $BASE/support-files $BASE/share $BASE/scripts \
355 $BASE/mysql-test $BASE/mysql-test/t $BASE/mysql-test/r \
356 $BASE/mysql-test/include $BASE/mysql-test/std_data $BASE/mysql-test/lib \
357 $BASE/mysql-test/suite
359 # Copy files if they exists, warn for those that don't.
360 # Note that when listing files to copy, we might list the file name
361 # twice, once in the directory location where it is built, and a
362 # second time in the ".libs" location. In the case the first one
363 # is a wrapper script, the second one will overwrite it with the
364 # binary file.
365 copyfileto()
367 destdir=$1
368 shift
369 for i
371 if [ -f $i ] ; then
372 $CP $i $destdir
373 elif [ -d $i ] ; then
374 echo "Warning: Will not copy directory \"$i\""
375 else
376 echo "Warning: Listed file not found \"$i\""
378 done
381 copyfileto $BASE/docs ChangeLog Docs/mysql.info
383 copyfileto $BASE COPYING COPYING.LIB README Docs/INSTALL-BINARY \
384 LICENSE.mysql
386 # Non platform-specific bin dir files:
387 BIN_FILES="extra/comp_err$BS extra/replace$BS extra/perror$BS \
388 extra/resolveip$BS extra/my_print_defaults$BS \
389 extra/resolve_stack_dump$BS extra/mysql_waitpid$BS \
390 storage/myisam/myisamchk$BS storage/myisam/myisampack$BS \
391 storage/myisam/myisamlog$BS storage/myisam/myisam_ftdump$BS \
392 sql/mysqld$BS sql/mysqld-debug$BS \
393 sql/mysql_tzinfo_to_sql$BS \
394 server-tools/instance-manager/mysqlmanager$BS \
395 client/mysql$BS client/mysqlshow$BS client/mysqladmin$BS \
396 client/mysqlslap$BS \
397 client/mysqldump$BS client/mysqlimport$BS \
398 client/mysqltest$BS client/mysqlcheck$BS \
399 client/mysqlbinlog$BS client/mysql_upgrade$BS \
400 tests/mysql_client_test$BS \
401 libmysqld/examples/mysql_client_test_embedded$BS \
402 libmysqld/examples/mysqltest_embedded$BS \
405 # Platform-specific bin dir files:
406 BIN_FILES="$BIN_FILES \
407 netware/mysqld_safe$BS netware/mysql_install_db$BS \
408 netware/init_db.sql netware/test_db.sql \
409 netware/mysqlhotcopy$BS netware/libmysql$BS netware/init_secure_db.sql \
412 copyfileto $BASE/bin $BIN_FILES
414 $CP netware/*.pl $BASE/scripts
415 $CP scripts/mysqlhotcopy $BASE/scripts/mysqlhotcopy.pl
417 copyfileto $BASE/lib \
418 libmysql/.libs/libmysqlclient.a \
419 libmysql/.libs/libmysqlclient.so* \
420 libmysql/.libs/libmysqlclient.sl* \
421 libmysql/.libs/libmysqlclient*.dylib \
422 libmysql/libmysqlclient.* \
423 libmysql_r/.libs/libmysqlclient_r.a \
424 libmysql_r/.libs/libmysqlclient_r.so* \
425 libmysql_r/.libs/libmysqlclient_r.sl* \
426 libmysql_r/.libs/libmysqlclient_r*.dylib \
427 libmysql_r/libmysqlclient_r.* \
428 libmysqld/.libs/libmysqld.a \
429 libmysqld/.libs/libmysqld.so* \
430 libmysqld/.libs/libmysqld.sl* \
431 libmysqld/.libs/libmysqld*.dylib \
432 mysys/libmysys.a strings/libmystrings.a dbug/libdbug.a \
433 libmysqld/libmysqld.a netware/libmysql.imp \
434 zlib/.libs/libz.a
436 # convert the .a to .lib for NetWare
437 for i in $BASE/lib/*.a
439 libname=`basename $i .a`
440 $MV $i $BASE/lib/$libname.lib
441 done
442 rm -f $BASE/lib/*.la
445 copyfileto $BASE/include config.h include/*
447 rm -f $BASE/include/Makefile* $BASE/include/*.in $BASE/include/config-win.h
449 # In a NetWare binary package, these tools and their manuals are not useful
450 rm -f $BASE/man/man1/make_win_*
452 copyfileto $BASE/support-files support-files/*
454 copyfileto $BASE/share scripts/*.sql
456 $CP -r sql/share/* $MYSQL_SHARE
457 rm -f $MYSQL_SHARE/Makefile* $MYSQL_SHARE/*/*.OLD
459 copyfileto $BASE/mysql-test \
460 mysql-test/mysql-test-run mysql-test/install_test_db \
461 mysql-test/mysql-test-run.pl mysql-test/README \
462 mysql-test/mysql-stress-test.pl \
463 mysql-test/valgrind.supp \
464 netware/mysql_test_run.nlm netware/install_test_db.ncf
466 $CP mysql-test/lib/*.pl $BASE/mysql-test/lib
467 $CP mysql-test/t/*.def $BASE/mysql-test/t
468 $CP mysql-test/include/*.inc $BASE/mysql-test/include
469 $CP mysql-test/include/*.sql $BASE/mysql-test/include
470 $CP mysql-test/include/*.test $BASE/mysql-test/include
471 $CP mysql-test/t/*.def $BASE/mysql-test/t
472 $CP mysql-test/std_data/*.dat mysql-test/std_data/*.frm \
473 mysql-test/std_data/*.MYD mysql-test/std_data/*.MYI \
474 mysql-test/std_data/*.pem mysql-test/std_data/Moscow_leap \
475 mysql-test/std_data/Index.xml \
476 mysql-test/std_data/des_key_file mysql-test/std_data/*.*001 \
477 mysql-test/std_data/*.cnf mysql-test/std_data/*.MY* \
478 $BASE/mysql-test/std_data
479 # Attention: when the wildcards expand to a line that is very long,
480 # it may exceed the command line length limit on some platform(s). Bug#54590
481 $CP mysql-test/t/*.test mysql-test/t/*.imtest $BASE/mysql-test/t
482 $CP mysql-test/t/*.disabled mysql-test/t/*.opt $BASE/mysql-test/t
483 $CP mysql-test/t/*.slave-mi mysql-test/t/*.sh mysql-test/t/*.sql $BASE/mysql-test/t
484 $CP mysql-test/r/*.result mysql-test/r/*.require \
485 $BASE/mysql-test/r
487 # Copy the additional suites "as is", they are in flux
488 $tar cf - mysql-test/suite | ( cd $BASE ; $tar xf - )
489 # Clean up if we did this from a bk tree
490 if [ -d mysql-test/SCCS ] ; then
491 find $BASE/mysql-test -name SCCS -print | xargs rm -rf
494 rm -f $BASE/bin/Makefile* $BASE/bin/*.in $BASE/bin/*.sh \
495 $BASE/bin/mysql_install_db $BASE/bin/make_binary_distribution \
496 $BASE/bin/make_win_* \
497 $BASE/bin/setsomevars $BASE/support-files/Makefile* \
498 $BASE/support-files/*.sh
501 # Copy system dependent files
503 ./scripts/fill_help_tables < ./Docs/manual.texi >> ./netware/init_db.sql
506 # Remove system dependent files
508 rm -f $BASE/support-files/magic \
509 $BASE/support-files/mysql.server \
510 $BASE/support-files/mysql*.spec \
511 $BASE/support-files/mysql-log-rotate \
512 $BASE/support-files/binary-configure \
513 $BASE/support-files/build-tags \
514 $BASE/support-files/MySQL-shared-compat.spec \
515 $BASE/INSTALL-BINARY
517 # Clean up if we did this from a bk tree
518 if [ -d $BASE/sql-bench/SCCS ] ; then
519 find $BASE/share -name SCCS -print | xargs rm -rf
520 find $BASE/sql-bench -name SCCS -print | xargs rm -rf
523 BASE2=$TMP/$NEW_NAME
524 rm -rf $BASE2
525 mv $BASE $BASE2
526 BASE=$BASE2
529 # Create a zip file for NetWare users
531 rm -f $NEW_NAME.zip
532 (cd $TMP; zip -r "$SOURCE/$NEW_NAME.zip" $NEW_NAME)
533 echo "$NEW_NAME.zip created"
535 echo "Removing temporary directory"
536 rm -rf $BASE