Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # User-friendly single-command FlightGear compilation for Linux
- # by Tomaskom
- #
- # This bash script handles everything needed to compile FlightGear
- # as a standalone isolated installation, not colliding with any other
- # FlightGear version possibly already present on the system. Everything
- # is handled automatically without any user interaction and knowledge
- # of the build system. The whole installation (FlightGear + its
- # dependency libraries from the OpenSceneGraph and Simgear packages) is
- # contained within a single folder and can be "uninstalled" simply by
- # deleting it.
- #
- # The user must however already have some dependencies installed on
- # the system, including:
- # make automake cmake gcc gcc-c++ boost-devel freeglut-devel plib-devel
- # openal-soft-devel (package names may slightly vary on your distro)
- #
- # All the user needs to supply as the input are the uncompressed folders
- # with Flightgear, OpenSceneGraph and Simgear sources, together with the
- # fgdata folder containing the FlightGear-data package. The folders must
- # be placed in the same folder as this script and their names must be
- # assigned to the variables below. To my knowledge, the Simgear version
- # must exactly match the Flightgear version.
- # Flightgear is installed to a newly created folder (its name is
- # assigned to the INST_D variable). Don't create this folder manually,
- # or the process will fail. This is to prevent overwriting any existing
- # data. To restart after a failed attempt, simply delete that folder.
- #
- # At the end, a script usable as the fgfs executable for the just
- # installed FlightGear version is created.
- # The process will stop upon any error, and can be completely stopped by
- # using the Ctrl+C (interrupt) signal at any time as well.
- OSG_D="OpenSceneGraph-3.2.1" #name of the OpenSceneGraph source folder (extracted from zip archive)
- SIMG_D="simgear-3.4.0" #name of the simgear source folder (extracted from tar.bz2 archive)
- FG_D="flightgear-3.4.0" #name of the flightgear source folder (extracted from tar.bz2 archive)
- FGDATA_D="fgdata" #name of the FGdata folder (extracted from tar.bz2 archive)
- INST_D="FG_3-4" #will be used as the destination folder for installation
- THREADS=4 #number of threads used for compilation (make -j $THREADS)
- #you don't need to edit anything below this line
- DIR="$PWD" #store current directory path
- #folders for temporary storing of compilation stuff
- OSG_BUILD="${DIR}/${INST_D}/builddir/osg"
- SIMG_BUILD="${DIR}/${INST_D}/builddir/simg"
- FG_BUILD="${DIR}/${INST_D}/builddir/flightgear"
- #prepare some generally used commands
- CMD_MAKE="make -j $THREADS"
- CMD_INST="make install"
- #prepare configuration command for osg, simg and fg
- CMD_OSG_CMAKE="cmake $DIR/$OSG_D -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${DIR}/${INST_D}/osg"
- CMD_SIMG_CMAKE="env OSG_DIR=${DIR}/${INST_D}/osg cmake $DIR/$SIMG_D -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${DIR}/${INST_D}/simg"
- CMD_FG_CMAKE="env SIMGEAR_DIR=${DIR}/${INST_D}/simg env OSG_DIR=${DIR}/${INST_D}/osg cmake $DIR/$FG_D -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${DIR}/${INST_D}/flightgear"
- #prepare command for 5 sec wait with visual countdown
- CMD_WAIT='echo -en "[ ]\r[" && sleep 1 && echo -n "." && sleep 1 && echo -n "." && sleep 1 && echo -n "." && sleep 1 && echo -n "." && sleep 1 && echo ".]"'
- #create installation folder and start the build & install process
- mkdir "${DIR}/${INST_D}" &&
- mkdir "${DIR}/${INST_D}/builddir" &&
- echo "" &&
- echo "#####################################################" &&
- echo "##### Configuring OpenSceneGraph build in 5s... #####" &&
- echo "#####################################################" &&
- eval "$CMD_WAIT" &&
- mkdir "$OSG_BUILD" && cd "$OSG_BUILD" &&
- eval "$CMD_OSG_CMAKE" &&
- echo "" &&
- echo "#############################################" &&
- echo "##### Compiling OpenSceneGraph in 5s... #####" &&
- echo "#############################################" &&
- eval "$CMD_WAIT" &&
- eval "$CMD_MAKE" &&
- echo "" &&
- echo "##############################################" &&
- echo "##### Installing OpenSceneGraph in 5s... #####" &&
- echo "##############################################" &&
- eval "$CMD_WAIT" &&
- eval "$CMD_INST" &&
- echo "" &&
- echo "##############################################" &&
- echo "##### Configuring SimGear build in 5s... #####" &&
- echo "##############################################" &&
- eval "$CMD_WAIT" &&
- mkdir "$SIMG_BUILD" && cd "$SIMG_BUILD" &&
- eval "$CMD_SIMG_CMAKE" &&
- echo "" &&
- echo "######################################" &&
- echo "##### Compiling SimGear in 5s... #####" &&
- echo "######################################" &&
- eval "$CMD_WAIT" &&
- eval "$CMD_MAKE" &&
- echo "" &&
- echo "#######################################" &&
- echo "##### Installing SimGear in 5s... #####" &&
- echo "#######################################" &&
- eval "$CMD_WAIT" &&
- eval "$CMD_INST" &&
- echo "" &&
- echo "#################################################" &&
- echo "##### Configuring FlightGear build in 5s... #####" &&
- echo "#################################################" &&
- eval "$CMD_WAIT" &&
- mkdir "$FG_BUILD" && cd "$FG_BUILD" &&
- eval "$CMD_FG_CMAKE" &&
- echo "" &&
- echo "#########################################" &&
- echo "##### Compiling FlightGear in 5s... #####" &&
- echo "#########################################" &&
- eval "$CMD_WAIT" &&
- eval "$CMD_MAKE" &&
- echo "" &&
- echo "##########################################" &&
- echo "##### Installing FlightGear in 5s... #####" &&
- echo "##########################################" &&
- eval "$CMD_WAIT" &&
- eval "$CMD_INST" &&
- echo "" &&
- echo "########################################################" &&
- echo "##### Moving fgdata to installed location in 5s... #####" &&
- echo "########################################################" &&
- eval "$CMD_WAIT" &&
- mkdir "${DIR}/${INST_D}/flightgear/lib" &&
- mkdir "${DIR}/${INST_D}/flightgear/lib/FlightGear" &&
- mv "${DIR}/${FGDATA_D}/"* "${DIR}/${INST_D}/flightgear/lib/FlightGear/" &&
- echo "" &&
- echo "####################################################" &&
- echo "##### Cleaning up compilation folders in 5s... #####" &&
- echo "####################################################" &&
- eval "$CMD_WAIT" &&
- rm -r "${DIR}/${INST_D}/builddir" &&
- #output some useful info upon success
- echo "" &&
- echo "" &&
- echo "#########################################################################" &&
- echo "##### Congratulations, you just successfully compiled filghtgear :) #####" &&
- echo "#########################################################################" &&
- echo "" &&
- echo "Library paths necessary for running this version of FlightGear:" &&
- echo "${DIR}/${INST_D}/osg/lib[64]" &&
- echo "${DIR}/${INST_D}/simg/lib[64]" &&
- echo "" &&
- echo "Flightgear executable location:" &&
- echo "${DIR}/${INST_D}/flightgear/bin/fgfs" &&
- echo "" &&
- echo "So to run FlightGear from the console right away, you would use:" &&
- echo "env LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${DIR}/${INST_D}/osg/lib:${DIR}/${INST_D}/osg/lib64:${DIR}/${INST_D}/simg/lib:${DIR}/${INST_D}/simg/lib64 ${DIR}/${INST_D}/flightgear/bin/fgfs" &&
- echo "" &&
- cd $DIR &&
- echo '#!/bin/bash' > runThisFG_${INST_D}.sh &&
- echo 'env LD_LIBRARY_PATH=$LD_LIBRARY_PATH'":${DIR}/${INST_D}/osg/lib:${DIR}/${INST_D}/osg/lib64:${DIR}/${INST_D}/simg/lib:${DIR}/${INST_D}/simg/lib64 ${DIR}/${INST_D}/flightgear/bin/fgfs"' $@' >> runThisFG_${INST_D}.sh &&
- chmod +x runThisFG_${INST_D}.sh &&
- echo "A script for running this version of FlightGear without having to remember the environment variables has been written to the file runThisFG_${INST_D}.sh" &&
- echo "You can use it directly as the flightgear executable for your launcher. " &&
- echo "Enjoy ;)"
- echo ""
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement