Advertisement
Tomaskom

Single-command FlightGear compilation for Linux

Sep 16th, 2014
440
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 7.68 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # User-friendly single-command FlightGear compilation for Linux
  4. # by Tomaskom
  5. #
  6. # This bash script handles everything needed to compile FlightGear
  7. # as a standalone isolated installation, not colliding with any other
  8. # FlightGear version possibly already present on the system. Everything
  9. # is handled automatically without any user interaction and knowledge
  10. # of the build system. The whole installation (FlightGear + its
  11. # dependency libraries from the OpenSceneGraph and Simgear packages) is
  12. # contained within a single folder and can be "uninstalled" simply by
  13. # deleting it.
  14. #
  15. # The user must however already have some dependencies installed on
  16. # the system, including:
  17. # make automake cmake gcc gcc-c++ boost-devel freeglut-devel plib-devel
  18. # openal-soft-devel (package names may slightly vary on your distro)
  19. #
  20. # All the user needs to supply as the input are the uncompressed folders
  21. # with Flightgear, OpenSceneGraph and Simgear sources, together with the
  22. # fgdata folder containing the FlightGear-data package. The folders must
  23. # be placed in the same folder as this script and their names must be
  24. # assigned to the variables below. To my knowledge, the Simgear version
  25. # must exactly match the Flightgear version.
  26. # Flightgear is installed to a newly created folder (its name is
  27. # assigned to the INST_D variable). Don't create this folder manually,
  28. # or the process will fail. This is to prevent overwriting any existing
  29. # data. To restart after a failed attempt, simply delete that folder.
  30. #
  31. # At the end, a script usable as the fgfs executable for the just
  32. # installed FlightGear version is created.
  33. # The process will stop upon any error, and can be completely stopped by
  34. # using the Ctrl+C (interrupt) signal at any time as well.
  35.  
  36.  
  37.  
  38. OSG_D="OpenSceneGraph-3.2.1" #name of the OpenSceneGraph source folder (extracted from zip archive)
  39. SIMG_D="simgear-3.4.0" #name of the simgear source folder (extracted from tar.bz2 archive)
  40. FG_D="flightgear-3.4.0" #name of the flightgear source folder (extracted from tar.bz2 archive)
  41. FGDATA_D="fgdata" #name of the FGdata folder (extracted from tar.bz2 archive)
  42.  
  43. INST_D="FG_3-4" #will be used as the destination folder for installation
  44. THREADS=4 #number of threads used for compilation (make -j $THREADS)
  45.  
  46.  
  47.  
  48. #you don't need to edit anything below this line
  49.  
  50. DIR="$PWD" #store current directory path
  51.  
  52. #folders for temporary storing of compilation stuff
  53. OSG_BUILD="${DIR}/${INST_D}/builddir/osg"
  54. SIMG_BUILD="${DIR}/${INST_D}/builddir/simg"
  55. FG_BUILD="${DIR}/${INST_D}/builddir/flightgear"
  56.  
  57. #prepare some generally used commands
  58. CMD_MAKE="make -j $THREADS"
  59. CMD_INST="make install"
  60.  
  61. #prepare configuration command for osg, simg and fg
  62. CMD_OSG_CMAKE="cmake $DIR/$OSG_D -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${DIR}/${INST_D}/osg"
  63.  
  64. 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"
  65.  
  66. 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"
  67.  
  68. #prepare command for 5 sec wait with visual countdown
  69. CMD_WAIT='echo -en "[     ]\r[" && sleep 1 && echo -n "." && sleep 1 && echo -n "." && sleep 1 && echo -n "." && sleep 1 && echo -n "." && sleep 1 && echo ".]"'
  70.  
  71.  
  72. #create installation folder and start the build & install process
  73. mkdir "${DIR}/${INST_D}" &&
  74. mkdir "${DIR}/${INST_D}/builddir" &&
  75.  
  76. echo "" &&
  77. echo "#####################################################" &&
  78. echo "##### Configuring OpenSceneGraph build in 5s... #####" &&
  79. echo "#####################################################" &&
  80. eval "$CMD_WAIT" &&
  81. mkdir "$OSG_BUILD" && cd "$OSG_BUILD" &&
  82. eval "$CMD_OSG_CMAKE" &&
  83. echo "" &&
  84. echo "#############################################" &&
  85. echo "##### Compiling OpenSceneGraph in 5s... #####" &&
  86. echo "#############################################" &&
  87. eval "$CMD_WAIT" &&
  88. eval "$CMD_MAKE" &&
  89. echo "" &&
  90. echo "##############################################" &&
  91. echo "##### Installing OpenSceneGraph in 5s... #####" &&
  92. echo "##############################################" &&
  93. eval "$CMD_WAIT" &&
  94. eval "$CMD_INST" &&
  95.  
  96. echo "" &&
  97. echo "##############################################" &&
  98. echo "##### Configuring SimGear build in 5s... #####" &&
  99. echo "##############################################" &&
  100. eval "$CMD_WAIT" &&
  101. mkdir "$SIMG_BUILD" && cd "$SIMG_BUILD" &&
  102. eval "$CMD_SIMG_CMAKE" &&
  103. echo "" &&
  104. echo "######################################" &&
  105. echo "##### Compiling SimGear in 5s... #####" &&
  106. echo "######################################" &&
  107. eval "$CMD_WAIT" &&
  108. eval "$CMD_MAKE" &&
  109. echo "" &&
  110. echo "#######################################" &&
  111. echo "##### Installing SimGear in 5s... #####" &&
  112. echo "#######################################" &&
  113. eval "$CMD_WAIT" &&
  114. eval "$CMD_INST" &&
  115.  
  116. echo "" &&
  117. echo "#################################################" &&
  118. echo "##### Configuring FlightGear build in 5s... #####" &&
  119. echo "#################################################" &&
  120. eval "$CMD_WAIT" &&
  121. mkdir "$FG_BUILD" && cd "$FG_BUILD" &&
  122. eval "$CMD_FG_CMAKE" &&
  123. echo "" &&
  124. echo "#########################################" &&
  125. echo "##### Compiling FlightGear in 5s... #####" &&
  126. echo "#########################################" &&
  127. eval "$CMD_WAIT" &&
  128. eval "$CMD_MAKE" &&
  129. echo "" &&
  130. echo "##########################################" &&
  131. echo "##### Installing FlightGear in 5s... #####" &&
  132. echo "##########################################" &&
  133. eval "$CMD_WAIT" &&
  134. eval "$CMD_INST" &&
  135.  
  136. echo "" &&
  137. echo "########################################################" &&
  138. echo "##### Moving fgdata to installed location in 5s... #####" &&
  139. echo "########################################################" &&
  140. eval "$CMD_WAIT" &&
  141. mkdir "${DIR}/${INST_D}/flightgear/lib" &&
  142. mkdir "${DIR}/${INST_D}/flightgear/lib/FlightGear" &&
  143. mv "${DIR}/${FGDATA_D}/"* "${DIR}/${INST_D}/flightgear/lib/FlightGear/" &&
  144.  
  145. echo "" &&
  146. echo "####################################################" &&
  147. echo "##### Cleaning up compilation folders in 5s... #####" &&
  148. echo "####################################################" &&
  149. eval "$CMD_WAIT" &&
  150. rm -r "${DIR}/${INST_D}/builddir" &&
  151.  
  152. #output some useful info upon success
  153. echo "" &&
  154. echo "" &&
  155. echo "#########################################################################" &&
  156. echo "##### Congratulations, you just successfully compiled filghtgear :) #####" &&
  157. echo "#########################################################################" &&
  158. echo "" &&
  159. echo "Library paths necessary for running this version of FlightGear:" &&
  160. echo "${DIR}/${INST_D}/osg/lib[64]" &&
  161. echo "${DIR}/${INST_D}/simg/lib[64]" &&
  162. echo "" &&
  163. echo "Flightgear executable location:" &&
  164. echo "${DIR}/${INST_D}/flightgear/bin/fgfs" &&
  165. echo "" &&
  166. echo "So to run FlightGear from the console right away, you would use:" &&
  167. 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" &&
  168. echo "" &&
  169. cd $DIR &&
  170. echo '#!/bin/bash' > runThisFG_${INST_D}.sh &&
  171. 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 &&
  172. chmod +x runThisFG_${INST_D}.sh &&
  173. 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" &&
  174. echo "You can use it directly as the flightgear executable for your launcher. " &&
  175. echo "Enjoy ;)"
  176.  
  177. echo ""
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement