|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347 |
- #!/usr/bin/make -f
- # Makefile for Carla C++ code #
- # --------------------------- #
- # Created by falkTX
- #
-
- # ---------------------------------------------------------------------------------------------------------------------
- # Base environment vars
-
- AR ?= ar
- CC ?= gcc
- CXX ?= g++
-
- WINECC ?= winegcc
-
- # ---------------------------------------------------------------------------------------------------------------------
- # Internationalization
-
- I18N_LANGUAGES :=
-
- # ---------------------------------------------------------------------------------------------------------------------
- # Base definitions for dependencies and system type
-
- include $(CWD)/Makefile.deps.mk
-
- # ---------------------------------------------------------------------------------------------------------------------
- # Set build and link flags
-
- BASE_FLAGS = -Wall -Wextra -pipe -DBUILDING_CARLA -DREAL_BUILD -MD -MP -fno-common
- BASE_OPTS = -O3 -ffast-math -fdata-sections -ffunction-sections
-
- ifeq ($(CPU_I386_OR_X86_64),true)
- BASE_OPTS += -mtune=generic -msse -msse2 -mfpmath=sse
- endif
-
- ifeq ($(CPU_ARM),true)
- ifneq ($(CPU_ARM64),true)
- BASE_OPTS += -mfpu=neon-vfpv4 -mfloat-abi=hard
- endif
- endif
-
- ifeq ($(MACOS),true)
- # MacOS linker flags
- BASE_FLAGS += -Wno-deprecated-declarations
- LINK_OPTS = -fdata-sections -ffunction-sections -Wl,-dead_strip -Wl,-dead_strip_dylibs
- ifneq ($(SKIP_STRIPPING),true)
- LINK_OPTS += -Wl,-x
- endif
- else
- # Common linker flags
- LINK_OPTS = -fdata-sections -ffunction-sections -Wl,--gc-sections -Wl,-O1 -Wl,--as-needed
- ifneq ($(SKIP_STRIPPING),true)
- LINK_OPTS += -Wl,--strip-all
- endif
- endif
-
- ifeq ($(NOOPT),true)
- # No CPU-specific optimization flags
- BASE_OPTS = -O2 -ffast-math -fdata-sections -ffunction-sections -DBUILDING_CARLA_NOOPT
- endif
-
- ifeq ($(WIN32),true)
- # Assume we want posix
- BASE_FLAGS += -posix
- # Needed for windows, see https://github.com/falkTX/Carla/issues/855
- BASE_FLAGS += -mstackrealign
- ifeq ($(BUILDING_FOR_WINE),true)
- BASE_FLAGS += -DBUILDING_CARLA_FOR_WINE
- endif
- else
- # Not needed for Windows
- BASE_FLAGS += -fPIC -DPIC
- endif
-
- ifeq ($(CLANG),true)
- BASE_FLAGS += -Wabsolute-value
- endif
-
- ifeq ($(DEBUG),true)
- BASE_FLAGS += -DDEBUG -O0 -g
- LINK_OPTS =
- else
- BASE_FLAGS += -DNDEBUG $(BASE_OPTS) -fvisibility=hidden
- CXXFLAGS += -fvisibility-inlines-hidden
- endif
-
- ifneq ($(MACOS),true)
- ifneq ($(WIN32),true)
- BASE_FLAGS += -fno-gnu-unique
- endif
- endif
-
- ifeq ($(WITH_LTO),true)
- BASE_FLAGS += -fno-strict-aliasing -flto
- LINK_OPTS += -fno-strict-aliasing -flto -Werror=odr -Werror=lto-type-mismatch
- endif
-
- 32BIT_FLAGS = -m32
- 64BIT_FLAGS = -m64
- ARM32_FLAGS = -mcpu=cortex-a7 -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -mvectorize-with-neon-quad
-
- BUILD_C_FLAGS = $(BASE_FLAGS) -std=gnu99 $(CFLAGS)
- BUILD_CXX_FLAGS = $(BASE_FLAGS) -std=gnu++11 $(CXXFLAGS)
- LINK_FLAGS = $(LINK_OPTS) $(LDFLAGS)
-
- ifneq ($(MACOS),true)
- # Not available on MacOS
- LINK_FLAGS += -Wl,--no-undefined
- endif
-
- ifeq ($(MACOS_OLD),true)
- BUILD_CXX_FLAGS = $(BASE_FLAGS) $(CXXFLAGS) -DHAVE_CPP11_SUPPORT=0
- endif
-
- ifeq ($(STATIC_BINARIES),true)
- LINK_FLAGS += -static
- endif
-
- # ---------------------------------------------------------------------------------------------------------------------
- # Strict test build
-
- ifeq ($(TESTBUILD),true)
- BASE_FLAGS += -Werror -Wcast-qual -Wconversion -Wdisabled-optimization
- BASE_FLAGS += -Wdouble-promotion -Wfloat-equal -Wpointer-arith -Wsign-conversion
- BASE_FLAGS += -Wformat=2 -Woverlength-strings
- BASE_FLAGS += -Wmissing-declarations -Wredundant-decls
- BASE_FLAGS += -Wshadow -Wundef -Wuninitialized -Wunused
- BASE_FLAGS += -Wstrict-aliasing -fstrict-aliasing
- BASE_FLAGS += -Wstrict-overflow -fstrict-overflow
- BASE_FLAGS += -Wnull-dereference
- ifneq ($(CLANG),true)
- BASE_FLAGS += -Wabi=98 -Wclobbered -Wlogical-op
- BASE_FLAGS += -Wformat-truncation=2 -Wformat-overflow=2
- BASE_FLAGS += -Wstringop-overflow=4 -Wstringop-truncation
- BASE_FLAGS += -Wduplicated-branches -Wduplicated-cond
- endif
- CFLAGS += -Winit-self -Wmissing-prototypes -Wnested-externs -Wstrict-prototypes -Wwrite-strings
- ifneq ($(CLANG),true)
- CFLAGS += -Wjump-misses-init
- endif
- CXXFLAGS += -Wc++0x-compat -Wc++11-compat
- CXXFLAGS += -Wnon-virtual-dtor -Woverloaded-virtual
- # CXXFLAGS += -Wold-style-cast -Wuseless-cast
- CXXFLAGS += -Wzero-as-null-pointer-constant
- ifneq ($(DEBUG),true)
- CXXFLAGS += -Weffc++
- endif
- ifeq ($(LINUX),true)
- BASE_FLAGS += -isystem /opt/kxstudio/include
- endif
- ifeq ($(MACOS),true)
- CXXFLAGS += -isystem /System/Library/Frameworks
- endif
- ifeq ($(WIN32),true)
- BASE_FLAGS += -isystem /opt/mingw32/include
- endif
- ifeq ($(WIN64),true)
- BASE_FLAGS += -isystem /opt/mingw64/include
- endif
- # TODO
- ifeq ($(CLANG),true)
- BASE_FLAGS += -Wno-double-promotion
- BASE_FLAGS += -Wno-format-nonliteral
- BASE_FLAGS += -Wno-tautological-pointer-compare
- endif
- endif
-
- # ---------------------------------------------------------------------------------------------------------------------
- # Set base defines
-
- ifeq ($(JACKBRIDGE_DIRECT),true)
- ifeq ($(HAVE_JACK),true)
- BASE_FLAGS += -DJACKBRIDGE_DIRECT
- else
- $(error jackbridge direct mode requested, but jack not available)
- endif
- endif
-
- ifeq ($(HAVE_DGL),true)
- BASE_FLAGS += -DHAVE_DGL
- BASE_FLAGS += -DDGL_NAMESPACE=CarlaDGL
- BASE_FLAGS += -DDGL_OPENGL
- BASE_FLAGS += -DDGL_FILE_BROWSER_DISABLED
- BASE_FLAGS += -DDGL_NO_SHARED_RESOURCES
- BASE_FLAGS += -DDONT_SET_USING_DGL_NAMESPACE
- endif
-
- ifeq ($(HAVE_FLUIDSYNTH),true)
- BASE_FLAGS += -DHAVE_FLUIDSYNTH
- ifeq ($(HAVE_FLUIDSYNTH_INSTPATCH),true)
- BASE_FLAGS += -DHAVE_FLUIDSYNTH_INSTPATCH
- endif
- endif
-
- ifeq ($(HAVE_FFMPEG),true)
- BASE_FLAGS += -DHAVE_FFMPEG
- endif
-
- ifeq ($(HAVE_HYLIA),true)
- BASE_FLAGS += -DHAVE_HYLIA
- endif
-
- ifeq ($(HAVE_LIBLO),true)
- BASE_FLAGS += -DHAVE_LIBLO
- endif
-
- ifeq ($(HAVE_LIBMAGIC),true)
- BASE_FLAGS += -DHAVE_LIBMAGIC
- endif
-
- ifeq ($(HAVE_PYQT),true)
- BASE_FLAGS += -DHAVE_PYQT
- endif
-
- ifeq ($(HAVE_SNDFILE),true)
- BASE_FLAGS += -DHAVE_SNDFILE
- endif
-
- ifeq ($(HAVE_X11),true)
- BASE_FLAGS += -DHAVE_X11
- endif
-
- ifeq ($(USING_JUCE),true)
- BASE_FLAGS += -DUSING_JUCE
- BASE_FLAGS += -DJUCE_APP_CONFIG_HEADER='"AppConfig.h"'
- ifeq ($(WIN32),true)
- BASE_FLAGS += -D_WIN32_WINNT=0x0600
- endif
- endif
-
- ifeq ($(USING_JUCE_AUDIO_DEVICES),true)
- BASE_FLAGS += -DUSING_JUCE_AUDIO_DEVICES
- endif
-
- ifeq ($(USING_RTAUDIO),true)
- BASE_FLAGS += -DUSING_RTAUDIO
- endif
-
- ifeq ($(STATIC_PLUGIN_TARGET),true)
- BASE_FLAGS += -DSTATIC_PLUGIN_TARGET
- endif
-
- # ---------------------------------------------------------------------------------------------------------------------
- # Allow custom namespace
-
- ifneq ($(CARLA_BACKEND_NAMESPACE),)
- BASE_FLAGS += -DCARLA_BACKEND_NAMESPACE=$(CARLA_BACKEND_NAMESPACE)
- endif
-
- # ---------------------------------------------------------------------------------------------------------------------
- # Set app extension
-
- ifeq ($(WIN32),true)
- APP_EXT = .exe
- endif
-
- # ---------------------------------------------------------------------------------------------------------------------
- # Set shared lib extension
-
- LIB_EXT = .so
-
- ifeq ($(MACOS),true)
- LIB_EXT = .dylib
- endif
-
- ifeq ($(WIN32),true)
- LIB_EXT = .dll
- endif
-
- BASE_FLAGS += -DCARLA_LIB_EXT=\"$(LIB_EXT)\"
-
- # ---------------------------------------------------------------------------------------------------------------------
- # Set static libs start & end
-
- ifneq ($(MACOS),true)
- LIBS_START = -Wl,--start-group -Wl,--whole-archive
- LIBS_END = -Wl,--no-whole-archive -Wl,--end-group
- endif
-
- # ---------------------------------------------------------------------------------------------------------------------
- # Handle the verbosity switch
-
- SILENT =
-
- ifeq ($(VERBOSE),1)
- else ifeq ($(VERBOSE),y)
- else ifeq ($(VERBOSE),yes)
- else ifeq ($(VERBOSE),true)
- else
- SILENT = @
- endif
-
- # ---------------------------------------------------------------------------------------------------------------------
- # Set shared library CLI arg
-
- ifeq ($(MACOS),true)
- SHARED = -dynamiclib
- else
- SHARED = -shared
- endif
-
- # ---------------------------------------------------------------------------------------------------------------------
- # Set arguments used for inline 'sed'
-
- ifeq ($(BSD),true)
- SED_ARGS=-i '' -e
- else
- SED_ARGS=-i -e
- endif
-
- # ---------------------------------------------------------------------------------------------------------------------
- # Set command used for file symlinking
-
- LINK := ln -sf
-
- # ---------------------------------------------------------------------------------------------------------------------
- # Check if we can generate ttl files
-
- ifneq ($(BUILDING_FOR_WINE),true)
- ifeq ($(CROSS_COMPILING),true)
- ifeq ($(WIN32),true)
- NEEDS_WINE = true
- endif
- endif
- endif
-
- ifneq ($(CROSS_COMPILING),true)
- CAN_GENERATE_LV2_TTL = true
- else ifeq ($(NEEDS_WINE),true)
- CAN_GENERATE_LV2_TTL = true
- endif
-
- # ---------------------------------------------------------------------------------------------------------------------
- # Check if we should build the external plugins
-
- ifeq ($(EXTERNAL_PLUGINS),true)
- ifneq ($(DEBUG),true)
- ifneq ($(TESTBUILD),true)
- ifneq (,$(wildcard $(CWD)/native-plugins/external/Makefile.mk))
- BASE_FLAGS += -DHAVE_EXTERNAL_PLUGINS
- include $(CWD)/native-plugins/external/Makefile.mk
- endif
- endif
- endif
- endif
-
- # ---------------------------------------------------------------------------------------------------------------------
|