Remove juce completely, cleanup
[carla.git] / source / Makefile.mk
blob3924c781850eaa704d6d3d7fcb379fbe3862989a
1 #!/usr/bin/make -f
2 # Makefile for Carla C++ code #
3 # --------------------------- #
4 # Created by falkTX
7 # ---------------------------------------------------------------------------------------------------------------------
8 # Base environment vars
10 WINECC ?= winegcc
12 # ---------------------------------------------------------------------------------------------------------------------
13 # Internationalization
15 I18N_LANGUAGES :=
17 # ---------------------------------------------------------------------------------------------------------------------
18 # Base definitions for dependencies and system type
20 include $(CWD)/Makefile.deps.mk
22 # ---------------------------------------------------------------------------------------------------------------------
23 # Set build and link flags
25 BASE_FLAGS = -Wall -Wextra -pipe -DBUILDING_CARLA -MD -MP -fno-common
26 BASE_OPTS = -O3 -ffast-math -fdata-sections -ffunction-sections
28 ifeq ($(WASM),true)
29 BASE_OPTS += -msse -msse2 -msse3 -msimd128
30 else ifeq ($(CPU_ARM32),true)
31 BASE_OPTS += -mfpu=neon-vfpv4 -mfloat-abi=hard
32 else ifeq ($(CPU_I386_OR_X86_64),true)
33 BASE_OPTS += -mtune=generic -msse -msse2 -mfpmath=sse
34 endif
36 ifeq ($(MACOS),true)
37 # MacOS linker flags
38 BASE_FLAGS += -Wno-deprecated-declarations
39 LINK_OPTS = -fdata-sections -ffunction-sections -Wl,-dead_strip,-dead_strip_dylibs
40 ifneq ($(SKIP_STRIPPING),true)
41 LINK_OPTS += -Wl,-x
42 endif
43 else
44 # Common linker flags
45 LINK_OPTS = -fdata-sections -ffunction-sections -Wl,-O1,--gc-sections
46 ifneq ($(WASM),true)
47 LINK_OPTS += -Wl,--as-needed
48 ifneq ($(SKIP_STRIPPING),true)
49 LINK_OPTS += -Wl,--strip-all
50 endif
51 endif
52 endif
54 ifeq ($(NOOPT),true)
55 # No CPU-specific optimization flags
56 BASE_OPTS = -O2 -ffast-math -fdata-sections -ffunction-sections -DBUILDING_CARLA_NOOPT
57 endif
59 ifeq ($(WINDOWS),true)
60 # Assume we want posix
61 BASE_FLAGS += -posix
62 # Needed for windows, see https://github.com/falkTX/Carla/issues/855
63 BASE_FLAGS += -mstackrealign
64 ifeq ($(BUILDING_FOR_WINE),true)
65 BASE_FLAGS += -DBUILDING_CARLA_FOR_WINE
66 endif
67 else
68 # Not needed for Windows
69 BASE_FLAGS += -fPIC -DPIC
70 endif
72 ifeq ($(CLANG),true)
73 BASE_FLAGS += -Wabsolute-value
74 endif
76 ifeq ($(DEBUG),true)
77 BASE_FLAGS += -DDEBUG -O0 -g
78 LINK_OPTS =
79 ifeq ($(WASM),true)
80 LINK_OPTS += -sASSERTIONS=1
81 endif
82 else
83 BASE_FLAGS += -DNDEBUG $(BASE_OPTS) -fvisibility=hidden
84 CXXFLAGS += -fvisibility-inlines-hidden
85 endif
87 ifneq ($(MACOS_OR_WASM_OR_WINDOWS),true)
88 ifneq ($(BSD),true)
89 BASE_FLAGS += -fno-gnu-unique
90 endif
91 endif
93 ifeq ($(WITH_LTO),true)
94 BASE_FLAGS += -fno-strict-aliasing -flto
95 LINK_OPTS += -fno-strict-aliasing -flto -Werror=odr -Werror=lto-type-mismatch
96 endif
98 32BIT_FLAGS = -m32
99 64BIT_FLAGS = -m64
100 ARM32_FLAGS = -mcpu=cortex-a7 -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -mvectorize-with-neon-quad
102 BUILD_C_FLAGS = $(BASE_FLAGS) -std=gnu99 $(CFLAGS)
103 BUILD_CXX_FLAGS = $(BASE_FLAGS) -std=gnu++11 $(CXXFLAGS)
104 LINK_FLAGS = $(LINK_OPTS) $(LDFLAGS)
106 ifeq ($(WASM),true)
107 # Special flag for emscripten
108 LINK_FLAGS += -sLLD_REPORT_UNDEFINED
109 else ifneq ($(MACOS),true)
110 # Not available on MacOS
111 LINK_FLAGS += -Wl,--no-undefined
112 endif
114 ifeq ($(WINDOWS),true)
115 # Always build static binaries on Windows
116 LINK_FLAGS += -static
117 endif
119 # ---------------------------------------------------------------------------------------------------------------------
120 # Strict test build
122 ifeq ($(TESTBUILD),true)
123 BASE_FLAGS += -Werror -Wcast-qual -Wconversion -Wdisabled-optimization
124 BASE_FLAGS += -Wdouble-promotion -Wfloat-equal -Wpointer-arith -Wsign-conversion
125 BASE_FLAGS += -Wformat=2 -Woverlength-strings
126 BASE_FLAGS += -Wmissing-declarations -Wredundant-decls
127 BASE_FLAGS += -Wshadow -Wundef -Wuninitialized -Wunused
128 BASE_FLAGS += -Wstrict-aliasing -fstrict-aliasing
129 BASE_FLAGS += -Wstrict-overflow -fstrict-overflow
130 BASE_FLAGS += -Wnull-dereference
131 ifneq ($(CLANG),true)
132 BASE_FLAGS += -Wabi=98 -Wclobbered -Wlogical-op
133 BASE_FLAGS += -Wformat-truncation=2 -Wformat-overflow=2
134 BASE_FLAGS += -Wstringop-overflow=4 -Wstringop-truncation
135 BASE_FLAGS += -Wduplicated-branches -Wduplicated-cond
136 endif
137 CFLAGS += -Winit-self -Wmissing-prototypes -Wnested-externs -Wstrict-prototypes -Wwrite-strings
138 ifneq ($(CLANG),true)
139 CFLAGS += -Wjump-misses-init
140 endif
141 CXXFLAGS += -Wc++0x-compat -Wc++11-compat
142 CXXFLAGS += -Wnon-virtual-dtor -Woverloaded-virtual
143 # CXXFLAGS += -Wold-style-cast -Wuseless-cast
144 CXXFLAGS += -Wzero-as-null-pointer-constant
145 ifneq ($(DEBUG),true)
146 CXXFLAGS += -Weffc++
147 endif
148 ifeq ($(LINUX),true)
149 BASE_FLAGS += -isystem /opt/kxstudio/include
150 endif
151 ifeq ($(MACOS),true)
152 CXXFLAGS += -isystem /System/Library/Frameworks
153 endif
154 # TODO
155 ifeq ($(CLANG),true)
156 BASE_FLAGS += -Wno-double-promotion
157 BASE_FLAGS += -Wno-format-nonliteral
158 BASE_FLAGS += -Wno-tautological-pointer-compare
159 endif
160 endif
162 # ---------------------------------------------------------------------------------------------------------------------
163 # Set base defines
165 ifeq ($(JACKBRIDGE_DIRECT),true)
166 ifeq ($(HAVE_JACKLIB),true)
167 BASE_FLAGS += -DJACKBRIDGE_DIRECT
168 else
169 $(error jackbridge direct mode requested, but jack not available)
170 endif
171 endif
173 ifeq ($(HAVE_DGL),true)
174 BASE_FLAGS += -DHAVE_DGL
175 BASE_FLAGS += -DHAVE_OPENGL
176 BASE_FLAGS += -DDGL_OPENGL
177 BASE_FLAGS += -DDONT_SET_USING_DGL_NAMESPACE
178 ifneq ($(USING_CUSTOM_DPF),true)
179 BASE_FLAGS += -DDGL_FILE_BROWSER_DISABLED
180 BASE_FLAGS += -DDGL_NO_SHARED_RESOURCES
181 else
182 BASE_FLAGS += -DDISTRHO_UI_FILE_BROWSER=0
183 endif
184 ifneq ($(DGL_NAMESPACE),)
185 BASE_FLAGS += -DDGL_NAMESPACE=$(DGL_NAMESPACE)
186 else
187 BASE_FLAGS += -DDGL_NAMESPACE=CarlaDGL
188 endif
189 endif
191 ifeq ($(HAVE_FLUIDSYNTH),true)
192 BASE_FLAGS += -DHAVE_FLUIDSYNTH
193 ifeq ($(HAVE_FLUIDSYNTH_INSTPATCH),true)
194 BASE_FLAGS += -DHAVE_FLUIDSYNTH_INSTPATCH
195 endif
196 endif
198 ifeq ($(HAVE_FFMPEG),true)
199 BASE_FLAGS += -DHAVE_FFMPEG
200 endif
202 ifeq ($(HAVE_HYLIA),true)
203 BASE_FLAGS += -DHAVE_HYLIA
204 endif
206 ifeq ($(HAVE_JACK),true)
207 BASE_FLAGS += -DHAVE_JACK
208 endif
210 ifeq ($(HAVE_LIBLO),true)
211 BASE_FLAGS += -DHAVE_LIBLO
212 endif
214 ifeq ($(HAVE_LIBMAGIC),true)
215 BASE_FLAGS += -DHAVE_LIBMAGIC
216 endif
218 ifeq ($(HAVE_PYQT),true)
219 BASE_FLAGS += -DHAVE_PYQT
220 endif
222 ifeq ($(HAVE_SDL2),true)
223 BASE_FLAGS += -DHAVE_SDL -DHAVE_SDL2
224 else ifeq ($(HAVE_SDL1),true)
225 BASE_FLAGS += -DHAVE_SDL -DHAVE_SDL1
226 endif
228 ifeq ($(HAVE_SNDFILE),true)
229 BASE_FLAGS += -DHAVE_SNDFILE
230 endif
232 ifeq ($(HAVE_X11),true)
233 BASE_FLAGS += -DHAVE_X11
234 endif
236 ifeq ($(HAVE_YSFX),true)
237 BASE_FLAGS += -DHAVE_YSFX
238 endif
240 ifeq ($(USING_RTAUDIO),true)
241 BASE_FLAGS += -DUSING_RTAUDIO
242 endif
244 ifeq ($(STATIC_PLUGIN_TARGET),true)
245 BASE_FLAGS += -DSTATIC_PLUGIN_TARGET
246 endif
248 # ---------------------------------------------------------------------------------------------------------------------
249 # Allow custom namespace
251 ifneq ($(CARLA_BACKEND_NAMESPACE),)
252 BASE_FLAGS += -DCARLA_BACKEND_NAMESPACE=$(CARLA_BACKEND_NAMESPACE)
253 endif
255 # ---------------------------------------------------------------------------------------------------------------------
256 # Set app extension
258 ifeq ($(WASM),true)
259 APP_EXT = .html
260 else ifeq ($(WINDOWS),true)
261 APP_EXT = .exe
262 endif
264 # ---------------------------------------------------------------------------------------------------------------------
265 # Set shared lib extension
267 ifeq ($(MACOS),true)
268 LIB_EXT = .dylib
269 else ifeq ($(WASM),true)
270 LIB_EXT = .js
271 else ifeq ($(WINDOWS),true)
272 LIB_EXT = .dll
273 else
274 LIB_EXT = .so
275 endif
277 BASE_FLAGS += -DCARLA_LIB_EXT=\"$(LIB_EXT)\"
279 # ---------------------------------------------------------------------------------------------------------------------
280 # Set static libs start & end
282 ifneq ($(MACOS),true)
283 LIBS_START = -Wl,--start-group -Wl,--whole-archive
284 LIBS_END = -Wl,--no-whole-archive -Wl,--end-group
285 endif
287 # ---------------------------------------------------------------------------------------------------------------------
288 # Handle the verbosity switch
290 SILENT =
292 ifeq ($(VERBOSE),1)
293 else ifeq ($(VERBOSE),y)
294 else ifeq ($(VERBOSE),yes)
295 else ifeq ($(VERBOSE),true)
296 else
297 SILENT = @
298 endif
300 # ---------------------------------------------------------------------------------------------------------------------
301 # Set shared library CLI arg
303 ifeq ($(MACOS),true)
304 SHARED = -dynamiclib
305 else ifeq ($(WASM),true)
306 SHARED = -sMAIN_MODULE=2
307 else
308 SHARED = -shared
309 endif
311 # ---------------------------------------------------------------------------------------------------------------------
312 # Set arguments used for inline 'sed'
314 ifeq ($(BSD),true)
315 SED_ARGS=-i '' -e
316 else
317 SED_ARGS=-i -e
318 endif
320 # ---------------------------------------------------------------------------------------------------------------------
321 # Set command used for file symlinking
323 LINK := ln -sf
325 # ---------------------------------------------------------------------------------------------------------------------
326 # Check if we can generate ttl files
328 ifneq ($(BUILDING_FOR_WINE),true)
329 ifeq ($(CROSS_COMPILING),true)
330 ifeq ($(WINDOWS),true)
331 NEEDS_WINE = true
332 endif
333 endif
334 endif
336 ifneq ($(CROSS_COMPILING),true)
337 CAN_GENERATE_LV2_TTL = true
338 else ifeq ($(NEEDS_WINE),true)
339 ifneq ($(EXE_WRAPPER),)
340 CAN_GENERATE_LV2_TTL = true
341 endif
342 endif
344 # ---------------------------------------------------------------------------------------------------------------------
345 # Check if we should build the external plugins
347 ifeq ($(EXTERNAL_PLUGINS),true)
348 ifneq ($(DEBUG),true)
349 ifneq ($(TESTBUILD),true)
350 ifneq (,$(wildcard $(CWD)/native-plugins/external/Makefile.mk))
351 BASE_FLAGS += -DHAVE_EXTERNAL_PLUGINS
352 include $(CWD)/native-plugins/external/Makefile.mk
353 endif
354 endif
355 endif
356 endif
358 # ---------------------------------------------------------------------------------------------------------------------