Source code

Revision control

Other Tools

1
# -*- makefile -*-
2
# vim:set ts=8 sw=8 sts=8 noet:
3
# This Source Code Form is subject to the terms of the Mozilla Public
4
# License, v. 2.0. If a copy of the MPL was not distributed with this
5
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
7
# Defines main targets for driving the Firefox build system.
8
#
9
# This make file should not be invoked directly. Instead, use
10
# `mach` (likely `mach build`) for invoking the build system.
11
#
12
# Options:
13
# MOZ_OBJDIR - Destination object directory
14
# MOZ_MAKE_FLAGS - Flags to pass to $(MAKE)
15
#
16
#######################################################################
17
# Defines
18
19
ifdef MACH
20
ifndef NO_BUILDSTATUS_MESSAGES
21
define BUILDSTATUS
22
@echo 'BUILDSTATUS $1'
23
24
endef
25
endif
26
endif
27
28
29
CWD := $(CURDIR)
30
31
ifeq "$(CWD)" "/"
32
CWD := /.
33
endif
34
35
PYTHON ?= $(shell which python2.7 > /dev/null 2>&1 && echo python2.7 || echo python)
36
37
####################################
38
# Load mozconfig Options
39
40
include $(OBJDIR)/.mozconfig-client-mk
41
42
ifdef MOZ_PARALLEL_BUILD
43
MOZ_MAKE_FLAGS := $(filter-out -j%,$(MOZ_MAKE_FLAGS))
44
MOZ_MAKE_FLAGS += -j$(MOZ_PARALLEL_BUILD)
45
endif
46
47
# Automatically add -jN to make flags if not defined. N defaults to number of cores.
48
ifeq (,$(findstring -j,$(MOZ_MAKE_FLAGS)))
49
cores=$(shell $(PYTHON) -c 'import multiprocessing; print(multiprocessing.cpu_count())')
50
MOZ_MAKE_FLAGS += -j$(cores)
51
endif
52
53
ifdef MOZ_AUTOMATION
54
ifeq (4.0,$(firstword $(sort 4.0 $(MAKE_VERSION))))
55
MOZ_MAKE_FLAGS += --output-sync=line
56
endif
57
endif
58
59
MOZ_MAKE = $(MAKE) $(MOZ_MAKE_FLAGS) -C $(OBJDIR)
60
61
# 'configure' scripts generated by autoconf.
62
CONFIGURES := $(TOPSRCDIR)/configure
63
CONFIGURES += $(TOPSRCDIR)/js/src/configure
64
65
#######################################################################
66
# Rules
67
68
# The default rule is build
69
build::
70
71
ifndef MACH
72
$(error client.mk must be used via `mach`. Try running \
73
`./mach $(firstword $(MAKECMDGOALS) $(.DEFAULT_GOAL))`)
74
endif
75
76
# In automation, manage an sccache daemon. The starting of the server
77
# needs to be in a make file so sccache inherits the jobserver.
78
ifdef MOZBUILD_MANAGE_SCCACHE_DAEMON
79
build::
80
# Terminate any sccache server that might still be around.
81
-$(MOZBUILD_MANAGE_SCCACHE_DAEMON) --stop-server > /dev/null 2>&1
82
# Start a new server, ensuring it gets the jobserver file descriptors
83
# from make (but don't use the + prefix when make -n is used, so that
84
# the command doesn't run in that case)
85
mkdir -p $(UPLOAD_PATH)
86
$(if $(findstring n,$(filter-out --%, $(MAKEFLAGS))),,+)env RUST_LOG=sccache=debug SCCACHE_ERROR_LOG=$(UPLOAD_PATH)/sccache.log $(MOZBUILD_MANAGE_SCCACHE_DAEMON) --start-server
87
endif
88
89
####################################
90
# Configure
91
92
$(CONFIGURES): %: %.in
93
@echo Generating $@
94
cp -f $< $@
95
chmod +x $@
96
97
CONFIGURE_ENV_ARGS += \
98
MAKE='$(MAKE)' \
99
$(NULL)
100
101
# configure uses the program name to determine @srcdir@. Calling it without
102
# $(TOPSRCDIR) will set @srcdir@ to "."; otherwise, it is set to the full
103
# path of $(TOPSRCDIR).
104
ifeq ($(TOPSRCDIR),$(OBJDIR))
105
CONFIGURE = ./configure
106
else
107
CONFIGURE = $(TOPSRCDIR)/configure
108
endif
109
110
configure:: $(CONFIGURES)
111
$(call BUILDSTATUS,TIERS configure)
112
$(call BUILDSTATUS,TIER_START configure)
113
@echo cd $(OBJDIR);
114
@echo $(CONFIGURE) $(CONFIGURE_ARGS)
115
@cd $(OBJDIR) && $(CONFIGURE_ENV_ARGS) $(CONFIGURE) $(CONFIGURE_ARGS) \
116
|| ( echo '*** Fix above errors and then restart with\
117
"./mach build"' && exit 1 )
118
@touch $(OBJDIR)/Makefile
119
$(call BUILDSTATUS,TIER_FINISH configure)
120
121
####################################
122
# Build it
123
124
build::
125
+$(MOZ_MAKE)
126
127
ifdef MOZ_AUTOMATION
128
build::
129
+$(MOZ_MAKE) automation/build
130
endif
131
132
# This makefile doesn't support parallel execution. It does pass
133
# MOZ_MAKE_FLAGS to sub-make processes, so they will correctly execute
134
# in parallel.
135
.NOTPARALLEL:
136
137
.PHONY: \
138
build \
139
configure