DISTRHO Plugin Framework
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

352 lines
12KB

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