Skip to content

Commit b55ed4f

Browse files
committed
examples: lora: Use TockLibrary.mk
Signed-off-by: Alistair Francis <[email protected]>
1 parent 54b281d commit b55ed4f

File tree

3 files changed

+68
-0
lines changed

3 files changed

+68
-0
lines changed

examples/lora/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,21 @@ RadioLib.
2323
Note that the Makefiles will do this automatically when
2424
you run `make` in a subdirectory, but if you want to do
2525
it manually you can run the `build-RadioLib.sh` script.
26+
27+
### Building
28+
29+
To bulid any example just enter the directory and type
30+
31+
```shell
32+
make
33+
```
34+
35+
This will build RadioLib and then the example application for
36+
both ARM and RISC-V architectures.
37+
38+
If you wish to use the RadioLib build infrastructure to build
39+
RadioLib (instead of the libtock-c system) you can also use
40+
41+
```shell
42+
CMAKE=1 make
43+
```

examples/lora/sensor-receive/Makefile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ override CPPFLAGS += -isystem ../RadioLib/examples/NonArduino/Tock
1515
# Include the base of libtock-c to fix the libtock/ includes from RadioLib
1616
override CPPFLAGS += -I$(TOCK_USERLAND_BASE_DIR)/
1717

18+
ifeq ($(CMAKE),1)
19+
# Use the RadioLib cmake build infrastructure
1820
LIBS_cortex-m += ../RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a
1921
LIBS_cortex-m0 += ../RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a
2022
LIBS_cortex-m3 += ../RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a
@@ -42,3 +44,26 @@ include $(TOCK_USERLAND_BASE_DIR)/AppMakefile.mk
4244
mkdir -p build-riscv && cd build-riscv && \
4345
LIBTOCK_C_DIRECTORY="$(TOCK_USERLAND_BASE_DIR)/../../../" cmake -G "CodeBlocks - Unix Makefiles" -DRISCV_BUILD=1 .. && \
4446
$(MAKE) -j4 2> /dev/null || true
47+
else
48+
# Use the libtock-c Make system
49+
LIBS_cortex-m0 += $(TOCK_USERLAND_BASE_DIR)/examples/lora/RadioLib/build/cortex-m0/RadioLib.a
50+
LIBS_cortex-m3 += $(TOCK_USERLAND_BASE_DIR)/examples/lora/RadioLib/build/cortex-m3/RadioLib.a
51+
LIBS_cortex-m4 += $(TOCK_USERLAND_BASE_DIR)/examples/lora/RadioLib/build/cortex-m4/RadioLib.a
52+
LIBS_cortex-m7 += $(TOCK_USERLAND_BASE_DIR)/examples/lora/RadioLib/build/cortex-m7/RadioLib.a
53+
54+
LIBS_rv32imc += $(TOCK_USERLAND_BASE_DIR)/examples/lora/RadioLib/build/rv32imc/RadioLib.a
55+
LIBS_rv32imac += $(TOCK_USERLAND_BASE_DIR)/examples/lora/RadioLib/build/rv32imac/RadioLib.a
56+
57+
include $(TOCK_USERLAND_BASE_DIR)/AppMakefile.mk
58+
59+
LIBNAME := RadioLib
60+
61+
$(LIBNAME)_DIR := $(TOCK_USERLAND_BASE_DIR)/examples/lora/$(LIBNAME)
62+
63+
$(LIBNAME)_SRCS := \
64+
$(wildcard $($(LIBNAME)_DIR)/src/*.cpp) \
65+
$(wildcard $($(LIBNAME)_DIR)/src/*/*.cpp) \
66+
$(wildcard $($(LIBNAME)_DIR)/src/*/*/*.cpp)
67+
68+
include $(TOCK_USERLAND_BASE_DIR)/TockLibrary.mk
69+
endif

examples/lora/sensor-transmit/Makefile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ override CPPFLAGS += -isystem ../RadioLib/examples/NonArduino/Tock
1515
# Include the base of libtock-c to fix the libtock/ includes from RadioLib
1616
override CPPFLAGS += -I$(TOCK_USERLAND_BASE_DIR)/
1717

18+
ifeq ($(CMAKE),1)
19+
# Use the RadioLib cmake build infrastructure
1820
LIBS_cortex-m += ../RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a
1921
LIBS_cortex-m0 += ../RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a
2022
LIBS_cortex-m3 += ../RadioLib/examples/NonArduino/Tock/build-arm/RadioLib/libRadioLib.a
@@ -42,3 +44,26 @@ include $(TOCK_USERLAND_BASE_DIR)/AppMakefile.mk
4244
mkdir -p build-riscv && cd build-riscv && \
4345
LIBTOCK_C_DIRECTORY="$(TOCK_USERLAND_BASE_DIR)/../../../" cmake -G "CodeBlocks - Unix Makefiles" -DRISCV_BUILD=1 .. && \
4446
$(MAKE) -j4 2> /dev/null || true
47+
else
48+
# Use the libtock-c Make system
49+
LIBS_cortex-m0 += $(TOCK_USERLAND_BASE_DIR)/examples/lora/RadioLib/build/cortex-m0/RadioLib.a
50+
LIBS_cortex-m3 += $(TOCK_USERLAND_BASE_DIR)/examples/lora/RadioLib/build/cortex-m3/RadioLib.a
51+
LIBS_cortex-m4 += $(TOCK_USERLAND_BASE_DIR)/examples/lora/RadioLib/build/cortex-m4/RadioLib.a
52+
LIBS_cortex-m7 += $(TOCK_USERLAND_BASE_DIR)/examples/lora/RadioLib/build/cortex-m7/RadioLib.a
53+
54+
LIBS_rv32imc += $(TOCK_USERLAND_BASE_DIR)/examples/lora/RadioLib/build/rv32imc/RadioLib.a
55+
LIBS_rv32imac += $(TOCK_USERLAND_BASE_DIR)/examples/lora/RadioLib/build/rv32imac/RadioLib.a
56+
57+
include $(TOCK_USERLAND_BASE_DIR)/AppMakefile.mk
58+
59+
LIBNAME := RadioLib
60+
61+
$(LIBNAME)_DIR := $(TOCK_USERLAND_BASE_DIR)/examples/lora/$(LIBNAME)
62+
63+
$(LIBNAME)_SRCS := \
64+
$(wildcard $($(LIBNAME)_DIR)/src/*.cpp) \
65+
$(wildcard $($(LIBNAME)_DIR)/src/*/*.cpp) \
66+
$(wildcard $($(LIBNAME)_DIR)/src/*/*/*.cpp)
67+
68+
include $(TOCK_USERLAND_BASE_DIR)/TockLibrary.mk
69+
endif

0 commit comments

Comments
 (0)