1#!/usr/bin/make -f
2# Makefile for DPF Example Plugins #
3# -------------------------------- #
4# Created by falkTX
5#
6
7# NOTE: NAME, FILES_DSP and FILES_UI must have been defined before including this file!
8
9
10ifeq ($(DPF_CUSTOM_PATH),)
11ifeq (,$(wildcard ../../Makefile.base.mk))
12DPF_PATH=../../dpf
13else
14DPF_PATH=../..
15endif
16else
17DPF_PATH = $(DPF_CUSTOM_PATH)
18endif
19
20include $(DPF_PATH)/Makefile.base.mk
21
22# ---------------------------------------------------------------------------------------------------------------------
23# Basic setup
24
25ifeq ($(DPF_CUSTOM_PATH),)
26TARGET_DIR = ../../bin
27BUILD_DIR = ../../build/$(NAME)
28else
29ifeq ($(DPF_CUSTOM_TARGET_DIR),)
30$(error DPF_CUSTOM_TARGET_DIR is not set)
31else
32TARGET_DIR = $(DPF_CUSTOM_TARGET_DIR)
33endif
34ifeq ($(DPF_CUSTOM_BUILD_DIR),)
35$(error DPF_CUSTOM_BUILD_DIR is not set)
36else
37BUILD_DIR = $(DPF_CUSTOM_BUILD_DIR)
38endif
39endif
40
41BUILD_C_FLAGS   += -I.
42BUILD_CXX_FLAGS += -I. -I$(DPF_PATH)/distrho -I$(DPF_PATH)/dgl
43
44ifeq ($(HAVE_CAIRO),true)
45DGL_FLAGS += -DHAVE_CAIRO
46endif
47
48ifeq ($(HAVE_OPENGL),true)
49DGL_FLAGS += -DHAVE_OPENGL
50endif
51
52ifeq ($(HAVE_JACK),true)
53BASE_FLAGS += -DHAVE_JACK
54endif
55
56ifeq ($(HAVE_LIBLO),true)
57BASE_FLAGS += -DHAVE_LIBLO
58endif
59
60# ---------------------------------------------------------------------------------------------------------------------
61# Set files to build
62
63OBJS_DSP = $(FILES_DSP:%=$(BUILD_DIR)/%.o)
64OBJS_UI  = $(FILES_UI:%=$(BUILD_DIR)/%.o)
65
66# ---------------------------------------------------------------------------------------------------------------------
67# Set plugin binary file targets
68
69jack       = $(TARGET_DIR)/$(NAME)$(APP_EXT)
70ladspa_dsp = $(TARGET_DIR)/$(NAME)-ladspa$(LIB_EXT)
71dssi_dsp   = $(TARGET_DIR)/$(NAME)-dssi$(LIB_EXT)
72dssi_ui    = $(TARGET_DIR)/$(NAME)-dssi/$(NAME)_ui$(APP_EXT)
73lv2        = $(TARGET_DIR)/$(NAME).lv2/$(NAME)$(LIB_EXT)
74lv2_dsp    = $(TARGET_DIR)/$(NAME).lv2/$(NAME)_dsp$(LIB_EXT)
75lv2_ui     = $(TARGET_DIR)/$(NAME).lv2/$(NAME)_ui$(LIB_EXT)
76vst        = $(TARGET_DIR)/$(NAME)-vst$(LIB_EXT)
77
78# ---------------------------------------------------------------------------------------------------------------------
79# Handle UI stuff, disable UI support automatically
80
81ifeq ($(FILES_UI),)
82UI_TYPE = none
83endif
84
85ifeq ($(UI_TYPE),)
86UI_TYPE = opengl
87endif
88
89ifeq ($(UI_TYPE),cairo)
90DGL_FLAGS += -DDGL_CAIRO
91ifeq ($(HAVE_CAIRO),true)
92DGL_FLAGS += $(CAIRO_FLAGS)
93DGL_LIBS  += $(CAIRO_LIBS)
94DGL_LIB    = $(DPF_PATH)/build/libdgl-cairo.a
95HAVE_DGL   = true
96else
97HAVE_DGL   = false
98endif
99endif
100
101ifeq ($(UI_TYPE),opengl)
102DGL_FLAGS += -DDGL_OPENGL
103ifeq ($(HAVE_OPENGL),true)
104DGL_FLAGS += $(OPENGL_FLAGS)
105DGL_LIBS  += $(OPENGL_LIBS)
106DGL_LIB    = $(DPF_PATH)/build/libdgl-opengl.a
107HAVE_DGL   = true
108else
109HAVE_DGL   = false
110endif
111endif
112
113ifeq ($(UI_TYPE),external)
114DGL_FLAGS += -DDGL_EXTERNAL
115HAVE_DGL   = true
116endif
117
118DGL_LIBS += $(DGL_SYSTEM_LIBS)
119
120ifneq ($(HAVE_DGL),true)
121dssi_ui =
122lv2_ui =
123DGL_LIBS =
124OBJS_UI =
125endif
126
127ifneq ($(HAVE_LIBLO),true)
128dssi_ui =
129endif
130
131# TODO split dsp and ui object build flags
132BASE_FLAGS += $(DGL_FLAGS)
133
134# ---------------------------------------------------------------------------------------------------------------------
135# all needs to be first
136
137all:
138
139# ---------------------------------------------------------------------------------------------------------------------
140# Common
141
142$(BUILD_DIR)/%.c.o: %.c
143	-@mkdir -p "$(shell dirname $(BUILD_DIR)/$<)"
144	@echo "Compiling $<"
145	$(SILENT)$(CC) $< $(BUILD_C_FLAGS) -c -o $@
146
147$(BUILD_DIR)/%.cc.o: %.cc
148	-@mkdir -p "$(shell dirname $(BUILD_DIR)/$<)"
149	@echo "Compiling $<"
150	$(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@
151
152$(BUILD_DIR)/%.cpp.o: %.cpp
153	-@mkdir -p "$(shell dirname $(BUILD_DIR)/$<)"
154	@echo "Compiling $<"
155	$(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@
156
157clean:
158	rm -rf $(BUILD_DIR)
159	rm -rf $(TARGET_DIR)/$(NAME) $(TARGET_DIR)/$(NAME)-* $(TARGET_DIR)/$(NAME).lv2
160
161# ---------------------------------------------------------------------------------------------------------------------
162
163$(BUILD_DIR)/DistrhoPluginMain_%.cpp.o: $(DPF_PATH)/distrho/DistrhoPluginMain.cpp
164	-@mkdir -p $(BUILD_DIR)
165	@echo "Compiling DistrhoPluginMain.cpp ($*)"
166	$(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) -DDISTRHO_PLUGIN_TARGET_$* -c -o $@
167
168$(BUILD_DIR)/DistrhoUIMain_%.cpp.o: $(DPF_PATH)/distrho/DistrhoUIMain.cpp
169	-@mkdir -p $(BUILD_DIR)
170	@echo "Compiling DistrhoUIMain.cpp ($*)"
171	$(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) -DDISTRHO_PLUGIN_TARGET_$* -c -o $@
172
173$(BUILD_DIR)/DistrhoPluginMain_JACK.cpp.o: $(DPF_PATH)/distrho/DistrhoPluginMain.cpp
174	-@mkdir -p $(BUILD_DIR)
175	@echo "Compiling DistrhoPluginMain.cpp (JACK)"
176	$(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) $(shell $(PKG_CONFIG) --cflags jack) -DDISTRHO_PLUGIN_TARGET_JACK -c -o $@
177
178$(BUILD_DIR)/DistrhoUIMain_DSSI.cpp.o: $(DPF_PATH)/distrho/DistrhoUIMain.cpp
179	-@mkdir -p $(BUILD_DIR)
180	@echo "Compiling DistrhoUIMain.cpp (DSSI)"
181	$(SILENT)$(CXX) $< $(BUILD_CXX_FLAGS) $(shell $(PKG_CONFIG) --cflags liblo) -DDISTRHO_PLUGIN_TARGET_DSSI -c -o $@
182
183# ---------------------------------------------------------------------------------------------------------------------
184# JACK
185
186jack: $(jack)
187
188ifeq ($(HAVE_DGL),true)
189$(jack): $(OBJS_DSP) $(OBJS_UI) $(BUILD_DIR)/DistrhoPluginMain_JACK.cpp.o $(BUILD_DIR)/DistrhoUIMain_JACK.cpp.o $(DGL_LIB)
190else
191$(jack): $(OBJS_DSP) $(BUILD_DIR)/DistrhoPluginMain_JACK.cpp.o
192endif
193	-@mkdir -p $(shell dirname $@)
194	@echo "Creating JACK standalone for $(NAME)"
195	$(SILENT)$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(DGL_LIBS) $(shell $(PKG_CONFIG) --libs jack) -o $@
196
197# ---------------------------------------------------------------------------------------------------------------------
198# LADSPA
199
200ladspa: $(ladspa_dsp)
201
202$(ladspa_dsp): $(OBJS_DSP) $(BUILD_DIR)/DistrhoPluginMain_LADSPA.cpp.o
203	-@mkdir -p $(shell dirname $@)
204	@echo "Creating LADSPA plugin for $(NAME)"
205	$(SILENT)$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(SHARED) -o $@
206
207# ---------------------------------------------------------------------------------------------------------------------
208# DSSI
209
210dssi:     $(dssi_dsp) $(dssi_ui)
211dssi_dsp: $(dssi_dsp)
212dssi_ui:  $(dssi_ui)
213
214$(dssi_dsp): $(OBJS_DSP) $(BUILD_DIR)/DistrhoPluginMain_DSSI.cpp.o
215	-@mkdir -p $(shell dirname $@)
216	@echo "Creating DSSI plugin library for $(NAME)"
217	$(SILENT)$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(SHARED) -o $@
218
219$(dssi_ui): $(OBJS_UI) $(BUILD_DIR)/DistrhoUIMain_DSSI.cpp.o $(DGL_LIB)
220	-@mkdir -p $(shell dirname $@)
221	@echo "Creating DSSI UI for $(NAME)"
222	$(SILENT)$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(DGL_LIBS) $(shell $(PKG_CONFIG) --libs liblo) -o $@
223
224# ---------------------------------------------------------------------------------------------------------------------
225# LV2
226
227lv2: $(lv2)
228lv2_dsp: $(lv2_dsp)
229lv2_sep: $(lv2_dsp) $(lv2_ui)
230
231$(lv2): $(OBJS_DSP) $(OBJS_UI) $(BUILD_DIR)/DistrhoPluginMain_LV2.cpp.o $(BUILD_DIR)/DistrhoUIMain_LV2.cpp.o $(DGL_LIB)
232	-@mkdir -p $(shell dirname $@)
233	@echo "Creating LV2 plugin for $(NAME)"
234	$(SILENT)$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(DGL_LIBS) $(SHARED) -o $@
235
236$(lv2_dsp): $(OBJS_DSP) $(BUILD_DIR)/DistrhoPluginMain_LV2.cpp.o
237	-@mkdir -p $(shell dirname $@)
238	@echo "Creating LV2 plugin library for $(NAME)"
239	$(SILENT)$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(SHARED) -o $@
240
241$(lv2_ui): $(OBJS_UI) $(BUILD_DIR)/DistrhoUIMain_LV2.cpp.o $(DGL_LIB)
242	-@mkdir -p $(shell dirname $@)
243	@echo "Creating LV2 plugin UI for $(NAME)"
244	$(SILENT)$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(DGL_LIBS) $(SHARED) -o $@
245
246# ---------------------------------------------------------------------------------------------------------------------
247# VST
248
249vst: $(vst)
250
251ifeq ($(HAVE_DGL),true)
252$(vst): $(OBJS_DSP) $(OBJS_UI) $(BUILD_DIR)/DistrhoPluginMain_VST.cpp.o $(BUILD_DIR)/DistrhoUIMain_VST.cpp.o $(DGL_LIB)
253else
254$(vst): $(OBJS_DSP) $(BUILD_DIR)/DistrhoPluginMain_VST.cpp.o
255endif
256	-@mkdir -p $(shell dirname $@)
257	@echo "Creating VST plugin for $(NAME)"
258	$(SILENT)$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(DGL_LIBS) $(SHARED) -o $@
259
260# ---------------------------------------------------------------------------------------------------------------------
261
262-include $(OBJS_DSP:%.o=%.d)
263ifeq ($(HAVE_DGL),true)
264-include $(OBJS_UI:%.o=%.d)
265endif
266
267-include $(BUILD_DIR)/DistrhoPluginMain_JACK.cpp.d
268-include $(BUILD_DIR)/DistrhoPluginMain_LADSPA.cpp.d
269-include $(BUILD_DIR)/DistrhoPluginMain_DSSI.cpp.d
270-include $(BUILD_DIR)/DistrhoPluginMain_LV2.cpp.d
271-include $(BUILD_DIR)/DistrhoPluginMain_VST.cpp.d
272
273-include $(BUILD_DIR)/DistrhoUIMain_JACK.cpp.d
274-include $(BUILD_DIR)/DistrhoUIMain_DSSI.cpp.d
275-include $(BUILD_DIR)/DistrhoUIMain_LV2.cpp.d
276-include $(BUILD_DIR)/DistrhoUIMain_VST.cpp.d
277
278# ---------------------------------------------------------------------------------------------------------------------
279