2021-08-26 16:26:45 +03:00
|
|
|
CC = gcc
|
|
|
|
CPP = g++
|
2022-11-05 20:14:50 +02:00
|
|
|
STRIP = strip
|
2022-11-15 15:03:30 +02:00
|
|
|
CFLAGS = -Ofast -g -Wstrict-aliasing -Iinclude -Iinclude/luajit-2.1 -DSOL_LUAJIT=1
|
2022-11-05 20:14:50 +02:00
|
|
|
CPPFLAGS = -std=gnu++20 -Wno-deprecated-enum-enum-conversion $(CFLAGS)
|
2022-11-15 15:03:30 +02:00
|
|
|
LDFLAGS = -lglfw -lGL -lX11 -lpthread -lXrandr -lXi -ldl -lm -lluajit-5.1
|
2021-08-29 16:17:56 +03:00
|
|
|
BIN = voksel
|
2021-08-26 16:26:45 +03:00
|
|
|
|
2022-11-05 20:14:50 +02:00
|
|
|
ifeq ($(CROSS), mingw-w64)
|
|
|
|
CC = x86_64-w64-mingw32-gcc
|
|
|
|
CPP = x86_64-w64-mingw32-g++
|
|
|
|
STRIP = x86_64-w64-mingw32-strip
|
2022-11-15 15:03:30 +02:00
|
|
|
LDFLAGS = -static -lglfw3 -lopengl32 -lgdi32 -luser32 -lkernel32 -lssp -lluajit
|
2022-11-05 20:14:50 +02:00
|
|
|
BIN = voksel.exe
|
|
|
|
endif
|
|
|
|
|
|
|
|
SRCDIR = src
|
|
|
|
BUILDDIR = out
|
|
|
|
|
|
|
|
CPPFILES := $(shell find ./$(SRCDIR) -type f -name '*.cpp')
|
|
|
|
CFILES := $(shell find ./$(SRCDIR) -type f -name '*.c')
|
|
|
|
OBJ := $(CPPFILES:./$(SRCDIR)/%.cpp=$(BUILDDIR)/%.o)
|
|
|
|
OBJ += $(CFILES:./$(SRCDIR)/%.c=$(BUILDDIR)/%.o)
|
2021-08-26 16:26:45 +03:00
|
|
|
|
2022-11-05 20:14:50 +02:00
|
|
|
.PHONY: all run clean
|
2021-08-26 16:26:45 +03:00
|
|
|
|
2022-11-05 20:14:50 +02:00
|
|
|
all: $(BIN)
|
2021-08-26 16:26:45 +03:00
|
|
|
|
2022-11-05 20:14:50 +02:00
|
|
|
run: $(BIN)
|
|
|
|
@echo "[RUN] $@"
|
|
|
|
@GALLIUM_HUD="simple,fps" ./$(BIN)
|
2021-08-26 16:26:45 +03:00
|
|
|
|
2022-11-05 20:14:50 +02:00
|
|
|
# Link rules for the final executable.
|
2021-08-26 16:26:45 +03:00
|
|
|
$(BIN): $(OBJ)
|
2022-11-15 15:03:30 +02:00
|
|
|
@echo "[LD] $@"
|
|
|
|
@$(CPP) $^ -o $@ $(LDFLAGS)
|
2021-08-26 16:26:45 +03:00
|
|
|
|
2022-11-05 20:14:50 +02:00
|
|
|
# Compilation rules for *.cpp files.
|
|
|
|
$(BUILDDIR)/%.o: src/%.cpp
|
|
|
|
@echo "[CPP] $< | $@"
|
|
|
|
@mkdir -p $(shell dirname $@)
|
|
|
|
@$(CPP) $(CPPFLAGS) -c $< -o $@
|
2021-08-26 16:26:45 +03:00
|
|
|
|
2022-11-05 20:14:50 +02:00
|
|
|
# Compilation rules for *.c files.
|
|
|
|
$(BUILDDIR)/%.o: src/%.c
|
2022-11-15 15:03:30 +02:00
|
|
|
@echo "[CC] $< | $@"
|
2022-11-05 20:14:50 +02:00
|
|
|
@mkdir -p $(shell dirname $@)
|
|
|
|
@$(CC) $(CFLAGS) -c $< -o $@
|
2021-08-26 16:26:45 +03:00
|
|
|
|
|
|
|
clean:
|
2022-11-05 20:14:50 +02:00
|
|
|
rm -rf $(BUILDDIR)
|