2024-10-15 05:06:52 +00:00
|
|
|
CC?=gcc
|
2024-10-23 23:47:28 +00:00
|
|
|
LD?=ld
|
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)
|
2024-10-30 03:25:26 +00:00
|
|
|
PKGFLAGS=$(shell pkg-config sdl2 --cflags --libs)
|
2024-10-24 00:01:22 +00:00
|
|
|
BINLINKFLAGS=-z noexecstack
|
|
|
|
else
|
2024-10-30 03:25:26 +00:00
|
|
|
PKGFLAGS=$(shell pkg-config sdl2 --cflags --libs) -mwindows -mconsole
|
2024-10-24 00:01:22 +00:00
|
|
|
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)
|
2024-10-30 03:25:26 +00:00
|
|
|
EXTOBJS = output/vb.o output/tinyfiledialogs.o
|
2024-10-23 23:47:28 +00:00
|
|
|
BINOBJS := $(BINFILES:%.bin=output/%.o)
|
|
|
|
|
2024-10-30 03:25:26 +00:00
|
|
|
OFILES := $(COBJS) $(EXTOBJS) $(BINOBJS)
|
2024-10-23 23:47:28 +00:00
|
|
|
|
|
|
|
output/%.o: %.c
|
|
|
|
@mkdir -p output
|
|
|
|
@$(CC) -c -o $@ $< -I . \
|
2024-10-30 03:25:26 +00:00
|
|
|
-I shrooms-vb-core/core $(PKGFLAGS) \
|
2024-10-26 16:46:26 +00:00
|
|
|
-O3 -flto=auto -Wno-long-long \
|
2024-10-24 02:50:44 +00:00
|
|
|
-Werror -std=c90 -Wall -Wextra -Wpedantic
|
2024-10-23 23:47:28 +00:00
|
|
|
|
|
|
|
output/vb.o: shrooms-vb-core/core/vb.c
|
|
|
|
@mkdir -p output
|
|
|
|
@$(CC) -c -o $@ $< -I . \
|
2024-10-26 05:20:25 +00:00
|
|
|
-I shrooms-vb-core/core \
|
|
|
|
-O3 -flto=auto -fno-strict-aliasing \
|
2024-10-24 02:50:44 +00:00
|
|
|
-Werror -std=c90 -Wall -Wextra -Wpedantic
|
2024-10-23 23:47:28 +00:00
|
|
|
|
2024-10-30 03:25:26 +00:00
|
|
|
output/tinyfiledialogs.o: external/tinyfiledialogs.c
|
|
|
|
@mkdir -p output
|
|
|
|
@$(CC) -c -o $@ $< -I . \
|
|
|
|
-I external \
|
|
|
|
-O3 -flto=auto -fno-strict-aliasing \
|
|
|
|
-Werror -std=c90 -Wall -Wextra -Wpedantic
|
|
|
|
|
2024-10-23 23:47:28 +00:00
|
|
|
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)
|
2024-10-30 03:25:26 +00:00
|
|
|
@$(CC) -o $@ $(OFILES) $(PKGFLAGS) -lm -flto=auto
|
2024-10-23 23:47:28 +00:00
|
|
|
|
|
|
|
build: shrooms-vb
|