summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfalkTX <falktx@gmail.com>2018-09-17 21:24:43 +0200
committerfalkTX <falktx@gmail.com>2018-09-17 21:24:43 +0200
commit72306e36099eab4afc2471849a0eb789b18a51a4 (patch)
treeb571fcb66962f5d2b1c5d55fbefe2698a53b1c70
parent16d33d5d4e6bb28997a15980d92ebd7e4a50f263 (diff)
Add a makefile to the root folder
-rw-r--r--Makefile54
-rw-r--r--Makefile.mk238
2 files changed, 292 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 00000000..c97fb041
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,54 @@
+#!/usr/bin/make -f
+# Makefile for DPF #
+# ---------------- #
+# Created by falkTX
+#
+
+include Makefile.mk
+
+all: libs examples gen
+
+# --------------------------------------------------------------
+
+libs:
+ifeq ($(HAVE_DGL),true)
+ $(MAKE) -C dgl
+endif
+
+examples: libs
+ $(MAKE) all -C examples/Info
+ $(MAKE) all -C examples/Latency
+ $(MAKE) all -C examples/Meters
+ $(MAKE) all -C examples/MidiThrough
+ $(MAKE) all -C examples/Parameters
+ $(MAKE) all -C examples/States
+
+ifneq ($(CROSS_COMPILING),true)
+gen: examples utils/lv2_ttl_generator
+ @$(CURDIR)/utils/generate-ttl.sh
+ifeq ($(MACOS),true)
+ @$(CURDIR)/utils/generate-vst-bundles.sh
+endif
+
+utils/lv2_ttl_generator:
+ $(MAKE) -C utils/lv2-ttl-generator
+else
+gen:
+endif
+
+# --------------------------------------------------------------
+
+clean:
+ $(MAKE) clean -C dgl
+ $(MAKE) clean -C examples/Info
+ $(MAKE) clean -C examples/Latency
+ $(MAKE) clean -C examples/Meters
+ $(MAKE) clean -C examples/MidiThrough
+ $(MAKE) clean -C examples/Parameters
+ $(MAKE) clean -C examples/States
+ $(MAKE) clean -C utils/lv2-ttl-generator
+ rm -rf bin build
+
+# --------------------------------------------------------------
+
+.PHONY: examples
diff --git a/Makefile.mk b/Makefile.mk
new file mode 100644
index 00000000..5ddab7b1
--- /dev/null
+++ b/Makefile.mk
@@ -0,0 +1,238 @@
+#!/usr/bin/make -f
+# Makefile for DPF #
+# ---------------- #
+# Created by falkTX
+#
+
+AR ?= ar
+CC ?= gcc
+CXX ?= g++
+
+# ---------------------------------------------------------------------------------------------------------------------
+# Auto-detect OS if not defined
+
+ifneq ($(BSD),true)
+ifneq ($(HAIKU),true)
+ifneq ($(HURD),true)
+ifneq ($(LINUX),true)
+ifneq ($(MACOS),true)
+ifneq ($(WIN32),true)
+
+TARGET_MACHINE := $(shell $(CC) -dumpmachine)
+ifneq (,$(findstring bsd,$(TARGET_MACHINE)))
+BSD=true
+endif
+ifneq (,$(findstring haiku,$(TARGET_MACHINE)))
+HAIKU=true
+endif
+ifneq (,$(findstring gnu,$(TARGET_MACHINE)))
+HURD=true
+endif
+ifneq (,$(findstring linux,$(TARGET_MACHINE)))
+LINUX=true
+endif
+ifneq (,$(findstring apple,$(TARGET_MACHINE)))
+MACOS=true
+endif
+ifneq (,$(findstring mingw,$(TARGET_MACHINE)))
+WIN32=true
+endif
+
+endif
+endif
+endif
+endif
+endif
+endif
+
+# ---------------------------------------------------------------------------------------------------------------------
+# Set LINUX_OR_MACOS
+
+ifeq ($(LINUX),true)
+LINUX_OR_MACOS=true
+endif
+
+ifeq ($(MACOS),true)
+LINUX_OR_MACOS=true
+endif
+
+# ---------------------------------------------------------------------------------------------------------------------
+# Set MACOS_OR_WIN32
+
+ifeq ($(MACOS),true)
+MACOS_OR_WIN32=true
+endif
+
+ifeq ($(WIN32),true)
+MACOS_OR_WIN32=true
+endif
+
+# ---------------------------------------------------------------------------------------------------------------------
+# Set UNIX
+
+ifeq ($(BSD),true)
+UNIX=true
+endif
+
+ifeq ($(HURD),true)
+UNIX=true
+endif
+
+ifeq ($(LINUX),true)
+UNIX=true
+endif
+
+ifeq ($(MACOS),true)
+UNIX=true
+endif
+
+# ---------------------------------------------------------------------------------------------------------------------
+# Set build and link flags
+
+BASE_FLAGS = -Wall -Wextra -pipe -MD -MP
+BASE_OPTS = -O3 -ffast-math -mtune=generic -msse -msse2 -fdata-sections -ffunction-sections
+
+ifeq ($(MACOS),true)
+# MacOS linker flags
+LINK_OPTS = -fdata-sections -ffunction-sections -Wl,-dead_strip -Wl,-dead_strip_dylibs
+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
+endif
+
+ifeq ($(WIN32),true)
+# mingw has issues with this specific optimization
+# See https://github.com/falkTX/Carla/issues/696
+BASE_OPTS += -fno-rerun-cse-after-loop
+ifeq ($(BUILDING_FOR_WINDOWS),true)
+BASE_FLAGS += -DBUILDING_CARLA_FOR_WINDOWS
+endif
+else
+# Not needed for Windows
+BASE_FLAGS += -fPIC -DPIC
+endif
+
+ifeq ($(DEBUG),true)
+BASE_FLAGS += -DDEBUG -O0 -g
+LINK_OPTS =
+else
+BASE_FLAGS += -DNDEBUG $(BASE_OPTS) -fvisibility=hidden
+CXXFLAGS += -fvisibility-inlines-hidden
+endif
+
+BUILD_C_FLAGS = $(BASE_FLAGS) -std=gnu99 $(CFLAGS)
+BUILD_CXX_FLAGS = $(BASE_FLAGS) -std=gnu++0x $(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 ($(WIN32),true)
+# Always build statically on windows
+LINK_FLAGS += -static
+endif
+
+# ---------------------------------------------------------------------------------------------------------------------
+# Strict test build
+
+ifeq ($(TESTBUILD),true)
+BASE_FLAGS += -Werror -Wcast-qual -Wconversion -Wformat -Wformat-security -Wredundant-decls -Wshadow -Wstrict-overflow -fstrict-overflow -Wundef -Wwrite-strings
+BASE_FLAGS += -Wpointer-arith -Wabi -Winit-self -Wuninitialized -Wstrict-overflow=5
+# BASE_FLAGS += -Wfloat-equal
+ifeq ($(CC),clang)
+BASE_FLAGS += -Wdocumentation -Wdocumentation-unknown-command
+BASE_FLAGS += -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-padded -Wno-exit-time-destructors -Wno-float-equal
+else
+BASE_FLAGS += -Wcast-align -Wunsafe-loop-optimizations
+endif
+ifneq ($(MACOS),true)
+BASE_FLAGS += -Wmissing-declarations -Wsign-conversion
+ifneq ($(CC),clang)
+BASE_FLAGS += -Wlogical-op
+endif
+endif
+CFLAGS += -Wold-style-definition -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes
+CXXFLAGS += -Weffc++ -Wnon-virtual-dtor -Woverloaded-virtual
+endif
+
+# ---------------------------------------------------------------------------------------------------------------------
+# Check for optional libs
+
+ifeq ($(LINUX),true)
+HAVE_DGL = $(shell pkg-config --exists gl x11 && echo true)
+HAVE_JACK = $(shell pkg-config --exists jack && echo true)
+HAVE_LIBLO = $(shell pkg-config --exists liblo && echo true)
+endif
+
+ifeq ($(MACOS),true)
+HAVE_DGL = true
+endif
+
+ifeq ($(WIN32),true)
+HAVE_DGL = true
+endif
+
+# ---------------------------------------------------------------------------------------------------------------------
+# Set libs stuff
+
+ifeq ($(HAVE_DGL),true)
+
+ifeq ($(MACOS),true)
+DGL_LIBS = -framework OpenGL -framework Cocoa
+endif
+
+ifeq ($(WIN32),true)
+DGL_LIBS = -lopengl32 -lgdi32
+endif
+
+ifneq ($(MACOS_OR_WIN32),true)
+DGL_FLAGS = $(shell pkg-config --cflags gl x11)
+DGL_LIBS = $(shell pkg-config --libs gl x11)
+endif
+
+endif # HAVE_DGL
+
+# ---------------------------------------------------------------------------------------------------------------------
+# 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
+
+# ---------------------------------------------------------------------------------------------------------------------
+# Set shared library CLI arg
+
+SHARED = -shared
+
+ifeq ($(MACOS),true)
+SHARED = -dynamiclib
+endif
+
+# ---------------------------------------------------------------------------------------------------------------------