summaryrefslogtreecommitdiff
path: root/build.sh
diff options
context:
space:
mode:
authorPeter Fors <peter.fors@mindkiller.com>2025-10-09 22:07:52 +0200
committerPeter Fors <peter.fors@mindkiller.com>2025-10-09 22:07:52 +0200
commit030724a9aea346e4a9843d5842fb28c6d6c4cf1a (patch)
treef06fb84aaef64b2f4e2d81b3d2d3eef71bad83ec /build.sh
parent412b2ef851516c1de8ba5006ddd284192cbcaf9b (diff)
Rearrangement and refactoring and optimizations and more accuracy
Diffstat (limited to 'build.sh')
-rwxr-xr-xbuild.sh34
1 files changed, 13 insertions, 21 deletions
diff --git a/build.sh b/build.sh
index 5ba1fb6..b854c3e 100755
--- a/build.sh
+++ b/build.sh
@@ -4,14 +4,15 @@
PROJECT_NAME="mknes" # Change this for each new project
CC=gcc
+WIN_CC=x86_64-w64-mingw32-gcc
# Base configuration common to all builds
-CFLAGS="-std=gnu11 -mtune=generic -fdump-tree-alias "
-CFLAGS+="-mbmi -fno-jump-tables -fno-argument-alias "
+CFLAGS="-std=gnu11 -mtune=generic "
+# -fdump-tree-alias "
+CFLAGS+="-mbmi -fno-argument-alias "
CFLAGS+="-mfunction-return=keep -mindirect-branch=keep "
CFLAGS+="-fwrapv -ffast-math -fno-trapping-math -fvisibility=hidden "
CFLAGS+="-fno-stack-protector -fno-PIE -no-pie -fcf-protection=none -ffunction-sections -fdata-sections "
-# CFLAGS+="-fno-exceptions -fno-rtti -fno-use-cxa-atexit "
CFLAGS+="-fno-non-call-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables "
CFLAGS+="-Wall -Wextra -Wstrict-aliasing=3 "
CFLAGS+="-Wno-unused-parameter -Wno-sign-compare -Wno-trigraphs -Wno-maybe-uninitialized "
@@ -24,17 +25,18 @@ CFLAGS+="-U_FORTIFY_SOURCE -fno-pic "
LDFLAGS="-Wl,--gc-sections -Wl,--as-needed "
# Base include paths (common for all platforms)
-INCLUDE_PATHS="-Ibase -I.. "
+INCLUDE_PATHS="-Ibase -I../mkfw "
# 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 -lglfw -larchive "
LINUX_INCLUDE=" "
-LINUX_LIBS="-lXi -lX11 -lGL -lm -ldl -pthread -lglfw -larchive "
+LINUX_LIBS="-lXi -lX11 -lGL -lm -ldl -pthread -larchive "
# Windows-specific includes and libraries
-# WINDOWS_INCLUDE=""
-# WINDOWS_LIBS="-lwinmm -lksuser -lole32 -lmmdevapi -lavrt -lgdi32 -lopengl32 -luuid"
+WINDOWS_INCLUDE=""
+WINDOWS_LIBS="-lwinmm -lgdi32 -lopengl32 -lavrt "
+# To enable ZIP support via libarchive, uncomment the line below and comment the line above:
+# WINDOWS_LIBS="-static -larchive -lz -lbz2 -llzma -lbcrypt -lwinmm -lgdi32 -lopengl32"
+# You'll also need to add -DUSE_LIBARCHIVE to CFLAGS
# Determine build type-specific flags
BUILD_TYPE=$1
@@ -69,7 +71,7 @@ case "$BUILD_TYPE" in
;;
"clean")
- rm -f *.gcda *.gcno *.gcov perf.data* *.alias
+ rm -f *.gcda *.gcno *.gcov perf.data* *.alias mknes
exit 0
;;
*)
@@ -78,28 +80,18 @@ case "$BUILD_TYPE" in
;;
esac
-# Make sure the shaders are up to date
-shader2h 330 vertex_shader vertex_shader.glsl
-shader2h 330 fragment_shader shader.h fragment_shader.glsl
-
# Make sure the compilation stops if any error happens.
set -e
# Build Linux version
(
- . dev
- # ../bin/ctime -begin .${PROJECT_NAME}_linux
$CC $CFLAGS ${PROJECT_NAME}.c -o ${PROJECT_NAME} $INCLUDE_PATHS $LINUX_INCLUDE $LDFLAGS $LINUX_LIBS
objdump -d -Mintel mknes > mknes.s
- # ../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 $?
+# $WIN_CC $CFLAGS ${PROJECT_NAME}.c -o ${PROJECT_NAME}.exe $INCLUDE_PATHS $WINDOWS_INCLUDE $LDFLAGS $WINDOWS_LIBS
# ) &
wait