-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
91 lines (79 loc) · 2.47 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
# Gavin lyons 06-2021
# Makefile to install library for NOKIA_5110_RPI library.
# URL: https://github.com/gavinlyonsrepo/NOKIA_5110_RPI
# Library is installed to /usr/lib and include files are placed at /usr/include.
# Uninstall and clean options provided
# == Options ==
# 1. make = compile library
# 2. make install = install library to filesystem (may need sudo)
# 3. make clean = deletes .o files generated by step 1 from build directory
# 4. make uninstall = uninstalls library (may need sudo)
# =============
# Where you want it installed
PREFIX=/usr
# where to place the libray
LIBDIR=$(PREFIX)/lib
# library name
LIB=libNOKIA_5110_RPI
# shared library name
LIBNAME=$(LIB).so.1.0
MD=mkdir
SRC=src
OBJ=obj
SRCS = $(wildcard $(SRC)/*.cpp)
OBJS = $(patsubst $(SRC)%.cpp, $(OBJ)/%.o, $(SRCS))
CC=g++
CFLAGS= -march=native -mtune=native -mcpu=native -Iinclude/
LDFLAGS= -lbcm2835
# make all
# reinstall the library after each recompilation
all: clean pre-build NOKIA_5110_RPI
pre-build:
@echo
@echo "*****************"
@echo "[START!]"
@echo
$(MD) -vp $(OBJ)
# Make the library
NOKIA_5110_RPI: $(OBJS)
$(CC) -shared -Wl,-soname,$(LIB).so.1 $(CFLAGS) $(LDFLAGS) -o ${LIBNAME} $^
# Library parts
$(OBJ)/%.o: $(SRC)/%.cpp
$(CC) -Wall -Wextra -Wshadow -fPIC -c $(CFLAGS) $< -o $@
# Install the library to LIBPATH
install:
@echo
@echo "*****************"
@echo "[INSTALL LIBRARY]"
@if ( test ! -d $(PREFIX)/lib ) ; then mkdir -vp $(PREFIX)/lib ; fi
@install -vm 0755 ${LIBNAME} ${LIBDIR}
@ln -svf ${LIBDIR}/${LIBNAME} ${LIBDIR}/${LIB}.so.1
@ln -svf ${LIBDIR}/${LIBNAME} ${LIBDIR}/${LIB}.so
@ldconfig
@rm -rvf ${LIB}.*
@echo "*****************"
@echo
@echo "[INSTALL HEADERS]"
@if ( test ! -d $(PREFIX)/include ) ; then mkdir -p $(PREFIX)/include ; fi
@cp -vf include/NOKIA_5110_RPI.hpp $(PREFIX)/include
@cp -vf include/NOKIA_5110_graphics.hpp $(PREFIX)/include
@cp -vf include/NOKIA_5110_Print.hpp $(PREFIX)/include
@cp -vf include/NOKIA_5110_RPI_Font.hpp $(PREFIX)/include
@echo "[DONE!]"
# Uninstall the library
uninstall:
@echo "******************"
@echo "[UNINSTALL LIBRARY]"
@rm -vf ${LIBDIR}/${LIB}.*
@echo "[UNINSTALL HEADERS]"
@rm -rvf $(PREFIX)/include/NOKIA_5110_RPI.hpp
@rm -rvf $(PREFIX)/include/NOKIA_5110_graphics.hpp
@rm -rvf $(PREFIX)/include/NOKIA_5110_Print.hpp
@rm -rvf $(PREFIX)/include/NOKIA_5110_RPI_Font.hpp
@echo "[DONE!]"
# clear build files
clean:
@echo "******************"
@echo "[CLEAN OBJECT FILES]"
rm -rvf $(OBJ)/*.o ${LIB}.*
@echo "[DONE!]"