forked from TheThingsArchive/packet_forwarder
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
81 lines (59 loc) · 1.99 KB
/
Makefile
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
### Application-specific constants
APP_NAME := beacon_pkt_fwd
### Environment constants
LGW_PATH ?= ../../lora_gateway/libloragw
ARCH ?=
CROSS_COMPILE ?=
### External constant definitions
# must get library build option to know if mpsse must be linked or not
include $(LGW_PATH)/library.cfg
RELEASE_VERSION := `cat ../VERSION`
### Constant symbols
CC := $(CROSS_COMPILE)gcc
AR := $(CROSS_COMPILE)ar
CFLAGS := -O2 -Wall -Wextra -std=c99 -Iinc -I.
VFLAG := -D VERSION_STRING="\"$(RELEASE_VERSION)\""
### Constants for Lora concentrator HAL library
# List the library sub-modules that are used by the application
LGW_INC =
ifneq ($(wildcard $(LGW_PATH)/inc/config.h),)
# only for HAL version 1.3 and beyond
LGW_INC += $(LGW_PATH)/inc/config.h
endif
LGW_INC += $(LGW_PATH)/inc/loragw_hal.h
LGW_INC += $(LGW_PATH)/inc/loragw_gps.h
### Linking options
ifeq ($(CFG_SPI),native)
LIBS := -lloragw -lrt -lpthread
else ifeq ($(CFG_SPI),ftdi)
LIBS := -lloragw -lrt -lpthread -lmpsse
else ifeq ($(CFG_SPI),mac)
$(error [error] Option mac not supported for SPI here)
else
# keep compatibility with SX1301 HAL version 1.2.x and bellow
ifeq ($(LGW_PHY),native)
LIBS := -lloragw -lrt -lpthread
else ifeq ($(LGW_PHY),ftdi)
LIBS := -lloragw -lrt -lpthread -lmpsse
else ifeq ($(LGW_PHY),mac)
$(error [error] Option mac not supported for SPI here)
else
$(error [error] Can't find configuration for SPI phy)
endif
endif
### General build targets
all: $(APP_NAME)
clean:
rm -f obj/*.o
rm -f $(APP_NAME)
### Sub-modules compilation
obj/base64.o: src/base64.c inc/base64.h
$(CC) -c $(CFLAGS) $< -o $@
obj/parson.o: src/parson.c inc/parson.h
$(CC) -c $(CFLAGS) $< -o $@
### Main program compilation and assembly
obj/$(APP_NAME).o: src/$(APP_NAME).c $(LGW_INC) inc/parson.h inc/base64.h
$(CC) -c $(CFLAGS) $(VFLAG) -I$(LGW_PATH)/inc $< -o $@
$(APP_NAME): obj/$(APP_NAME).o $(LGW_PATH)/libloragw.a obj/parson.o obj/base64.o
$(CC) -L$(LGW_PATH) $< obj/parson.o obj/base64.o -o $@ $(LIBS)
### EOF