2024-01-24 11:08:49 +00:00
|
|
|
include vars.mk
|
|
|
|
|
2024-01-30 08:56:00 +00:00
|
|
|
ifeq ($(OS), Windows_NT)
|
|
|
|
EXE_SUFFIX = .exe
|
|
|
|
else
|
2024-01-30 14:41:30 +00:00
|
|
|
UNAME_S = $(shell uname -s)
|
2024-01-30 08:56:00 +00:00
|
|
|
EXE_SUFFIX =
|
|
|
|
PREFIX = /usr/local
|
|
|
|
BINDIR = ${PREFIX}/bin
|
|
|
|
endif
|
|
|
|
|
2024-02-01 05:59:10 +00:00
|
|
|
COMMON_DIR := $(or $(COMMON_DIR),.)
|
|
|
|
DATA_DIR := $(or $(DATA_DIR),.)
|
2024-02-01 05:16:50 +00:00
|
|
|
PLUGIN_DIR := $(or $(PLUGIN_DIR),src)
|
|
|
|
|
2024-01-24 11:08:49 +00:00
|
|
|
CC = gcc
|
2024-02-02 10:25:20 +00:00
|
|
|
CXX = g++
|
2024-01-24 11:08:49 +00:00
|
|
|
|
2024-01-31 08:14:18 +00:00
|
|
|
CFLAGS = -O3 -Wall -Wpedantic -Wextra
|
2024-02-01 05:59:10 +00:00
|
|
|
CFLAGS_ALL = -I${DATA_DIR}/src -I${PLUGIN_DIR} -I${TINYWAV_DIR} -I${MIDI_PARSER_DIR}/include -fPIC ${CFLAGS} ${CFLAGS_EXTRA}
|
2024-01-31 08:14:18 +00:00
|
|
|
|
|
|
|
LDFLAGS =
|
|
|
|
LDFLAGS_ALL = ${LDFLAGS} ${LDFLAGS_EXTRA}
|
2024-01-24 11:08:49 +00:00
|
|
|
|
2024-02-02 10:25:20 +00:00
|
|
|
CXXFLAGS = ${CFLAGS}
|
|
|
|
CXXFLAGS_ALL = -I${DATA_DIR}/src -I${PLUGIN_DIR} -I${TINYWAV_DIR} -I${MIDI_PARSER_DIR}/include -fPIC ${CXXFLAGS} ${CXXFLAGS_EXTRA}
|
|
|
|
|
2024-02-01 17:16:03 +00:00
|
|
|
ifeq ($(UNAME_S), Darwin)
|
|
|
|
CFLAGS_ALL := ${CFLAGS_ALL} -arch arm64 -arch x86_64
|
|
|
|
LDFLAGS_ALL := ${LDFLAGS_ALL} -arch arm64 -arch x86_64
|
2024-02-02 10:25:20 +00:00
|
|
|
CXXFLAGS_ALL := ${CXXFLAGS_ALL} -arch arm64 -arch x86_64
|
2024-02-01 17:16:03 +00:00
|
|
|
endif
|
|
|
|
|
2024-01-30 08:56:00 +00:00
|
|
|
PROGRAM = ${BUNDLE_NAME}${EXE_SUFFIX}
|
2024-01-24 11:08:49 +00:00
|
|
|
|
2024-02-02 10:25:20 +00:00
|
|
|
C_SRCS = ${COMMON_DIR}/src/main.c ${TINYWAV_DIR}/tinywav.c ${MIDI_PARSER_DIR}/src/midi-parser.c ${C_SRCS_EXTRA}
|
2024-02-01 18:35:18 +00:00
|
|
|
C_OBJS = $(addprefix build/obj/, $(notdir $(C_SRCS:.c=.o)))
|
|
|
|
|
2024-02-02 10:25:20 +00:00
|
|
|
CXX_SRCS = ${CXX_SRCS_EXTRA}
|
|
|
|
CXX_OBJS = $(addprefix build/obj/, $(notdir $(CXX_SRCS:.cpp=.o)))
|
|
|
|
|
2024-01-30 08:56:00 +00:00
|
|
|
all: build/${PROGRAM}
|
|
|
|
|
2024-02-02 10:25:20 +00:00
|
|
|
ifeq ($(CXX_OBJS),)
|
2024-02-01 18:35:18 +00:00
|
|
|
build/${PROGRAM}: ${C_OBJS} | build
|
|
|
|
${CC} $^ -o $@ ${CFLAGS_ALL} ${LDFLAGS_ALL}
|
2024-02-02 10:25:20 +00:00
|
|
|
else
|
|
|
|
build/${PROGRAM}: ${C_OBJS} ${CXX_OBJS} | build
|
2024-02-02 10:55:39 +00:00
|
|
|
${CXX} $^ -o $@ ${CFLAGS_ALL} ${CXXFLAGS_ALL} ${LDFLAGS_ALL}
|
2024-02-02 10:25:20 +00:00
|
|
|
endif
|
2024-01-30 14:41:30 +00:00
|
|
|
|
2024-02-01 18:35:18 +00:00
|
|
|
build build/obj:
|
2024-01-24 11:08:49 +00:00
|
|
|
mkdir -p $@
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -fr build
|
|
|
|
|
2024-01-30 14:41:30 +00:00
|
|
|
ifeq ($(OS), Windows_NT)
|
|
|
|
.PHONY: all clean
|
|
|
|
else
|
2024-01-30 08:56:00 +00:00
|
|
|
install: all
|
|
|
|
mkdir -p -m 0755 ${BINDIR}
|
|
|
|
install -m 0755 build/${PROGRAM} ${BINDIR}
|
|
|
|
|
2024-01-30 14:41:30 +00:00
|
|
|
.PHONY: all clean install
|
|
|
|
endif
|
2024-02-02 10:25:20 +00:00
|
|
|
|
|
|
|
.SECONDEXPANSION:
|
|
|
|
|
|
|
|
PERCENT := %
|
|
|
|
|
|
|
|
$(C_OBJS): build/obj/%.o: $$(filter $$(PERCENT)/$$(basename $$(notdir $$@)).c,$$(C_SRCS)) | build/obj
|
|
|
|
${CC} $^ -o $@ -c ${CFLAGS_ALL}
|
|
|
|
|
|
|
|
$(CXX_OBJS): build/obj/%.o: $$(filter $$(PERCENT)/$$(basename $$(notdir $$@)).cpp,$$(CXX_SRCS)) | build/obj
|
|
|
|
${CXX} $^ -o $@ -c ${CXXFLAGS_ALL}
|