Added support for new MSVC compiler version.
[DynamicAudioNormalizer.git] / DynamicAudioNormalizerAPI / makefile
blob9d3550e2af25836706820678de131d088155bd1f
1 ##############################################################################
2 # Dynamic Audio Normalizer - Audio Processing Library
3 # Copyright (c) 2014-2019 LoRd_MuldeR <mulder2@gmx.de>. Some rights reserved.
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License, or (at your option) any later version.
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 # http://www.gnu.org/licenses/lgpl-2.1.txt
20 ##############################################################################
22 ECHO=echo -e
23 SHELL=/bin/bash
25 JAVA_HOME ?= $(shell update-java-alternatives -l 2>/dev/null | grep -oE '[^[:space:]]+$$' || echo "/usr/lib/jvm/default")
27 ##############################################################################
28 # Constants
29 ##############################################################################
31 LIBRARY_NAME := libDynamicAudioNormalizerAPI
33 ifndef API_VERSION
34 $(error API_VERSION variable is not set!)
35 endif
37 ##############################################################################
38 # JDK Checks
39 ##############################################################################
41 ifneq ($(MAKECMDGOALS),clean)
42 ifneq ($(ENABLE_JNI),false)
43 JDK_CHECK := $(shell [ -f $(JAVA_HOME)/include/jni.h ] && echo true || echo false)
44 ifneq ($(JDK_CHECK),true)
45 $(error File "include/jni.h" not found in JAVA_HOME path!)
46 endif
47 endif
48 endif
50 ##############################################################################
51 # Flags
52 ##############################################################################
54 DEBUG_BUILD ?= 0
55 MARCH ?= native
57 ifeq ($(DEBUG_BUILD), 1)
58 CONFIG_NAME = Debug
59 CXXFLAGS = -g -O0 -D_DEBUG
60 else
61 CONFIG_NAME = Release
62 CXXFLAGS = -O3 -Wall -ffast-math -mfpmath=sse -msse -fomit-frame-pointer -fno-tree-vectorize -DNDEBUG -march=$(MARCH)
63 endif
65 ifneq ($(findstring MINGW,$(shell uname -s)),MINGW)
66 CXXFLAGS += -fPIC
67 endif
69 CXXFLAGS += -std=gnu++11
70 CXXFLAGS += -fvisibility=hidden
71 CXXFLAGS += -DMDYNAMICAUDIONORMALIZER_EXPORTS
73 CXXFLAGS += -I./src
74 CXXFLAGS += -I./include
75 CXXFLAGS += -I../DynamicAudioNormalizerShared/include
76 CXXFLAGS += -I../DynamicAudioNormalizerJNI/include
78 ifneq ($(ENABLE_JNI),false)
79 CXXFLAGS += -I$(JAVA_HOME)/include
80 ifeq ($(findstring MINGW,$(shell uname -s)),MINGW)
81 CXXFLAGS += -I$(JAVA_HOME)/include/win32
82 else ifeq ($(shell uname), Darwin)
83 CXXFLAGS += -I$(JAVA_HOME)/include/darwin
84 else
85 CXXFLAGS += -I$(JAVA_HOME)/include/linux
86 endif
87 else
88 CXXFLAGS += -DNO_JAVA_SUPPORT
89 endif
91 ##############################################################################
92 # File Names
93 ##############################################################################
95 ifeq ($(findstring MINGW,$(shell uname -s)),MINGW)
96 SO_EXT = dll
97 LDXFLAGS += -Wl,--out-implib,$@.a
98 SHAREDFLAG = -shared
99 else ifeq ($(shell uname), Darwin)
100 SO_EXT = dylib
101 SHAREDFLAG = -dynamiclib
102 else
103 SO_EXT = so
104 SHAREDFLAG = -shared
105 endif
107 SOURCES_CPP = $(wildcard src/*.cpp)
108 SOURCES_OBJ = $(patsubst %.cpp,%.o,$(SOURCES_CPP))
110 LIBRARY_OUT = lib/$(LIBRARY_NAME)-$(API_VERSION)
111 LIBRARY_BIN = $(LIBRARY_OUT).$(SO_EXT)
112 LIBRARY_DBG = $(LIBRARY_OUT)-DBG.$(SO_EXT)
114 ##############################################################################
115 # Rules
116 ##############################################################################
118 .PHONY: all clean
120 all: $(LIBRARY_DBG) $(LIBRARY_BIN)
122 #-------------------------------------------------------------
123 # Link & Strip
124 #-------------------------------------------------------------
126 $(LIBRARY_BIN): $(SOURCES_OBJ)
127 @$(ECHO) "\e[1;36m[STR] $@\e[0m"
128 @mkdir -p $(dir $@)
129 g++ $(SHAREDFLAG) -g0 -o $@ $+ $(LDXFLAGS)
130 ifeq ($(shell uname), Darwin)
131 install_name_tool -id "@loader_path/$(notdir $@)" $@
132 strip -u -r -x $@
133 else
134 strip --strip-unneeded $@
135 endif
137 $(LIBRARY_DBG): $(SOURCES_OBJ)
138 @$(ECHO) "\e[1;36m[LNK] $@\e[0m"
139 @mkdir -p $(dir $@)
140 g++ $(SHAREDFLAG) -o $@ $+ $(LDXFLAGS)
141 ifeq ($(shell uname), Darwin)
142 install_name_tool -id "@loader_path/$(notdir $@)" $@
143 endif
145 #-------------------------------------------------------------
146 # Compile
147 #-------------------------------------------------------------
149 %.o: %.cpp
150 @$(ECHO) "\e[1;36m[CXX] $<\e[0m"
151 @mkdir -p $(dir $@)
152 g++ $(CXXFLAGS) -c $< -o $@
154 #-------------------------------------------------------------
155 # Clean
156 #-------------------------------------------------------------
158 clean:
159 rm -fv $(SOURCES_OBJ)
160 rm -rfv ./lib