-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
59 lines (46 loc) · 1.23 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
CC = gcc
CFLAGS = -fPIC -std=c99 -Wall -Werror
SRC = $(wildcard *.c)
HDR = $(wildcard *.h)
OBJS = ${SRC:.c=.o}
LIB = libxpb
VERSION_MAJ = 0
VERSION_MIN = 2
SONAME = ${LIB}.so
SONAME_MAJ = ${SONAME}.${VERSION_MAJ}
SONAME_FULL = ${SONAME_MAJ}.${VERSION_MIN}
LIBFLAGS = -shared -Wl,-soname,${SONAME_MAJ} -lX11
INSTALL_PATH = /usr/local
INSTALL_PATH_HDR = ${INSTALL_PATH}/include
INSTALL_PATH_LIB = ${INSTALL_PATH}/lib
.PHONY: all
all: ${LIB}
${LIB}: ${OBJS}
${CC} ${LIBFLAGS} -o ${SONAME_FULL} ${OBJS}
.PHONY: debug
debug: CFLAGS += -DDEBUG -g
debug: ${LIB}
.PHONY: test
test: all
$(MAKE) -C test
.PHONY: install
install: all install_lib install_hdr
.PHONY: install_lib
install_lib:
@echo Installing libxpb to ${INSTALL_PATH_LIB}
@mkdir -p ${INSTALL_PATH_LIB}
@cp -f ${SONAME_FULL} ${INSTALL_PATH_LIB}
@chmod 755 ${INSTALL_PATH_LIB}/${SONAME_FULL}
@ln -sf ${SONAME_FULL} ${INSTALL_PATH_LIB}/${SONAME_MAJ}
@ln -sf ${SONAME_FULL} ${INSTALL_PATH_LIB}/${SONAME}
.PHONY: install_hdr
install_hdr:
@echo Installing headers to ${INSTALL_PATH_HDR}
@mkdir -p ${INSTALL_PATH_HDR}
@for file in ${HDR}; do \
cp -f $$file ${INSTALL_PATH_HDR}; \
chmod 644 ${INSTALL_PATH_HDR}/$$file; \
done
.PHONY: clean
clean:
@rm -f ${SONAME_FULL} ${OBJS}