forked from ArduPilot/ardupilot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenviron.mk
203 lines (171 loc) · 5.62 KB
/
environ.mk
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
196
197
198
199
200
201
202
203
# find key paths and system type
# Save the system type for later use.
#
SYSTYPE := $(shell uname)
GIT_VERSION := $(shell git rev-parse HEAD | cut -c1-8)
EXTRAFLAGS += -DGIT_VERSION="\"$(GIT_VERSION)\""
# force LANG to C so awk works sanely on MacOS
export LANG=C
#
# Locate the sketch sources based on the initial Makefile's path
#
SRCROOT := $(realpath $(dir $(firstword $(MAKEFILE_LIST))))
ifneq ($(findstring CYGWIN, $(SYSTYPE)),)
# Workaround a $(realpath ) bug on cygwin
ifeq ($(SRCROOT),)
SRCROOT := $(shell cygpath -m ${CURDIR})
$(warning your realpath function is not working)
$(warning > setting SRCROOT to $(SRCROOT))
endif
endif
#
# We need to know the location of the sketchbook. If it hasn't been overridden,
# try the parent of the current directory. If there is no libraries directory
# there, assume that we are in a library's examples directory and try backing up
# further.
#
ifeq ($(SKETCHBOOK),)
SKETCHBOOK := $(shell cd $(SRCROOT)/.. && pwd)
ifeq ($(wildcard $(SKETCHBOOK)/libraries),)
SKETCHBOOK := $(shell cd $(SRCROOT)/../.. && pwd)
endif
ifeq ($(wildcard $(SKETCHBOOK)/libraries),)
SKETCHBOOK := $(shell cd $(SRCROOT)/../../.. && pwd)
endif
ifeq ($(wildcard $(SKETCHBOOK)/libraries),)
SKETCHBOOK := $(shell cd $(SRCROOT)/../../../.. && pwd)
endif
ifeq ($(wildcard $(SKETCHBOOK)/libraries),)
$(error ERROR: cannot determine sketchbook location - please specify on the commandline with SKETCHBOOK=<path>)
endif
else
ifeq ($(wildcard $(SKETCHBOOK)/libraries),)
$(warning WARNING: sketchbook directory $(SKETCHBOOK) contains no libraries)
endif
endif
ifneq ($(findstring CYGWIN, $(SYSTYPE)),)
# Convert cygwin path into a windows normal path
SKETCHBOOK := $(shell cygpath ${SKETCHBOOK})
endif
#
# Work out the sketch name from the name of the source directory.
#
SKETCH := $(lastword $(subst /, ,$(SRCROOT)))
# Workaround a $(lastword ) bug on cygwin
ifeq ($(SKETCH),)
WORDLIST := $(subst /, ,$(SRCROOT))
SKETCH := $(word $(words $(WORDLIST)),$(WORDLIST))
endif
#
# Work out where we are going to be building things
#
TMPDIR ?= /tmp
ifneq ($(findstring px4, $(MAKECMDGOALS)),)
# when building px4 we need all sources to be inside the sketchbook directory
# as the NuttX build system relies on it
BUILDROOT := $(SKETCHBOOK)/Build.$(SKETCH)
endif
ifneq ($(findstring vrbrain, $(MAKECMDGOALS)),)
# when building vrbrain we need all sources to be inside the sketchbook directory
# as the NuttX build system relies on it
BUILDROOT := $(SKETCHBOOK)/Build.$(SKETCH)
endif
ifneq ($(findstring vrubrain, $(MAKECMDGOALS)),)
# when building vrbrain we need all sources to be inside the sketchbook directory
# as the NuttX build system relies on it
BUILDROOT := $(SKETCHBOOK)/Build.$(SKETCH)
endif
ifneq ($(findstring vrhero, $(MAKECMDGOALS)),)
# when building vrbrain we need all sources to be inside the sketchbook directory
# as the NuttX build system relies on it
BUILDROOT := $(SKETCHBOOK)/Build.$(SKETCH)
endif
ifeq ($(BUILDROOT),)
BUILDROOT := $(abspath $(TMPDIR)/$(SKETCH).build)
endif
ifneq ($(findstring CYGWIN, $(SYSTYPE)),)
# Workaround a $(abspath ) bug on cygwin
ifeq ($(BUILDROOT),)
BUILDROOT := C:$(TMPDIR)/$(SKETCH).build
$(warning your abspath function is not working)
$(warning > setting BUILDROOT to $(BUILDROOT))
else
BUILDROOT := $(shell cygpath ${BUILDROOT})
endif
endif
# Jump over the next makefile sections when runing a "make configure"
ifneq ($(MAKECMDGOALS),configure)
################################################################################
# Config options
#
# The Makefile calling us must specify BOARD
#
include $(SKETCHBOOK)/config.mk
ifeq ($(PORT),)
$(error ERROR: could not locate $(SKETCHBOOK)/config.mk, please run 'make configure' first and edit config.mk)
endif
ifneq ($(APPDIR),)
# this is a recusive PX4 build
HAL_BOARD = HAL_BOARD_PX4
endif
# handle target based overrides for board type
ifneq ($(findstring px4, $(MAKECMDGOALS)),)
HAL_BOARD = HAL_BOARD_PX4
endif
ifneq ($(findstring sitl, $(MAKECMDGOALS)),)
HAL_BOARD = HAL_BOARD_AVR_SITL
HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_NONE
endif
ifneq ($(findstring linux, $(MAKECMDGOALS)),)
HAL_BOARD = HAL_BOARD_LINUX
HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_LINUX_NONE
endif
ifneq ($(findstring erle, $(MAKECMDGOALS)),)
HAL_BOARD = HAL_BOARD_LINUX
HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_LINUX_ERLE
endif
ifneq ($(findstring pxf, $(MAKECMDGOALS)),)
HAL_BOARD = HAL_BOARD_LINUX
HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_LINUX_PXF
endif
ifneq ($(findstring navio, $(MAKECMDGOALS)),)
HAL_BOARD = HAL_BOARD_LINUX
HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_LINUX_NAVIO
endif
ifneq ($(findstring vrbrain, $(MAKECMDGOALS)),)
HAL_BOARD = HAL_BOARD_VRBRAIN
HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_NONE
endif
ifneq ($(findstring vrubrain, $(MAKECMDGOALS)),)
HAL_BOARD = HAL_BOARD_VRBRAIN
HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_NONE
endif
ifneq ($(findstring vrhero, $(MAKECMDGOALS)),)
HAL_BOARD = HAL_BOARD_VRBRAIN
HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_NONE
endif
ifneq ($(findstring apm1, $(MAKECMDGOALS)),)
HAL_BOARD = HAL_BOARD_APM1
HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_AVR_APM1
endif
ifneq ($(findstring apm2, $(MAKECMDGOALS)),)
HAL_BOARD = HAL_BOARD_APM2
HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_AVR_APM2
endif
ifneq ($(findstring flymaple, $(MAKECMDGOALS)),)
HAL_BOARD = HAL_BOARD_FLYMAPLE
endif
# default to APM2
ifeq ($(HAL_BOARD),)
#$(warning No HAL_BOARD in config.mk - defaulting to HAL_BOARD_APM2)
HAL_BOARD = HAL_BOARD_APM2
HAL_BOARD_SUBTYPE = HAL_BOARD_SUBTYPE_AVR_APM2
endif
HARDWARE ?= arduino
ifeq ($(BOARD),)
BOARD = mega2560
endif
ifneq ($(findstring apm1-1280, $(MAKECMDGOALS)),)
BOARD = mega
endif
endif