shrooms-vb-native/makefile

54 lines
1.4 KiB
Makefile

CC?=gcc
LD?=ld
msys_version := $(if $(findstring Msys, $(shell uname -o)),$(word 1, $(subst ., ,$(shell uname -r))),0)
ifeq ($(msys_version), 0)
PKGFLAGS=$(shell pkg-config sdl2 --cflags --libs)
BINLINKFLAGS=-z noexecstack
else
PKGFLAGS=$(shell pkg-config sdl2 --cflags --libs) -mwindows -mconsole
BINLINKFLAGS=
endif
.PHONY: clean build
clean:
@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)
EXTOBJS = output/vb.o output/tinyfiledialogs.o
BINOBJS := $(BINFILES:%.bin=output/%.o)
OFILES := $(COBJS) $(EXTOBJS) $(BINOBJS)
output/%.o: %.c
@mkdir -p output
@$(CC) -c -o $@ $< -I . \
-I shrooms-vb-core/core $(PKGFLAGS) \
-O3 -flto=auto -Wno-long-long \
-Werror -std=c90 -Wall -Wextra -Wpedantic
output/vb.o: shrooms-vb-core/core/vb.c
@mkdir -p output
@$(CC) -c -o $@ $< -I . \
-I shrooms-vb-core/core \
-O3 -flto=auto -fno-strict-aliasing \
-Werror -std=c90 -Wall -Wextra -Wpedantic
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
output/%.o: assets/%.bin
@mkdir -p output
@$(LD) -r -b binary $(BINLINKFLAGS) -o $@ $<
shrooms-vb: $(OFILES)
@$(CC) -o $@ $(OFILES) $(PKGFLAGS) -lm -flto=auto
build: shrooms-vb