Tiago Barros | 27e7c38 | 2016-09-08 13:46:12 -0300 | [diff] [blame] | 1 | # |
| 2 | # Copyright (c) 2016, CESAR. |
| 3 | # All rights reserved. |
| 4 | # |
| 5 | # This software may be modified and distributed under the terms |
| 6 | # of the BSD license. See the LICENSE file for details. |
| 7 | # |
| 8 | # KNoTThing Arduino Library Makefile |
| 9 | # |
| 10 | |
| 11 | # TODO: change this variables according to operating system |
| 12 | MKDIR=mkdir |
| 13 | CP=cp |
| 14 | GIT=git |
| 15 | ZIP=zip |
Rodrigo Alves | 3725a9e | 2016-11-23 13:35:31 -0300 | [diff] [blame] | 16 | FIND=find |
Tiago Barros | 27e7c38 | 2016-09-08 13:46:12 -0300 | [diff] [blame] | 17 | |
| 18 | KNOT_THING_NAME = KNoTThing |
Tiago Barros | 27e7c38 | 2016-09-08 13:46:12 -0300 | [diff] [blame] | 19 | KNOT_THING_TARGET = $(KNOT_THING_NAME).zip |
Erick Simões | 67192a8 | 2016-10-24 13:29:54 -0300 | [diff] [blame] | 20 | KNOT_THING_FILES = ./src |
Tiago Barros | 27e7c38 | 2016-09-08 13:46:12 -0300 | [diff] [blame] | 21 | |
| 22 | KNOT_THING_DOWNLOAD_DIR = download |
Tiago Barros | 27e7c38 | 2016-09-08 13:46:12 -0300 | [diff] [blame] | 23 | |
Lucas Cavalcanti | 5efde27 | 2017-01-18 13:09:14 -0300 | [diff] [blame] | 24 | ifdef release |
| 25 | KNOT_THING_LIB_VERSION = $(release) |
| 26 | KNOT_THING_LIB_REPO = knot-thing-source |
| 27 | KNOT_THING_LIB_SITE = https://github.com/CESARBR/$(KNOT_THING_LIB_REPO).git |
| 28 | KNOT_THING_FILES = ./$(KNOT_THING_DOWNLOAD_DIR)/$(KNOT_THING_LIB_REPO)/src |
| 29 | endif |
| 30 | |
Tiago Barros | 27e7c38 | 2016-09-08 13:46:12 -0300 | [diff] [blame] | 31 | #Dependencies |
Erick Simões | 67192a8 | 2016-10-24 13:29:54 -0300 | [diff] [blame] | 32 | KNOT_PROTOCOL_LIB_VERSION = master |
Rodrigo Alves | 03acedc | 2017-01-02 15:17:52 -0300 | [diff] [blame] | 33 | ifdef release |
| 34 | KNOT_PROTOCOL_LIB_VERSION = $(release) |
| 35 | endif |
Tiago Barros | 27e7c38 | 2016-09-08 13:46:12 -0300 | [diff] [blame] | 36 | KNOT_PROTOCOL_LIB_REPO = knot-protocol-source |
Erick Simões | dc7e381 | 2016-10-14 13:19:11 -0300 | [diff] [blame] | 37 | KNOT_PROTOCOL_LIB_SITE = https://github.com/CESARBR/$(KNOT_PROTOCOL_LIB_REPO).git |
Tiago Barros | 27e7c38 | 2016-09-08 13:46:12 -0300 | [diff] [blame] | 38 | KNOT_PROTOCOL_LIB_DIR = ./$(KNOT_THING_DOWNLOAD_DIR)/$(KNOT_PROTOCOL_LIB_REPO)/src |
| 39 | |
Erick Simões | 67192a8 | 2016-10-24 13:29:54 -0300 | [diff] [blame] | 40 | KNOT_HAL_LIB_VERSION = master |
Rodrigo Alves | 03acedc | 2017-01-02 15:17:52 -0300 | [diff] [blame] | 41 | ifdef release |
| 42 | KNOT_HAL_LIB_VERSION = $(release) |
| 43 | endif |
Erick Simões | 67192a8 | 2016-10-24 13:29:54 -0300 | [diff] [blame] | 44 | KNOT_HAL_LIB_REPO = knot-hal-source |
| 45 | KNOT_HAL_LIB_SITE = https://github.com/CESARBR/$(KNOT_HAL_LIB_REPO).git |
Claudio Takahasi | 99c902a | 2017-05-03 15:51:47 -0300 | [diff] [blame] | 46 | KNOT_HAL_HDR_LIB_DIR = ./$(KNOT_THING_DOWNLOAD_DIR)/$(KNOT_HAL_LIB_REPO)/hal |
Erick Simões | 67192a8 | 2016-10-24 13:29:54 -0300 | [diff] [blame] | 47 | KNOT_HAL_SRC_LIB_DIR = ./$(KNOT_THING_DOWNLOAD_DIR)/$(KNOT_HAL_LIB_REPO)/src/hal |
Tiago Barros | 27e7c38 | 2016-09-08 13:46:12 -0300 | [diff] [blame] | 48 | |
Rodrigo Alves | 3725a9e | 2016-11-23 13:35:31 -0300 | [diff] [blame] | 49 | KNOT_HAL_SRC_DRIVERS_LIB_DIR = ./$(KNOT_THING_DOWNLOAD_DIR)/$(KNOT_HAL_LIB_REPO)/src/drivers |
| 50 | KNOT_HAL_SRC_NRF_LIB_DIR = ./$(KNOT_THING_DOWNLOAD_DIR)/$(KNOT_HAL_LIB_REPO)/src/nrf24l01 |
| 51 | KNOT_HAL_SRC_SPI_LIB_DIR = ./$(KNOT_THING_DOWNLOAD_DIR)/$(KNOT_HAL_LIB_REPO)/src/spi |
| 52 | |
Tiago Barros | 9c807b5 | 2017-07-11 10:38:08 -0300 | [diff] [blame] | 53 | .PHONY: clean clean-local |
Tiago Barros | 27e7c38 | 2016-09-08 13:46:12 -0300 | [diff] [blame] | 54 | |
| 55 | default: all |
| 56 | |
| 57 | all: $(KNOT_THING_TARGET) |
| 58 | |
Rodrigo Alves | 03acedc | 2017-01-02 15:17:52 -0300 | [diff] [blame] | 59 | |
Tiago Barros | 27e7c38 | 2016-09-08 13:46:12 -0300 | [diff] [blame] | 60 | $(KNOT_THING_DOWNLOAD_DIR): |
| 61 | $(MKDIR) -p ./$(KNOT_THING_DOWNLOAD_DIR) |
| 62 | |
Tiago Barros | 27e7c38 | 2016-09-08 13:46:12 -0300 | [diff] [blame] | 63 | $(KNOT_PROTOCOL_LIB_DIR): $(KNOT_THING_DOWNLOAD_DIR) |
Paulo Serra Filho | ea729bf | 2017-07-18 16:58:20 -0300 | [diff] [blame] | 64 | if [ ! -d "./$(KNOT_THING_DOWNLOAD_DIR)/$(KNOT_PROTOCOL_LIB_REPO)" ]; then \ |
| 65 | $(GIT) clone -b $(KNOT_PROTOCOL_LIB_VERSION) $(KNOT_PROTOCOL_LIB_SITE) ./$(KNOT_THING_DOWNLOAD_DIR)/$(KNOT_PROTOCOL_LIB_REPO); \ |
| 66 | fi |
| 67 | if [ ! -d "./$(KNOT_THING_DOWNLOAD_DIR)/$(KNOT_HAL_LIB_REPO)" ]; then \ |
| 68 | $(GIT) clone -b $(KNOT_HAL_LIB_VERSION) $(KNOT_HAL_LIB_SITE) ./$(KNOT_THING_DOWNLOAD_DIR)/$(KNOT_HAL_LIB_REPO); \ |
| 69 | fi |
Lucas Cavalcanti | 5efde27 | 2017-01-18 13:09:14 -0300 | [diff] [blame] | 70 | ifdef release |
| 71 | $(GIT) clone -b $(KNOT_THING_LIB_VERSION) $(KNOT_THING_LIB_SITE) ./$(KNOT_THING_DOWNLOAD_DIR)/$(KNOT_THING_LIB_REPO) |
| 72 | endif |
Tiago Barros | 27e7c38 | 2016-09-08 13:46:12 -0300 | [diff] [blame] | 73 | $(KNOT_THING_TARGET): $(KNOT_PROTOCOL_LIB_DIR) |
Erick Simões | 67192a8 | 2016-10-24 13:29:54 -0300 | [diff] [blame] | 74 | #Creating subdirectories |
Claudio Takahasi | 99c902a | 2017-05-03 15:51:47 -0300 | [diff] [blame] | 75 | $(MKDIR) -p ./$(KNOT_THING_NAME)/src/hal |
Erick Simões | 9ceee7e | 2017-01-05 09:49:56 -0300 | [diff] [blame] | 76 | $(MKDIR) -p ./$(KNOT_THING_NAME)/examples |
Erick Simões | 67192a8 | 2016-10-24 13:29:54 -0300 | [diff] [blame] | 77 | |
Gabriel Bandeira | c032804 | 2017-02-09 18:24:37 -0300 | [diff] [blame] | 78 | #Filling with configuration files for Arduino IDE |
Erick Simões | 67192a8 | 2016-10-24 13:29:54 -0300 | [diff] [blame] | 79 | # TODO: Create keywords.txt file to KNoT Thing |
| 80 | # TODO: Amend keywords of the HAL libs, protocol and thing |
| 81 | $(CP) -r $(KNOT_THING_FILES)/library.properties ./$(KNOT_THING_NAME) |
Paulo Serra Filho | d474040 | 2017-07-18 12:56:02 -0300 | [diff] [blame] | 82 | ifdef release |
| 83 | $$(sed -i '/version/ s/=.*/=$(KNOT_THING_LIB_VERSION)/g' ./$(KNOT_THING_NAME)/library.properties) |
| 84 | $$(sed -i '/version/ s/\([v\.]\)0\+\([[:digit:]]\+\)/\1\2/g' ./$(KNOT_THING_NAME)/library.properties) |
| 85 | $$(sed -i '/version/ s/KNOT-v//g' ./$(KNOT_THING_NAME)/library.properties |
| 86 | endif |
Erick Simões | 67192a8 | 2016-10-24 13:29:54 -0300 | [diff] [blame] | 87 | |
| 88 | #Filling root and thing directory |
| 89 | $(CP) -r $(KNOT_THING_FILES)/*.h ./$(KNOT_THING_NAME)/src |
| 90 | $(CP) -r $(KNOT_THING_FILES)/*.c ./$(KNOT_THING_NAME)/src |
| 91 | $(CP) -r $(KNOT_THING_FILES)/*.cpp ./$(KNOT_THING_NAME)/src |
| 92 | |
| 93 | #Filling protocol directory |
Marcela Oliveira | b725d8b | 2017-05-15 16:33:27 -0300 | [diff] [blame] | 94 | $(CP) -r $(KNOT_PROTOCOL_LIB_DIR)/*.h ./$(KNOT_THING_NAME)/src |
| 95 | $(CP) -r $(KNOT_PROTOCOL_LIB_DIR)/*.c ./$(KNOT_THING_NAME)/src |
Erick Simões | 67192a8 | 2016-10-24 13:29:54 -0300 | [diff] [blame] | 96 | |
Erick Simões | b277b1e | 2016-12-01 12:58:57 -0300 | [diff] [blame] | 97 | #Filling hal headers directory |
Paulo Serra Filho | c146c54 | 2017-06-17 12:37:35 -0300 | [diff] [blame] | 98 | $(FIND) ./$(KNOT_HAL_HDR_LIB_DIR) \( ! -name '*linux*' -and -name '*.h' \) -exec $(CP) -r {} ./$(KNOT_THING_NAME)/src/hal \; |
Rodrigo Alves | 3725a9e | 2016-11-23 13:35:31 -0300 | [diff] [blame] | 99 | |
| 100 | #include folder |
Rodrigo Alves | 3725a9e | 2016-11-23 13:35:31 -0300 | [diff] [blame] | 101 | $(FIND) ./$(KNOT_HAL_SRC_LIB_DIR)/log/ \( ! -name '*linux*' -and -name '*.cpp' \) -exec $(CP) {} ./$(KNOT_THING_NAME)/src \; |
| 102 | $(FIND) ./$(KNOT_HAL_SRC_LIB_DIR)/storage/ \( ! -name '*linux*' -and -name '*.cpp' \) -exec $(CP) {} ./$(KNOT_THING_NAME)/src \; |
| 103 | $(FIND) ./$(KNOT_HAL_SRC_LIB_DIR)/time/ \( ! -name '*linux*' -and -name '*.cpp' \) -exec $(CP) {} ./$(KNOT_THING_NAME)/src \; |
Paulo Serra Filho | 3a2e1ab | 2017-01-25 09:10:18 -0300 | [diff] [blame] | 104 | $(FIND) ./$(KNOT_HAL_SRC_LIB_DIR)/gpio/ \( ! -name '*linux*' -and -name '*.cpp' \) -exec $(CP) {} ./$(KNOT_THING_NAME)/src \; |
Rodrigo Alves | 3725a9e | 2016-11-23 13:35:31 -0300 | [diff] [blame] | 105 | |
| 106 | # Include comm headers and source files |
| 107 | $(FIND) ./$(KNOT_HAL_SRC_LIB_DIR)/comm/ \( \( -name '*.c' -or -name '*.h' \) -and ! -name '*serial*' \) -exec $(CP) {} ./$(KNOT_THING_NAME)/src \; |
| 108 | |
| 109 | # Include nrf24l01 headers and source files |
| 110 | $(FIND) ./$(KNOT_HAL_SRC_NRF_LIB_DIR)/ \( \( -name '*.c' -or -name '*.h' \) -and ! -name '*linux*' \) -exec $(CP) {} ./$(KNOT_THING_NAME)/src \; |
| 111 | |
| 112 | # Include drivers headers and source files |
| 113 | $(CP) -r ./$(KNOT_HAL_SRC_DRIVERS_LIB_DIR)/*.c ./$(KNOT_THING_NAME)/src |
| 114 | $(CP) -r ./$(KNOT_HAL_SRC_DRIVERS_LIB_DIR)/*.h ./$(KNOT_THING_NAME)/src |
| 115 | |
| 116 | # Include SPI headers and source files |
| 117 | $(FIND) ./$(KNOT_HAL_SRC_SPI_LIB_DIR)/ \( \( -name '*.c' -or -name '*.h' \) -and ! -name '*linux*' \) -exec $(CP) {} ./$(KNOT_THING_NAME)/src \; |
Erick Simões | 67192a8 | 2016-10-24 13:29:54 -0300 | [diff] [blame] | 118 | |
Erick Simões | ac960c7 | 2016-12-20 14:49:19 -0300 | [diff] [blame] | 119 | # Include examples files |
Paulo Serra Filho | c146c54 | 2017-06-17 12:37:35 -0300 | [diff] [blame] | 120 | $(FIND) ./examples/* \( ! -name '*.c' -prune \) -exec $(CP) -r {} ./$(KNOT_THING_NAME)/examples/ \; |
Erick Simões | ac960c7 | 2016-12-20 14:49:19 -0300 | [diff] [blame] | 121 | |
Erick Simões | 67192a8 | 2016-10-24 13:29:54 -0300 | [diff] [blame] | 122 | #Zip directory |
Tiago Barros | 27e7c38 | 2016-09-08 13:46:12 -0300 | [diff] [blame] | 123 | $(ZIP) -r $(KNOT_THING_TARGET) ./$(KNOT_THING_NAME) |
| 124 | |
| 125 | clean: |
| 126 | $(RM) $(KNOT_THING_TARGET) |
| 127 | $(RM) -rf ./$(KNOT_THING_DOWNLOAD_DIR) |
Erick Simões | b277b1e | 2016-12-01 12:58:57 -0300 | [diff] [blame] | 128 | $(RM) -rf ./$(KNOT_THING_NAME) |
Tiago Barros | 9c807b5 | 2017-07-11 10:38:08 -0300 | [diff] [blame] | 129 | |
| 130 | clean-local: |
| 131 | $(RM) $(KNOT_THING_TARGET) |
Tiago Barros | 9c807b5 | 2017-07-11 10:38:08 -0300 | [diff] [blame] | 132 | $(RM) -rf ./$(KNOT_THING_NAME) |