Compiling mysql 5.6.23

#See https://adrhc.go.ro/wordpress/common-commands-when-building/ for building environment, x.sh script and other things not defined here.
#Before starting do declare the environment variables specified to the link above.

NEW_BUILD_NAME=mysql
NEW_BUILD_VER=5.6.23
NEW_BUILD_NAME_AND_VER=$NEW_BUILD_NAME-$NEW_BUILD_VER
ls -l /tmp/$NEW_BUILD_NAME-*
ls -l ~/ffp_0.7_armv5/packages/$NEW_BUILD_NAME-*
NEW_BUILD_NR=0

cd $HOME/compile
rm -r $HOME/compile/mysql-5.6.23
tar -xzvf mysql-5.6.23.tar.gz
cd $HOME/compile/mysql-5.6.23
~/x.sh ffpg

#all params with help text
#cmake . -LAH > cmake.help.txt

#Clear/reset previously run configure & generate:
make clean
rm CMakeCache.txt

#interactive configure
cmake . -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/ffp -DFEATURE_SET=large -DMYSQL_DATADIR=/ffp/opt/srv/mysql/data -DSYSCONFDIR=/ffp/etc -DTMPDIR=/ffp/opt/srv/mysql/tmp -DWITH_DEBUG=OFF -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DWITH_EMBEDDED_SHARED_LIBRARY=ON -DHAVE_LLVM_LIBCPP=1 -DCMAKE_CXX_FLAGS_RELEASE="$BUILD_FLAGS" -DCMAKE_C_FLAGS_RELEASE="$BUILD_FLAGS" -DHAVE_GCC_ATOMIC_BUILTINS="" -LAH

nohup /ffp/bin/make -C ~/compile/$NEW_BUILD_NAME_AND_VER &
renice -11 `pidof cc1plus` -p `pidof make` -p `pidof as` -p `pidof ld` -p `pidof configure` -p `pidof cc1` -p `pidof ccmake`
tail -f nohup.out

rm -r $HOME/temp/$NEW_BUILD_NAME_AND_VER
make install DESTDIR=$HOME/temp/$NEW_BUILD_NAME_AND_VER
cd $HOME/temp/$NEW_BUILD_NAME_AND_VER
makepkg $NEW_BUILD_NAME $NEW_BUILD_VER $NEW_BUILD_NR
cp -v /tmp/$NEW_BUILD_NAME-$NEW_BUILD_VER-arm-$NEW_BUILD_NR.txz ~/ffp_0.7_armv5/packages/
funpkg -q $NEW_BUILD_NAME
funpkg -i ~/ffp_0.7_armv5/packages/$NEW_BUILD_NAME-$NEW_BUILD_VER-arm-$NEW_BUILD_NR.txz

# see also CREATE SYSTEM DB (first step and mandatory before using mysql)
# search my blog for: CREATE SYSTEM DB

Compiling PHP 5.6.x

#See https://adrhc.go.ro/wordpress/common-commands-when-building/ for building environment, x.sh script and other things not defined here.
#Before starting do declare the environment variables specified to the link above.

NEW_BUILD_NAME=php
NEW_BUILD_VER1=5.6.13
NEW_BUILD_VER=$NEW_BUILD_VER1-zts
MYSQL_BUILD_NAME_AND_VER=mysql-5.6.25
NEW_BUILD_NAME_AND_VER=$NEW_BUILD_NAME-$MYSQL_BUILD_NAME_AND_VER-$NEW_BUILD_VER
ls -l /tmp/$NEW_BUILD_NAME-*
ls -l ~/ffp_0.7_armv5/packages/$NEW_BUILD_NAME-*
NEW_BUILD_NR=0

cd ~/compile
wget -O $NEW_BUILD_NAME_AND_VER.tar.gz http://ro1.php.net/get/php-$NEW_BUILD_VER1.tar.gz/from/this/mirror
tar -xzf $NEW_BUILD_NAME-$NEW_BUILD_VER1.tar.gz
mv $NEW_BUILD_NAME-$NEW_BUILD_VER1 $NEW_BUILD_NAME_AND_VER
cd ~/compile/$NEW_BUILD_NAME_AND_VER
nohup ~/x.sh ffpg &
tail -f nohup.out
cp -r . ../$NEW_BUILD_NAME_AND_VER+ffpg
  
#REINSTALL (start from here when reinstalling)
cd ~/compile
rm -r ~/compile/$NEW_BUILD_NAME_AND_VER
cp -r ~/compile/$NEW_BUILD_NAME_AND_VER+ffpg ~/compile/$NEW_BUILD_NAME_AND_VER
cd ~/compile/$NEW_BUILD_NAME_AND_VER
 
./configure --help > configure.help.txt
cat configure.help.txt
 
ERROR0:
    don't know how to define struct flock on this system ... set --enable-opcache=no
SOLUTION0:
    funpkg -r libgd-2.1.0-arm-0
 
#When using --with-apxs2=/ffp/opt/apache-2.2.9-prefork/bin/apxs we'll get php-non-ZTS!
#When using --with-apxs2=/ffp/opt/apache-2.2.29-worker/bin/apxs we'll get php-ZTS!
#--with-recode -> couldn't build it for the moment
#--with-tidy -> too old, makes no sense to use it
#--without-sqlite3=/ffp -> doesn't work (stupid option)
#--enable-mysqlnd -> I don't use it
#--enable-dba=shared -> somehow disables mysqli

sed -i s/"HAVE_GD_XPM\s1"/"HAVE_GD_XPM 0"/g configure
sed -i s/"lxmlrpc\s"/"lxmlrpc-epi "/g configure

./configure --prefix=/ffp --enable-re2c-cgoto=shared,/ffp --with-apxs2=/ffp/opt/apache-2.2.29-worker/bin/apxs --enable-fpm --with-config-file-path=/ffp/etc/php.ini --with-config-file-scan-dir=/ffp/etc --with-libxml-dir=/ffp --with-openssl=shared,/ffp --with-pcre-regex=/ffp --with-zlib=shared,/ffp --enable-bcmath --with-bz2=shared,/ffp --enable-calendar --with-curl=shared,/ffp --with-enchant=shared,/ffp --enable-exif --enable-ftp --with-gd=shared,/ffp --with-jpeg-dir=/ffp --with-png-dir=/ffp --with-freetype-dir=/ffp --enable-gd-native-ttf --enable-gd-jis-conv --with-gettext=shared,/ffp --with-gmp=shared,/ffp --with-mhash=shared,/ffp --enable-intl --with-icu-dir=/ffp --enable-mbstring --with-mcrypt=shared,/ffp --with-mysql=shared,/ffp --with-mysql-sock=/ffp/var/run/mysql/mysql.sock --with-mysqli=shared,/ffp/bin/mysql_config --enable-opcache --enable-pcntl --with-pdo-mysql=shared,/ffp --with-readline=shared,/ffp --enable-shmop --enable-soap --enable-sockets --enable-wddx --with-libexpat-dir=/ffp --with-xmlrpc=shared,/ffp --with-iconv=shared,/ffp --with-xsl=/ffp --enable-zip --with-pear --with-pcre-dir=/ffp --with-openssl-dir=/ffp --with-zlib-dir=/ffp --with-iconv-dir=/ffp

sed -i s/"lxmlrpc\s"/"lxmlrpc-epi "/g Makefile
sed -i s/"define\sHAVE_GD_XPM\s0"/"undef HAVE_GD_XPM"/g main/php_config.h

#make
nohup make -C . &
renice -11 `pidof cc1plus` -p `pidof make` -p `pidof as` -p `pidof ld` -p `pidof configure` -p `pidof cc1`
tail -f nohup.out
#tests
nohup make test &

#INSTALL
rm -r $HOME/temp/$NEW_BUILD_NAME_AND_VER
mkdir -p $HOME/temp/$NEW_BUILD_NAME_AND_VER/ffp/opt/apache-2.2.29-worker/conf/
cp -v /ffp/opt/apache-2.2.29-worker/conf/httpd.conf $HOME/temp/$NEW_BUILD_NAME_AND_VER/ffp/opt/apache-2.2.29-worker/conf/
INSTALL_ROOT=$HOME/temp/$NEW_BUILD_NAME_AND_VER make install
#if after make you are asked for running 'libtool --finish ...' then do it:
libtool --finish libs
#You'll get something like this:
#Libraries have been installed in:
#   /ffp/home/root/compile/$NEW_BUILD_NAME_AND_VER/libs -> here you'll find libphp5.so and libphp5.la
rm -vr $HOME/temp/$NEW_BUILD_NAME_AND_VER/ffp/opt/apache-2.2.29-worker/conf/
cd $HOME/temp/$NEW_BUILD_NAME_AND_VER
ls -l /tmp/php-*
ls -l ~/ffp_0.7_armv5/packages/php-*
#for the files found below remove the -n or/and -q php's call options:
grep -nr "\s\(-q\|-n\)\s" ffp/bin/
sed -i s/"\s-q"/""/ ffp/bin/peardev
sed -i s/"\s-q"/""/ ffp/bin/pear
sed -i s/"\s-q"/""/ ffp/bin/pecl
sed -i s/"\s-n"/""/ ffp/bin/pecl
sed -i s/"\!\/bin"/"\!\/ffp\/bin"/ ffp/bin/pecl
sed -i s/"\!\/bin"/"\!\/ffp\/bin"/ ffp/bin/pear
sed -i s/"\!\/bin"/"\!\/ffp\/bin"/ ffp/bin/peardev
makepkg $NEW_BUILD_NAME-$MYSQL_BUILD_NAME_AND_VER $NEW_BUILD_VER 0
cp -v /tmp/php-*.txz $HOME/ffp_0.7_armv5/packages/
funpkg -i $HOME/ffp_0.7_armv5/packages/$NEW_BUILD_NAME_AND_VER-arm-0.txz
 
#AFTER INSTALL
#INSTALL PEAR & PECL
wget http://pear.php.net/go-pear.phar
#go-pear.phar installs also pecl
php go-pear.phar
#ERROR (when running go-pear.phar)
	SHA1 signature could not be verified: broken signature
#SOLUTION
	Don't modify go-pear.phar with "~/x.sh ffpg" command!!!
	Configure php.ini: phar.require_hash = Off.
	Execute with specific php.ini:
	php -c /ffp/etc/php.ini go-pear.phar

#Modify the following /ffp/bin/ files: pear, peardev, pecl, pecl-gen:
##!/bin/sh -> #!/ffp/bin/sh

#USING PECL: https://adrhc.go.ro/wordpress/using-pecl/
#USING PEAR: https://adrhc.go.ro/wordpress/using-pear/

#ERROR (make)
	PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled.
#SOLUTION (do it after installing pear)
	A part of the solution is to at least install PEAR package PHP_Archive.
	PHP_Archive is required for running phar files (see http://php.net/manual/en/intro.phar.php).

#My personal setup:
pecl channel-update pecl.php.net
pear install --alldeps PHP_Archive-0.11.4
pecl install --alldeps --force APCu-4.0.7
pecl install --alldeps msgpack-0.5.6
pecl install --alldeps --force pthreads-2.0.10

#INSTALL APCu manually (compile or use https://adrhc.go.ro/wordpress/using-pecl/)
cd ~/compile
wget http://pecl.php.net/get/apcu-4.0.7.tgz
tar zxfv apcu-4.0.7.tgz
cd ~/compile/apcu-4.0.7
phpize
./configure --with-php-config=/ffp/bin/php-config --enable-apcu
make install

#dezactiveaza autentificarea in ~/compile/apcu-4.0.7/apc.php: defaults('USE_AUTHENTICATION',0)
#Nu copia apc.php in /i-data/60cb70cf/www/pages/wordpress/wp-content/plugins/wp-apc-panel/include/ pt ca deja exista!
cp -v ~/compile/apcu-4.0.7/apc.php $HOME/tools/

#show php modules
php -m
 
#Using php5_module with Apache:
LoadModule php5_module /usr/local/zy-pkgs/lib/libphp5.so
Link required: /usr/local/zy-pkgs/php/php.ini -> /ffp/etc/php.ini
PHPIniDir /usr/local/zy-pkgs/php
AddHandler php5-script .php
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps