File build.inc of Package mysql-cluster.import4837

%if 0%{?suse_version} < 1120 && 0%{?suse_version} > 0
%define socketpath /var/lib/mysql
%else
%define socketpath /var/run/mysql
%endif
autoreconf -f -i
export CFLAGS="$RPM_OPT_FLAGS -DPIC -fPIC -DUNDEF_HAVE_INITGROUPS -DFORCE_INIT_OF_VARS -fno-strict-aliasing"
export CXXFLAGS="$CFLAGS -fno-exceptions -fno-rtti"
# Make the compile a function, since we do multiple builds
BuildMySQL() {
	# The --enable-assembler simply does nothing on systems that do not
	# support assembler speedups.
	suffix="$1"; shift
	mkdir _build$suffix
	pushd _build$suffix
	../configure \
		--enable-assembler \
		--without-readline \
		--infodir=%{_infodir} \
		--libdir=%{_libdir} \
		--libexecdir=/usr/sbin \
		--localstatedir=/var/lib/mysql \
		--mandir=%{_mandir} \
		--prefix=%{_prefix} \
		--sysconfdir=/etc \
		--with-mysqld-user=mysql \
		--with-mysqld-group=mysql \
		--without-debug \
		--datadir=/usr/share \
		--includedir=/usr/include \
		--with-charset=utf8 \
		--with-collation=utf8_unicode_ci \
		--with-extra-charsets=all \
		--with-unix-socket-path=%{socketpath}/mysql.sock \
		--enable-thread-safe-client \
		--with-comment="SUSE MySQL RPM" \
		--with-libwrap \
		--with-server-suffix=$suffix \
%ifarch s390 s390x
		--with-atomic-ops=rwlocks \
%else
		--with-atomic-ops=smp \
%endif
		--with-ssl=/usr \
		--with-plugins=%{builtin_plugins} \
		HOSTNAME="/bin/hostname -f" \
		"$@"
	# Add this for MyISAM RAID support:
	# --with-raid
	# benchdir does not fit in above model. Fix when we make a separate package
	make %{?jobs:-j%jobs}
	nm --numeric-sort sql/mysqld > sql/mysqld.sym
	# needed for make check, which is not VPATH aware
	# copy the files unconditionally so that manual 'make check' after
	# the build works, too
	cp -a ../mysql-test/* mysql-test/
	for i in ../sql/share/{english,charsets}; do
		[ -d $i ] && cp -a $i sql/share/
	done
	cp -a ../scripts/*.sql scripts/
%if %{?_with_testsuite:1}0
	pushd mysql-test; perl ./mysql-test-run.pl --force; popd
%endif
	popd
}
# Build the client, extra tools, libraries
BuildMySQL "" --with-embedded-server
# build mysqld-debug
BuildMySQL "-debug" --with-debug --without-embedded-server

%if 0%{?prefered} > 0
mkdir -p _buildlibmysqld/tmp
cd _buildlibmysqld/tmp
ar -x ../../_build/libmysqld/libmysqld.a
gcc $CFLAGS $LDFLAGS -shared -Wl,-soname,libmysqld.so.0 -o ../libmysqld.so.0.0.1 \
*.o \
-lpthread -lcrypt -lnsl -lssl -lcrypto -lz -lrt -lstdc++ -lm -lc
cd ..
rm -rf tmp
cd ..
%endif