##
Build the CinGG.AppImage from scratch

If a developer wants to create an appimage from git, follow these next few steps. An existing automated script is available, bld_appimage.sh, in the directory /{path to cinelerra-5.1}.

This follows four steps:

- Build static version of CINELERRA-GG.
- If desired and needed, build the HTML manual for context-sensitive help.
- Organize code and if present, the manual, in a AppImage specific format AppDir. Do this with tool makeappimage, which is built if needed.
- Call an external tool to make the AppDir into an AppImage

Start by downloading the CINELERRA-GG source from Cinelerra's git. The last parameter is a directory name of your choice, the directory must not exist. As example, the name cinelerra5 is used.

    	git clone --depth 1 git://git.cinelerra-gg.org/goodguy/cinelerra.git cinelerra5

The source will be in a subdirectory cinelerra-5.1 of the directory created by the git clone operation.

If context-sensitive help is needed, download the manual sources too, with a different destination directory.

    	git clone --depth 1 git://git.cinelerra-gg.org/goodguy/cin-manual-latex.git cin-manual-latex

Then move to the /{path to cinelerra-5.1/} directory.

There are two preliminaries to do before running the script:

1- If context sensitive help in the appimage version is required, the source of the manual and the tools (packages) to build it must be on the system. In the bld_appimage.sh script, set the variable MANUAL_DIRECTORY=$(pwd)/../../ cin-manual-latex to the path of the source of the manual. If the variable is empty, or the specified directory does not exist, CINELERRA-GG will be built without built-in help. The path to the manual source can be an absolute or relative one. An easier method to include the help from the manual rather than having to install a bunch of latex building software, is to simply download the latest tgz version from `https://cinelerra-gg.org/download/images/HTML_Manual-202xxxxx.tgz`. Then extract the files using "tar xvf" into the cinelerra AppDir/usr/bin/doc directory. This alternative method may not contain the most recent changes to the Manual but rather will contain what had been checked into Git by the date of the tgz file.

2- The script bld_appimage.sh uses a platform specific version of appimagetool so that it can create appimages for x86_64, i686, aarch64, or armv7l architecture. We need to add appimagetool-(platform).AppImage to the /{path to cinelerra- 5.1}/tools directory, or somewhere in your path. You can download the tool for your system (e.g. appimagetool-x86_64.AppImage) from git: `https://github.com/AppImage/AppImageKit/releases`. Be aware of the possibility that an older appimagetool from 2020 might work better on some systems compared to the latest release.

Always remember to make it executable. The four supported platforms are:

- appimagetool-aarch64.AppImage
- appimagetool-armhf.AppImage
- appimagetool-i686.AppImage
- appimagetool-x86_64.AppImage

With the preparations done, let's go back to the bld_appimage.sh script.

Make the script executable if it isn't already:

    chmod x+u bld_appimage.sh

Start the script with:

    ./bld_appimage.sh

The first part of the script customizes configure, depending on the architecture of our system. The next step compiles and installs CINELERRA-GG in the bin subdirectory. The third part creates the manual in HTML; It will be the basis for the context help (see Help and Context Help). The fourth part creates the directory /AppDir/usr, which is the basic structure of an appimage, and then populates it with the contents of /{path to cinelerra-5.1}/bin. Finally, the fifth step starts a script, called makeappimage, which points to bld.sh contained in /tools/makeappimagetool/.

The script specifies all executables that are part of CINELERRA-GG, so makeappimage can pick up dependencies. Any executable code in other places is not picked up. makeappimage will populate the AppDir directory, and then call the platform dependent appimagetool found in /{path to cinelerra-5.1}/tools.

At the end of the compilation there will be an appimage in the cinelerra-5.1 directory, which we can move and use.