# Depends on gcc95
# Depends on yasm >= 1.2.0
# Depends on python2
# Depends on which
# Depends on unzip
# Depends on zip
# Depends on gtk2
# Depends on dbus-glib
# Requires 4GB+ RAM
# Requires 2GB+ free disk space

# Exit on error:
set -e

echo
echo To fix errors:
echo pale-moon/obj-i686-pc-linux-gnu/build/unix/elfhack/elfhack:
echo /lib/libstdc++.so.6: version 'CXXABI_1.3.8' not found
echo /lib/libstdc++.so.6: version 'CXXABI_1.3.9' not found
echo /lib/libstdc++.so.6: version 'GLIBCXX_3.4.21' not found
echo
echo Be sure to use GCC 9.5.0 version of libstdc++.so.6
echo '(which is in /bloat/lib in GLLFSC).'
echo As root:
echo ldconfig /bloat/lib
echo

# Be verbose:
set -v

sleep 10s

# 5.4MB:
wget https://repo.palemoon.org/MoonchildProductions/Pale-Moon/archive/33.8.2_Release.tar.gz

# 253MB:
wget https://repo.palemoon.org/MoonchildProductions/UXP/archive/RC_20250820.tar.gz

tar xf 33.8.2_Release.tar.gz

tar xf RC_20250820.tar.gz
mv uxp/* pale-moon/platform
mv uxp/.[a-z]* pale-moon/platform
rmdir uxp

cd pale-moon

cat > .mozconfig << EOF
# Use this if 64bit build:
#_BUILD_64=1

_GTK_VERSION=2

# Standard build options for Pale Moon
ac_add_options --enable-application=palemoon
ac_add_options --enable-optimize="-O2 -w"
ac_add_options --enable-default-toolkit=cairo-gtk2
ac_add_options --enable-jemalloc
ac_add_options --enable-strip
ac_add_options --enable-devtools
ac_add_options --enable-av1
ac_add_options --enable-jxl
ac_add_options --disable-webrtc
ac_add_options --disable-gamepad
ac_add_options --disable-tests
ac_add_options --disable-debug
ac_add_options --disable-necko-wifi
ac_add_options --disable-updater
ac_add_options --with-pthreads

# Please see https://www.palemoon.org/redist.shtml for restrictions when using the official branding.
ac_add_options --enable-official-branding
export MOZILLA_OFFICIAL=1

# Comment out the --x-libraries to avoid error
# 0:22.29 Unified_cpp_media_libstagefright0.cpp:(.text+0xab1): undefined reference to '__divmoddi4'
#ac_add_options --x-libraries=/usr/lib

export MOZ_PKG_SPECIAL=gtk2

# Is GCONF really useful?
ac_add_options --disable-gconf

# Is Pulseaudio really useful?
ac_add_options --disable-pulseaudio

# To use GCC 9.5 (installed in /bloat/bin):
export PATH=/usr/lib/pkgusr:/bloat/bin:/local/bin:/bin

# Fix
# /bin/ld: failed to set dynamic section sizes: Memory exhausted
ac_add_options --disable-debug-symbols

EOF

# Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
export PYTHONHOME=/usr

# Building time: 30 minutes on Intel Core i5-3570 CPU @ 3.40 GHz with 8 GB RAM
./mach build 2>&1 | tee mach-build.log

echo
echo It\'s now time to test binary located in:
echo pale-moon/obj-i686-pc-linux-gnu/dist/bin/palemoon
echo

exit 0

#./mach run

# 4 minutes
./mach package
cp obj-i686-pc-linux-gnu/dist/palemoon-33.8.2.linux-i686-gtk2.tar.xz ..
cd ..

rm RC_20250820.tar.gz
rm 32.5.1_Release.tar.gz

tar xf pale-moon/obj-i686-pc-linux-gnu/dist/palemoon-33.8.2.linux-i686-gtk2.tar.xz \
    -C /lib
mv /lib/palemoon{,-33.8.2}
ln -sv /lib/palemoon-33.8.2/palemoon /bin/palemoon

exit 0

http://developer.palemoon.org/build/Linux/

At least 6 GB RAM free depending on number of processor cores
(limit using the mk_add_options MOZ_MAKE_FLAGS="-jN" option)

GCC Compatibility
14.x 	Generally Considered Stable 	Mid-term tested.
13.x 	Generally Considered Stable 	Mid-term tested.
12.x 	Generally Considered Stable 	Mid-term tested.
11.x 	Recommended 	Long-term tested. Currently in-use for MCP Applications.
10.x 	Deprecated 	Mid-term tested.
9.x 	Deprecated 	Long-term tested.
<=8.x 	Unsupported
