2024-02-22 11:31:35 +00:00
|
|
|
#
|
|
|
|
# Tibia
|
|
|
|
#
|
|
|
|
# Copyright (C) 2023, 2024 Orastron Srl unipersonale
|
|
|
|
#
|
|
|
|
# Tibia is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, version 3 of the License.
|
|
|
|
#
|
|
|
|
# Tibia is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with Tibia. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
# File author: Stefano D'Angelo
|
|
|
|
#
|
|
|
|
|
2023-12-11 17:54:54 +00:00
|
|
|
include vars.mk
|
|
|
|
|
2024-01-30 14:41:30 +00:00
|
|
|
ifeq ($(OS), Windows_NT)
|
2024-06-16 09:18:29 +00:00
|
|
|
DLL_SUFFIX := .vst3
|
|
|
|
PLATFORM := x86_64-win
|
|
|
|
VST3DIR := $(shell echo '$(COMMONPROGRAMFILES)' | sed 's:\\:/:g')/VST3
|
|
|
|
VST3DIR_USER := $(shell echo '$(LOCALAPPDATA)' | sed 's:\\:/:g')/Programs/Common/VST3
|
|
|
|
CC := gcc
|
|
|
|
CXX := g++
|
2024-01-30 14:41:30 +00:00
|
|
|
else
|
2024-06-16 09:18:29 +00:00
|
|
|
UNAME_S := $(shell uname -s)
|
2024-01-30 14:41:30 +00:00
|
|
|
ifeq ($(UNAME_S), Darwin)
|
2024-06-16 09:18:29 +00:00
|
|
|
DLL_SUFFIX :=
|
|
|
|
PLATFORM := MacOS
|
|
|
|
VST3DIR := /Library/Audio/Plug-Ins/VST3
|
|
|
|
VST3DIR_USER := $(HOME)/Library/Audio/Plug-Ins/VST3
|
|
|
|
CC := clang
|
|
|
|
CXX := clang++
|
2024-01-30 14:41:30 +00:00
|
|
|
else
|
2024-06-16 09:18:29 +00:00
|
|
|
DLL_SUFFIX := .so
|
|
|
|
PLATFORM := $(shell uname -m)-linux
|
|
|
|
VST3DIR := /usr/local/lib/vst3
|
|
|
|
VST3DIR_USER := $(HOME)/.vst3
|
|
|
|
CC := gcc
|
|
|
|
CXX := g++
|
2024-01-30 14:41:30 +00:00
|
|
|
endif
|
|
|
|
endif
|
2024-01-23 14:18:39 +00:00
|
|
|
|
2024-02-01 08:15:00 +00:00
|
|
|
COMMON_DIR := $(or $(COMMON_DIR),.)
|
|
|
|
DATA_DIR := $(or $(DATA_DIR),.)
|
|
|
|
PLUGIN_DIR := $(or $(PLUGIN_DIR),src)
|
|
|
|
|
2024-06-16 09:18:29 +00:00
|
|
|
CFLAGS := -O3 -Wall -Wpedantic -Wextra
|
|
|
|
CFLAGS_ALL := -I$(DATA_DIR)/src -I$(PLUGIN_DIR) -fPIC $(CFLAGS) $(CFLAGS_EXTRA)
|
2024-01-31 08:14:18 +00:00
|
|
|
|
2024-06-16 09:18:29 +00:00
|
|
|
LDFLAGS :=
|
|
|
|
LDFLAGS_ALL := -shared -lm $(LDFLAGS) $(LDFLAGS_EXTRA)
|
2023-12-11 17:54:54 +00:00
|
|
|
|
2024-06-16 09:18:29 +00:00
|
|
|
CXXFLAGS := $(CFLAGS)
|
|
|
|
CXXFLAGS_ALL := -I$(DATA_DIR)/src -I$(PLUGIN_DIR) -fPIC $(CXXFLAGS) $(CXXFLAGS_EXTRA)
|
2024-02-02 11:02:42 +00:00
|
|
|
|
2024-02-01 17:16:03 +00:00
|
|
|
ifeq ($(UNAME_S), Darwin)
|
2024-06-16 09:18:29 +00:00
|
|
|
CFLAGS_ALL := $(CFLAGS_ALL) -arch arm64 -arch x86_64
|
|
|
|
LDFLAGS_ALL := $(LDFLAGS_ALL) -arch arm64 -arch x86_64
|
|
|
|
CXXFLAGS_ALL := $(CXXFLAGS_ALL) -arch arm64 -arch x86_64
|
|
|
|
ifeq ($(HAS_UI), yes)
|
|
|
|
LDFLAGS_ALL := $(LDFLAGS_ALL) -Wl,-framework,Foundation -Wl,-framework,Cocoa -Wl,-framework,Corevideo
|
2024-05-30 15:07:34 +00:00
|
|
|
endif
|
2024-02-01 17:16:03 +00:00
|
|
|
endif
|
|
|
|
|
2024-05-10 15:54:13 +00:00
|
|
|
ifeq ($(UNAME_S), Linux)
|
2024-06-17 07:56:33 +00:00
|
|
|
CFLAGS_ALL := $(CFLAGS_ALL) -D_GNU_SOURCE
|
2024-06-17 08:30:56 +00:00
|
|
|
LDFLAGS_ALL := $(LDFLAGS_ALL) -ldl
|
2024-06-16 09:18:29 +00:00
|
|
|
ifeq ($(HAS_UI), yes)
|
|
|
|
CFLAGS_ALL := $(CFLAGS_ALL) $(shell pkg-config --cflags x11)
|
|
|
|
LDFLAGS_ALL := $(LDFLAGS_ALL) $(shell pkg-config --libs x11)
|
|
|
|
CXXFLAGS_ALL := $(CXXFLAGS_ALL) $(shell pkg-config --cflags x11)
|
2024-05-10 15:54:13 +00:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2024-06-16 09:18:29 +00:00
|
|
|
BUNDLE_DIR := $(BUNDLE_NAME).vst3
|
2023-12-11 17:54:54 +00:00
|
|
|
|
2024-06-16 09:18:29 +00:00
|
|
|
DLL_DIR := Contents/$(PLATFORM)
|
|
|
|
DLL_FILE := $(DLL_DIR)/$(BUNDLE_NAME)$(DLL_SUFFIX)
|
2023-12-11 17:54:54 +00:00
|
|
|
|
2024-09-27 13:24:51 +00:00
|
|
|
BUNDLE_DATA_PATH := build/$(BUNDLE_DIR)/Contents/Resources
|
|
|
|
BUNDLE_BIN_PATH := build/$(BUNDLE_DIR)/$(DLL_DIR)
|
|
|
|
|
2024-06-16 09:18:29 +00:00
|
|
|
C_SRCS := $(COMMON_DIR)/src/vst3.c $(C_SRCS_EXTRA)
|
|
|
|
C_OBJS := $(addprefix build/obj/, $(notdir $(C_SRCS:.c=.o)))
|
2024-02-01 19:48:22 +00:00
|
|
|
|
2024-07-26 13:46:22 +00:00
|
|
|
M_SRCS := $(M_SRCS_EXTRA)
|
|
|
|
M_OBJS := $(addprefix build/obj/, $(notdir $(M_SRCS:.m=.o)))
|
|
|
|
|
2024-06-16 09:18:29 +00:00
|
|
|
CXX_SRCS := $(CXX_SRCS_EXTRA)
|
|
|
|
CXX_OBJS := $(addprefix build/obj/, $(notdir $(CXX_SRCS:.cpp=.o)))
|
2024-01-30 14:41:30 +00:00
|
|
|
|
2024-06-16 09:18:29 +00:00
|
|
|
ALL := build/$(BUNDLE_DIR)/$(DLL_FILE)
|
2023-12-11 17:54:54 +00:00
|
|
|
|
2024-06-16 09:18:29 +00:00
|
|
|
ifeq ($(UNAME_S), Darwin)
|
|
|
|
ALL := $(ALL) build/$(BUNDLE_DIR)/Contents/Info.plist build/$(BUNDLE_DIR)/Contents/PkgInfo
|
2024-02-01 17:10:53 +00:00
|
|
|
endif
|
|
|
|
|
2024-06-16 10:04:02 +00:00
|
|
|
-include $(COMMON_DIR)/vars-extra.mk
|
|
|
|
|
2024-06-16 09:18:29 +00:00
|
|
|
all: $(ALL)
|
|
|
|
|
2024-02-02 11:02:42 +00:00
|
|
|
ifeq ($(CXX_OBJS),)
|
2024-07-26 13:46:22 +00:00
|
|
|
build/$(BUNDLE_DIR)/$(DLL_FILE): $(C_OBJS) $(M_OBJS) | build/$(BUNDLE_DIR)/$(DLL_DIR)
|
2024-06-16 09:18:29 +00:00
|
|
|
$(CC) $^ -o $@ $(CFLAGS_ALL) $(LDFLAGS_ALL)
|
2024-02-02 11:02:42 +00:00
|
|
|
else
|
2024-07-26 13:46:22 +00:00
|
|
|
build/$(BUNDLE_DIR)/$(DLL_FILE): $(C_OBJS) $(M_OBJS) $(CXX_OBJS) | build/$(BUNDLE_DIR)/$(DLL_DIR)
|
2024-06-16 09:18:29 +00:00
|
|
|
$(CXX) $^ -o $@ $(CFLAGS_ALL) $(CXXFLAGS_ALL) $(LDFLAGS_ALL)
|
2024-02-02 11:02:42 +00:00
|
|
|
endif
|
2023-12-11 17:54:54 +00:00
|
|
|
|
2024-06-16 09:18:29 +00:00
|
|
|
ifeq ($(UNAME_S), Darwin)
|
|
|
|
build/$(BUNDLE_DIR)/Contents/%: $(DATA_DIR)/data/% | build/$(BUNDLE_DIR)/Contents
|
|
|
|
cp $^ $@
|
2024-07-29 14:26:42 +00:00
|
|
|
|
|
|
|
build/$(BUNDLE_DIR)/Contents/%: $(COMMON_DIR)/data/% | build/$(BUNDLE_DIR)/Contents
|
|
|
|
cp $^ $@
|
2024-06-16 09:18:29 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
build/$(BUNDLE_DIR)/Contents build/$(BUNDLE_DIR)/$(DLL_DIR) build/obj:
|
2023-12-11 17:54:54 +00:00
|
|
|
mkdir -p $@
|
|
|
|
|
2024-09-27 13:24:51 +00:00
|
|
|
${BUNDLE_DATA_PATH}:
|
|
|
|
mkdir -p $@
|
|
|
|
|
2023-12-11 17:54:54 +00:00
|
|
|
clean:
|
|
|
|
rm -fr build
|
|
|
|
|
2024-01-30 14:41:30 +00:00
|
|
|
install: all
|
2024-06-29 11:12:19 +00:00
|
|
|
@for d in `find build/$(BUNDLE_DIR) -type d`; do \
|
|
|
|
d=`echo $$d | sed 's:^build/::'` ; \
|
|
|
|
echo mkdir -m 0755 -p "$(VST3DIR)/$$d"; \
|
|
|
|
mkdir -m 0755 -p "$(VST3DIR)/$$d"; \
|
|
|
|
done
|
2024-06-16 09:18:29 +00:00
|
|
|
@for f in `find build/$(BUNDLE_DIR) -type f`; do \
|
|
|
|
m=`[ -x $$f ] && echo 0755 || echo 0644`; \
|
|
|
|
d=`echo $$f | sed 's:^build/::'` ; \
|
|
|
|
d=`dirname $$d`; \
|
2024-06-29 11:12:19 +00:00
|
|
|
echo install -m $$m $$f "$(VST3DIR)/$$d"; \
|
|
|
|
install -m $$m $$f "$(VST3DIR)/$$d"; \
|
2024-06-16 09:18:29 +00:00
|
|
|
done
|
2024-01-30 14:41:30 +00:00
|
|
|
|
|
|
|
install-user: all
|
2024-06-29 11:12:19 +00:00
|
|
|
@for d in `find build/$(BUNDLE_DIR) -type d`; do \
|
|
|
|
d=`echo $$d | sed 's:^build/::'` ; \
|
|
|
|
echo mkdir -m 0755 -p "$(VST3DIR_USER)/$$d"; \
|
|
|
|
mkdir -m 0755 -p "$(VST3DIR_USER)/$$d"; \
|
|
|
|
done
|
2024-06-16 09:18:29 +00:00
|
|
|
@for f in `find build/$(BUNDLE_DIR) -type f`; do \
|
|
|
|
m=`[ -x $$f ] && echo 0755 || echo 0644`; \
|
|
|
|
d=`echo $$f | sed 's:^build/::'` ; \
|
|
|
|
d=`dirname $$d`; \
|
2024-06-29 11:12:19 +00:00
|
|
|
echo install -m $$m $$f "$(VST3DIR_USER)/$$d"; \
|
|
|
|
install -m $$m $$f "$(VST3DIR_USER)/$$d"; \
|
2024-06-16 09:18:29 +00:00
|
|
|
done
|
2024-01-30 14:41:30 +00:00
|
|
|
|
2024-06-16 10:04:02 +00:00
|
|
|
-include $(COMMON_DIR)/rules-extra.mk
|
2024-01-30 14:41:30 +00:00
|
|
|
|
|
|
|
.PHONY: all clean install install-user
|
2024-02-02 11:02:42 +00:00
|
|
|
|
|
|
|
.SECONDEXPANSION:
|
|
|
|
|
|
|
|
PERCENT := %
|
|
|
|
|
|
|
|
$(C_OBJS): build/obj/%.o: $$(filter $$(PERCENT)/$$(basename $$(notdir $$@)).c,$$(C_SRCS)) | build/obj
|
2024-06-16 09:18:29 +00:00
|
|
|
$(CC) $^ -o $@ -c $(CFLAGS_ALL)
|
2024-02-02 11:02:42 +00:00
|
|
|
|
2024-07-26 13:46:22 +00:00
|
|
|
$(M_OBJS): build/obj/%.o: $$(filter $$(PERCENT)/$$(basename $$(notdir $$@)).m,$$(M_SRCS)) | build/obj
|
|
|
|
$(CC) $^ -o $@ -c $(CFLAGS_ALL)
|
|
|
|
|
2024-02-02 11:02:42 +00:00
|
|
|
$(CXX_OBJS): build/obj/%.o: $$(filter $$(PERCENT)/$$(basename $$(notdir $$@)).cpp,$$(CXX_SRCS)) | build/obj
|
2024-06-16 09:18:29 +00:00
|
|
|
$(CXX) $^ -o $@ -c $(CXXFLAGS_ALL)
|
|
|
|
|
2024-06-16 10:04:02 +00:00
|
|
|
-include $(COMMON_DIR)/rules-secondexp-extra.mk
|