-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
87 lines (73 loc) · 2.08 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
# Gavin lyons 06-2021
# Makefile to install library for ST7735_TFT_RPI.
# URL: https://github.com/gavinlyonsrepo/ST7735_TFT_RPI
# Library is installed to /usr/lib and include files are placed at /usr/include.
# == 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 library
LIBDIR=$(PREFIX)/lib
# library name
LIB=libST7735_TFT_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: clean pre-build ST7735_TFT_RPI
pre-build:
@echo
@echo "*****************"
@echo "[START!]"
@echo
@echo "[MAKE LIBRARY]"
$(MD) -vp $(OBJ)
# Make the library
ST7735_TFT_RPI: $(OBJS)
$(CC) -shared -Wl,-soname,$(LIB).so.1 $(CFLAGS) $(LDFLAGS) -o ${LIBNAME} $^
# Library parts
$(OBJ)/%.o: $(SRC)/%.cpp
$(CC) -Wall -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/ST7735_TFT* $(PREFIX)/include
@echo "[DONE!]"
# Uninstall the library
uninstall:
@echo "******************"
@echo "[UNINSTALL LIBRARY]"
@rm -vf ${LIBDIR}/${LIB}.*
@echo "[UNINSTALL HEADERS]"
@rm -rvf $(PREFIX)/include/ST7735_TFT*
@echo "[DONE!]"
# clear build files
clean:
@echo "******************"
@echo "[CLEAN OBJECT FILES]"
rm -rvf $(OBJ)/*.o ${LIB}.*
@echo "[DONE!]"
@echo "******************"