Compiling mysql 5.6.24

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

NEW_BUILD_NAME=mysql
#NEW_BUILD_VER=5.6.24.large
NEW_BUILD_VER=5.6.24.small+innodb
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/$NEW_BUILD_NAME_AND_VER
tar -xzvf mysql-5.6.24.tar.gz
cd $HOME/compile/$NEW_BUILD_NAME_AND_VER
~/x.sh ffpg

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

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

#large = embedded + archive + federated + blackhole + innodb
#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 -DHAVE_LLVM_LIBCPP=1 -DCMAKE_CXX_FLAGS_RELEASE="$BUILD_FLAGS" -DCMAKE_C_FLAGS_RELEASE="$BUILD_FLAGS" -DHAVE_GCC_ATOMIC_BUILTINS="" -LAH

#small = embedded
#below we have small + innodb
cmake . -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/ffp -DFEATURE_SET=small -DWITH_INNOBASE_STORAGE_ENGINE=1 -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 -DHAVE_LLVM_LIBCPP=1 -DCMAKE_CXX_FLAGS_RELEASE="$BUILD_FLAGS" -DCMAKE_C_FLAGS_RELEASE="$BUILD_FLAGS" -DHAVE_GCC_ATOMIC_BUILTINS="" -LAH

#ERROR (FEATURE_SET=large)
	/ffp/home/root/compile/mysql-5.6.24/sql/sql_table.cc:2020:7: error: 'old_part_info' was not declared in this scope
	   if (old_part_info)
		   ^
	make[2]: *** [sql/CMakeFiles/sql.dir/sql_table.cc.o] Error 1
#SOLUTION
	#Modify /ffp/home/root/compile/mysql-5.6.24/sql/sql_table.cc to this:
	end:
	#ifdef WITH_PARTITION_STORAGE_ENGINE
	  if (old_part_info)
	  {
		lpt->table->file->set_part_info(old_part_info, false);
	  }
	#endif
	DBUG_RETURN(error);

nohup /ffp/bin/make -C . &
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 -v /tmp/$NEW_BUILD_NAME-*.txz
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 nginx 1.9.2

#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=nginx
NEW_BUILD_VER=1.9.1
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 /ffp/home/root/compile/$NEW_BUILD_NAME_AND_VER
~/x.sh ffpg-all
./configure --help > configure.help.txt

#additional modules
#+nginx-dav-ext-module
#+ngx_devel_kit-0.2.19
#+lua-nginx-module-0.9.16rc3
#+echo-nginx-module-0.58
#+rds-json-nginx-module-0.14
#+drizzle-nginx-module-0.1.9
#+set-misc-nginx-module-0.29
#
#--with-pcre-jit -> must be the last

./configure --prefix=/ffp --conf-path=/ffp/etc/nginx/nginx.conf --error-log-path=/ffp/log/nginx-error.log --pid-path=/ffp/var/run/nginx.pid --user=nobody --group=nobody --with-file-aio --with-http_ssl_module --with-http_spdy_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_image_filter_module --with-http_geoip_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_stub_status_module --with-http_perl_module --with-perl=/ffp/bin/perl --http-log-path=/ffp/log/nginx-access.log --http-client-body-temp-path=/ffp/tmp/nginx/client-body --http-proxy-temp-path=/ffp/tmp/nginx/proxy --http-fastcgi-temp-path=/ffp/tmp/nginx/fastcgi --http-uwsgi-temp-path=/ffp/tmp/nginx/uwsgi --http-scgi-temp-path=/ffp/tmp/nginx/scgi --with-stream --with-stream_ssl_module --with-cc=/ffp/bin/cc --with-cpp=/ffp/bin/cpp --with-cpu-opt=armv5te --with-debug --add-module=$HOME/compile/nginx-modules/nginx-dav-ext-module --add-module=$HOME/compile/nginx-modules/ngx_devel_kit-0.2.19 --add-module=$HOME/compile/nginx-modules/set-misc-nginx-module-0.29 --add-module=$HOME/compile/nginx-modules/drizzle-nginx-module-0.1.9 --add-module=$HOME/compile/nginx-modules/echo-nginx-module-0.58 --add-module=$HOME/compile/nginx-modules/rds-json-nginx-module-0.14 --add-module=$HOME/compile/nginx-modules/lua-nginx-module-0.9.16rc3 --with-pcre --with-pcre-jit

#ERROR (lua-nginx-module-0.9.16rc1)
	ngx_http_lua_initworkerby.c:(.text+0x2b8): undefined reference to `ngx_http_set_connection_log'
	objs/addon/src/ngx_http_lua_timer.o: In function `ngx_http_lua_timer_handler':
	ngx_http_lua_timer.c:(.text+0x4c0): undefined reference to `ngx_http_set_connection_log'
#SOLUTION
	sed -i s/"ngx_http_set_connection_log"/"ngx_set_connection_log"/ nginx-modules/lua-nginx-module-0.9.16rc1/src/ngx_http_lua_timer.c
	sed -i s/"ngx_http_set_connection_log"/"ngx_set_connection_log"/ nginx-modules/lua-nginx-module-0.9.16rc1/src/ngx_http_lua_initworkerby.c

#ERROR (drizzle-nginx-module-0.1.8)
	/ffp/home/root/compile/nginx-modules/drizzle-nginx-module-0.1.9/src/ngx_http_drizzle_util.c:607:13: error: 'ngx_http_upstream_state_t' has no member named 'response_sec'
		 u->state->response_sec = tp->sec;
				 ^
	/ffp/home/root/compile/nginx-modules/drizzle-nginx-module-0.1.8/src/ngx_http_drizzle_util.c:608:13: error: 'ngx_http_upstream_state_t' has no member named 'response_msec'
		 u->state->response_msec = tp->msec;
#SOLUTION
	#Replace any "->response_msec" with "->response_time".
	#Comment any line containing: "->response_sec =".
	#Replace any "&& u->state->response_time" with "&& u->state->response_time".
	#Do the above replacements/comments using these commands:
	sed -i s/"\s\s\su->state->response_sec"/"\/\/u->state->response_sec"/g /ffp/home/root/compile/nginx-modules/drizzle-nginx-module-0.1.8/src/ngx_http_drizzle_util.c
	sed -i s/"u->state->response_msec"/"u->state->response_time"/g /ffp/home/root/compile/nginx-modules/drizzle-nginx-module-0.1.8/src/ngx_http_drizzle_util.c
	sed -i s/"u->state->response_sec"/"u->state->response_time"/g /ffp/home/root/compile/nginx-modules/drizzle-nginx-module-0.1.8/src/ngx_http_drizzle_util.c

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

#directories required by nginx in order to run with default settings
mkdir -p /ffp/tmp/nginx/client-body
mkdir -p /ffp/tmp/nginx/proxy
mkdir -p /ffp/tmp/nginx/fastcgi
mkdir -p /ffp/tmp/nginx/uwsgi
mkdir -p /ffp/tmp/nginx/scgi

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 ~/apache-htdocs/ffp_0.7_armv5/packages/$NEW_BUILD_NAME-$NEW_BUILD_VER-arm-$NEW_BUILD_NR.txz

Compiling boost 1.46.0

#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=boost
NEW_BUILD_VER=1.46.0
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 ~/compile
wget http://sourceforge.net/projects/boost/files/boost/1.46.0/boost_1_46_0.tar.gz/download
tar xvzf boost_1_46_0.tar.gz
cd ~/compile/boost_1_46_0
~/x.sh ffpg

ERROR
	Threading support unavaliable: it has been explicitly disabled with BOOST_DISABLE_THREADS
SOLUTION
	cd ~/compile/boost_1_46_0
	wget https://svn.boost.org/trac/boost/raw-attachment/ticket/6165/libstdcpp3.hpp.patch
	patch -p0 -i libstdcpp3.hpp.patch

#for compilation with mpi do:
echo "using mpi ;" >> tools/build/v2/user-config.jam
wget https://svn.boost.org/trac/boost/raw-attachment/ticket/6165/libstdcpp3.hpp.patch
patch -p0 -i libstdcpp3.hpp.patch

./bootstrap.sh

rm -r $HOME/temp/$NEW_BUILD_NAME_AND_VER
#compilation with mpi
#requires http://www.mpich.org/static/downloads/3.1.4/mpich-3.1.4.tar.gz
#or http://www.open-mpi.org/software/ompi/v1.8/
nohup ./bjam --prefix=$HOME/temp/boost-$NEW_BUILD_VER/ffp variant=release install &
#or compile it without mpi:
nohup ./bjam --prefix=$HOME/temp/boost-$NEW_BUILD_VER/ffp --without-mpi variant=release install &

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 ~/apache-htdocs/ffp_0.7_armv5/packages/$NEW_BUILD_NAME-$NEW_BUILD_VER-arm-$NEW_BUILD_NR.txz

Using zyxel utils hooks

#you can't apply/stop one hook; you start/stop all of them with:
/ffp/start/zyxel_utils.sh start/stop

#you enable/disable hook by uncommenting/commenting entries in /ffp/start/zyxel_utils.sh
#e.g. enable nfs hooking:
#uncomment hook_nfs entry in /ffp/start/zyxel_utils.sh

#see zyxel_utils.sh log
cat /tmp/intercept.log

#see active zyxel_utils.sh hooks
cat /tmp/.ffpstick/zyxelutils

#/etc/exports (link to /usr/local/zy-pkgs/etc/exports or /ffp/etc/exports) content:
/i-data/60cb70cf 192.168.1.0/24(ro,sync,no_subtree_check,wdelay,no_root_squash) #hdd1
#mount NFS share to windows 7 (next drive letter available):
mount 192.168.1.31:/i-data/60cb70cf *
#mount NFS share to windows 7 the Z drive:
mount 192.168.1.31:/i-data/60cb70cf z:
#unmount NFS share (–a Unmounts all NFS network drives):
umount z:

#manually start/stop NFS
/usr/local/zy-pkgs/etc/init.d/NFS start
/usr/local/zy-pkgs/etc/init.d/NFS stop

Compiling LuaJIT-2.0.3

#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=LuaJIT
NEW_BUILD_VER=2.0.3
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 /ffp/home/root/compile/LuaJIT-2.0.3
~/x.sh ffpg
sed -i s/"PREFIX= \/usr\/local"/"PREFIX= \/ffp"/ Makefile
make

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 ~/apache-htdocs/ffp_0.7_armv5/packages/$NEW_BUILD_NAME-$NEW_BUILD_VER-arm-$NEW_BUILD_NR.txz

Compiling and using luarocks

#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=luarocks
NEW_BUILD_VER=2.2.2
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 /ffp/home/root/compile/luarocks-2.2.2
~/x.sh ffpg
./configure --help > configure.help.txt
./configure --prefix=/ffp
make build

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 ~/apache-htdocs/ffp_0.7_armv5/packages/$NEW_BUILD_NAME-$NEW_BUILD_VER-arm-$NEW_BUILD_NR.txz

#using luarocks
luarocks search cjson
luarocks install lua-cjson --deps-mode all
luarocks install router --deps-mode all
#*.lua rocks are installed to /ffp/share/lua/5.1/
#*.so rocks are installed to /ffp/lib/lua/5.1/

#nginx configuration
lua_package_cpath	'/ffp/lib/lua/5.1/?.so;;';
lua_package_path	'/ffp/share/lua/5.1/?.lua;;';

#using router; for some versions ngx.var.request_method must be lower-case: 
router:execute(string.lower(ngx.var.request_method), ngx.var.restPaths)

Compiling nginx 1.9.0

#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=nginx
NEW_BUILD_VER=1.9.0
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=1

cd /ffp/home/root/compile/nginx-1.9.0
~/x.sh ffpg
./configure --help > configure.help.txt

#additional modules
#+nginx-dav-ext-module
#+ngx_devel_kit-0.2.19
#+lua-nginx-module-0.9.16rc1
#+echo-nginx-module-0.57
#+rds-json-nginx-module
#+drizzle-nginx-module
#
#--with-pcre-jit -> must be the last

./configure --prefix=/ffp --conf-path=/ffp/etc/nginx/nginx.conf --error-log-path=/ffp/log/nginx-error.log --pid-path=/ffp/var/run/nginx.pid --user=nobody --group=nobody --with-file-aio --with-http_ssl_module --with-http_spdy_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_image_filter_module --with-http_geoip_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_stub_status_module --with-http_perl_module --with-perl=/ffp/bin/perl --http-log-path=/ffp/log/nginx-access.log --http-client-body-temp-path=/ffp/tmp/nginx/client-body --http-proxy-temp-path=/ffp/tmp/nginx/proxy --http-fastcgi-temp-path=/ffp/tmp/nginx/fastcgi --http-uwsgi-temp-path=/ffp/tmp/nginx/uwsgi --http-scgi-temp-path=/ffp/tmp/nginx/scgi --with-cc=/ffp/bin/cc --with-cpp=/ffp/bin/cpp --with-cpu-opt=armv5te --with-debug --add-module=$HOME/compile/nginx-modules/nginx-dav-ext-module --add-module=$HOME/compile/nginx-modules/ngx_devel_kit-0.2.19 --add-module=$HOME/compile/nginx-modules/drizzle-nginx-module --add-module=$HOME/compile/nginx-modules/echo-nginx-module-0.57 --add-module=$HOME/compile/nginx-modules/rds-json-nginx-module --add-module=$HOME/compile/nginx-modules/lua-nginx-module-0.9.16rc1 --with-pcre --with-pcre-jit

ERROR
	ngx_http_lua_initworkerby.c:(.text+0x2b8): undefined reference to `ngx_http_set_connection_log'
	objs/addon/src/ngx_http_lua_timer.o: In function `ngx_http_lua_timer_handler':
	ngx_http_lua_timer.c:(.text+0x4c0): undefined reference to `ngx_http_set_connection_log'
SOLUTION
	sed -i s/"ngx_http_set_connection_log"/"ngx_set_connection_log"/ nginx-modules/lua-nginx-module-0.9.16rc1/src/ngx_http_lua_timer.c
	sed -i s/"ngx_http_set_connection_log"/"ngx_set_connection_log"/ nginx-modules/lua-nginx-module-0.9.16rc1/src/ngx_http_lua_initworkerby.c

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

#directories required for nginx to run with default settings
mkdir -p /ffp/tmp/nginx/client-body
mkdir -p /ffp/tmp/nginx/proxy
mkdir -p /ffp/tmp/nginx/fastcgi
mkdir -p /ffp/tmp/nginx/uwsgi
mkdir -p /ffp/tmp/nginx/scgi

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 ~/apache-htdocs/ffp_0.7_armv5/packages/$NEW_BUILD_NAME-$NEW_BUILD_VER-arm-$NEW_BUILD_NR.txz