-
Notifications
You must be signed in to change notification settings - Fork 2
/
makefile.cargo
195 lines (167 loc) · 5.7 KB
/
makefile.cargo
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
185
186
187
188
189
190
191
192
193
194
195
# We need to use bash here, as there are a couple of targets below
# that use [[ to do conditional things
SHELL := /usr/bin/env bash
# Default flags
CONFIGURE_FLAGS := \
--disable-jemalloc \
--disable-js-shell \
--disable-tests \
--disable-shared-js \
--build-backends=RecursiveMake \
--enable-posix-nspr-emulation
ifeq (windows,$(findstring windows,$(TARGET)))
WINDOWS := 1
else
WINDOWS :=
endif
ifneq ($(HOST),$(TARGET))
ifeq (armv7-linux-androideabi,$(TARGET))
# Reset TARGET variable because armv7 target name used by Rust is not
# the same as the target name needed for the CXX toolchain.
TARGET = arm-linux-androideabi
CONFIGURE_FLAGS += \
--with-arch=armv7-a \
--with-fpu=neon \
$(NULL)
endif
ifeq (aarch64-unknown-linux-gnu,$(TARGET))
# Reset TARGET variable because aarch64 target name used by Rust is not
# the same as the target name needed for the CXX toolchain.
TARGET = aarch64-linux-gnu
CONFIGURE_FLAGS += \
--with-arch=armv8-a \
$(NULL)
endif
ifeq (android,$(findstring android,$(TARGET)))
ifneq (,$(STLPORT_CPPFLAGS))
CONFIGURE_FLAGS += STLPORT_CPPFLAGS="$(STLPORT_CPPFLAGS)"
endif
ifneq (,$(ANDROID_NDK))
CONFIGURE_FLAGS += --with-android-ndk=$(ANDROID_NDK)
endif
ifneq (,$(ANDROID_NDK_VERSION))
CONFIGURE_FLAGS += --with-android-ndk-version=$(ANDROID_NDK_VERSION)
endif
ifneq (,$(ANDROID_VERSION))
CONFIGURE_FLAGS += --with-android-version=$(ANDROID_VERSION)
endif
ifneq (,$(ANDROID_PLATFORM_DIR))
CONFIGURE_FLAGS += --with-android-platform=$(ANDROID_PLATFORM_DIR)
endif
ifneq (,$(ANDROID_TOOLCHAIN_DIR))
CONFIGURE_FLAGS += --with-android-toolchain=$(ANDROID_TOOLCHAIN_DIR)
endif
ifneq (,$(ANDROID_CLANG))
CONFIGURE_FLAGS += --with-android-clang=$(ANDROID_CLANG)
endif
endif
ifeq ($(WINDOWS),)
CC ?= $(TARGET)-gcc
CPP ?= $(TARGET)-gcc -E
CXX ?= $(TARGET)-g++
AR ?= $(TARGET)-ar
CONFIGURE_FLAGS += --target=$(TARGET) --disable-gold
endif
else
ifeq (,$(WINDOWS))
ifeq (freebsd,$(findstring freebsd,$(TARGET)))
# Does not symlink clang as "gcc" like macOS does
CC ?= clang
CPP ?= clang -E
CXX ?= clang++
else
CC ?= gcc
CPP ?= gcc -E
CXX ?= g++
endif
AR ?= ar
# check if python2 is a valid Python executable, otherwise fall back to python
ifeq (, $(findstring Python 2.,$(shell python2 --version 2> /dev/null)))
PYTHON ?= python2
else
PYTHON ?= python
endif
endif
endif
ifneq (,$(CARGO_FEATURE_DEBUGMOZJS))
CONFIGURE_FLAGS += --enable-debug --disable-optimize --enable-gczeal
endif
ifneq (,$(CARGO_FEATURE_PROFILEMOZJS))
CONFIGURE_FLAGS += --enable-profiling
endif
ifneq (,$(CCACHE))
CONFIGURE_FLAGS += --with-ccache=$(CCACHE)
endif
ifneq ($(WINDOWS),)
# Visual Studio build
NEED_WIN_PYTHON := 1
# There's no cygpath in mozilla-build, and we're expecting to
# be building with MOZ_BUILD_TOOLS, so do our best
OUT_DIR:=$(subst \,/,$(OUT_DIR))
ifeq ($(findstring x86_64,$(TARGET)),x86_64)
# This is the correct target for MSVC builds
CONFIGURE_FLAGS += --target=x86_64-pc-mingw32 --host=x86_64-pc-mingw32
else ifeq ($(findstring i686,$(TARGET)),i686)
# This is the correct target for MSVC builds
CONFIGURE_FLAGS += --target=i686-pc-mingw32 --host=x86_64-pc-mingw32
else ifeq ($(findstring aarch64,$(TARGET)),aarch64)
# This is the correct target for MSVC builds
CONFIGURE_FLAGS += --target=aarch64-windows-mingw32 --host=x86_64-pc-mingw32
endif
MOZ_TOOLS=/
else ifeq ($(MSYSTEM),MINGW64)
# MSYS2/MINGW64 build
NEED_WIN_PYTHON := 1
# msys2 sets CC=cc as default. however, there is no `cc.exe`.
# overwrite it here.
ifeq ($(CC),cc)
CC = gcc
CPP = gcc -E
endif
# cargo uses Windows native path. msys2 make unfortunately doesn't understand it.
OUT_DIR:=$(shell cygpath "$(OUT_DIR)")
# Fake out the SM build with a dummy dir here; just needs $(MOZ_TOOLS)/bin
# to exist
MOZ_TOOLS=/
# We don't need to build shared JS, and we need to disable export attrs
CONFIGURE_FLAGS += --disable-shared-js --disable-export-js
else
# We don't need to build shared JS
CONFIGURE_FLAGS += --disable-shared-js
endif
# If we need to do extra work to find an appropriate python on
# Windows, do it here
ifeq ($(NEED_WIN_PYTHON),1)
ifneq (,$(NATIVE_WIN32_PYTHON))
PYTHON := $(NATIVE_WIN32_PYTHON)
else ifneq (,$(wildcard c:/python27/python.exe))
PYTHON := c:/python27/python.exe
else
$(message You must either have the Native Win32 python installed in C:/python27, or set NATIVE_WIN32_PYTHON to point to the appropriate python.exe.)
$(message Download the Python installer from https://www.python.org/downloads/release/python-2710/)
$(error Native Win32 Python not found)
endif
endif
SRC_DIR = $(shell pwd)
.PHONY : all maybe-configure
all: maybe-configure
cd $(OUT_DIR) && $(MAKE) -f Makefile
# Only touch and run configure if we need to, to avoid unnecessary rebuilds.
# The second two time checks handle the case of configure.in and configure having
# the same timestamp (e.g. after a git checkout)
JSSRC := $(SRC_DIR)/mozjs/js/src
maybe-configure:
[[ $(JSSRC)/configure -ot $(JSSRC)/configure.in ]] && touch $(JSSRC)/configure || true
[[ $(JSSRC)/old-configure -ot $(JSSRC)/old-configure.in ]] && touch $(JSSRC)/old-configure || true
! [[ $(JSSRC)/configure.in -ot $(JSSRC)/configure ]] && touch $(JSSRC)/configure || true
! [[ $(JSSRC)/old-configure.in -ot $(JSSRC)/old-configure ]] && touch $(JSSRC)/old-configure || true
if [[ $(JSSRC)/configure -nt $(OUT_DIR)/config.status ]] ; then \
cd $(OUT_DIR) && \
PYTHON="$(PYTHON)" MOZ_TOOLS="$(MOZ_TOOLS)" \
CC="$(CC)" CFLAGS="$(CFLAGS)" \
CPP="$(CPP)" CPPFLAGS="$(CPPFLAGS)" \
CXX="$(CXX)" CXXFLAGS="$(CXXFLAGS)" \
AS="$(AS)" AR="$(AR)" \
STLPORT_LIBS="$(STLPORT_LIBS)" \
$(JSSRC)/configure $(strip $(CONFIGURE_FLAGS)) || (cat config.log && exit 1) ; \
fi