|
@ -2,13 +2,13 @@ |
|
|
# Change your executable name here |
|
|
# Change your executable name here |
|
|
GAME_NAME="game" |
|
|
GAME_NAME="game" |
|
|
|
|
|
|
|
|
# Set your sources here (relative to the ./builds/linux directory) |
|
|
|
|
|
|
|
|
# Set your sources here (relative paths!) |
|
|
# Example with two source folders: |
|
|
# Example with two source folders: |
|
|
# SOURCES="../../src/*.c ../../src/submodule/*.c" |
|
|
|
|
|
SOURCES="../../core_basic_window.c" |
|
|
|
|
|
|
|
|
# SOURCES="src/*.c src/submodule/*.c" |
|
|
|
|
|
SOURCES="core_basic_window.c" |
|
|
|
|
|
|
|
|
# Set your raylib/src location here, relative to the ./temp/x directory |
|
|
|
|
|
RAYLIB_SRC="../../../../src" |
|
|
|
|
|
|
|
|
# Set your raylib/src location here (relative path!) |
|
|
|
|
|
RAYLIB_SRC="../../src" |
|
|
|
|
|
|
|
|
# About this build script: it does many things, but in essence, it's |
|
|
# About this build script: it does many things, but in essence, it's |
|
|
# very simple. It has 3 compiler invocations: building raylib (which |
|
|
# very simple. It has 3 compiler invocations: building raylib (which |
|
@ -17,14 +17,18 @@ RAYLIB_SRC="../../../../src" |
|
|
# wrapped in an if statement to make the -qq flag work, it's pretty |
|
|
# wrapped in an if statement to make the -qq flag work, it's pretty |
|
|
# verbose, sorry. |
|
|
# verbose, sorry. |
|
|
|
|
|
|
|
|
|
|
|
# Stop the script if a compilation (or something else?) fails |
|
|
|
|
|
set -e |
|
|
|
|
|
|
|
|
# Get arguments |
|
|
# Get arguments |
|
|
while getopts ":hdurcq" opt; do |
|
|
|
|
|
|
|
|
while getopts ":hdusrcq" opt; do |
|
|
case $opt in |
|
|
case $opt in |
|
|
h) |
|
|
h) |
|
|
echo "Usage: ./linux-build.sh [-hdurcqq]" |
|
|
|
|
|
|
|
|
echo "Usage: ./linux-build.sh [-hdusrcqq]" |
|
|
echo " -h Show this information" |
|
|
echo " -h Show this information" |
|
|
echo " -d Faster builds that have debug symbols, and enable warnings" |
|
|
echo " -d Faster builds that have debug symbols, and enable warnings" |
|
|
echo " -u Run upx* on the executable after compilation (before -r)" |
|
|
echo " -u Run upx* on the executable after compilation (before -r)" |
|
|
|
|
|
echo " -s Run strip on the executable after compilation (before -r)" |
|
|
echo " -r Run the executable after compilation" |
|
|
echo " -r Run the executable after compilation" |
|
|
echo " -c Remove the temp/(debug|release) directory, ie. full recompile" |
|
|
echo " -c Remove the temp/(debug|release) directory, ie. full recompile" |
|
|
echo " -q Suppress this script's informational prints" |
|
|
echo " -q Suppress this script's informational prints" |
|
@ -47,6 +51,9 @@ while getopts ":hdurcq" opt; do |
|
|
u) |
|
|
u) |
|
|
UPX_IT="1" |
|
|
UPX_IT="1" |
|
|
;; |
|
|
;; |
|
|
|
|
|
s) |
|
|
|
|
|
STRIP_IT="1" |
|
|
|
|
|
;; |
|
|
r) |
|
|
r) |
|
|
RUN_AFTER_BUILD="1" |
|
|
RUN_AFTER_BUILD="1" |
|
|
;; |
|
|
;; |
|
@ -72,23 +79,23 @@ if [ -z "$CC" ]; then |
|
|
CC=cc |
|
|
CC=cc |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
# Directories |
|
|
|
|
|
ROOT_DIR=$PWD |
|
|
|
|
|
SOURCES="$ROOT_DIR/$SOURCES" |
|
|
|
|
|
RAYLIB_SRC="$ROOT_DIR/$RAYLIB_SRC" |
|
|
|
|
|
|
|
|
# Flags |
|
|
# Flags |
|
|
OUTPUT_DIR="builds/linux" |
|
|
OUTPUT_DIR="builds/linux" |
|
|
COMPILATION_FLAGS="-std=c99 -Os -flto" |
|
|
COMPILATION_FLAGS="-std=c99 -Os -flto" |
|
|
if [ "$CC" = "clang" ]; then |
|
|
|
|
|
# Clang 7.0.1 fails to compile with -Os, possibly the same bug as this: |
|
|
|
|
|
# https://www.mail-archive.com/llvm-bugs@lists.llvm.org/msg25771.html |
|
|
|
|
|
COMPILATION_FLAGS="-std=c99 -O2 -flto" |
|
|
|
|
|
[ -z "$QUIET" ] && echo "COMPILE-WARNING: \$CC is clang, using -O2 instead of -Os." |
|
|
|
|
|
fi |
|
|
|
|
|
FINAL_COMPILE_FLAGS="-s" |
|
|
FINAL_COMPILE_FLAGS="-s" |
|
|
WARNING_FLAGS="-Wall -Wextra -Wpedantic" |
|
|
WARNING_FLAGS="-Wall -Wextra -Wpedantic" |
|
|
LINK_FLAGS="-lm -ldl -lpthread -lX11 -lxcb -lGL -lGLX -lXext -lGLdispatch -lXau -lXdmcp" |
|
|
|
|
|
|
|
|
LINK_FLAGS="-flto -lm -ldl -lpthread -lX11 -lxcb -lGL -lGLX -lXext -lGLdispatch -lXau -lXdmcp" |
|
|
# Debug changes to flags |
|
|
# Debug changes to flags |
|
|
if [ -n "$BUILD_DEBUG" ]; then |
|
|
if [ -n "$BUILD_DEBUG" ]; then |
|
|
OUTPUT_DIR="builds-debug/linux" |
|
|
OUTPUT_DIR="builds-debug/linux" |
|
|
COMPILATION_FLAGS="-std=c99 -O0 -g" |
|
|
COMPILATION_FLAGS="-std=c99 -O0 -g" |
|
|
FINAL_COMPILE_FLAGS="" |
|
|
FINAL_COMPILE_FLAGS="" |
|
|
|
|
|
LINK_FLAGS="-lm -ldl -lpthread -lX11 -lxcb -lGL -lGLX -lXext -lGLdispatch -lXau -lXdmcp" |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
# Display what we're doing |
|
|
# Display what we're doing |
|
@ -99,7 +106,6 @@ else |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
# Create the raylib cache directory |
|
|
# Create the raylib cache directory |
|
|
ROOT_DIR=$(pwd) |
|
|
|
|
|
TEMP_DIR="temp/release" |
|
|
TEMP_DIR="temp/release" |
|
|
if [ -n "$BUILD_DEBUG" ]; then |
|
|
if [ -n "$BUILD_DEBUG" ]; then |
|
|
TEMP_DIR="temp/debug" |
|
|
TEMP_DIR="temp/debug" |
|
@ -131,15 +137,20 @@ mkdir -p $OUTPUT_DIR |
|
|
cd $OUTPUT_DIR |
|
|
cd $OUTPUT_DIR |
|
|
[ -z "$QUIET" ] && echo "COMPILE-INFO: Compiling game code." |
|
|
[ -z "$QUIET" ] && echo "COMPILE-INFO: Compiling game code." |
|
|
if [ -n "$REALLY_QUIET" ]; then |
|
|
if [ -n "$REALLY_QUIET" ]; then |
|
|
$CC -c -o main.o -I$RAYLIB_SRC $COMPILATION_FLAGS $WARNING_FLAGS $SOURCES > /dev/null 2>&1 |
|
|
|
|
|
$CC -o $GAME_NAME $ROOT_DIR/$TEMP_DIR/*.o main.o $LINK_FLAGS > /dev/null 2>&1 |
|
|
|
|
|
|
|
|
$CC -c -I$RAYLIB_SRC $COMPILATION_FLAGS $WARNING_FLAGS $SOURCES > /dev/null 2>&1 |
|
|
|
|
|
$CC -o $GAME_NAME $ROOT_DIR/$TEMP_DIR/*.o *.o $LINK_FLAGS > /dev/null 2>&1 |
|
|
else |
|
|
else |
|
|
$CC -c -o main.o -I$RAYLIB_SRC $COMPILATION_FLAGS $WARNING_FLAGS $SOURCES |
|
|
|
|
|
$CC -o $GAME_NAME $ROOT_DIR/$TEMP_DIR/*.o main.o $LINK_FLAGS |
|
|
|
|
|
|
|
|
$CC -c -I$RAYLIB_SRC $COMPILATION_FLAGS $WARNING_FLAGS $SOURCES |
|
|
|
|
|
$CC -o $GAME_NAME $ROOT_DIR/$TEMP_DIR/*.o *.o $LINK_FLAGS |
|
|
fi |
|
|
fi |
|
|
rm main.o |
|
|
|
|
|
|
|
|
rm *.o |
|
|
[ -z "$QUIET" ] && echo "COMPILE-INFO: Game compiled into an executable in: $OUTPUT_DIR/" |
|
|
[ -z "$QUIET" ] && echo "COMPILE-INFO: Game compiled into an executable in: $OUTPUT_DIR/" |
|
|
|
|
|
|
|
|
|
|
|
if [ -n "$STRIP_IT" ]; then |
|
|
|
|
|
[ -z "$QUIET" ] && echo "COMPILE-INFO: Stripping $GAME_NAME." |
|
|
|
|
|
strip $GAME_NAME |
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
if [ -n "$UPX_IT" ]; then |
|
|
if [ -n "$UPX_IT" ]; then |
|
|
[ -z "$QUIET" ] && echo "COMPILE-INFO: Packing $GAME_NAME with upx." |
|
|
[ -z "$QUIET" ] && echo "COMPILE-INFO: Packing $GAME_NAME with upx." |
|
|
upx $GAME_NAME > /dev/null 2>&1 |
|
|
upx $GAME_NAME > /dev/null 2>&1 |
|
|