-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
184 lines (123 loc) · 4.31 KB
/
Copy pathMakefile
File metadata and controls
184 lines (123 loc) · 4.31 KB
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#
# Copyright (c) 2008-2010 TrueCrypt Developers Association. All rights reserved.
#
# Governed by the TrueCrypt License 3.0 the full text of which is contained in
# the file License.txt included in TrueCrypt binary and source code distribution
# packages.
#
#------ Command line arguments ------
# DEBUG: Disable optimizations and enable debugging checks
# DEBUGGER: Enable debugging information for use by debuggers
# NOASM: Exclude modules requiring assembler
# NOSTRIP: Do not strip release binary
# NOTEST: Do not test release binary
# VERBOSE: Enable verbose messages
#------ Targets ------
# libBasaltCore Build the core static library (no UI dependency)
# cli Build standalone command-line tool
# clean Remove build artifacts
#------ Build configuration ------
export APPNAME := basalt
export BASE_DIR := $(CURDIR)
export BUILD_INC := $(BASE_DIR)/Build/Include
export SRC_DIR := $(BASE_DIR)/src
export AR ?= ar
export CC ?= gcc
export CXX ?= g++
export AS := nasm
export RANLIB ?= ranlib
export CFLAGS := -Wall
export CXXFLAGS := -Wall -Wno-unused-parameter -Wno-potentially-evaluated-expression
C_CXX_FLAGS := -MMD -D__STDC_WANT_LIB_EXT1__=1 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGE_FILES -I$(BASE_DIR)/src -I$(BASE_DIR)/src/Crypto
export ASFLAGS := -Ox -D __GNUC__
export LFLAGS :=
export LIBS :=
export PKG_CONFIG_PATH ?= /usr/local/lib/pkgconfig
export TC_BUILD_CONFIG := Release
ifeq "$(origin DEBUG)" "command line"
ifneq "$(DEBUG)" "0"
TC_BUILD_CONFIG := Debug
endif
endif
ifneq "$(origin VERBOSE)" "command line"
MAKEFLAGS += -s
endif
#------ Release configuration ------
ifeq "$(TC_BUILD_CONFIG)" "Release"
C_CXX_FLAGS += -O2 -fno-strict-aliasing # Do not enable strict aliasing
else
#------ Debug configuration ------
C_CXX_FLAGS += -DDEBUG
CXXFLAGS += -fno-default-inline -Wno-unused-function -Wno-unused-variable
endif
#------ Debugger configuration ------
ifeq "$(origin DEBUGGER)" "command line"
C_CXX_FLAGS += -ggdb
endif
#------ Platform configuration ------
export CPU_ARCH ?= unknown
ARCH = $(shell uname -m)
ifneq (,$(filter x86_64 x86-64 amd64 x64,$(ARCH)))
CPU_ARCH = x64
else ifneq (,$(filter arm64 aarch64,$(ARCH)))
CPU_ARCH = arm64
endif
ifeq "$(origin NOASM)" "command line"
CPU_ARCH = unknown
endif
ifeq "$(CPU_ARCH)" "x64"
C_CXX_FLAGS += -D TC_ARCH_X64
endif
#------ macOS configuration ------
export PLATFORM := MacOSX
export PLATFORM_UNSUPPORTED := 0
APPNAME := Basalt
TC_OSX_SDK ?= $(shell xcrun --show-sdk-path)
C_CXX_FLAGS += -DTC_UNIX -DTC_BSD -DTC_MACOSX -mmacosx-version-min=11.0 -isysroot $(TC_OSX_SDK)
CXXFLAGS += -std=c++14 -stdlib=libc++ -Wno-deprecated-declarations
LFLAGS += -mmacosx-version-min=11.0 -Wl,-syslibroot,$(TC_OSX_SDK) -stdlib=libc++
ASM_OBJ_FORMAT = macho64
ASFLAGS += --prefix _
ifeq "$(TC_BUILD_CONFIG)" "Release"
export DISABLE_PRECOMPILED_HEADERS := 1
S := $(C_CXX_FLAGS)
C_CXX_FLAGS = $(subst -MMD,,$(S))
C_CXX_FLAGS += -g
LFLAGS += -Wl,-dead_strip
endif
#------ Common configuration ------
CFLAGS := $(C_CXX_FLAGS) $(CFLAGS) $(TC_EXTRA_CFLAGS)
CXXFLAGS := $(C_CXX_FLAGS) $(CXXFLAGS) $(TC_EXTRA_CXXFLAGS)
ASFLAGS += -f $(ASM_OBJ_FORMAT)
LFLAGS := $(LFLAGS) $(TC_EXTRA_LFLAGS)
#------ Project build ------
CORE_DIRS := Platform Volume Fuse Core
.PHONY: libBasaltCore cli clean darwinfuse
#------ DarwinFUSE (NFSv4 userspace FUSE) ------
DARWINFUSE_LIB := $(SRC_DIR)/DarwinFUSE/libdarwinfuse.a
darwinfuse: $(DARWINFUSE_LIB)
$(DARWINFUSE_LIB):
$(MAKE) -C $(SRC_DIR)/DarwinFUSE TC_BUILD_CONFIG=$(TC_BUILD_CONFIG)
#------ Core library (no UI dependency) ------
CORE_ARCHIVES := \
$(SRC_DIR)/Platform/Platform.a \
$(SRC_DIR)/Volume/Volume.a \
$(SRC_DIR)/Fuse/Fuse.a \
$(SRC_DIR)/Core/Core.a
libBasaltCore: $(DARWINFUSE_LIB)
@for DIR in $(CORE_DIRS); do \
$(MAKE) -C $(SRC_DIR)/$$DIR -f $$DIR.make NAME=$$DIR || exit $$?; \
done
@echo "Creating libBasaltCore.a..."
libtool -static -o $(BASE_DIR)/libBasaltCore.a $(CORE_ARCHIVES)
#------ Standalone CLI (no UI dependency) ------
cli: libBasaltCore
$(MAKE) -C CLI -f CLI.make APPNAME=basalt-cli
#------ Clean ------
clean:
@for DIR in $(CORE_DIRS); do \
$(MAKE) -C $(SRC_DIR)/$$DIR -f $$DIR.make NAME=$$DIR clean 2>/dev/null || true; \
done
$(MAKE) -C CLI -f CLI.make clean 2>/dev/null || true
$(MAKE) -C $(SRC_DIR)/DarwinFUSE clean 2>/dev/null || true
rm -f $(BASE_DIR)/libBasaltCore.a