forked from CESARBR/knot-thing-source
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
123 lines (97 loc) · 4.58 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
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
#
# Copyright (c) 2016, CESAR.
# All rights reserved.
#
# This software may be modified and distributed under the terms
# of the BSD license. See the LICENSE file for details.
#
# KNoTThing Arduino Library Makefile
#
# TODO: change this variables according to operating system
MKDIR=mkdir
CP=cp
GIT=git
ZIP=zip
FIND=find
KNOT_THING_NAME = KNoTThing
KNOT_THING_TARGET = $(KNOT_THING_NAME).zip
KNOT_THING_FILES = ./src
KNOT_THING_DOWNLOAD_DIR = download
KNOT_THING_BUILD_DIR = build
ifdef release
KNOT_THING_LIB_VERSION = $(release)
KNOT_THING_LIB_REPO = knot-thing-source
KNOT_THING_LIB_SITE = https://github.com/CESARBR/$(KNOT_THING_LIB_REPO).git
KNOT_THING_FILES = ./$(KNOT_THING_DOWNLOAD_DIR)/$(KNOT_THING_LIB_REPO)/src
endif
#Dependencies
KNOT_PROTOCOL_LIB_VERSION = master
ifdef release
KNOT_PROTOCOL_LIB_VERSION = $(release)
endif
KNOT_PROTOCOL_LIB_REPO = knot-protocol-source
KNOT_PROTOCOL_LIB_SITE = https://github.com/CESARBR/$(KNOT_PROTOCOL_LIB_REPO).git
KNOT_PROTOCOL_LIB_DIR = ./$(KNOT_THING_DOWNLOAD_DIR)/$(KNOT_PROTOCOL_LIB_REPO)/src
KNOT_HAL_LIB_VERSION = master
ifdef release
KNOT_HAL_LIB_VERSION = $(release)
endif
KNOT_HAL_LIB_REPO = knot-hal-source
KNOT_HAL_LIB_SITE = https://github.com/CESARBR/$(KNOT_HAL_LIB_REPO).git
KNOT_HAL_HDR_LIB_DIR = ./$(KNOT_THING_DOWNLOAD_DIR)/$(KNOT_HAL_LIB_REPO)/hal
KNOT_HAL_SRC_LIB_DIR = ./$(KNOT_THING_DOWNLOAD_DIR)/$(KNOT_HAL_LIB_REPO)/src/hal
KNOT_HAL_SRC_DRIVERS_LIB_DIR = ./$(KNOT_THING_DOWNLOAD_DIR)/$(KNOT_HAL_LIB_REPO)/src/drivers
KNOT_HAL_SRC_NRF_LIB_DIR = ./$(KNOT_THING_DOWNLOAD_DIR)/$(KNOT_HAL_LIB_REPO)/src/nrf24l01
KNOT_HAL_SRC_SPI_LIB_DIR = ./$(KNOT_THING_DOWNLOAD_DIR)/$(KNOT_HAL_LIB_REPO)/src/spi
.PHONY: clean
default: all
all: $(KNOT_THING_TARGET)
$(KNOT_THING_DOWNLOAD_DIR):
$(MKDIR) -p ./$(KNOT_THING_DOWNLOAD_DIR)
$(KNOT_THING_BUILD_DIR):
$(MKDIR) -p ./$(KNOT_THING_BUILD_DIR)
$(KNOT_PROTOCOL_LIB_DIR): $(KNOT_THING_DOWNLOAD_DIR)
$(GIT) clone -b $(KNOT_PROTOCOL_LIB_VERSION) $(KNOT_PROTOCOL_LIB_SITE) ./$(KNOT_THING_DOWNLOAD_DIR)/$(KNOT_PROTOCOL_LIB_REPO)
$(GIT) clone -b $(KNOT_HAL_LIB_VERSION) $(KNOT_HAL_LIB_SITE) ./$(KNOT_THING_DOWNLOAD_DIR)/$(KNOT_HAL_LIB_REPO)
ifdef release
$(GIT) clone -b $(KNOT_THING_LIB_VERSION) $(KNOT_THING_LIB_SITE) ./$(KNOT_THING_DOWNLOAD_DIR)/$(KNOT_THING_LIB_REPO)
endif
$(KNOT_THING_TARGET): $(KNOT_PROTOCOL_LIB_DIR)
#Creating subdirectories
$(MKDIR) -p ./$(KNOT_THING_NAME)/src/hal
$(MKDIR) -p ./$(KNOT_THING_NAME)/examples
#Filling with configuration files for Arduino IDE
# TODO: Create keywords.txt file to KNoT Thing
# TODO: Amend keywords of the HAL libs, protocol and thing
$(CP) -r $(KNOT_THING_FILES)/library.properties ./$(KNOT_THING_NAME)
#Filling root and thing directory
$(CP) -r $(KNOT_THING_FILES)/*.h ./$(KNOT_THING_NAME)/src
$(CP) -r $(KNOT_THING_FILES)/*.c ./$(KNOT_THING_NAME)/src
$(CP) -r $(KNOT_THING_FILES)/*.cpp ./$(KNOT_THING_NAME)/src
#Filling protocol directory
$(CP) -r $(KNOT_PROTOCOL_LIB_DIR)/*[^*.am] ./$(KNOT_THING_NAME)/src
#Filling hal headers directory
$(CP) -r $(KNOT_HAL_HDR_LIB_DIR)/*.h ./$(KNOT_THING_NAME)/src/hal
#include folder
$(FIND) ./$(KNOT_HAL_SRC_LIB_DIR)/log/ \( ! -name '*linux*' -and -name '*.cpp' \) -exec $(CP) {} ./$(KNOT_THING_NAME)/src \;
$(FIND) ./$(KNOT_HAL_SRC_LIB_DIR)/storage/ \( ! -name '*linux*' -and -name '*.cpp' \) -exec $(CP) {} ./$(KNOT_THING_NAME)/src \;
$(FIND) ./$(KNOT_HAL_SRC_LIB_DIR)/time/ \( ! -name '*linux*' -and -name '*.cpp' \) -exec $(CP) {} ./$(KNOT_THING_NAME)/src \;
$(FIND) ./$(KNOT_HAL_SRC_LIB_DIR)/gpio/ \( ! -name '*linux*' -and -name '*.cpp' \) -exec $(CP) {} ./$(KNOT_THING_NAME)/src \;
# Include comm headers and source files
$(FIND) ./$(KNOT_HAL_SRC_LIB_DIR)/comm/ \( \( -name '*.c' -or -name '*.h' \) -and ! -name '*serial*' \) -exec $(CP) {} ./$(KNOT_THING_NAME)/src \;
# Include nrf24l01 headers and source files
$(FIND) ./$(KNOT_HAL_SRC_NRF_LIB_DIR)/ \( \( -name '*.c' -or -name '*.h' \) -and ! -name '*linux*' \) -exec $(CP) {} ./$(KNOT_THING_NAME)/src \;
# Include drivers headers and source files
$(CP) -r ./$(KNOT_HAL_SRC_DRIVERS_LIB_DIR)/*.c ./$(KNOT_THING_NAME)/src
$(CP) -r ./$(KNOT_HAL_SRC_DRIVERS_LIB_DIR)/*.h ./$(KNOT_THING_NAME)/src
# Include SPI headers and source files
$(FIND) ./$(KNOT_HAL_SRC_SPI_LIB_DIR)/ \( \( -name '*.c' -or -name '*.h' \) -and ! -name '*linux*' \) -exec $(CP) {} ./$(KNOT_THING_NAME)/src \;
# Include examples files
$(CP) -r ./examples/* ./$(KNOT_THING_NAME)/examples/
#Zip directory
$(ZIP) -r $(KNOT_THING_TARGET) ./$(KNOT_THING_NAME)
clean:
$(RM) $(KNOT_THING_TARGET)
$(RM) -rf ./$(KNOT_THING_DOWNLOAD_DIR)
$(RM) -rf ./$(KNOT_THING_BUILD_DIR)
$(RM) -rf ./$(KNOT_THING_NAME)