summaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
Diffstat (limited to 'build')
-rw-r--r--build/Makefile15
-rw-r--r--build/common.mk45
-rw-r--r--build/cross-compile.mk94
-rw-r--r--build/native.mk19
4 files changed, 21 insertions, 152 deletions
diff --git a/build/Makefile b/build/Makefile
index d77ff68..572db07 100644
--- a/build/Makefile
+++ b/build/Makefile
@@ -6,7 +6,6 @@ include common.mk
# Include build modules
include native.mk
-include cross-compile.mk
include dependencies.mk
# Help system
@@ -19,13 +18,6 @@ help:
@echo " glautils - Build utilities only"
@echo " clean - Clean build files"
@echo " rebuild - Clean and rebuild"
-ifeq ($(PLATFORM),linux)
- @echo ""
- @echo "Cross-compilation (Linux → Windows):"
- @echo " win - Build glamac for Windows"
- @echo " win-all - Build everything for Windows"
- @echo " setup-cross - Setup cross-compilation"
-endif
@echo ""
@echo "Dependencies:"
@echo " deps - Install SDL3 dependencies"
@@ -35,11 +27,6 @@ endif
@echo " convert-catalogs - Convert Excel files to JSON"
@echo ""
@echo "Quick start:"
-ifeq ($(PLATFORM),linux)
- @echo " make deps && make all # Native build"
- @echo " make setup-cross && make win # Windows build"
-else
- @echo " Install SDL3, then: make all"
-endif
+ @echo " make deps && make all # Install dependencies and build"
.PHONY: help \ No newline at end of file
diff --git a/build/common.mk b/build/common.mk
index d1262c8..967a08d 100644
--- a/build/common.mk
+++ b/build/common.mk
@@ -1,34 +1,19 @@
# Common build variables and functions for GlaMaC
# This file contains shared configuration used by all build modules
-# Detect OS and set platform-specific variables
-UNAME_S := $(shell uname -s 2>/dev/null || echo Windows_NT)
-ifeq ($(UNAME_S),Linux)
- PLATFORM := linux
- EXE_EXT :=
- MKDIR := mkdir -p
- RM := rm -f
- RMDIR := rm -rf
- CC := gcc
- MINGW_CC := x86_64-w64-mingw32-gcc
- SDL3_LIBS := $(shell pkg-config --libs sdl3 SDL3_ttf 2>/dev/null || echo -lSDL3 -lSDL3_ttf) -lm
- CROSS_PREFIX := /usr/x86_64-w64-mingw32
-else
- PLATFORM := windows
- EXE_EXT := .exe
- MKDIR := mkdir
- RM := del /Q
- RMDIR := rmdir /s /q
- CC := gcc
- SDL3_LIBS := -lSDL3 -lSDL3_ttf -mwindows
-endif
+# Linux-only build configuration
+PLATFORM := linux
+EXE_EXT :=
+MKDIR := mkdir -p
+RM := rm -f
+RMDIR := rm -rf
+CC := gcc
+SDL3_LIBS := $(shell pkg-config --libs sdl3 SDL3_ttf 2>/dev/null || echo -lSDL3 -lSDL3_ttf) -lm
# Directories (relative to project root)
SRCDIR := ../src
BINDIR := ../bin
-BINDIR_WIN := ../bin/win
INCDIR := ../include
-DLL_CACHE := $(HOME)/.cache/glamac-dlls
# Base flags
CFLAGS_BASE := -I$(INCDIR) -O2 -flto
@@ -37,24 +22,16 @@ SECURITY_FLAGS := -fstack-protector-strong -D_FORTIFY_SOURCE=2 -fPIE
WARNING_FLAGS := -Wall -Wextra -Wformat=2 -Wformat-security -Wnull-dereference -Wstack-protector -Wvla
# Compiler flags
-CFLAGS := $(CFLAGS_BASE) $(SECURITY_FLAGS) $(WARNING_FLAGS)
-CFLAGS_NATIVE := $(CFLAGS) -march=native
-# Windows cross-compilation flags (without stack protector to avoid libssp dependency)
-WARNING_FLAGS_WIN := -Wall -Wextra -Wformat=2 -Wformat-security -Wnull-dereference -Wvla
-CFLAGS_CROSS := $(CFLAGS_BASE) $(WARNING_FLAGS_WIN) -I$(CROSS_PREFIX)/include
+CFLAGS := $(CFLAGS_BASE) $(SECURITY_FLAGS) $(WARNING_FLAGS) -march=native
# Source files
GLAMAC_SRCS := $(wildcard $(SRCDIR)/glamac/*.c)
GLAUTILS_SRCS := $(wildcard $(SRCDIR)/glautils/*.c)
-GLAUTILS_BINS := $(patsubst $(SRCDIR)/glautils/%.c, $(BINDIR)/%$(EXE_EXT), $(GLAUTILS_SRCS))
-GLAUTILS_BINS_WIN := $(patsubst $(SRCDIR)/glautils/%.c, $(BINDIR_WIN)/%.exe, $(GLAUTILS_SRCS))
+GLAUTILS_BINS := $(patsubst $(SRCDIR)/glautils/%.c, $(BINDIR)/%, $(GLAUTILS_SRCS))
# Glass data dependencies for fgla
GLASS_DATA_SRCS := $(SRCDIR)/glamac/glass_data.c $(SRCDIR)/glamac/glamac_errors.c
# Common directory creation rules
$(BINDIR):
- $(MKDIR) $(BINDIR)
-
-$(BINDIR_WIN):
- $(MKDIR) $(BINDIR_WIN) \ No newline at end of file
+ $(MKDIR) $(BINDIR) \ No newline at end of file
diff --git a/build/cross-compile.mk b/build/cross-compile.mk
deleted file mode 100644
index 5dc65f8..0000000
--- a/build/cross-compile.mk
+++ /dev/null
@@ -1,94 +0,0 @@
-# Cross-compilation rules for GlaMaC
-# This file contains rules for Windows cross-compilation from Linux
-
-# Windows cross-compilation (Linux only)
-ifeq ($(PLATFORM),linux)
-
-win: $(BINDIR_WIN)/glamac.exe win-dlls win-data
-
-win-all: win $(GLAUTILS_BINS_WIN)
-
-$(BINDIR_WIN)/glamac.exe: $(GLAMAC_SRCS) | $(BINDIR_WIN)
- @echo "Cross-compiling glamac for Windows..."
- @which $(MINGW_CC) >/dev/null 2>&1 || (echo "ERROR: Install mingw-w64-gcc first" && exit 1)
- $(MINGW_CC) $^ $(CFLAGS_CROSS) -L$(CROSS_PREFIX)/lib -lmingw32 -lSDL3 -lSDL3_ttf -mwindows -static-libgcc -o $@
-
-$(BINDIR_WIN)/%.exe: $(SRCDIR)/glautils/%.c | $(BINDIR_WIN)
- $(MINGW_CC) $< $(CFLAGS_CROSS) -static-libgcc -o $@
-
-# Windows DLL management
-win-dlls: | $(BINDIR_WIN)
- @echo "Getting Windows DLLs..."
- @$(MKDIR) $(DLL_CACHE)
- @if [ ! -f "$(DLL_CACHE)/SDL3.dll" ]; then \
- echo "Downloading SDL3.dll..."; \
- cd $(DLL_CACHE) && \
- wget -q https://github.com/libsdl-org/SDL/releases/download/release-3.2.10/SDL3-3.2.10-win32-x64.zip && \
- unzip -j SDL3-3.2.10-win32-x64.zip SDL3.dll && \
- $(RM) SDL3-3.2.10-win32-x64.zip; \
- fi
- @if [ ! -f "$(DLL_CACHE)/SDL3_ttf.dll" ]; then \
- echo "Downloading SDL3_ttf.dll..."; \
- cd $(DLL_CACHE) && \
- wget -q https://github.com/libsdl-org/SDL_ttf/releases/download/release-3.2.2/SDL3_ttf-3.2.2-win32-x64.zip && \
- unzip -j SDL3_ttf-3.2.2-win32-x64.zip SDL3_ttf.dll && \
- $(RM) SDL3_ttf-3.2.2-win32-x64.zip; \
- fi
- @cp $(DLL_CACHE)/*.dll $(BINDIR_WIN)/
- @echo "Windows build ready in $(BINDIR_WIN)/"
-
-# Copy data files for Windows build
-win-data: | $(BINDIR_WIN)
- @echo "Copying data files for Windows..."
- @$(MKDIR) $(BINDIR_WIN)/data/json
- @if [ -f "../data/json/glasses.json" ]; then \
- cp ../data/json/glasses.json $(BINDIR_WIN)/data/json/; \
- cp ../data/json/glasses.json $(BINDIR_WIN)/; \
- echo "Copied glasses.json to Windows build"; \
- else \
- echo "Warning: glasses.json not found, Windows build may use fallback data"; \
- fi
- @echo "Copying font for Windows..."
- @if [ -f "/usr/share/fonts/TTF/DejaVuSans.ttf" ]; then \
- cp /usr/share/fonts/TTF/DejaVuSans.ttf $(BINDIR_WIN)/; \
- echo "Copied DejaVuSans.ttf to Windows build"; \
- elif [ -f "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf" ]; then \
- cp /usr/share/fonts/truetype/dejavu/DejaVuSans.ttf $(BINDIR_WIN)/; \
- echo "Copied DejaVuSans.ttf to Windows build"; \
- else \
- echo "Warning: DejaVu font not found, Windows build may fail to start"; \
- fi
-
-# Cross-compilation setup
-setup-cross:
- @echo "Setting up cross-compilation..."
- @which wget >/dev/null 2>&1 || (echo "Install wget first: sudo pacman -S wget" && exit 1)
- @which $(MINGW_CC) >/dev/null 2>&1 || (echo "Install mingw-w64-gcc first: sudo pacman -S mingw-w64-gcc" && exit 1)
- sudo $(MKDIR) $(CROSS_PREFIX)/include $(CROSS_PREFIX)/lib
- @echo "Downloading SDL3 development libraries..."
- cd /tmp && \
- wget -q https://github.com/libsdl-org/SDL/releases/download/release-3.2.10/SDL3-devel-3.2.10-mingw.tar.gz && \
- wget -q https://github.com/libsdl-org/SDL_ttf/releases/download/release-3.2.2/SDL3_ttf-devel-3.2.2-mingw.tar.gz && \
- tar -xzf SDL3-devel-3.2.10-mingw.tar.gz && \
- tar -xzf SDL3_ttf-devel-3.2.2-mingw.tar.gz && \
- sudo cp -r SDL3-3.2.10/x86_64-w64-mingw32/include/* $(CROSS_PREFIX)/include/ && \
- sudo cp -r SDL3-3.2.10/x86_64-w64-mingw32/lib/* $(CROSS_PREFIX)/lib/ && \
- sudo cp -r SDL3_ttf-3.2.2/x86_64-w64-mingw32/include/* $(CROSS_PREFIX)/include/ && \
- sudo cp -r SDL3_ttf-3.2.2/x86_64-w64-mingw32/lib/* $(CROSS_PREFIX)/lib/ && \
- $(RM) -rf SDL3-3.2.10* SDL3_ttf-3.2.2*
- @echo "Cross-compilation setup complete!"
-
-else
-# Windows host - disable cross-compilation
-win win-all win-dlls setup-cross:
- @echo "Cross-compilation not available on Windows. Use 'make all' instead."
-endif
-
-# Cross-compilation cleanup
-clean-cache:
- $(RMDIR) $(DLL_CACHE) 2>/dev/null || true
-
-clean-all: clean clean-cache clean-deps-files
-
-# Cross-compilation phony targets
-.PHONY: win win-all win-dlls setup-cross win-data clean-cache clean-all \ No newline at end of file
diff --git a/build/native.mk b/build/native.mk
index e4495d5..133c417 100644
--- a/build/native.mk
+++ b/build/native.mk
@@ -1,25 +1,24 @@
-# Native build rules for GlaMaC
-# This file contains rules for building on the native platform (Linux/Windows)
+# Native build rules for GlaMaC (Linux-only)
# Default target
all: glamac glautils
-# Native build targets
-glamac: $(BINDIR)/glamac$(EXE_EXT)
+# Build targets
+glamac: $(BINDIR)/glamac
glautils: $(GLAUTILS_BINS)
-$(BINDIR)/glamac$(EXE_EXT): $(GLAMAC_SRCS) | $(BINDIR)
+$(BINDIR)/glamac: $(GLAMAC_SRCS) | $(BINDIR)
@echo "Building glamac..."
- $(CC) $^ $(CFLAGS_NATIVE) $(SDL3_LIBS) -o $@
+ $(CC) $^ $(CFLAGS) $(SDL3_LIBS) -o $@
# Special rule for fgla which needs glass_data dependencies
-$(BINDIR)/fgla$(EXE_EXT): $(SRCDIR)/glautils/fgla.c $(GLASS_DATA_SRCS) | $(BINDIR)
- $(CC) $^ $(CFLAGS_NATIVE) -o $@
+$(BINDIR)/fgla: $(SRCDIR)/glautils/fgla.c $(GLASS_DATA_SRCS) | $(BINDIR)
+ $(CC) $^ $(CFLAGS) -o $@
# General rule for other glautils (excluding fgla)
-$(BINDIR)/%$(EXE_EXT): $(SRCDIR)/glautils/%.c | $(BINDIR)
- $(CC) $< $(CFLAGS_NATIVE) -o $@
+$(BINDIR)/%: $(SRCDIR)/glautils/%.c | $(BINDIR)
+ $(CC) $< $(CFLAGS) -o $@
# Excel to JSON conversion
EXCEL_FILES := $(wildcard ../data/Excel/*.xlsx)
Back to https://optics-design.com