-
Notifications
You must be signed in to change notification settings - Fork 12
/
Makefile.mk
112 lines (86 loc) · 3 KB
/
Makefile.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/usr/bin/make -f
# Makefile for 2FS #
# ---------------- #
# Created by falkTX
#
# ---------------------------------------------------------------------------------------------------------------------
# Check for fluidsynth
HAVE_FLUIDSYNTH = $(shell pkg-config --exists fluidsynth && echo true)
ifneq ($(HAVE_FLUIDSYNTH),true)
$(error fluidsynth missing, cannot continue)
endif
# ---------------------------------------------------------------------------------------------------------------------
# Fallback to Linux if no other OS defined
ifneq ($(HAIKU),true)
ifneq ($(MACOS),true)
ifneq ($(WIN32),true)
LINUX=true
endif
endif
endif
# ---------------------------------------------------------------------------------------------------------------------
# Set compiler
CC ?= gcc
CXX ?= g++
# ---------------------------------------------------------------------------------------------------------------------
# Set build and link flags
BASE_FLAGS = -Wall -Wextra -Wshadow -pipe
BASE_OPTS = -O2 -ffast-math -mtune=generic -msse -msse2 -mfpmath=sse -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 -Wl,--strip-all
endif
ifeq ($(NOOPT),true)
# No optimization flags
BASE_OPTS = -O2 -ffast-math -fdata-sections -ffunction-sections
endif
ifneq ($(WIN32),true)
# Not needed for Windows
BASE_FLAGS += -fPIC -DPIC
endif
ifeq ($(DEBUG),true)
BASE_FLAGS += -DDEBUG -O0 -g
ifeq ($(WIN32),true)
BASE_FLAGS += -msse -msse2
endif
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
# ---------------------------------------------------------------------------------------------------------------------
# Set fluidsynth flags
FLUIDSYNTH_FLAGS = $(shell pkg-config --cflags fluidsynth)
FLUIDSYNTH_LIBS = $(shell pkg-config --libs fluidsynth)
# ---------------------------------------------------------------------------------------------------------------------
# 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
ifeq ($(MACOS),true)
SHARED = -dynamiclib
else
SHARED = -shared
endif
# ---------------------------------------------------------------------------------------------------------------------