This repository has been archived by the owner on May 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 41
/
Makefile
152 lines (124 loc) · 4.83 KB
/
Makefile
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
# Copyright 2018-present RebirthDB
#
# 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.
#
# This file incorporates work covered by the following copyright:
#
# Copyright 2010-present, The Linux Foundation, portions copyright Google and
# others and used with permission or subject to their respective license
# agreements.
#
# 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 instructions for rebirthdb are available on the rethinkdb website:
# http://www.rethinkdb.com/docs/build/
# There is additional information about the build system in the mk/README file
# This Makefile sets up the environment before delegating to mk/main.mk
ifeq (,$(filter else-if,$(.FEATURES)))
$(error GNU Make >= 3.8.1 is required)
endif
# $(TOP) is the root of the rebirthdb source tree
TOP ?= .
ifeq (/,$(firstword $(subst /,/ ,$(TOP))))
# if $(TOP) is absolute, make $(CWD) absolute
CWD := $(shell pwd)
else
# if $(TOP) is relative, $(CWD) is $(TOP) followed by the relative path from $(TOP) to the working directory
CWD_ABSPATH := $(shell pwd)
ROOT_ABSPATH := $(abspath $(CWD_ABSPATH)/$(TOP))
CWD := $(patsubst $(ROOT_ABSPATH)%,$(patsubst %/,%,$(TOP))%,$(CWD_ABSPATH))
endif
# Prefix $(CWD) to $1 and collapse unecessary ../'s
fixpath = $(patsubst ./%,%,$(shell echo $(CWD)/$1 | sed 's|[^/]\+/\.\./||'))
MAKECMDGOALS ?=
# Build the make command line
MAKE_CMD_LINE = $(MAKE) -f $(TOP)/mk/main.mk
MAKE_CMD_LINE += --no-print-directory
MAKE_CMD_LINE += --warn-undefined-variables
MAKE_CMD_LINE += --no-builtin-rules
MAKE_CMD_LINE += --no-builtin-variables
MAKE_CMD_LINE += TOP=$(TOP) CWD=$(CWD)
# Makefiles can override the goals by setting OVERRIDE_GOALS=<goal>=<replacement>
OVERRIDE_GOALS ?=
NEW_MAKECMDGOALS := $(if $(MAKECMDGOALS),$(MAKECMDGOALS),default-goal)
comma := ,
$(foreach _, $(OVERRIDE_GOALS), $(eval NEW_MAKECMDGOALS := $$(patsubst $(subst =,$(comma),$_), $$(NEW_MAKECMDGOALS))))
# Call fixpath on all goals that aren't phony
MAKE_GOALS = $(foreach goal,$(filter-out $(PHONY_LIST),$(NEW_MAKECMDGOALS)),$(call fixpath,$(goal))) $(filter $(PHONY_LIST),$(NEW_MAKECMDGOALS))
# Delegate the build to mk/main.mk
.PHONY: make
make:
@$(CHECK_ARG_VARIABLES)
+@$(MAKE_CMD_LINE) COUNTDOWN_TOTAL=$(COUNTDOWN_TOTAL) $(MAKE_GOALS)
.PHONY: command-line
command-line:
@echo $(MAKE_CMD_LINE)
%: make
@true
# List all rules
.PHONY: dump-db
dump-db:
+@$(CHECK_ARG_VARIABLES)
+@$(MAKE_CMD_LINE) --print-data-base --question JUST_SCAN_MAKEFILES=1 || true
# Load the configuration
include $(TOP)/mk/configure.mk
# Require CHECK_ARG_VARIABLES
include $(TOP)/mk/check-env.mk
# The cached list of phony targets
PHONY_LIST = var-%
-include $(TOP)/mk/gen/phony-list.mk
# Explicitely add `deps' to the phony list, which was not being rebuilt properly (see review 1773).
# This line can be removed after #2700 is fixed.
PHONY_LIST += deps
.PHONY: debug-count
debug-count:
@$(eval MAKE_GOALS := $(filter-out $@,$(MAKE_GOALS)))$(COUNTDOWN_COMMAND)
COUNTDOWN_COMMAND = MAKEFLAGS='$(MAKEFLAGS)' $(MAKE_CMD_LINE) $(MAKE_GOALS) --dry-run JUST_SCAN_MAKEFILES=1 -j1
ifneq (1,$(SHOW_COUNTDOWN))
COUNTDOWN_TOTAL :=
else ifeq (Windows,$(OS))
COUNTDOWN_TOTAL :=
else
# See mk/lib.mk for JUST_SCAN_MAKEFILES
COUNTDOWN_TOTAL = $(firstword $(shell $(COUNTDOWN_COMMAND) 2>&1 | grep "[!!!]" | wc -l 2>/dev/null))
endif
# Build the list of phony targets
$(TOP)/mk/gen/phony-list.mk: $(CONFIG)
+@MAKEFLAGS= $(MAKE_CMD_LINE) --print-data-base var-MAKEFILE_LIST JUST_SCAN_MAKEFILES=1 \
| egrep '^.PHONY: |^MAKEFILE_LIST = ' \
| egrep -v '\$$' \
| sed 's/^.PHONY:/PHONY_LIST +=/' \
| sed 's|^MAKEFILE_LIST =|$$(TOP)/mk/gen/phony-list.mk: $$(patsubst $(TOP)/%,$$(TOP)/%,$$(filter-out %.d,|;s|$$|))|' \
> $@ 2>/dev/null
# Don't try to rebuild any of the Makefiles
Makefile:
@true
%/Makefile:
@true
%.mk:
@true
##### Cancel builtin rules
.SUFFIXES:
%: %,v
%: RCS/%,v
%: RCS/%
%: s.%
%: SCCS/s.%