Download standard libraries in a zipfile. ### Description

This is a re-work of #3166. After this PR, the standard libraries are not vendored with `pyodide.asm.data`. Instead, it is now downloaded separately in a zip file similar to how we download pyodide_py.tar.

~~The hard part of this PR is to bootstrap Python without Python source codes. This requires deep-freezing all modules that are required during the bootstrap.~~

~~As mentioned in #3539, `encodings` module is needed during the bootstrap stage, but it is a large module (> 1.0MB) containing a bunch of encodings in the world, so I tried to freeze a subset of the encodings module that is used in the bootstrap (thanks for the idea from Hood), so the size increase of pyodide.asm.wasm is only 70KB.~~

~~However, the problem of freezing only part of the module is that the current Python import system does not support it. Therefore, I added some hacks to make it work, which is explained in a comment in pyodide.ts.~~

### File size change after this PR:

Before

```
- pyodide.asm.data:
    Original size: 4555 KB
    Gzip compressed size (level 1): 3062 KB
    Gzip compressed size (level 6): 2911 KB
    Gzip compressed size (level 9): 2911 KB
    Brotli compressed size: 2522 KB
- pyodide.asm.js:
    Original size: 1186 KB
    Gzip compressed size (level 1): 246 KB
    Gzip compressed size (level 6): 208 KB
    Gzip compressed size (level 9): 208 KB
    Brotli compressed size: 169 KB
- pyodide.asm.wasm:
    Original size: 8715 KB
    Gzip compressed size (level 1): 3142 KB
    Gzip compressed size (level 6): 2791 KB
    Gzip compressed size (level 9): 2791 KB
    Brotli compressed size: 2096 KB
```

After

```
- pyodide.asm.data:
    Original size: 4 KB
    Gzip compressed size (level 1): 0 KB
    Gzip compressed size (level 6): 0 KB
    Gzip compressed size (level 9): 0 KB
    Brotli compressed size: 0 KB
- pyodide.asm.js:
    Original size: 1086 KB
    Gzip compressed size (level 1): 213 KB
    Gzip compressed size (level 6): 177 KB
    Gzip compressed size (level 9): 177 KB
    Brotli compressed size: 145 KB
- pyodide.asm.wasm:
    Original size: 8775 KB
    Gzip compressed size (level 1): 3162 KB
    Gzip compressed size (level 6): 2806 KB
    Gzip compressed size (level 9): 2806 KB
    Brotli compressed size: 2105 KB
- python_stdlib.zip:
    Original size: 2230 KB
    Gzip compressed size (level 1): 2196 KB
    Gzip compressed size (level 6): 2194 KB
    Gzip compressed size (level 9): 2194 KB
    Brotli compressed size: 2181 KB
```


### Remaining works:

- remove pyodide.asm.data: the only remaining parts inside pyodide.asm.data is our [webbrowser.py](https://github.com/pyodide/pyodide/blob/main/src/py/lib/webbrowser.py) stub, I think we can either remove it or move it into pyodide_py.
- maybe merge pyodide_py.tar into the standard libraries zipfile.
- add option to use pycompiled standard libraries.

### Checklists

- [x] Add a [CHANGELOG](https://github.com/pyodide/pyodide/blob/main/docs/project/changelog.md) entry
- [x] Add / update tests

#!/bin/sh

# Based on http://hpc.sourceforge.net/buildf2c with curl replaced by wget

############################################################

# This UNIX script builds the f2c FORTRAN --> C translator #

# under Mac OS X.                                          #

# Make this script executable with "chmod +x buildf2c"     #

############################################################

echo "==================================="

echo "Build f2c FORTRAN --> C translator."

echo "==================================="

echo "USAGE:  ./buildf2c"



######################################

# Set trap to allow abort on signal: #

######################################

trap 'echo "Interrupted by signal" >&2; exit' 1 2 3 15



########################################################

# 1. Download f2c source from Bell Labs.               #

# (Tar file is not visible - it's created on the fly.) #

########################################################

echo "--------------------------------------------"

echo "1. Downloading f2c source from Bell Labs ..."

echo "--------------------------------------------"

# wget --passive-ftp ftp://netlib.bell-labs.com/netlib/f2c.tar

wget http://hpc.sourceforge.net/f2c.tar -O "f2c.tar"

echo "... done."



#####################################

# 2. Uncompress f2c tarred archive: #

#####################################

echo "-------------------------------"

echo "2. Uncompressing f2c source ..."

echo "-------------------------------"

tar -xvf f2c.tar

gunzip -rf f2c/*

(cd f2c && unzip libf2c.zip -d libf2c)

echo "... done."



###############################################################

# 3. Prepare the unix makefiles for building the f2c library. #

#    Note: CC compiler switched from 'cc' to '/usr/bin/cc'   #

###############################################################

echo "-------------------------------------------"

echo "3. Preparing makefiles for building f2c ..."

echo "-------------------------------------------"

sed 's/CC = cc/CC = \/usr\/bin\/cc/' f2c/libf2c/makefile.u > f2c/libf2c/makefile

sed 's/CC = cc/CC = \/usr\/bin\/cc/' f2c/src/makefile.u > f2c/src/makefile

echo "... done."



##########################################

# 4. Create and install f2c header file. #

# If you use a C++ compiler:  make hadd  #

# Otherwise:                  make f2c.h #

##########################################

echo "----------------------------------------------------"

echo "4. Creating and installing f2c header file f2c.h ..."

echo "----------------------------------------------------"

cd f2c/libf2c || exit

make f2c.h

if test ! -d /usr/local/include; then

    mkdir -p /usr/local/include

fi

cp f2c.h /usr/local/include/

echo "... done."



################################################

# 5. Create and install f2c library "libf2c.a" #

################################################

echo "-----------------------------------------------------"

echo "5. Creating and installing f2c library \"libf2c.a\" ..."

echo "-----------------------------------------------------"

make

if test ! -d /usr/local/lib; then

    mkdir -p /usr/local/lib

fi

cp libf2c.a /usr/local/lib/

ranlib /usr/local/lib/libf2c.a

echo "... done."



######################################

# 6. Make executable f2c translator: #

######################################

echo "---------------------------------------------"

echo "6. Creating and installing f2c translator ..."

echo "---------------------------------------------"

cd ../src || exit

gcc -o xsum xsum.c

make veryclean

make f2c

if test ! -d /usr/local/bin; then

    mkdir -p /usr/local/bin

fi

cp f2c /usr/local/bin/

echo "... done."



################################################################

# 7. Install fc script:                                        #

#                                                              #

# 1. Remove "-Olimit 2000" in the -O processing options within #

#    the 'fc' script.                                          #

# 2. Eliminate all references to the math library (-lm) in     #

#    the script 'fc' since it is included the System framework #

#    and is linked by default under Mac OS X.                  #

# 3. Eliminate '-u MAIN__' at the bottom of the 'fc' script.   #

#    You will have to explicitly load FORTRAN MAIN programs      #

#    (explicitly mention the relevant .f or .o file).          #

################################################################

echo "---------------------------"

echo "7. Installing fc script ..."

echo "---------------------------"

# shellcheck disable=SC2103
cd ..

mv "fc" fc.orig

sed 's/ -Olimit 2000//g; s/ -lm//g; s/ -u MAIN__//g' fc.orig > "fc"

chmod +x "fc"

cp "fc" /usr/local/bin/

echo "... done."



#########################

# 8. Install man pages: #

#########################

echo "---------------------------"

echo "8. Installing man pages ..."

echo "---------------------------"

cp f2c.1t /usr/share/man/man1/f2c.1

echo "... done."



################

# 9. Clean up: #

################

echo "------------------"

echo "9. Cleaning up ..."

echo "------------------"

cd src || exit

make clean

cd ../libf2c || exit

make clean

cd ../..

echo "... All done!"



#############################################

# 10. Test f2c on your FORTRAN source code: #

#############################################

echo "======================================================"

echo "======================================================"

echo "======================================================"

echo "   === To test f2c on your FORTRAN source code: ==="

echo "   === cd ~/wherever/your/code/is               ==="

echo "   === 1. f2c myprog.f                          ==="

echo "   ===    cc -O -o myprog.exe myprog.c -lf2c    ==="

echo "   ===    myprog.exe                            ==="

echo "   === 2. fc -O -w -o myprog.exe myprog.f       ==="

echo "   ===    myprog.exe                            ==="

echo "======================================================"

echo "======================================================"

echo "======================================================"

exit

#!/bin/sh

# Based on http://hpc.sourceforge.net/buildf2c with curl replaced by wget

############################################################

# This UNIX script builds the f2c FORTRAN --> C translator #

# under Mac OS X.                                          #

# Make this script executable with "chmod +x buildf2c"     #

############################################################

echo "==================================="

echo "Build f2c FORTRAN --> C translator."

echo "==================================="

echo "USAGE:  ./buildf2c"



######################################

# Set trap to allow abort on signal: #

######################################

trap 'echo "Interrupted by signal" >&2; exit' 1 2 3 15



########################################################

# 1. Download f2c source from Bell Labs.               #

# (Tar file is not visible - it's created on the fly.) #

########################################################

echo "--------------------------------------------"

echo "1. Downloading f2c source from Bell Labs ..."

echo "--------------------------------------------"

# wget --passive-ftp ftp://netlib.bell-labs.com/netlib/f2c.tar

wget http://hpc.sourceforge.net/f2c.tar -O "f2c.tar"

echo "... done."



#####################################

# 2. Uncompress f2c tarred archive: #

#####################################

echo "-------------------------------"

echo "2. Uncompressing f2c source ..."

echo "-------------------------------"

tar -xvf f2c.tar

gunzip -rf f2c/*

(cd f2c && unzip libf2c.zip -d libf2c)

echo "... done."



###############################################################

# 3. Prepare the unix makefiles for building the f2c library. #

#    Note: CC compiler switched from 'cc' to '/usr/bin/cc'   #

###############################################################

echo "-------------------------------------------"

echo "3. Preparing makefiles for building f2c ..."

echo "-------------------------------------------"

sed 's/CC = cc/CC = \/usr\/bin\/cc/' f2c/libf2c/makefile.u > f2c/libf2c/makefile

sed 's/CC = cc/CC = \/usr\/bin\/cc/' f2c/src/makefile.u > f2c/src/makefile

echo "... done."



##########################################

# 4. Create and install f2c header file. #

# If you use a C++ compiler:  make hadd  #

# Otherwise:                  make f2c.h #

##########################################

echo "----------------------------------------------------"

echo "4. Creating and installing f2c header file f2c.h ..."

echo "----------------------------------------------------"

cd f2c/libf2c || exit

make f2c.h

if test ! -d /usr/local/include; then

    mkdir -p /usr/local/include

fi

cp f2c.h /usr/local/include/

echo "... done."



################################################

# 5. Create and install f2c library "libf2c.a" #

################################################

echo "-----------------------------------------------------"

echo "5. Creating and installing f2c library \"libf2c.a\" ..."

echo "-----------------------------------------------------"

make

if test ! -d /usr/local/lib; then

    mkdir -p /usr/local/lib

fi

cp libf2c.a /usr/local/lib/

ranlib /usr/local/lib/libf2c.a

echo "... done."



######################################

# 6. Make executable f2c translator: #

######################################

echo "---------------------------------------------"

echo "6. Creating and installing f2c translator ..."

echo "---------------------------------------------"

cd ../src || exit

gcc -o xsum xsum.c

make veryclean

make f2c

if test ! -d /usr/local/bin; then

    mkdir -p /usr/local/bin

fi

cp f2c /usr/local/bin/

echo "... done."



################################################################

# 7. Install fc script:                                        #

#                                                              #

# 1. Remove "-Olimit 2000" in the -O processing options within #

#    the 'fc' script.                                          #

# 2. Eliminate all references to the math library (-lm) in     #

#    the script 'fc' since it is included the System framework #

#    and is linked by default under Mac OS X.                  #

# 3. Eliminate '-u MAIN__' at the bottom of the 'fc' script.   #

#    You will have to explicitly load FORTRAN MAIN programs      #

#    (explicitly mention the relevant .f or .o file).          #

################################################################

echo "---------------------------"

echo "7. Installing fc script ..."

echo "---------------------------"

# shellcheck disable=SC2103
cd ..

mv "fc" fc.orig

sed 's/ -Olimit 2000//g; s/ -lm//g; s/ -u MAIN__//g' fc.orig > "fc"

chmod +x "fc"

cp "fc" /usr/local/bin/

echo "... done."



#########################

# 8. Install man pages: #

#########################

echo "---------------------------"

echo "8. Installing man pages ..."

echo "---------------------------"

cp f2c.1t /usr/share/man/man1/f2c.1

echo "... done."



################

# 9. Clean up: #

################

echo "------------------"

echo "9. Cleaning up ..."

echo "------------------"

cd src || exit

make clean

cd ../libf2c || exit

make clean

cd ../..

echo "... All done!"



#############################################

# 10. Test f2c on your FORTRAN source code: #

#############################################

echo "======================================================"

echo "======================================================"

echo "======================================================"

echo "   === To test f2c on your FORTRAN source code: ==="

echo "   === cd ~/wherever/your/code/is               ==="

echo "   === 1. f2c myprog.f                          ==="

echo "   ===    cc -O -o myprog.exe myprog.c -lf2c    ==="

echo "   ===    myprog.exe                            ==="

echo "   === 2. fc -O -w -o myprog.exe myprog.f       ==="

echo "   ===    myprog.exe                            ==="

echo "======================================================"

echo "======================================================"

echo "======================================================"

exit
