tibia/templates/cmd-make/Makefile

83 lines
2.1 KiB
Makefile
Raw Normal View History

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
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),.)
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
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}
LDFLAGS =
2024-02-19 13:40:03 +00:00
LDFLAGS_ALL = -lm ${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
C_SRCS = ${COMMON_DIR}/src/main.c ${C_SRCS_EXTRA}
ifeq ($(HAS_MIDI_IN), yes)
C_SRCS += ${MIDI_PARSER_DIR}/src/midi-parser.c
endif
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),)
build/${PROGRAM}: ${C_OBJS} build/obj/tinywav.o | build
2024-02-01 18:35:18 +00:00
${CC} $^ -o $@ ${CFLAGS_ALL} ${LDFLAGS_ALL}
2024-02-02 10:25:20 +00:00
else
2024-02-06 10:54:59 +00:00
build/${PROGRAM}: ${C_OBJS} ${CXX_OBJS} build/obj/tinywav.o | 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-02-01 18:35:18 +00:00
build build/obj:
2024-01-24 11:08:49 +00:00
mkdir -p $@
clean:
rm -fr build
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}
.PHONY: all clean install
endif
2024-02-02 10:25:20 +00:00
.SECONDEXPANSION:
PERCENT := %
build/obj/tinywav.o: ${TINYWAV_DIR}/tinywav.c
${CC} $^ -o $@ -c ${CFLAGS_ALL} -Wno-unused-result
2024-02-02 10:25:20 +00:00
$(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}