-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
40 lines (29 loc) · 930 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
BIN = build/release/libstest.so
INCDIRS = src include
SRCDIR = src
OBJDIR = build/obj
HEADER_INSTALL_DIR = /usr/local/include
LIB_INSTALL_DIR = /usr/local/lib
CC = gcc
INCLUDES := $(foreach dir,$(INCDIRS),-I$(dir))
DEPFLAGS = -MD -MP
OPT_BUILD = -Os
CFLAGS := -Wall -Werror -Wextra -std=c99 $(OPT_BUILD) $(INCLUDES) $(DEPFLAGS)
SRCFILES := $(wildcard $(SRCDIR)/*.c)
OBJFILES := $(patsubst $(SRCDIR)/%.c,$(OBJDIR)/%.o,$(SRCFILES))
DEPFILES := $(patsubst %.o,%.d,$(OBJFILES))
all: $(BIN)
$(BIN): $(OBJFILES)
@$(CC) -shared -o $@ $^
$(OBJDIR)/%.o: $(SRCDIR)/%.c
@$(CC) $(CFLAGS) -c -fPIC $< -o $@
clean:
@rm -rf $(OBJFILES) $(DEPFILES) $(BIN)
install: $(BIN)
@sudo cp -i include/stest.h $(HEADER_INSTALL_DIR)
@sudo cp -i build/release/libstest.so $(LIB_INSTALL_DIR)
uninstall:
@sudo rm $(HEADER_INSTALL_DIR)/stest.h
@sudo rm $(LIB_INSTALL_DIR)/libstest.so
-include $(DEPFILES)
.PHONY: all clean install uninstall