summaryrefslogtreecommitdiff
path: root/build.sh
diff options
context:
space:
mode:
Diffstat (limited to 'build.sh')
-rwxr-xr-xbuild.sh79
1 files changed, 79 insertions, 0 deletions
diff --git a/build.sh b/build.sh
new file mode 100755
index 0000000..efe3158
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,79 @@
+#!/bin/bash
+
+# Set the project name here
+PROJECT_NAME="mknes" # Change this for each new project
+
+# Base configuration common to all builds
+CFLAGS="-std=gnu11 "
+CFLAGS+="-mavx2 -mtune=native -mfunction-return=keep -mindirect-branch=keep "
+CFLAGS+="-fwrapv -ffast-math -fno-trapping-math -fwhole-program "
+CFLAGS+="-fno-stack-protector -fno-PIE -no-pie -fno-strict-aliasing -ffunction-sections -fdata-sections "
+CFLAGS+="-Wall -Wextra "
+CFLAGS+="-Wno-unused-parameter -Wno-sign-compare -Wno-trigraphs -Wno-maybe-uninitialized "
+CFLAGS+="-Wno-unused-variable -Wno-unused-const-variable -Wno-unused-function "
+
+LDFLAGS="-Wl,--gc-sections "
+
+# Base include paths (common for all platforms)
+INCLUDE_PATHS="-Ibase -I.."
+
+# Linux-specific includes and libraries
+LINUX_INCLUDE="-I/usr/include/pipewire-0.3 -I/usr/include/spa-0.2"
+LINUX_LIBS="-lpipewire-0.3 -lXi -lX11 -lGL -lm -ldl -pthread"
+
+# Windows-specific includes and libraries
+# WINDOWS_INCLUDE=""
+# WINDOWS_LIBS="-lwinmm -lksuser -lole32 -lmmdevapi -lavrt -lgdi32 -lopengl32 -luuid"
+
+# Determine build type-specific flags
+BUILD_TYPE=$1
+
+if [ -z "$BUILD_TYPE" ]; then
+ BUILD_TYPE="normal"
+fi
+
+case "$BUILD_TYPE" in
+ "normal")
+ CFLAGS+=" -g -O2 -DDEBUG_INTERNAL"
+ ;;
+ "release")
+ CFLAGS+=" -s -O2"
+ ;;
+ "debug")
+ CFLAGS+=" -g -O0"
+ LDFLAGS+=" -fno-pie -no-pie"
+ ;;
+ *)
+ echo "Unknown build type: $BUILD_TYPE"
+ exit 1
+ ;;
+esac
+
+# Rebuild assets every time we compile
+#rm -rf data
+#mkdir -p data/p{1,2,3,4,5,6,7,8}
+#env -C org_assets ../../bin/mks_time ./process.sh
+
+# Make sure the <basecode> shaders are up to date if you are experimenting with them.
+#env -C ../base ../bin/shader2h 140 vertex_shader vertex_shader.glsl
+#env -C ../base ../bin/shader2h 140 fragment_shader shader.h fragment_shader.glsl
+
+# Make sure the compilation stops if any error happens.
+set -e
+
+# Build Linux version
+(
+ # ../bin/ctime -begin .${PROJECT_NAME}_linux
+ gcc $CFLAGS ${PROJECT_NAME}.c -o ${PROJECT_NAME} $INCLUDE_PATHS $LINUX_INCLUDE $LDFLAGS $LINUX_LIBS
+ # ../bin/ctime -end .${PROJECT_NAME}_linux $?
+) &
+
+# Build Windows version
+# (
+# ../bin/ctime -begin .${PROJECT_NAME}_windows
+# x86_64-w64-mingw32-gcc $CFLAGS ${PROJECT_NAME}.c -o ${PROJECT_NAME}.exe $INCLUDE_PATHS $WINDOWS_INCLUDE $LDFLAGS $WINDOWS_LIBS
+# # x86_64-w64-mingw32-gcc $CFLAGS ${PROJECT_NAME}.c -o ${PROJECT_NAME}.exe -mwindows $INCLUDE_PATHS $WINDOWS_INCLUDE $LDFLAGS $WINDOWS_LIBS
+# ../bin/ctime -end .${PROJECT_NAME}_windows $?
+# ) &
+
+wait