-
Notifications
You must be signed in to change notification settings - Fork 53
/
Makefile.rules
89 lines (77 loc) · 4.18 KB
/
Makefile.rules
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
#*******************************************************************************
# Ledger SDK
# (c) 2017 Ledger
#
# 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.
#*******************************************************************************
# temporary redef, to ensure wider compliance of the SDK with pre-1.6 apps
ifeq ($(DISABLE_UI),0)
ifeq ($(TARGET_NAME),$(filter $(TARGET_NAME),TARGET_NANOS TARGET_NANOX TARGET_NANOS2))
SDK_SOURCE_PATH += lib_bagl lib_ux
endif
endif
define uniq =
$(eval seen :=)
$(foreach _,$1,$(if $(filter $_,${seen}),,$(eval seen += $_)))
${seen}
endef
define check_duplicate =
$(eval LIST := $(sort $(foreach file_h, $(notdir $1), $(notdir $(shell find $2 -name $(file_h))))))
$(if $(LIST), $(info [WARNING] Found duplicate files in SDK and APP: ${LIST}))
endef
# Expose all SDK header files with their full relative path to the SDK root folder
INCLUDES_PATH += ${BOLOS_SDK}
#include the lib_cxng definition by default if not asked otherwise
ifeq ($(NO_CXNG),)
INCLUDES_PATH += $(BOLOS_SDK)/lib_cxng/include
endif
# Get absolute App root directory to ensure correct stem replacement
APP_DIR := $(shell git rev-parse --show-toplevel)
ifeq ($(APP_DIR),)
MSG := "[ERROR] You should be inside a git repo (you can use 'git init')"
ifneq ($(ENABLE_SDK_WERROR),0)
$(error $(MSG))
else
$(warning $(MSG))
endif
endif
# Extract BOLOS_SDK source files added by the App Makefile
APP_SRC_FROM_SDK = $(filter $(BOLOS_SDK)/%, $(APP_SOURCE_FILES))
# Extract generated and glyphs source files added by the App Makefile
APP_SRC_GEN = $(filter $(GEN_SRC_DIR)/%, $(APP_SOURCE_FILES))
# Extract proto source files added by the App Makefile
APP_SRC_PROTOC = $(filter %.pb.c, $(APP_SOURCE_FILES) $(SOURCE_FILES)) $(shell find $(APP_SOURCE_PATH) -name '*.pb.c')
# Filter remaining real source files from App (proto filtered globally hereafter)
APP_SRC_FILTER = $(filter-out $(APP_SRC_FROM_SDK) $(APP_SRC_GEN), $(APP_SOURCE_FILES))
# Separate SDK and APP and GEN sources
SOURCES_SDK += $(foreach libdir, src $(SDK_SOURCE_PATH), $(shell find $(BOLOS_SDK)/$(libdir) -name '*.[csS]')) $(APP_SRC_FROM_SDK)
SOURCES_APP += $(filter-out %.pb.c, $(abspath $(SOURCE_FILES) $(foreach libdir, $(SOURCE_PATH) $(APP_SOURCE_PATH), $(shell find $(libdir) -name '*.[csS]')) $(APP_SRC_FILTER)))
SOURCES_GEN += $(GLYPH_DESTC) $(APP_SRC_GEN)
VPATH += $(call uniq, $(dir $(SOURCES_SDK) $(SOURCES_APP) $(GLYPH_DESTC)))
# Retrieve APP header filenames
INCLUDES_APP += $(shell find $(APP_SOURCE_PATH) -name '*.h')
# Warn if a same header filename is found in both APP and SDK
$(call check_duplicate, $(INCLUDES_APP), $(BOLOS_SDK))
# Compute header directories list
INCLUDES_PATH += $(call uniq, $(dir $(foreach libdir, $(SDK_SOURCE_PATH), $(dir $(shell find $(BOLOS_SDK)/$(libdir) -name '*.h')))) include $(BOLOS_SDK)/include $(BOLOS_SDK)/include/arm $(dir $(INCLUDES_APP)) $(GLYPH_SRC_DIR))
# Separate object files from SDK and APP to avoid name conflicts
OBJECTS_SDK += $(sort $(subst $(BOLOS_SDK), $(OBJ_DIR)/sdk, $(addsuffix .o, $(basename $(SOURCES_SDK)))))
OBJECTS_APP += $(sort $(addprefix $(OBJ_DIR)/app, $(addsuffix .o, $(basename $(foreach f, $(SOURCES_APP), $(shell echo $(f) | sed "s|$(APP_DIR)||" 2>/dev/null))))))
OBJECTS_GEN += $(sort $(SOURCES_GEN:%c=%o))
OBJECTS_PROTOC += $(sort $(addprefix $(OBJ_DIR)/, $(addsuffix .o, $(basename $(APP_SRC_PROTOC)))))
OBJECT_FILES = $(OBJECTS_GEN) $(OBJECTS_PROTOC) $(OBJECTS_APP) $(OBJECTS_SDK)
OBJECTS_DIR += $(sort $(dir $(OBJECT_FILES)))
# Separate dependency files from SDK and APP to avoid name conflicts
DEPEND_FILES = $(subst $(OBJ_DIR), $(DEP_DIR), $(addsuffix .d, $(basename $(OBJECT_FILES))))
DEPEND_DIR += $(sort $(dir $(DEPEND_FILES)))
include $(BOLOS_SDK)/Makefile.rules_generic