1##############################################################################
2# Main makefile for basic_modem
3##############################################################################
4
5-include makefiles/printing.mk
6-include makefiles/options.mk
7
8
9#-----------------------------------------------------------------------------
10# default action: print help
11#-----------------------------------------------------------------------------
12help:
13	$(call echo_help_b, "Available TARGETs:	sx128x	lr1110	lr1120	lr1121	sx1261	sx1262	sx1268 sx1272 sx1276")
14	$(call echo_help, "")
15	$(call echo_help_b, "-------------------------------- Clean -------------------------------------")
16	$(call echo_help, " * make clean_<TARGET>                     : clean basic_modem for a given target")
17	$(call echo_help, " * make clean_all                          : clean all")
18	$(call echo_help, "")
19	$(call echo_help_b, "----------------------------- Compilation ----------------------------------")
20	$(call echo_help, " * make basic_modem_<TARGET> MCU_FLAGS=xxx : build basic_modem on a given target with chosen mcu flags")
21	$(call echo_help, " *                                           MCU_FLAGS are mandatory. Ex for stm32l4:")
22	$(call echo_help, " *                                           MCU_FLAGS=\"-mcpu=cortex-m4 -mthumb -mabi=aapcs -mfpu=fpv4-sp-d16 -mfloat-abi=hard\"")
23	$(call echo_help, "")
24	$(call echo_help_b, "---------------------- Optional build parameters ---------------------------")
25	$(call echo_help, " * REGION=xxx                              : choose which region should be compiled (default: ALL)")
26	$(call echo_help, " *                                           Combinations also work (i.e. REGION=EU_868,US_915 )")
27	$(call echo_help, " *                                          - AS_923")
28	$(call echo_help, " *                                          - AU_915")
29	$(call echo_help, " *                                          - CN_470")
30	$(call echo_help, " *                                          - CN_470_RP_1_0")
31	$(call echo_help, " *                                          - EU_868")
32	$(call echo_help, " *                                          - IN_865")
33	$(call echo_help, " *                                          - KR_920")
34	$(call echo_help, " *                                          - RU_864")
35	$(call echo_help, " *                                          - US_915")
36	$(call echo_help, " *                                          - WW_2G4 (to be used only for lr1120 and sx128x targets)")
37	$(call echo_help, " *                                          - ALL (to build all possible regions according to the radio target) ")
38	$(call echo_help, " * CRYPTO=xxx                              : choose which crypto should be compiled (default: SOFT)")
39	$(call echo_help, " *                                          - SOFT")
40	$(call echo_help, " *                                          - LR11XX (only for lr1110 and lr1120 targets)")
41	$(call echo_help, " *                                          - LR11XX_WITH_CREDENTIALS (only for lr1110 and lr1120 targets)")
42	$(call echo_help, " * MODEM_TRACE=yes/no                      : choose to enable or disable modem trace print (default: yes)")
43	$(call echo_help, " * LBM_CLASS_B=yes/no                      : choose to build class B feature (default: no)")
44	$(call echo_help, " * LBM_CLASS_C=yes/no                      : choose to build class C feature (default: no)")
45	$(call echo_help, " * LBM_MULTICAST=yes/no                    : choose to build multicast stack feature (default: no)")
46	$(call echo_help, " * LBM_CSMA=yes/no                         : choose to build CSMA Feature (default: yes)")
47	$(call echo_help, " * USE_CSMA_BY_DEFAULT=yes/no              : in case CSMA is built choose to enable CSMA Feature at start (default: no)")
48	$(call echo_help, " * LBM_ALC_SYNC=yes/no                     : choose to build ALCSync service (default: no)")
49	$(call echo_help, " * LBM_ALC_SYNC_VERSION=x                  : choose which version of ALCSync package should be compiled (default: 1)")
50	$(call echo_help, " * LBM_FUOTA=yes/no                        : choose to build LoRaWAN Packages for FUOTA (default: no)")
51	$(call echo_help, " * LBM_FUOTA_VERSION=x                     : choose which version of FUOTA packageq should be compiled (default: 1)")
52	$(call echo_help, " * LBM_FUOTA_ENABLE_FMP=yes/no             : in case FUOTA is enabled choose to build LoRaWAN Firmware Management Package (default: yes)")
53	$(call echo_help, " * LBM_FUOTA_ENABLE_MPA=yes/no             : in case FUOTA is enabled choose to build LoRaWAN Multi-Package Access Package (default: no)")
54	$(call echo_help, " * LBM_ALMANAC=yes/no                      : choose to build Cloud Almanac Update service (default: no)")
55	$(call echo_help, " * LBM_STREAM=yes/no                       : choose to build Cloud Stream service (default: no)")
56	$(call echo_help, " * LBM_LFU=yes/no                          : choose to build Cloud Large File Upload service (default: no)")
57	$(call echo_help, " * LBM_DEVICE_MANAGEMENT=yes/no            : choose to build Cloud Device Management service (default: no)")
58	$(call echo_help, " * LBM_GEOLOCATION=yes/no                  : choose to build Geolocation service (default: no)")
59	$(call echo_help, " * LBM_STORE_AND_FORWARD=yes/no            : choose to build Store and Forward service (default: no)")
60	$(call echo_help, " * LBM_RELAY_TX_ENABLE=yes/no              : choose to build Relay Tx service (default: no)")
61	$(call echo_help, " * LBM_RELAY_RX_ENABLE=yes/no              : choose to build Relay Rx service (default: no)")
62	$(call echo_help, "")
63	$(call echo_help_b, "-------------------- Optional makefile parameters --------------------------")
64	$(call echo_help, " * EXTRAFLAGS=xxx                          : Add specific compilation flag for LBM lib build")
65	$(call echo_help, " * DEBUG=yes/no                            : -g options for debugging (default: no)")
66	$(call echo_help, " * OPT=xxx                                 : Choose compilation optimization  (default: -Os)")
67	$(call echo_help, " * MULTITHREAD=yes/no                      : Multithreaded build (default: yes)")
68	$(call echo_help, " * VERBOSE=yes/no                          : Increase build verbosity (default: no)")
69	$(call echo_help, " * SIZE=yes/no                             : Display size for all objects (default: no)")
70	$(call echo_help, "")
71	$(call echo_help_b, "---------------------------------------------------------------------------")
72	$(call echo_help_b, "All options can also be directly updated in makefiles/options.mk file")
73
74
75
76#-----------------------------------------------------------------------------
77# Makefile include selection
78#-----------------------------------------------------------------------------
79ifeq ($(RADIO),lr1110)
80-include makefiles/lr11xx.mk
81endif
82
83ifeq ($(RADIO),lr1120)
84-include makefiles/lr11xx.mk
85endif
86
87ifeq ($(RADIO),lr1121)
88-include makefiles/lr11xx.mk
89endif
90
91ifeq ($(RADIO),sx1261)
92-include makefiles/sx126x.mk
93endif
94
95ifeq ($(RADIO),sx1262)
96-include makefiles/sx126x.mk
97endif
98
99ifeq ($(RADIO),sx1268)
100-include makefiles/sx126x.mk
101endif
102
103ifeq ($(RADIO),sx128x)
104-include makefiles/sx128x.mk
105endif
106
107ifeq ($(RADIO),sx1272)
108-include makefiles/sx127x.mk
109endif
110
111ifeq ($(RADIO),sx1276)
112-include makefiles/sx127x.mk
113endif
114
115#-----------------------------------------------------------------------------
116-include makefiles/common.mk
117
118.PHONY: clean_all all help
119
120all: basic_modem_sx128x basic_modem_lr1110 basic_modem_lr1120  basic_modem_lr1121 basic_modem_sx1261 basic_modem_sx1262 basic_modem_sx1272 basic_modem_sx1276
121
122#-----------------------------------------------------------------------------
123# Clean
124#-----------------------------------------------------------------------------
125clean_all:
126	-rm -rf $(BUILD_ROOT)
127
128clean_sx128x:
129	$(MAKE) clean_target RADIO=sx128x
130
131clean_lr1110:
132	$(MAKE) clean_target RADIO=lr1110
133
134clean_lr1120:
135	$(MAKE) clean_target RADIO=lr1120
136
137clean_lr1121:
138	$(MAKE) clean_target RADIO=lr1121
139
140clean_sx1261:
141	$(MAKE) clean_target RADIO=sx1261
142
143clean_sx1262:
144	$(MAKE) clean_target RADIO=sx1262
145
146clean_sx1268:
147	$(MAKE) clean_target RADIO=sx1268
148
149clean_sx1272:
150	$(MAKE) clean_target RADIO=sx1272
151
152clean_sx1276:
153	$(MAKE) clean_target RADIO=sx1276
154
155clean:
156	$(MAKE) clean_target
157
158#-----------------------------------------------------------------------------
159# Compilation
160#-----------------------------------------------------------------------------
161basic_modem:
162ifeq ($(RADIO),nc)
163	$(call echo_error,"No radio selected! Please specified the target radio  using RADIO=radio_name option")
164else
165ifneq ($(CRYPTO),SOFT)
166ifeq ($(LBM_RELAY_TX_ENABLE),yes)
167	$(call echo_error, "------------------------------------------------------------")
168	$(call echo_error, "When Relay Tx feature is enable: only soft crypto can be used")
169	$(call echo_error, "Please use CRYPTO=SOFT option")
170	$(call echo_error, "------------------------------------------------------------")
171	exit 1
172endif
173ifeq ($(LBM_RELAY_RX_ENABLE),yes)
174	$(call echo_error, "------------------------------------------------------------")
175	$(call echo_error, "When Relay Rx feature is enable: only soft crypto can be used")
176	$(call echo_error, "Please use CRYPTO=SOFT option")
177	$(call echo_error, "------------------------------------------------------------")
178	exit 1
179endif
180ifneq ($(NB_OF_STACK),1)
181	$(call echo_error, "----------------------------------------------------------")
182	$(call echo_error, "More than one stack compiled: only soft crypto can be used")
183	$(call echo_error, "Please use CRYPTO=SOFT option")
184	$(call echo_error, "----------------------------------------------------------")
185	exit 1
186endif
187ifneq ($(RADIO),lr1110)
188ifneq ($(RADIO),lr1120)
189ifneq ($(RADIO),lr1121)
190	$(call echo_error, "------------------------------------------------------------")
191	$(call echo_error, "sx126x sx127x and sx128x radio tagets: only soft crypto can be used")
192	$(call echo_error, "Please use CRYPTO=SOFT option")
193	$(call echo_error, "------------------------------------------------------------")
194	exit 1
195endif
196endif
197endif
198endif
199	$(MAKE) basic_modem_build
200endif
201
202basic_modem_sx128x:
203	$(MAKE) basic_modem RADIO=sx128x $(MTHREAD_FLAG)
204
205basic_modem_lr1110:
206	$(MAKE) basic_modem RADIO=lr1110 $(MTHREAD_FLAG)
207
208basic_modem_lr1120:
209	$(MAKE) basic_modem RADIO=lr1120 $(MTHREAD_FLAG)
210
211basic_modem_lr1121:
212	$(MAKE) basic_modem RADIO=lr1121 $(MTHREAD_FLAG)
213
214basic_modem_sx1261:
215	$(MAKE) basic_modem RADIO=sx1261 $(MTHREAD_FLAG)
216
217basic_modem_sx1262:
218	$(MAKE) basic_modem RADIO=sx1262 $(MTHREAD_FLAG)
219
220basic_modem_sx1268:
221	$(MAKE) basic_modem RADIO=sx1268 $(MTHREAD_FLAG)
222
223basic_modem_sx1272:
224	$(MAKE) basic_modem RADIO=sx1272 $(MTHREAD_FLAG)
225
226basic_modem_sx1276:
227	$(MAKE) basic_modem RADIO=sx1276 $(MTHREAD_FLAG)
228