# Recipe for version 2.0.0.3 by Lucas C. Villa Real, on Sat May 26 15:09:21 BRT 2007
# Recipe (MakeRecipe) for Firefox by Jonas Karlsson <jonka750@student.liu.se>, on Sun May 1 10:13:41 CEST 2005
compile_version=1.8.2
url="ftp://ftp.mozilla.org/pub/mozilla.org/firefox/releases/2.0.0.3/source/firefox-2.0.0.3-source.tar.bz2"
file_size=37135441
file_md5=24398e3d98673a2a92a01a8f771ca12a
dir='mozilla'
recipe_type=configure

# Let plugins be found in runtime at $goboLibraries/mozilla
build_variables=(
    mozappdir=$goboLibraries/mozilla
    MOZAPPDIR=$goboLibraries/mozilla
)
install_variables=(
    mozappdir=$target/lib/mozilla
    MOZAPPDIR=$target/lib/mozilla
)

configure_options=(
    --includedir=$target/include/mozilla
    --enable-application=browser   # It's the browser Firefox we want to build, right?
    --enable-default-toolkit=gtk2  # Use gtk+ 2.x instead of gtk+ 1.x

    --enable-xft

    --with-system-zlib             # These options are used so that the Firefox binaries are linked to
    --with-system-png              # the system-installed copies of the specified libraries instead of
    --with-system-jpeg             # the source tree code which may not be the most recent versions.

#    --enable-official-branding     # This option causes the installed binaries to have the official Firefox name embedded in them. 
# Due to license restrictions, you may not distribute binaries created using this option.

    --with-distribution-id=GoboLinux

    --enable-strip                 # This option is used so that the debugging symbols are removed from the
    --enable-optimize              # installed binaries during the installation process. Comment out this option
    --disable-debug                # if you may have a need to retain the debugging symbols in the installed binaries.

    --disable-tests                # This option is added so that test libraries and programs are not built.
    --disable-installer            # This option is added so that the Mozilla Installer program is not built or installed.
    --disable-accessibility        # Disable the a11y support. Comment out this option if you require a11y support.
)

pre_build()
{
    # Fix an anonymous enum in an external/public interface header file
    sed -i "s/^    enum$/& xptinfo_enum_1/" xpcom/reflect/xptinfo/public/xptinfo.h
}

pre_link()
{
    mkdir -p ${target}/Shared/applications
    cp $recipedir/firefox.desktop ${target}/Shared/applications
}

post_install()
{
    # Give Firefox an icon while minimized
    install -v -m755 -o0 -g0 -d ${target}/lib/mozilla/chrome/icons/default
    ln -v -s ../../../icons/default.xpm ${target}/lib/mozilla/chrome/icons/default
    
    # Changes the ownership of some installed files to more appropriate user:group names
    chown -v -R 0:0 ${target}/lib/mozilla/extensions/inspector@mozilla.org/*
    
    # install some additional LDAP interface headers
    install -v -m644 -o0 -g0 firefox-build/dist/public/ldap-private/* ${target}/include/mozilla/ldap
    
    # replace the broken nss files with symbolic links to known good files
    ln -v -sf ${goboLibraries}/pkgconfig/nss.pc ${target}/lib/pkgconfig/firefox-nss.pc
    ln -v -sf ${goboLibraries}/pkgconfig/nspr.pc ${target}/lib/pkgconfig/firefox-nspr.pc

    # Shortcut to the icon
    mkdir -p ${target}/Shared/icons/firefox
    cp ${target}/lib/mozilla/icons/mozicon128.png ${target}/Shared/icons/firefox
}
