-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
57 lines (42 loc) · 1.39 KB
/
Makefile
File metadata and controls
57 lines (42 loc) · 1.39 KB
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
# -----------------------------------------------------------
CXXFLAGS= -Wall -Wextra -Werror -pedantic -std=gnu++2a
PREFIX=/usr/local
LIBDIR=${PREFIX}/lib
INCLUDEDIR=${PREFIX}/include
# -----------------------------------------------------------
# jobs
all: install cxx_examples
install: includes library
# -----------------------------------------------------------
# include files
INCLUDES=$(wildcard include/*.h)
INCLUDES_DIST=$(addprefix ${INCLUDEDIR}/, $(notdir ${INCLUDES}))
includes: $(INCLUDES_DIST)
${INCLUDEDIR}/%: %
sudo cp $^ ${INCLUDEDIR}/
vpath %.h include
# -----------------------------------------------------------
# library files
SOURCE_NAME=ledcube
LIBRARY_NAME=lib${SOURCE_NAME}-c++.so
LIBRARY_SOURCE=src/${SOURCE_NAME}.cpp
OBJECT=$(LIBRARY_SOURCE:.cpp=.o)
LIBRARY=lib/${LIBRARY_NAME}
LIBRARY_DIST=${LIBDIR}/$(notdir ${LIBRARY})
library: ${LIBRARY_DIST}.0
${OBJECT}: ${LIBRARY_SOURCE} ${INCLUDES}
${CXX} ${CXXFLAGS} -c -fPIC -o $@ $< -lpng
${LIBRARY}.0: ${OBJECT}
mkdir -p lib
${CXX} ${CXXFLAGS} -g -shared -Wl,-soname,${LIBRARY_NAME} -o $@ $<
${LIBRARY_DIST}.0: ${LIBRARY}.0
sudo cp $< $@
sudo sh -c "cd ${LIBDIR} && ln -sf ${LIBRARY_NAME}.0 ${LIBRARY_NAME}"
sudo ldconfig
# -----------------------------------------------------------
# examples
cxx_examples:
cd examples && $(MAKE)
# -----------------------------------------------------------
clean:
rm -f *o src/*.o lib/*.so*