53 lines
1.1 KiB
Makefile
53 lines
1.1 KiB
Makefile
#!/usr/bin/env -S gmake -f
|
|
|
|
# if need be, set these variables to whatever you need them to be
|
|
MKDIR ?= mkdir -p
|
|
|
|
EXTENSION ?= out
|
|
CFLAGS ?= -Wall -Wpedantic -Wextra -g -Og
|
|
CXXFLAGS ?= -std=c++20 -Wall -Wpedantic -Wextra -g -Og
|
|
LDFLAGS ?=
|
|
|
|
NAME := suwi
|
|
libs := m z portaudio SDL3
|
|
includes := src/
|
|
cflags := $(addprefix -I,${includes}) ${CFLAGS}
|
|
cxxflags := $(addprefix -I,${includes}) ${CXXFLAGS}
|
|
ldflags := $(addprefix -l,${libs}) ${LDFLAGS}
|
|
LD := ${CXX}
|
|
|
|
ns := out/${NS}
|
|
|
|
csrcs := $(wildcard src/*.c)
|
|
cxxsrcs := $(wildcard src/*.c++)
|
|
objs := ${csrcs:src/%.c=${ns}/%.o} ${cxxsrcs:src/%.c++=${ns}/%.o}
|
|
deps := $(wildcard out/*.d)
|
|
|
|
.PHONY: all res bin run clean
|
|
|
|
all: res bin
|
|
bin: ${ns}/${NAME}.${EXTENSION}
|
|
run: ${ns}/${NAME}.${EXTENSION}
|
|
$<
|
|
|
|
clean:
|
|
${RM} -r ${ns}/
|
|
|
|
${ns}/${NAME}.${EXTENSION}: ${objs}
|
|
${LD} -o $@ $^ ${ldflags}
|
|
|
|
${ns}/%.o: src/%.c | ${ns}/
|
|
${CC} ${cflags} -c -o $@ -MMD -MP -MF ${@:.o=.d} $<
|
|
|
|
${ns}/%.o: src/%.c++ | ${ns}/
|
|
${CXX} ${cxxflags} -c -o $@ -MMD -MP -MF ${@:.o=.d} $<
|
|
|
|
%/:
|
|
@${MKDIR} $@
|
|
|
|
#include assets.mk
|
|
|
|
ifeq ($(filter clean mostlyclean,${MAKECMDGOALS}),)
|
|
include ${deps}
|
|
endif
|