Licenses: PHP in the app
The Mailgist app for Mac and Windows runs on a bundled PHP interpreter. It contains libraries under the GNU LGPL 2.1 — you may modify them, rebuild PHP and put your own build into the installed app. Below: what is included, how we build PHP and how to replace it.
What is included and under which licenses
- PHP 8.5.12 — PHP License 3.01. Sources: php-8.5.12.tar.xz, github.com/php/php-src.
- libmbfl (inside the mbstring extension, Mac and Windows) — GNU LGPL 2.1. Sources are in the PHP tree: ext/mbstring/libmbfl.
- GNU libiconv (Windows only, inside the official PHP build, in
php8.dll) — GNU LGPL 2.1. Sources: gnu.org/software/libiconv; the variant used to build PHP for Windows — github.com/winlibs/libiconv. - On Mac, PHP contains no GNU libiconv: iconv comes from macOS itself (
/usr/lib/libiconv.2.dylib). - Other libraries inside PHP (libxml2, OpenSSL, curl, SQLite, libzip, libsodium, Oniguruma, zlib) are under permissive licenses (MIT, Apache 2.0, BSD, ISC, public domain); their texts are in the sources linked above.
Mac: how we build PHP
PHP for Mac is built statically with static-php-cli 2.8.5 (MIT), then rebuilt against the system iconv. You need macOS 14+ and the Xcode Command Line Tools.
- Download spc and verify its sha256:
curl -LO https://github.com/crazywhalecc/static-php-cli/releases/download/2.8.5/spc-macos-aarch64.tar.gz shasum -a 256 spc-macos-aarch64.tar.gz # Apple Silicon: acf2f25d56d0cbf8e65aa82e5054fef555f7be7c5c38046c6e0819f266d83225 # Intel (spc-macos-x86_64.tar.gz): e8b798048f62ca4960764196543b60ae703f7174aa418824cf542aeec1d2cd6a tar xzf spc-macos-aarch64.tar.gz - Build PHP with the same extensions:
EXTS="ctype,curl,dom,fileinfo,filter,iconv,mbstring,mbregex,openssl,pcntl,pdo,pdo_sqlite,phar,posix,session,simplexml,sodium,sqlite3,tokenizer,xml,xmlreader,xmlwriter,zip,zlib" ./spc doctor --auto-fix ./spc download --with-php=8.5.12 --for-extensions="$EXTS" --prefer-pre-built ./spc build --build-cli "$EXTS" - Our relink step with the macOS iconv (so that GNU libiconv is not linked in):
- remove
libiconv.*,libcharset.*, their.pcfiles and the headersiconv.h,libcharset.h,localcharset.hfrombuildroot; - rebuild libxml2 with the same cmake command from the spc log (
log/spc.shell.log), adding-DIconv_IS_BUILT_IN=FALSE -DIconv_INCLUDE_DIR=$(xcrun --show-sdk-path)/usr/include -DIconv_LIBRARY=$(xcrun --show-sdk-path)/usr/lib/libiconv.tbd, and remove-liconvfromlibxml-2.0.pc; - in
source/php-src:make clean,./configurewith the arguments from./config.status --config, with--with-iconv=replaced by$(xcrun --show-sdk-path)/usr, then the samemake … clicommand from the spc log, without-lcharset; strip -S sapi/cli/php, delete the rpath entries (install_name_tool -delete_rpath) and sign ad hoc:codesign -f -s - php.
- remove
- Check:
otool -L phpshows/usr/lib/libiconv.2.dylib, andphp -mlists all the extensions.
To use a modified libmbfl, change the sources in source/php-src/ext/mbstring/libmbfl and repeat the last PHP build step. We will send our complete build script on request.
Windows: which PHP we use
On Windows we use the official build from windows.php.net, unmodified: php-8.5.12-nts-Win32-vs17-x64.zip, sha256 2ab242af38d76bdf417cde5ec048b1bcd76a5a40f39a3d15d5f046f38571c477. From it we take php.exe, the core DLLs and the curl, fileinfo, mbstring, openssl, pdo_sqlite, sodium, sqlite3 and zip extensions.
Sources of this build: php-8.5.12-src.zip; build tools — php-sdk-binary-tools; dependency libraries (including libiconv) — downloads.php.net/~windows/php-sdk/deps. The build procedure is in the PHP guide.
How to replace PHP in the installed app
- Mac. Quit Mailgist. The file is
/Applications/Mailgist.app/Contents/MacOS/php. Replace it with your build and re-sign the app:codesign --force --deep --sign - /Applications/Mailgist.app. This removes the developer signature, so macOS may ask for confirmation on the next launch. - Windows. Quit Mailgist. The folder is
%LOCALAPPDATA%\Mailgist\php\. Replacephp.exe,php8.dllorext\php_mbstring.dllwith your own files built from the same PHP version.
An app update restores our build — repeat the replacement afterwards. Use the same PHP version and the same set of extensions, otherwise the app may fail to start.
Copy of the sources
On request to support@mailgist.app we will send a copy of the sources of the LGPL libraries and PHP in exactly the versions included in the app, together with our build script. This offer is valid for at least three years from the release of each app version.