2024-10-15 05:06:52 +00:00
|
|
|
CC?=gcc
|
2024-10-23 23:47:28 +00:00
|
|
|
LD?=ld
|
2024-10-15 05:06:52 +00:00
|
|
|
SHROOMSFLAGS=shrooms-vb-core/core/vb.c -I shrooms-vb-core/core
|
2024-10-24 00:01:22 +00:00
|
|
|
msys_version := $(if $(findstring Msys, $(shell uname -o)),$(word 1, $(subst ., ,$(shell uname -r))),0)
|
|
|
|
|
|
|
|
ifeq ($(msys_version), 0)
|
|
|
|
SDL2FLAGS=$(shell pkg-config sdl2 --cflags --libs)
|
|
|
|
BINLINKFLAGS=-z noexecstack
|
|
|
|
else
|
|
|
|
SDL2FLAGS=$(shell pkg-config sdl2 --cflags --libs) -mwindows -mconsole
|
|
|
|
BINLINKFLAGS=
|
|
|
|
endif
|
2024-10-15 05:06:52 +00:00
|
|
|
|
2024-10-23 23:47:28 +00:00
|
|
|
.PHONY: clean build
|
2024-10-15 05:06:52 +00:00
|
|
|
clean:
|
2024-10-23 23:47:28 +00:00
|
|
|
@rm -rf shrooms-vb output
|
|
|
|
|
|
|
|
CFILES := $(foreach dir,./,$(notdir $(wildcard $(dir)/*.c)))
|
|
|
|
BINFILES := $(foreach dir,assets/,$(notdir $(wildcard $(dir)/*.bin)))
|
|
|
|
|
|
|
|
COBJS := $(CFILES:%.c=output/%.o)
|
|
|
|
SHROOMSOBJS := output/vb.o
|
|
|
|
BINOBJS := $(BINFILES:%.bin=output/%.o)
|
|
|
|
|
|
|
|
OFILES := $(COBJS) $(SHROOMSOBJS) $(BINOBJS)
|
|
|
|
|
|
|
|
output/%.o: %.c
|
|
|
|
@mkdir -p output
|
|
|
|
@$(CC) -c -o $@ $< -I . \
|
|
|
|
-I shrooms-vb-core/core $(SDL2FLAGS) \
|
|
|
|
-D _POSIX_C_SOURCE=199309L \
|
|
|
|
-O3 -flto -fno-strict-aliasing \
|
|
|
|
-Werror -std=c11 -Wall -Wextra -Wpedantic
|
|
|
|
|
|
|
|
output/vb.o: shrooms-vb-core/core/vb.c
|
|
|
|
@mkdir -p output
|
|
|
|
@$(CC) -c -o $@ $< -I . \
|
|
|
|
-I shrooms-vb-core/core $(SDL2FLAGS) \
|
|
|
|
-D _POSIX_C_SOURCE=199309L \
|
|
|
|
-O3 -flto -fno-strict-aliasing \
|
|
|
|
-Werror -std=c11 -Wall -Wextra -Wpedantic
|
|
|
|
|
|
|
|
output/%.o: assets/%.bin
|
|
|
|
@mkdir -p output
|
2024-10-24 00:01:22 +00:00
|
|
|
@$(LD) -r -b binary $(BINLINKFLAGS) -o $@ $<
|
2024-10-23 23:47:28 +00:00
|
|
|
|
|
|
|
shrooms-vb: $(OFILES)
|
|
|
|
@$(CC) -o $@ $(OFILES) $(SDL2FLAGS) -flto
|
|
|
|
|
|
|
|
build: shrooms-vb
|