-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
58 lines (37 loc) · 940 Bytes
/
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
CC = gcc
CFLAGS += -Wall -O2 -g
# inputs
SRC_DIR = src
INC_DIR = include
TEST_DIR = test
SOURCES := $(wildcard $(SRC_DIR)/*.c)
# outputs
LIB_DIR = lib
SO = $(LIB_DIR)/libsequoia.so
OBJS := $(patsubst $(SRC_DIR)/%.c,$(LIB_DIR)/%.o,$(SOURCES))
INSTALL_DIR_LIB = /usr/local/lib
INSTALL_DIR_INC = /usr/local/include
##########################
.PHONY: all library clean install uninstall test
##########################
default: library
library: $(SO)
test:
cd $(TEST_DIR) && make
pwd
##########################
$(SO): $(LIB_DIR) $(OBJS)
$(CC) $(CFLAGS) -shared -o$@ $(OBJS)
$(LIB_DIR)/%.o: $(SRC_DIR)/%.c
$(CC) $(CFLAGS) -c -fPIC -I$(INC_DIR) -o$@ $?
$(LIB_DIR):
mkdir -p $(LIB_DIR)
##########################
install: $(SO)
sudo cp $< $(INSTALL_DIR_LIB)
sudo cp -r $(INC_DIR)/* $(INSTALL_DIR_INC)
uninstall:
sudo rm $(INSTALL_DIR_LIB)/$(SO) # TODO fix this
clean:
rm -rf $(LIB_DIR)
cd $(TEST_DIR) && make clean