-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathMakefile
58 lines (46 loc) · 1.22 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
# Installation directories following GNU conventions
prefix ?= /usr/local
exec_prefix = $(prefix)
bindir = $(exec_prefix)/bin
sbindir = $(exec_prefix)/sbin
datarootdir = $(prefix)/share
datadir = $(datarootdir)
includedir = $(prefix)/include
mandir = $(datarootdir)/man
libdir = $(prefix)/lib
BIN=bin
OBJ=obj
SRC=src
LIB=lib
CC ?= gcc
CFLAGS ?= -Wextra -Wall -iquote$(SRC) -fpic
HEADERS = nms.h
LIBRARIES = libnms.so
.PHONY: all install uninstall clean
all: $(LIBRARIES)
libnms.so: $(OBJ)/libnms.o | $(LIB)
$(CC) -shared -o $(LIB)/$@ $^
$(OBJ)/%.o: $(SRC)/%.c | $(OBJ)
$(CC) $(CFLAGS) -o $@ -c $<
$(LIB):
mkdir -p $(LIB)
$(OBJ):
mkdir -p $(OBJ)
clean:
rm -rf $(LIB)
rm -rf $(OBJ)
install:
install -d $(DESTDIR)$(libdir)
install -d $(DESTDIR)$(includedir)
cd $(LIB) && install $(LIBRARIES) $(DESTDIR)$(libdir)
cd $(SRC) && install $(HEADERS) $(DESTDIR)$(includedir)
if [ -d /etc/ld.so.conf.d ]; then \
echo "$(DESTDIR)$(libdir)" > /etc/ld.so.conf.d/libnms.conf ; \
fi
ldconfig
uninstall:
for library in $(LIBRARIES); do rm $(DESTDIR)$(libdir)/$$library; done
for header in $(HEADERS); do rm $(DESTDIR)$(includedir)/$$header; done
if [ -a /etc/ld.so.conf.d/libnms.conf ] ; then \
rm /etc/ld.so.conf.d/libnms.conf ; \
fi