Optimized High Speed NRF24L01+ Driver Class Documenation  V1.0
TMRh20 2014 - Optimized Fork of NRF24L01+ Driver
Makefile
Go to the documentation of this file.
1 #############################################################################
2 #
3 # Makefile for librf24
4 #
5 # License: GPL (General Public License)
6 # Author: Charles-Henri Hallard
7 # Date: 2013/03/13
8 #
9 # Description:
10 # ------------
11 # use make all and make install to install the library
12 #
13 
14 CONFIG_FILE=Makefile.inc
15 REMOTE_ERROR="[ERROR] Remote machine not configured. Run configure with respective arguments."
16 
17 include $(CONFIG_FILE)
18 
19 # Objects to compile
20 OBJECTS=RF24.o
21 ifeq ($(DRIVER), MRAA)
22 OBJECTS+=spi.o gpio.o compatibility.o
23 else ifeq ($(DRIVER), RPi)
24 OBJECTS+=spi.o bcm2835.o interrupt.o
25 else ifeq ($(DRIVER), SPIDEV)
26 OBJECTS+=spi.o gpio.o compatibility.o interrupt.o
27 endif
28 
29 # make all
30 # reinstall the library after each recompilation
31 all: $(LIBNAME)
32 
33 # Make the library
34 $(LIBNAME): $(OBJECTS)
35  @echo "[Linking]"
36  $(CC) $(SHARED_LINKER_FLAGS) $(CFLAGS) -o $(LIBNAME) $^
37 
38 # Library parts
39 RF24.o: RF24.cpp
40  $(CXX) -fPIC $(CFLAGS) -c $^
41 
42 bcm2835.o: $(DRIVER_DIR)/bcm2835.c
43  $(CC) -fPIC $(CFLAGS) -c $^
44 
45 spi.o: $(DRIVER_DIR)/spi.cpp
46  $(CXX) -fPIC $(CFLAGS) -c $^
47 
48 compatibility.o: $(DRIVER_DIR)/compatibility.c
49  $(CC) -fPIC $(CFLAGS) -c $(DRIVER_DIR)/compatibility.c
50 
51 gpio.o: $(DRIVER_DIR)/gpio.cpp
52  $(CXX) -fPIC $(CFLAGS) -c $(DRIVER_DIR)/gpio.cpp
53 
54 interrupt.o: $(DRIVER_DIR)/interrupt.c
55  $(CXX) -fPIC $(CFLAGS) -c $(DRIVER_DIR)/interrupt.c
56 
57 # clear configuration files
58 cleanconfig:
59  @echo "[Cleaning configuration]"
60  rm -rf $(CONFIG_FILE) utility/includes.h
61 
62 # clear build files
63 clean:
64  @echo "[Cleaning]"
65  rm -rf *.o $(LIBNAME)
66 
67 $(CONFIG_FILE):
68  @echo "[Running configure]"
69  @./configure --no-clean
70 
71 install: all install-libs install-headers
72 upload: all upload-libs upload-headers
73 
74 # Install the library to LIBPATH
75 install-libs:
76  @echo "[Installing Libs to $(LIB_DIR)]"
77  @if ( test ! -d $(LIB_DIR) ); then mkdir -p $(LIB_DIR); fi
78  @install -m 0755 $(LIBNAME) $(LIB_DIR)
79  @orig=$(LIBNAME) && \
80  for sl in $(LIBSYMLINKS); do \
81  ln -sf $(LIB_DIR)/$${orig} $(LIB_DIR)/$${sl}; \
82  orig=$${sl}; \
83  done && \
84  if [ "$(LIBDEPRECATE)" ]; then ln -sf $(LIB_DIR)/$${orig} $(LIB_DIR)/$(LIBDEPRECATE); fi
85 ifneq ($(LDCONFIG),)
86  @$(LDCONFIG)
87 endif
88 
89 upload-libs:
90  @echo "[Uploading Libs to $(REMOTE):$(REMOTE_LIB_DIR)]"
91 ifeq ($(REMOTE),)
92  @echo "$(REMOTE_ERROR)"
93  @exit 1
94 endif
95  @ssh -q -t -p $(REMOTE_PORT) $(REMOTE) "mkdir -p $(REMOTE_LIB_DIR)"
96  @scp -q -P $(REMOTE_PORT) $(LIBNAME) $(REMOTE):/tmp
97  @ssh -q -t -p $(REMOTE_PORT) $(REMOTE) "sudo install -m 0755 /tmp/$(LIBNAME) $(REMOTE_LIB_DIR) &&" \
98  " orig=$(LIBNAME) && for sl in $(LIBSYMLINKS); do sudo ln -sf $(REMOTE_LIB_DIR)/\$${orig} $(REMOTE_LIB_DIR)/\$${sl}; orig=\$${sl}; done &&" \
99  " if [ "$(LIBDEPRECATE)" ]; then sudo ln -sf $(REMOTE_LIB_DIR)/\$${orig} $(REMOTE_LIB_DIR)/$(LIBDEPRECATE); fi &&" \
100  " rm /tmp/$(LIBNAME)"
101 ifneq ($(REMOTE_LDCONFIG),)
102  @ssh -q -t -p $(REMOTE_PORT) $(REMOTE) "sudo $(REMOTE_LDCONFIG)"
103 endif
104 
105 install-headers:
106  @echo "[Installing Headers to $(HEADER_DIR)]"
107  @mkdir -p $(HEADER_DIR)/$(DRIVER_DIR)
108  @install -m 0644 *.h $(HEADER_DIR)
109  @install -m 0644 $(DRIVER_DIR)/*.h $(HEADER_DIR)/$(DRIVER_DIR)
110  @install -m 0644 $(ARCH_DIR)/*.h $(HEADER_DIR)/$(ARCH_DIR)
111 
112 upload-headers:
113  @echo "[Uploading Headers to $(REMOTE):$(REMOTE_HEADER_DIR)]"
114 ifeq ($(REMOTE),)
115  @echo "$(REMOTE_ERROR)"
116  @exit 1
117 endif
118  @ssh -q -t -p $(REMOTE_PORT) $(REMOTE) "sudo mkdir -p $(REMOTE_HEADER_DIR)/$(DRIVER_DIR)"
119  @ssh -q -t -p $(REMOTE_PORT) $(REMOTE) "mkdir -p /tmp/RF24 && rm -rf /tmp/RF24/*"
120  @rsync -a --include="*.h" --include="*/" --exclude="*" -e "ssh -p $(REMOTE_PORT)" . $(REMOTE):/tmp/RF24
121  @ssh -q -t -p $(REMOTE_PORT) $(REMOTE) "sudo install -m 0644 /tmp/RF24/*.h $(REMOTE_HEADER_DIR)"
122  @ssh -q -t -p $(REMOTE_PORT) $(REMOTE) "sudo install -m 0644 /tmp/RF24/$(DRIVER_DIR)/*.h $(REMOTE_HEADER_DIR)/$(DRIVER_DIR)"
123  @ssh -q -t -p $(REMOTE_PORT) $(REMOTE) "sudo install -m 0644 /tmp/RF24/$(ARCH_DIR)/*.h $(REMOTE_HEADER_DIR)/$(ARCH_DIR)"
124  @ssh -q -t -p $(REMOTE_PORT) $(REMOTE) "rm -rf /tmp/RF24"