This repository has been archived by the owner on Dec 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathMakefile.common
181 lines (151 loc) · 4.17 KB
/
Makefile.common
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
# Copyright 2016 WebAssembly Community Group participants
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Build debug: make
# : make DEBUG=1
# Build release: make RELEASE=1
# Note: If using -jN, be sure to run "make gen" first.
# Include rules for parameterizing the build.
# Defines whether we are building bootstrapped subsystem, so that we can
# generate corresponding source files.
CXX := clang++
EXE :=
CXX_BOOT := $(CXX)
ifndef GEN
GEN=0
endif
ifndef GENSRCS
GENSRCS=0
endif
# Define if updating tests
ifndef UPDATE
UPDATE=0
endif
# Define if release or debug build
ifdef DEBUG
ifdef RELEASE
ifeq ($(DEBUG), 0)
ifneq ($(RELEASE), 0)
RELEASE = 1
else
$(error Cant specify both DEBUG and RELEASE)
endif
else ifneq ($(RELEASE), 0)
$(error Cant specify both DEBUG and RELEASE)
endif
else ifeq ($(DEBUG), 0)
RELEASE = 1
else
RELEASE = 0
endif
else
ifndef RELEASE
DEBUG = 1
RELEASE = 0
else ifeq ($(RELEASE), 0)
DEBUG = 1
else
DEBUG = 0
endif
endif
# PAGE_SIZE (if defined) specifies that log2 size (i.e. number of bits) to use
# for page size.
PAGE_SIZE := 0
ifeq ($(PAGE_SIZE), 0)
USE_PAGE_SIZE = default
PAGE_BUILD_SUFFIX=
MAKE_PAGE_SIZE=
else
PAGE_BUILD_SUFFIX=/p$(PAGE_SIZE)
USE_PAGE_SIZE = $(PAGE_SIZE)
MAKE_PAGE_SIZE = "PAGESIZE=$(PAGE_SIZE)"
endif
WASM_INSTALL=$(PWD)/travis_deps/wasm-install
WASM_BIN=$(WASM_INSTALL)/bin
WASM_CXX=$(WASM_BIN)/emscripten/em++
WASM := 0
WASM_VANILLA := 1
ifneq ($(WASM), 0)
ifeq ($(WASM_VANILLA), 0)
EMSCRIPTEN_CONFIG=$(WASM_INSTALL)/../wasm_emscripten_config
WASM_SUBDIR=/wasm
else
EMSCRIPTEN_CONFIG=$(WASM_INSTALL)/../wasm_emscripten_config_vanilla
WASM_SUBDIR=/wasm-vanilla
endif
CXX := $(WASM_CXX)
WASM_SYSROOT=$(WASM_INSTALL)/sysroot
TARGET_CXXFLAGS := \
--em-config $(EMSCRIPTEN_CONFIG) \
--target=wasm32-unknown-unknown \
-S --sysroot=$(WASM_INSTALL) \
-s BINARYEN=1
TARGET_CXXFLAGS += -DSTACK_SIZE=1044480 \
-w -Wno-implicit-function-declaration
EXE = .js
else
$info(Else Using WASM=$(WASM))
endif
ifeq ($(CXX),clang++)
CXX_SUBDIR =
else
ifeq ($(CXX), $(WASM_CXX))
CXX_SUBDIR =
else
CXX_SUBDIR = /$(CXX)
endif
endif
PLATFORM := Default
PLATFORM_CXXFLAGS_DEFAULT = --std=c++11 -DOVERRIDE= -DFINAL=
# Define platform specific stuff.
ifeq ($(PLATFORM), Travis)
# Add flags to handle that Travis g++ uses -std=c++0x with missing c++11 options.
ifeq ($(CXX),g++)
PLATFORM_CXXFLAGS += -std=c++0x -DOVERRIDE= -DFINAL=
else
PLATFORM_CXXFLAGS += -std=c++11 -DOVERRIDE=override -DFINAL=final
endif
else ifeq ($(PLATFORM), Default)
PLATFORM_CXXFLAGS += $(PLATFORM_CXXFLAGS_DEFAULT)
else
$(error Unrecognized platform: $(PLATFORM))
endif
WABT_DIR = third_party/wabt
SRCDIR = src
BUILDBASEDIR = build$(WASM_SUBDIR)$(CXX_SUBDIR)$(PAGE_BUILD_SUFFIX)
ifeq ($(RELEASE), 0)
BUILDDIR = $(BUILDBASEDIR)/debug
else
BUILDDIR = $(BUILDBASEDIR)/release
endif
#BUILDDIR_BOOT = build/boot$(CXX_SUBDIR)$(PAGE_BUILD_SUFFIX)
BUILDDIR_BOOT = build/boot
GENDIR = build/src
TEST_GENDIR = build/test
SRC_GENDIR = $(GENDIR)
OBJDIR = $(BUILDDIR)/obj
OBJDIR_BOOT = $(BUILDDIR_BOOT)/obj
LIBDIR = $(BUILDDIR)/lib
LIBPREFIX = wasm-decomp-
MAKE_RELEASE = DEBUG=$(DEBUG) RELEASE=$(RELEASE)
$(info -----------------------------------------------)
$(info Using GENSRCS = $(GENSRCS))
$(info Using PLATFORM = $(PLATFORM))
$(info Using CXX = $(CXX))
$(info Using CXX_BOOT = $(CXX_BOOT))
$(info Using RELEASE = $(RELEASE))
$(info Using PAGE_SIZE = $(USE_PAGE_SIZE))
$(info Using CXX_SUBDIR = $(CXX_SUBDIR))
$(info Using WASM = $(WASM))
$(info Using BUILDDIR = $(BUILDDIR))
$(info -----------------------------------------------)