-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathMakefile
77 lines (64 loc) · 2.07 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
#############################################################################
#
# Makefile for librf24-bcm on Raspberry Pi
#
# License: GPL (General Public License)
# Author: Charles-Henri Hallard
# Date: 2013/03/13
#
# Description:
# ------------
# use make all and mak install to install the library
# You can change the install directory by editing the LIBDIR line
#
PREFIX=/usr/local
# Library parameters
# where to put the lib
LIBDIR=$(PREFIX)/lib
# lib name
LIB_RFN=librf24network
# shared library name
LIBNAME_RFN=$(LIB_RFN).so.1.0
LIB_RF24=librf24-bcm
# shared library name
LIBNAME_RF24=$(LIB_RF24).so.1.0
# The recommended compiler flags for the Raspberry Pi
CCFLAGS=-Ofast -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s
# make all
# reinstall the library after each recompilation
all: librf24-bcm install-rf24 librf24network install-rf24n
# Make the library
librf24network: RF24Network.o
g++ -shared -Wl,-soname,[email protected] ${CCFLAGS} -o ${LIBNAME_RFN} $^ -lrf24-bcm
librf24-bcm: RF24.o bcm2835.o
g++ -shared -Wl,-soname,[email protected] ${CCFLAGS} -o ${LIBNAME_RF24} $^
rx-example: rx-example.cpp
g++ ${CCFLAGS} -Wall -lrf24-bcm -lrf24network $^ -o $@
# Library parts
RF24Network.o: RF24Network.cpp
g++ -Wall -fPIC ${CCFLAGS} -c $^
RF24.o: RF24.cpp
g++ -Wall -fPIC ${CCFLAGS} -c $^
bcm2835.o: bcm2835.c
gcc -Wall -fPIC ${CCFLAGS} -c $^
# clear build files
clean:
rm -rf *.o ${LIB_RF24}.* ${LIB_RFN}.*
# Install the library to LIBPATH
.PHONY: install-rf24n install-rf24
install-rf24n:
@echo "[Install]"
@if ( test ! -d $(PREFIX)/lib ) ; then mkdir -p $(PREFIX)/lib ; fi
@install -m 0755 ${LIBNAME_RFN} ${LIBDIR}
@ln -sf ${LIBDIR}/${LIBNAME_RFN} ${LIBDIR}/${LIB_RFN}.so.1
@ln -sf ${LIBDIR}/${LIBNAME_RFN} ${LIBDIR}/${LIB_RFN}.so
@ldconfig
install-rf24:
@echo "[Install]"
@if ( test ! -d $(PREFIX)/lib ) ; then mkdir -p $(PREFIX)/lib ; fi
@install -m 0755 ${LIBNAME_RF24} ${LIBDIR}
@ln -sf ${LIBDIR}/${LIBNAME_RF24} ${LIBDIR}/${LIB_RF24}.so.1
@ln -sf ${LIBDIR}/${LIBNAME_RF24} ${LIBDIR}/${LIB_RF24}.so
@ldconfig
install: install-r24 install-rf24n
@echo "[Install]"