forked from chronopoulos/libsequoia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
51 lines (32 loc) · 858 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
CC = gcc
CFLAGS += -Wall -O2
# inputs
SRC_DIR = src
INC_DIR = include
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 examples clean install uninstall
##########################
default: library
library: $(SO)
##########################
$(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)