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.

388 lines
13KB

  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. # FIXME no-overloaded-virtual should be fixed!
  60. AU_LINK_FLAGS = \
  61. -bundle \
  62. -framework AudioToolbox \
  63. -framework AudioUnit \
  64. -framework CoreFoundation \
  65. -framework CoreServices \
  66. -exported_symbols_list $(DPF_PATH)/distrho/src/DistrhoPluginAU.exp
  67. # not needed yet
  68. # -I$(DPF_PATH)/distrho/src/CoreAudio106/AudioUnits/AUPublic/AUCarbonViewBase
  69. # -I$(DPF_PATH)/distrho/src/CoreAudio106/AudioUnits/AUPublic/AUInstrumentBase
  70. # -I$(DPF_PATH)/distrho/src/CoreAudio106/AudioUnits/AUPublic/AUViewBase
  71. # -I$(DPF_PATH)/distrho/src/CoreAudio106/AudioUnits/AUPublic/OtherBases
  72. # -framework CoreAudio \
  73. # ---------------------------------------------------------------------------------------------------------------------
  74. # Set flags for 'Rez', needed for AU
  75. ifneq ($(CROSS_COMPILING),true)
  76. # Use environment to find arch
  77. ifeq ($(shell echo ${CXXFLAGS} | grep -q -- -arch && echo true),true)
  78. ifeq ($(shell echo ${CXXFLAGS} | grep -q -- x86_64 && echo true),true)
  79. REZ_FLAGS += -arch x86_64 -d x86_64_YES
  80. endif
  81. ifeq ($(shell echo ${CXXFLAGS} | grep -q -- i386 && echo true),true)
  82. REZ_FLAGS += -arch i386 -d i386_YES
  83. endif
  84. else # No "-arch" in environment, automatically detect arch
  85. ifeq ($(shell gcc -dM -E - < /dev/null | grep -q -- __x86_64__ && echo true),true)
  86. REZ_FLAGS += -arch x86_64 -d x86_64_YES
  87. endif
  88. ifeq ($(shell gcc -dM -E - < /dev/null | grep -q -- __i386__ && echo true),true)
  89. REZ_FLAGS += -arch i386 -d i386_YES
  90. endif
  91. endif # CXXFLAGS
  92. endif # CROSS_COMPILING
  93. # ---------------------------------------------------------------------------------------------------------------------
  94. # Handle UI stuff, disable UI support automatically
  95. ifeq ($(FILES_UI),)
  96. UI_TYPE = none
  97. endif
  98. ifeq ($(UI_TYPE),)
  99. UI_TYPE = opengl
  100. endif
  101. ifeq ($(UI_TYPE),cairo)
  102. ifeq ($(HAVE_CAIRO),true)
  103. DGL_FLAGS += $(CAIRO_FLAGS) -DDGL_CAIRO
  104. DGL_LIBS += $(CAIRO_LIBS)
  105. DGL_LIB = $(DPF_PATH)/build/libdgl-cairo.a
  106. HAVE_DGL = true
  107. else
  108. HAVE_DGL = false
  109. endif
  110. endif
  111. ifeq ($(UI_TYPE),opengl)
  112. ifeq ($(HAVE_OPENGL),true)
  113. DGL_FLAGS += $(OPENGL_FLAGS) -DDGL_OPENGL
  114. DGL_LIBS += $(OPENGL_LIBS)
  115. DGL_LIB = $(DPF_PATH)/build/libdgl-opengl.a
  116. HAVE_DGL = true
  117. else
  118. HAVE_DGL = false
  119. endif
  120. endif
  121. DGL_LIBS += $(DGL_SYSTEM_LIBS)
  122. ifneq ($(HAVE_DGL),true)
  123. dssi_ui =
  124. lv2_ui =
  125. DGL_LIBS =
  126. OBJS_UI =
  127. endif
  128. # TODO split dsp and ui object build flags
  129. BASE_FLAGS += $(DGL_FLAGS)
  130. # ---------------------------------------------------------------------------------------------------------------------
  131. # all needs to be first
  132. all:
  133. # ---------------------------------------------------------------------------------------------------------------------
  134. # Common
  135. $(BUILD_DIR)/%.c.o: %.c
  136. -@mkdir -p "$(shell dirname $(BUILD_DIR)/$<)"
  137. @echo "Compiling $<"
  138. @$(CC) $< $(BUILD_C_FLAGS) -c -o $@
  139. $(BUILD_DIR)/%.cc.o: %.cc
  140. -@mkdir -p "$(shell dirname $(BUILD_DIR)/$<)"
  141. @echo "Compiling $<"
  142. @$(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@
  143. $(BUILD_DIR)/%.cpp.o: %.cpp
  144. -@mkdir -p "$(shell dirname $(BUILD_DIR)/$<)"
  145. @echo "Compiling $<"
  146. @$(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@
  147. clean:
  148. rm -rf $(BUILD_DIR)
  149. rm -rf $(TARGET_DIR)/$(NAME) $(TARGET_DIR)/$(NAME)-* $(TARGET_DIR)/$(NAME).lv2
  150. # ---------------------------------------------------------------------------------------------------------------------
  151. $(BUILD_DIR)/DistrhoPluginMain_%.cpp.o: $(DPF_PATH)/distrho/DistrhoPluginMain.cpp
  152. -@mkdir -p $(BUILD_DIR)
  153. @echo "Compiling DistrhoPluginMain.cpp ($*)"
  154. @$(CXX) $< $(BUILD_CXX_FLAGS) -DDISTRHO_PLUGIN_TARGET_$* -c -o $@
  155. $(BUILD_DIR)/DistrhoUIMain_%.cpp.o: $(DPF_PATH)/distrho/DistrhoUIMain.cpp
  156. -@mkdir -p $(BUILD_DIR)
  157. @echo "Compiling DistrhoUIMain.cpp ($*)"
  158. @$(CXX) $< $(BUILD_CXX_FLAGS) -DDISTRHO_PLUGIN_TARGET_$* -c -o $@
  159. $(BUILD_DIR)/DistrhoPluginMain_JACK.cpp.o: $(DPF_PATH)/distrho/DistrhoPluginMain.cpp
  160. -@mkdir -p $(BUILD_DIR)
  161. @echo "Compiling DistrhoPluginMain.cpp (JACK)"
  162. @$(CXX) $< $(BUILD_CXX_FLAGS) $(shell $(PKG_CONFIG) --cflags jack) -DDISTRHO_PLUGIN_TARGET_JACK -c -o $@
  163. $(BUILD_DIR)/DistrhoPluginMain_AU.cpp.o: $(DPF_PATH)/distrho/DistrhoPluginMain.cpp
  164. -@mkdir -p $(BUILD_DIR)
  165. @echo "Compiling DistrhoPluginMain.cpp (AU)"
  166. $(CXX) $< $(BUILD_CXX_FLAGS) $(AU_BUILD_FLAGS) -DDISTRHO_PLUGIN_TARGET_AU -c -o $@
  167. $(BUILD_DIR)/DistrhoUIMain_DSSI.cpp.o: $(DPF_PATH)/distrho/DistrhoUIMain.cpp
  168. -@mkdir -p $(BUILD_DIR)
  169. @echo "Compiling DistrhoUIMain.cpp (DSSI)"
  170. @$(CXX) $< $(BUILD_CXX_FLAGS) $(shell $(PKG_CONFIG) --cflags liblo) -DDISTRHO_PLUGIN_TARGET_DSSI -c -o $@
  171. $(BUILD_DIR)/DistrhoPluginAUexport.cpp.o: $(DPF_PATH)/distrho/src/DistrhoPluginAUexport.cpp
  172. -@mkdir -p $(BUILD_DIR)
  173. @echo "Compiling DistrhoPluginAUexport.cpp"
  174. $(CXX) $< $(BUILD_CXX_FLAGS) -c -o $@
  175. # ---------------------------------------------------------------------------------------------------------------------
  176. # JACK
  177. jack: $(jack)
  178. ifeq ($(HAVE_DGL),true)
  179. $(jack): $(OBJS_DSP) $(OBJS_UI) $(BUILD_DIR)/DistrhoPluginMain_JACK.cpp.o $(BUILD_DIR)/DistrhoUIMain_JACK.cpp.o $(DGL_LIB)
  180. else
  181. $(jack): $(OBJS_DSP) $(BUILD_DIR)/DistrhoPluginMain_JACK.cpp.o
  182. endif
  183. -@mkdir -p $(shell dirname $@)
  184. @echo "Creating JACK standalone for $(NAME)"
  185. @$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(DGL_LIBS) $(shell $(PKG_CONFIG) --libs jack) -o $@
  186. # ---------------------------------------------------------------------------------------------------------------------
  187. # LADSPA
  188. ladspa: $(ladspa_dsp)
  189. $(ladspa_dsp): $(OBJS_DSP) $(BUILD_DIR)/DistrhoPluginMain_LADSPA.cpp.o
  190. -@mkdir -p $(shell dirname $@)
  191. @echo "Creating LADSPA plugin for $(NAME)"
  192. @$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(SHARED) -o $@
  193. # ---------------------------------------------------------------------------------------------------------------------
  194. # DSSI
  195. dssi: $(dssi_dsp) $(dssi_ui)
  196. dssi_dsp: $(dssi_dsp)
  197. dssi_ui: $(dssi_ui)
  198. $(dssi_dsp): $(OBJS_DSP) $(BUILD_DIR)/DistrhoPluginMain_DSSI.cpp.o
  199. -@mkdir -p $(shell dirname $@)
  200. @echo "Creating DSSI plugin library for $(NAME)"
  201. @$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(SHARED) -o $@
  202. $(dssi_ui): $(OBJS_UI) $(BUILD_DIR)/DistrhoUIMain_DSSI.cpp.o $(DGL_LIB)
  203. -@mkdir -p $(shell dirname $@)
  204. @echo "Creating DSSI UI for $(NAME)"
  205. @$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(DGL_LIBS) $(shell $(PKG_CONFIG) --libs liblo) -o $@
  206. # ---------------------------------------------------------------------------------------------------------------------
  207. # LV2
  208. lv2: $(lv2)
  209. lv2_dsp: $(lv2_dsp)
  210. lv2_sep: $(lv2_dsp) $(lv2_ui)
  211. $(lv2): $(OBJS_DSP) $(OBJS_UI) $(BUILD_DIR)/DistrhoPluginMain_LV2.cpp.o $(BUILD_DIR)/DistrhoUIMain_LV2.cpp.o $(DGL_LIB)
  212. -@mkdir -p $(shell dirname $@)
  213. @echo "Creating LV2 plugin for $(NAME)"
  214. @$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(DGL_LIBS) $(SHARED) -o $@
  215. $(lv2_dsp): $(OBJS_DSP) $(BUILD_DIR)/DistrhoPluginMain_LV2.cpp.o
  216. -@mkdir -p $(shell dirname $@)
  217. @echo "Creating LV2 plugin library for $(NAME)"
  218. @$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(SHARED) -o $@
  219. $(lv2_ui): $(OBJS_UI) $(BUILD_DIR)/DistrhoUIMain_LV2.cpp.o $(DGL_LIB)
  220. -@mkdir -p $(shell dirname $@)
  221. @echo "Creating LV2 plugin UI for $(NAME)"
  222. @$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(DGL_LIBS) $(SHARED) -o $@
  223. # ---------------------------------------------------------------------------------------------------------------------
  224. # VST
  225. vst: $(vst)
  226. ifeq ($(HAVE_DGL),true)
  227. $(vst): $(OBJS_DSP) $(OBJS_UI) $(BUILD_DIR)/DistrhoPluginMain_VST.cpp.o $(BUILD_DIR)/DistrhoUIMain_VST.cpp.o $(DGL_LIB)
  228. else
  229. $(vst): $(OBJS_DSP) $(BUILD_DIR)/DistrhoPluginMain_VST.cpp.o
  230. endif
  231. -@mkdir -p $(shell dirname $@)
  232. @echo "Creating VST plugin for $(NAME)"
  233. @$(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(DGL_LIBS) $(SHARED) -o $@
  234. # ---------------------------------------------------------------------------------------------------------------------
  235. # AU
  236. ifneq ($(CROSS_COMPILING),true)
  237. au: $(au_plugin) $(au_pkginfo) $(au_plist) $(au_rsrc)
  238. else
  239. au: $(au_plugin) $(au_pkginfo) $(au_plist)
  240. endif
  241. ifeq ($(HAVE_DGL),true)
  242. $(au_plugin): $(OBJS_DSP) $(OBJS_UI) $(BUILD_DIR)/DistrhoPluginMain_AU.cpp.o $(BUILD_DIR)/DistrhoUIMain_AU.cpp.o $(DGL_LIB)
  243. else
  244. $(au_plugin): $(OBJS_DSP) $(BUILD_DIR)/DistrhoPluginMain_AU.cpp.o
  245. endif
  246. -@mkdir -p $(shell dirname $@)
  247. @echo "Creating AU plugin for $(NAME)"
  248. $(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) $(AU_LINK_FLAGS) $(DGL_LIBS) -o $@
  249. $(au_pkginfo):
  250. -@mkdir -p $(shell dirname $@)
  251. @echo "Creating AU PkgInfo for $(NAME)"
  252. cp $(DPF_PATH)/distrho/src/CoreAudio106/PkgInfo $@
  253. $(au_plist):
  254. -@mkdir -p $(shell dirname $@)
  255. @echo "Creating AU Info.plist for $(NAME)"
  256. sed -e "s/X-DPF-EXECUTABLE-DPF-X/$(NAME)/g" $(DPF_PATH)/distrho/src/CoreAudio106/Info.plist > $@
  257. $(au_rsrc): $(BUILD_DIR)/step2.rsrc
  258. -@mkdir -p $(shell dirname $@)
  259. @echo "Creating AU rsrc for $(NAME) (part 3/3)"
  260. ResMerger $< -dstIs DF -o $@
  261. $(BUILD_DIR)/step2.rsrc: $(BUILD_DIR)/step1.rsrc
  262. -@mkdir -p $(shell dirname $@)
  263. @echo "Creating AU rsrc for $(NAME) (part 2/3)"
  264. ResMerger -dstIs DF $< -o $@
  265. $(BUILD_DIR)/step1.rsrc: $(DPF_PATH)/distrho/src/DistrhoPluginAU.r $(BUILD_DIR)/DistrhoPluginInfo.r $(OBJS_DSP)
  266. -@mkdir -p $(shell dirname $@)
  267. @echo "Creating AU rsrc for $(NAME) (part 1/3)"
  268. Rez $< \
  269. -d SystemSevenOrLater=1 \
  270. -useDF -script Roman \
  271. -i . \
  272. -i $(BUILD_DIR) \
  273. -i $(DPF_PATH)/distrho/src/CoreAudio106/AudioUnits/AUPublic \
  274. -i $(DPF_PATH)/distrho/src/CoreAudio106/AudioUnits/AUPublic/AUBase \
  275. -i $(DPF_PATH)/distrho/src/CoreAudio106/AudioUnits/AUPublic/OtherBases \
  276. -i $(DPF_PATH)/distrho/src/CoreAudio106/AudioUnits/AUPublic/Utility \
  277. -i $(DPF_PATH)/distrho/src/CoreAudio106/PublicUtility \
  278. -I /Developer/SDKs/MacOSX10.6.sdk \
  279. -I /System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Versions/A/Headers \
  280. $(REZ_FLAGS) \
  281. -o $@
  282. $(BUILD_DIR)/DistrhoPluginInfo.r: $(OBJS_DSP) $(BUILD_DIR)/DistrhoPluginAUexport.cpp.o
  283. -@mkdir -p $(shell dirname $@)
  284. @echo "Creating DistrhoPluginInfo.r for $(NAME)"
  285. $(CXX) $^ $(BUILD_CXX_FLAGS) $(LINK_FLAGS) -o $(BUILD_DIR)/DistrhoPluginInfoGenerator && \
  286. $(BUILD_DIR)/DistrhoPluginInfoGenerator "$(BUILD_DIR)" && \
  287. rm $(BUILD_DIR)/DistrhoPluginInfoGenerator
  288. # ---------------------------------------------------------------------------------------------------------------------
  289. -include $(OBJS_DSP:%.o=%.d)
  290. ifeq ($(HAVE_DGL),true)
  291. -include $(OBJS_UI:%.o=%.d)
  292. endif
  293. -include $(BUILD_DIR)/DistrhoPluginMain_JACK.cpp.d
  294. -include $(BUILD_DIR)/DistrhoPluginMain_LADSPA.cpp.d
  295. -include $(BUILD_DIR)/DistrhoPluginMain_DSSI.cpp.d
  296. -include $(BUILD_DIR)/DistrhoPluginMain_LV2.cpp.d
  297. -include $(BUILD_DIR)/DistrhoPluginMain_VST.cpp.d
  298. -include $(BUILD_DIR)/DistrhoPluginMain_AU.cpp.d
  299. -include $(BUILD_DIR)/DistrhoUIMain_JACK.cpp.d
  300. -include $(BUILD_DIR)/DistrhoUIMain_DSSI.cpp.d
  301. -include $(BUILD_DIR)/DistrhoUIMain_LV2.cpp.d
  302. -include $(BUILD_DIR)/DistrhoUIMain_VST.cpp.d
  303. -include $(BUILD_DIR)/DistrhoUIMain_AU.cpp.d
  304. # ---------------------------------------------------------------------------------------------------------------------