Make the build script more reusable.

master
poikilos 2021-11-05 08:07:46 -04:00
parent b615b8c314
commit d3a88615a8
1 changed files with 23 additions and 26 deletions

View File

@ -4,6 +4,7 @@ if [ -z "$PREFIX" ]; then
PREFIX="/usr" PREFIX="/usr"
fi fi
REPO_PATH="`pwd`" REPO_PATH="`pwd`"
SRC_PATH="$REPO_PATH"
mkdir -p $PREFIX || exit 1 mkdir -p $PREFIX || exit 1
if [ -z "$DEBUG" ]; then if [ -z "$DEBUG" ]; then
@ -59,31 +60,26 @@ fi
#^ can't find a pc file #^ can't find a pc file
# gcc -o build/b3view main.cpp Debug.cpp Engine.cpp EventHandler.cpp settings.cpp UserInterface.cpp Utility.cpp View.cpp -I$FT2_INCDIR # gcc -o build/b3view main.cpp Debug.cpp Engine.cpp EventHandler.cpp settings.cpp UserInterface.cpp Utility.cpp View.cpp -I$FT2_INCDIR
# based on qtcreator's build after clean (see contributing.md; some options are unclear): _O_FILES=""
g++ -c -pipe $OPTION1 $OPTION2 $OPTION3 -fPIC -I$REPO_PATH -I$FT2_INCDIR -o $OBJDIR/main.o $REPO_PATH/main.cpp for fn in main Engine EventHandler UserInterface View Debug CGUITTFont Utility settings
if [ $? -ne 0 ]; then echo "Error: building main failed."; exit 1; fi do
g++ -c -pipe $OPTION1 $OPTION2 $OPTION3 -fPIC -I$REPO_PATH -I$FT2_INCDIR -o $OBJDIR/Engine.o $REPO_PATH/Engine.cpp # based on qtcreator's build after clean (see contributing.md; some options are unclear):
if [ $? -ne 0 ]; then echo "Error: building Engine failed."; exit 1; fi THIS_PATH=$SRC_PATH/$fn.cpp
g++ -c -pipe $OPTION1 $OPTION2 $OPTION3 -fPIC -I$REPO_PATH -I$FT2_INCDIR -o $OBJDIR/EventHandler.o $REPO_PATH/EventHandler.cpp if [ -f "$SRC_PATH/extlib/$fn.cpp" ]; then
if [ $? -ne 0 ]; then echo "Error: building EventHandler failed."; exit 1; fi THIS_PATH=$SRC_PATH/extlib/$fn.cpp
g++ -c -pipe $OPTION1 $OPTION2 $OPTION3 -fPIC -I$REPO_PATH -I$FT2_INCDIR -o $OBJDIR/UserInterface.o $REPO_PATH/UserInterface.cpp fi
if [ $? -ne 0 ]; then echo "Error: building UserInterface failed."; exit 1; fi g++ -c -pipe $OPTION1 $OPTION2 $OPTION3 -fPIC -I$REPO_PATH -I$FT2_INCDIR -o $OBJDIR/$fn.o $THIS_PATH
g++ -c -pipe $OPTION1 $OPTION2 $OPTION3 -fPIC -I$REPO_PATH -I$FT2_INCDIR -o $OBJDIR/View.o $REPO_PATH/View.cpp if [ $? -ne 0 ]; then echo "Error: building $fn failed."; exit 1; fi
if [ $? -ne 0 ]; then echo "Error: building View failed."; exit 1; fi #-w: suppress warning
g++ -c -pipe $OPTION1 $OPTION2 $OPTION3 -fPIC -I$REPO_PATH -I$FT2_INCDIR -o $OBJDIR/Debug.o $REPO_PATH/Debug.cpp # -I.: include the current directory (suppresses errors when using include < instead of include "
if [ $? -ne 0 ]; then echo "Error: building Debug failed."; exit 1; fi #-pipe: "Use pipes rather than intermediate files."
g++ -c -pipe $OPTION1 $OPTION2 $OPTION3 -fPIC -I$REPO_PATH -I$FT2_INCDIR -o $OBJDIR/CGUITTFont.o $REPO_PATH/extlib/CGUITTFont.cpp #Options starting with -g, -f, -m, -O, -W, or --param are automatically
if [ $? -ne 0 ]; then echo "Error: building CGUITTFont failed."; exit 1; fi # passed on to the various sub-processes invoked by g++. In order to pass
g++ -c -pipe $OPTION1 $OPTION2 $OPTION3 -fPIC -I$REPO_PATH -I$FT2_INCDIR -o $OBJDIR/Utility.o $REPO_PATH/Utility.cpp # other options on to these processes the -W<letter> options must be used.
if [ $? -ne 0 ]; then echo "Error: building Utility failed."; exit 1; fi _O_FILES="$_O_FILES $OBJDIR/$fn.o"
g++ -c -pipe $OPTION1 $OPTION2 $OPTION3 -fPIC -I$REPO_PATH -I$FT2_INCDIR -o $OBJDIR/settings.o $REPO_PATH/settings.cpp done
if [ $? -ne 0 ]; then echo "Error: building settings failed."; exit 1; fi
#-w: suppress warning
# -I.: include the current directory (suppresses errors when using include < instead of include "
#-pipe: "Use pipes rather than intermediate files."
#Options starting with -g, -f, -m, -O, -W, or --param are automatically
# passed on to the various sub-processes invoked by g++. In order to pass
# other options on to these processes the -W<letter> options must be used.
if [ -f "$$OUT_BIN" ]; then if [ -f "$$OUT_BIN" ]; then
mv "$OUT_BIN" "$OUT_BIN.BAK" mv "$OUT_BIN" "$OUT_BIN.BAK"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
@ -91,7 +87,7 @@ if [ -f "$$OUT_BIN" ]; then
exit 1 exit 1
fi fi
fi fi
g++ -o $OUT_BIN $OBJDIR/main.o $OBJDIR/Engine.o $OBJDIR/EventHandler.o $OBJDIR/UserInterface.o $OBJDIR/Debug.o $OBJDIR/View.o $OBJDIR/CGUITTFont.o $OBJDIR/Utility.o $OBJDIR/settings.o -lIrrlicht -lX11 -lGL -lXxf86vm -lXcursor -lstdc++fs -lfreetype g++ -o $OUT_BIN $_O_FILES -lIrrlicht -lX11 -lGL -lXxf86vm -lXcursor -lstdc++fs -lfreetype
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
cat <<END cat <<END
Error: Linking failed. Ensure you have installed: Error: Linking failed. Ensure you have installed:
@ -99,6 +95,7 @@ Error: Linking failed. Ensure you have installed:
- libXcursor-devel - libXcursor-devel
- freetype-devel - freetype-devel
END END
exit 1
else else
echo "* linking succeeded." echo "* linking succeeded."
fi fi