-
-
Save jordiwes/a73074e7066f085c738d40a7a9a5eb68 to your computer and use it in GitHub Desktop.
Compile iconv php extension on IBMi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#1 get latest iconv php extension which is included in the php-src | |
git clone http://git.php.net/repository/php-src.git | |
#2.0 find your PHP Version | |
php -v | |
#2.1 check out your specific branch of PHP | |
git checkout PHP-5.6.7 | |
#3 If you dont have libiconv.a, Get libiconv from perzl and then fix it | |
wget http://www.oss4aix.org/download/RPMS/libiconv/libiconv-1.14-3.aix5.1.ppc.rpm | |
rpm --ignoreos --ignorearch --nodeps --replacepkgs --oldpackage -hUv libiconv-1.14-3.aix5.1.ppc.rpm | |
#4 tonys code on fixing libiconv | |
ar -x /QOpenSys/usr/lib/libiconv.a | |
# Argh Matie, we be needin' to make a ugly baby to fool the IFS Kraken | |
cp /opt/freeware/lib/libiconv.a /opt/freeware/lib/libiconv-lady-in-waiting.a | |
#ar -rv /opt/freeware/lib/libiconv-lady-in-waiting.a shr4.o | |
ar -rv /opt/freeware/lib/libiconv-lady-in-waiting.a /QOpenSys/litmis/ibmichroot/shr4.o | |
#ar -rv /opt/freeware/lib/libiconv-lady-in-waiting.a shr.o | |
ar -rv /opt/freeware/lib/libiconv-lady-in-waiting.a /QOpenSys/litmis/ibmichroot/shr.o | |
rm /opt/freeware/lib/libiconv.a | |
cp /opt/freeware/lib/libiconv-lady-in-waiting.a /opt/freeware/lib/libiconv.a | |
#5 change directory to where php-src was downloaded and go to the iconv extension directory | |
cd php-src/ext/iconv | |
#6 make a copy of our current iconv.so extension (so you can revert back if needed) | |
cp /usr/local/zendsvr/lib/php_extensions/iconv.so /usr/local/zendsvr/lib/php_extensions/iconv.so-orig | |
#7 setup environment variables for configure and make | |
export IBM_DB_HOME=/usr | |
export PHP_HOME=/usr/local/phpdave7 | |
export PASE_TOOLS_HOME=/QOpenSys/usr | |
export AIX_TOOLS_HOME=/usr/local | |
export PATH=$PATH:$PHP_HOME/bin:$PASE_TOOLS_HOME/bin:$AIX_TOOLS_HOME/bin | |
export LIBPATH=$PHP_HOME/lib:$PASE_TOOLS_HOME/lib:$AIX_TOOLS_HOME/lib | |
export CC=gcc | |
export CFLAGS="-DPASE -I=.:$PHP_HOME/php/include" | |
export CCHOST=powerpc-ibm-aix6.1.0.0 | |
#8 check the gcc version | |
gcc -v | |
Target: powerpc-ibm-aix6.1.0.0 ... used in CCHOST above | |
#9 compile php extension by running: | |
#phpize, configure, gmake, gmake test, and gmake install | |
aclocal && phpize && ./configure --build=$CCHOST --host=$CCHOST --target=$CCHOST && gmake && gmake test && gmake install | |
#"gmake install"s it to /usr/local/phpdave7/lib/php/extensions/no-debug-non-zts-20160303/iconv.so | |
#10 -d will force temporary loading the extension (add extension=iconv.so to permenantly always load it) --ri display the configuration of an extension | |
php -dextension=iconv.so --ri iconv | |
#11 check what php extension modules are loaded | |
php -m | |
#12 edit php.ini to tell PHP to load iconv php extension by adding extension=iconv.so | |
echo "extension=iconv.so" >> /usr/local/lib/php.ini | |
#::NOTES:: | |
#if you have two libiconv.a you'll have to fix that or the libpath might cause issues | |
#common symbolic links | |
#ln -sf /QOpenSys/opt/freeware/bin /usr/local/bin | |
#ln -sf /QOpenSys/opt/freeware/lib /usr/local/lib | |
#Rather not create hard links try and figure alternative | |
export PATH=/opt/freeware/bin:$PATH | |
#Had to remove LIBPATH w/ $PASE_TOOLS_HOME because it was using the wrong libiconv | |
#export LIBPATH=/usr/local/phpdave7/lib:/usr/local/lib | |
#php -v | |
#Could not load program php: | |
# Dependent module /QOpenSys/usr/lib/libiconv.a(libiconv.so.2) could not be loaded. | |
# Member libiconv.so.2 is not found in archive | |
##had to create symlink to glink.o which was missing when i started compiling | |
#ln -s /QOpenSys/usr/lib/glink.o /usr/lib/glink.o | |
#note depending on how PHP is configured on your system their will be either be a debug build or Zend Thread Safety (ZTS) builds of the extension | |
#$PREFIX/lib/php/extensions/no-debug-non-zts-API_NO for release builds without ZTS | |
#$PREFIX/lib/php/extensions/debug-non-zts-API_NO for debug builds without ZTS | |
#$PREFIX/lib/php/extensions/no-debug-zts-API_NO for release builds with ZTS | |
#$PREFIX/lib/php/extensions/debug-zts-API_NO for debug builds with ZTS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment