diff --git a/CMakeLists.txt b/CMakeLists.txt index 5f7bd59..423b84f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -173,6 +173,9 @@ add_custom_command( COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/php/libcrypto.3.dylib" "${PHPDESKTOP_APP}/Contents/MacOS/libcrypto.3.dylib" + COMMAND ${CMAKE_COMMAND} -E copy + "${CMAKE_CURRENT_SOURCE_DIR}/php/libiconv.2.dylib" + "${PHPDESKTOP_APP}/Contents/MacOS/libiconv.2.dylib" COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/php/libxml2.2.dylib" "${PHPDESKTOP_APP}/Contents/MacOS/libxml2.2.dylib" diff --git a/README.md b/README.md index 45b0fea..42547e6 100644 --- a/README.md +++ b/README.md @@ -10,11 +10,13 @@ 1. Install PHP build dependencies. See https://www.php.net/manual/en/install.unix.source.php . 1. Best to disable Homebrew or similar package managers, so that dependencies are portable. 1. Download OpenSSL sources and extract it in the "phpdesktop/php/" directory. See https://github.com/openssl/openssl/releases . +1. Download libiconv sources and extract in php/ directory. See https://www.gnu.org/software/libiconv/ . 1. Download libxml2 official distribution tarball (tar.xz) and extract in php/ directory. See https://gitlab.gnome.org/GNOME/libxml2/-/releases . 1. Download sqlite sources and extract in php/ directory. See https://www.sqlite.org/download.html . 1. Download zlib 1.3.1 sources and extract in php/ directory. See https://github.com/madler/zlib/releases . 1. Download PHP sources and extract it in the "phpdesktop/php/" directory. See https://www.php.net/downloads.php . 1. RUn `buildopenssl.sh` script. +1. Run `buildiconv.sh` script. 1. Run `buildxml.sh`script. 1. Run `buildsqlite.sh` script. 1. Run `buildzlib.sh` script. diff --git a/buildiconv.sh b/buildiconv.sh new file mode 100755 index 0000000..3cbbf57 --- /dev/null +++ b/buildiconv.sh @@ -0,0 +1,38 @@ +# Download sources from: https://www.gnu.org/software/libiconv/ +# Then extract in php/ directory. + +# Exit immediately if a command exits with a non-zero status. +set -e + +# Print all executed commands to terminal. +set -x + +clear && clear + +root_dir=$(realpath $(dirname $0)) +echo "root_dir=$root_dir" + +if ! cd $root_dir/php/ ; then + echo "php/ directory doesn't exist" + exit 1 +fi +rm -f libiconv.2.dylib + +if ! cd $root_dir/php/libiconv-*/ ; then + echo "Can't find iconv directory" + exit 1 +fi +iconv_dir=$(realpath $(pwd)) +echo "Found iconv: ${iconv_dir}" + +echo "Configure iconv..." +./configure \ + --prefix=${iconv_dir}/dist-install \ + --exec-prefix=${iconv_dir}/dist-install +echo "Build iconv..." +make install + +cp ./dist-install/lib/libiconv.2.dylib ./../libiconv.2.dylib +install_name_tool -id libiconv.2.dylib ./../libiconv.2.dylib + +echo "Done." diff --git a/buildphp.sh b/buildphp.sh index f2bc8a6..5e23552 100755 --- a/buildphp.sh +++ b/buildphp.sh @@ -48,6 +48,13 @@ fi openssl_dir=$(realpath $(pwd)) echo "Found OpenSSL: ${openssl_dir}" +if ! cd $root_dir/php/libiconv-*/ ; then + echo "Can't find iconv directory" + exit 1 +fi +iconv_dir=$(realpath $(pwd)) +echo "Found iconv: ${iconv_dir}" + if ! cd $root_dir/php/libxml2-*/ ; then echo "Can't find libxml2 directory" exit 1 @@ -77,38 +84,40 @@ php_dir=$(realpath $(pwd)) echo "Found PHP: ${php_dir}" echo "Configure PHP..." +cp $sqlite_dir/dist-install/lib/libsqlite3.dylib ./libsqlite3.dylib # To get around bug in conftest export EXTRA_CFLAGS="-Wno-unused-command-line-argument -lresolv" # To get around bug: uresolved symbol "_res_9_dn_expand". export OPENSSL_CFLAGS="-I${openssl_dir}/dist-install/include" export OPENSSL_LIBS="-L${openssl_dir}/dist-install/lib -lcrypto -lssl" export LIBXML_CFLAGS="-I${libxml2_dir}/dist-install/include" -export LIBXML_LIBS="-L${libxml2_dir}/dist-install-exec-prefix/lib -lxml2" +export LIBXML_LIBS="-L${libxml2_dir}/dist-install/lib -lxml2" export SQLITE_CFLAGS="-I${sqlite_dir}/dist-install/include" export SQLITE_LIBS="-L${sqlite_dir}/dist-install/lib -lsqlite3" export ZLIB_CFLAGS="-I${zlib_dir}/dist-install/include" -export ZLIB_LIBS="-L${zlib_dir}/dist-install-exec-prefix/lib -lz" -./configure \ +export ZLIB_LIBS="-L${zlib_dir}/dist-install/lib -lz" +./configure -v \ --prefix=${php_dir}/dist-install \ - --exec-prefix=${php_dir}/dist-install-exec-prefix \ + --exec-prefix=${php_dir}/dist-install \ --with-mysqli \ --with-openssl \ - --without-iconv + --with-iconv="$iconv_dir/dist-install" echo "Build PHP..." make install -cp ./dist-install-exec-prefix/bin/php-cgi ./../php-cgi +cp ./dist-install/bin/php-cgi ./../php-cgi cp $root_dir/php.ini $root_dir/php/php.ini cd $root_dir/php/ install_name_tool -rpath $openssl_dir/dist-install/lib @loader_path/. php-cgi -install_name_tool -delete_rpath $libxml2_dir/dist-install-exec-prefix/lib php-cgi +install_name_tool -delete_rpath $libxml2_dir/dist-install/lib php-cgi install_name_tool -delete_rpath $sqlite_dir/dist-install/lib php-cgi -install_name_tool -delete_rpath $zlib_dir/dist-install-exec-prefix/lib php-cgi +install_name_tool -delete_rpath $zlib_dir/dist-install/lib php-cgi install_name_tool -change $openssl_dir/dist-install/lib/libcrypto.3.dylib libcrypto.3.dylib php-cgi install_name_tool -change $openssl_dir/dist-install/lib/libssl.3.dylib libssl.3.dylib php-cgi -install_name_tool -change $libxml2_dir/dist-install-exec-prefix/lib/libxml2.2.dylib libxml2.2.dylib php-cgi +install_name_tool -change $iconv_dir/dist-install/lib/libiconv.2.dylib libiconv.2.dylib php-cgi +install_name_tool -change $libxml2_dir/dist-install/lib/libxml2.2.dylib libxml2.2.dylib php-cgi install_name_tool -change $sqlite_dir/dist-install/lib/libsqlite3.dylib libsqlite3.dylib php-cgi -install_name_tool -change $zlib_dir/dist-install-exec-prefix/lib/libz.1.dylib libz.1.3.1.dylib php-cgi +install_name_tool -change $zlib_dir/dist-install/lib/libz.1.dylib libz.1.3.1.dylib php-cgi echo "Done." diff --git a/buildsqlite.sh b/buildsqlite.sh index d38fbc1..da6ea78 100755 --- a/buildsqlite.sh +++ b/buildsqlite.sh @@ -32,7 +32,7 @@ echo "Configure sqlite..." echo "Build sqlite..." make install -cp ./dist-install/lib/libsqlite3.dylib ./../libsqlite3.dylib +cp ./dist-install/lib/libsqlite3.dylib.3.* ./../libsqlite3.dylib install_name_tool -id libsqlite3.dylib ./../libsqlite3.dylib install_name_tool -delete_rpath $sqlite_dir/dist-install/lib ./../libsqlite3.dylib diff --git a/buildxml.sh b/buildxml.sh index 2d6d92c..a02cedf 100755 --- a/buildxml.sh +++ b/buildxml.sh @@ -18,6 +18,13 @@ if ! cd $root_dir/php/ ; then fi rm -f libxml2.2.dylib +if ! cd $root_dir/php/libiconv-*/ ; then + echo "Can't find iconv directory" + exit 1 +fi +iconv_dir=$(realpath $(pwd)) +echo "Found iconv: ${iconv_dir}" + if ! cd $root_dir/php/libxml2-*/ ; then echo "Can't find libxml2 directory" exit 1 @@ -28,12 +35,14 @@ echo "Found Libxml2: ${libxml2_dir}" echo "Configure libxml2..." ./configure \ --prefix=${libxml2_dir}/dist-install \ - --exec-prefix=${libxml2_dir}/dist-install-exec-prefix \ - --without-python + --exec-prefix=${libxml2_dir}/dist-install \ + --without-python \ + --with-iconv="$iconv_dir/dist-install" echo "Build libxml2..." make install -cp ./dist-install-exec-prefix/lib/libxml2.2.dylib ./../libxml2.2.dylib +cp ./dist-install/lib/libxml2.2.dylib ./../libxml2.2.dylib install_name_tool -id libxml2.2.dylib ./../libxml2.2.dylib +install_name_tool -change $iconv_dir/dist-install/lib/libiconv.2.dylib libiconv.2.dylib ./../libxml2.2.dylib echo "Done." diff --git a/buildzlib.sh b/buildzlib.sh index 92806e0..5950a3b 100755 --- a/buildzlib.sh +++ b/buildzlib.sh @@ -28,11 +28,11 @@ echo "Found zlib: ${zlib_dir}" echo "Configure zlib..." ./configure \ --prefix=${zlib_dir}/dist-install \ - --eprefix=${zlib_dir}/dist-install-exec-prefix + --eprefix=${zlib_dir}/dist-install echo "Build zlib..." make install -cp ./dist-install-exec-prefix/lib/libz.1.3.1.dylib ./../libz.1.3.1.dylib +cp ./dist-install/lib/libz.1.3.1.dylib ./../libz.1.3.1.dylib install_name_tool -id libz.1.3.1.dylib ./../libz.1.3.1.dylib echo "Done."