forked from fairecasoimeme/Butineuse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.macos
144 lines (106 loc) · 4.82 KB
/
Makefile.macos
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
# Leave at the top
THIS_MAKEFILE := $(lastword $(MAKEFILE_LIST))
# Application target name
TARGET = JN516xSniffer
# Default device type
JENNIC_CHIP ?= JN5169
# Default SDK
JENNIC_SDK ?= JN-SW-4163
##############################################################################
# Select the network stack (e.g. MAC, ZBPRO)
JENNIC_STACK ?= None
##############################################################################
# Debug options define DEBUG for HW debug
#DEBUG ?=HW
#
# Define which UART to use for debug
DEBUG_PORT ?= UART1
##############################################################################
# Define TRACE to use with DBG module
TRACE ?=1
##############################################################################
# Path definitions
SDK_BASE_DIR ?= $(abspath ../sdk/$(JENNIC_SDK)/)
SRC_DIR = src
OBJ_DIR = debug
TOOL_COMMON_BASE_DIR= /usr/local
#TOOL_COMMON_BASE_DIR= $(HOME)/bin
TOOLCHAIN_PATH =
#TOOLCHAIN_PATH = ba-elf-gcc-4.7.4
# Needs patch of sdk/JN-SW-4163/Chip/Common/Build/config_ba2.mk to not replace this value
##############################################################################
# Application Source files
APPSRC += main.c crc-ccitt.c UartBuffered.c Queue.c Printf.c
# Specify additional Component libraries
APPLIBS += MMAC
APPLIBS += DBG
##############################################################################
# Standard Application header search paths
INCFLAGS += -I$(COMPONENTS_BASE_DIR)/MicroSpecific/Include
INCFLAGS += -Iinc
##############################################################################
##############################################################################
# Configure for the selected chip or chip family
include $(SDK_BASE_DIR)/Chip/Common/Build/config.mk
include $(SDK_BASE_DIR)/Platform/Common/Build/Config.mk
include $(SDK_BASE_DIR)/Stack/Common/Build/config.mk
###TODO: change this
#INCFLAGS += -I$(TOOL_COMMON_BASE_DIR)/$(TOOLCHAIN_PATH)/include
INCFLAGS += -I/usr/local/Cellar/gcc/7.3.0/lib/gcc/ba-elf/4.7.4/include
INCFLAGS += -I/usr/local/ba-elf/include
INCFLAGS += -I$(SDK_BASE_DIR)/Components/Xcv/Include
LDFLAGS += -L/usr/local/Cellar/gcc/7.3.0/lib/gcc/ba-elf/4.7.4/mcpu_jn51xx_sizeopt/
LDFLAGS += -L/usr/local/ba-elf/lib -fno-lto
##############################################################################
APPOBJS = $(addprefix $(OBJ_DIR)/,$(APPSRC:.c=.o))
APPSRCS = $(addprefix $(SRC_DIR)/,$(APPSRC))
##############################################################################
# Application dynamic dependencies
APPDEPS = $(APPOBJS:.o=.d)
#########################################################################
# Linker
# Add application libraries before chip specific libraries to linker so
# symbols are resolved correctly (i.e. ordering is significant for GCC)
LDLIBS := $(addsuffix _$(JENNIC_CHIP_FAMILY),$(APPLIBS)) $(LDLIBS)
#########################################################################
# Dependency rules
.PHONY: all clean
# Path to directories containing application source
#vpath % $(APP_SRC_DIR)
all: $(OBJ_DIR)/$(TARGET)_$(JENNIC_CHIP)$(BIN_SUFFIX).bin $(THIS_MAKEFILE)
-include $(APPDEPS)
$(OBJ_DIR)/%.d:
rm -f $(OBJ_DIR)/$*.o
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.S $(OBJ_DIR)/.dirok $(THIS_MAKEFILE)
$(info Assembling $< ...)
$(CC) -c -o $@ $(CFLAGS) $(INCFLAGS) $< -MMD -MF $(OBJ_DIR)/$*.d -MP
@echo
$(OBJ_DIR)/%.i: $(SRC_DIR)/%.c $(OBJ_DIR)/.dirok $(THIS_MAKEFILE)
$(info Compiling $< ...)
$(CC) -E -o $@ $(CFLAGS) $(INCFLAGS) $<
@echo
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c $(OBJ_DIR)/.dirok $(THIS_MAKEFILE)
$(info Compiling $< ...)
$(CC) -c -o $@ $(CFLAGS) $(INCFLAGS) $< -MMD -MF $(OBJ_DIR)/$*.d -MP
@echo
$(OBJ_DIR)/$(TARGET)_$(JENNIC_CHIP)$(BIN_SUFFIX).elf: $(APPOBJS) $(addsuffix _$(JENNIC_CHIP_FAMILY).a,$(addprefix $(COMPONENTS_BASE_DIR)/Library/lib,$(APPLIBS))) $(THIS_MAKEFILE)
$(info Linking $@ ...)
$(CC) -Wl,--gc-sections -Wl,-u_AppColdStart -Wl,-u_AppWarmStart $(LDFLAGS) -T$(LINKCMD) -o $@ $(APPOBJS) -Wl,--start-group $(addprefix -l,$(LDLIBS)) -Wl,--end-group -Wl,-Map,$(OBJ_DIR)/$(TARGET)_$(JENNIC_CHIP)$(BIN_SUFFIX).map
${SIZE} $@
@echo
$(OBJ_DIR)/$(TARGET)_$(JENNIC_CHIP)$(BIN_SUFFIX).dis: $(OBJ_DIR)/$(TARGET)_$(JENNIC_CHIP)$(BIN_SUFFIX).elf
$(info Disassembling $< to $@ ...)
$(OBJDUMP) -S $< > $@
@echo
$(OBJ_DIR)/$(TARGET)_$(JENNIC_CHIP)$(BIN_SUFFIX).bin: $(OBJ_DIR)/$(TARGET)_$(JENNIC_CHIP)$(BIN_SUFFIX).elf $(THIS_MAKEFILE)
$(info Generating binary ...)
$(OBJCOPY) -S -O binary $< $@
$(OBJ_DIR)/.dirok: $(THIS_MAKEFILE)
echo $@
mkdir -p $(dir $@)
touch $@
#########################################################################
clean:
# rm -f $(APPOBJS) $(APPDEPS) $(OBJ_DIR)/$(TARGET)_$(JENNIC_CHIP)*.bin $(OBJ_DIR)/$(TARGET)_$(JENNIC_CHIP)*.elf $(OBJ_DIR)/$(TARGET)_$(JENNIC_CHIP)*.map
rm -fR $(OBJ_DIR)
#########################################################################