-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmakefile
79 lines (60 loc) · 1.57 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
BIN_DIR := bin
OUT_TARGET := $(BIN_DIR)/regxstr
LIB_TARGET := $(BIN_DIR)/libregxstr.a
SO_TARGET := $(BIN_DIR)/libregxstr.so
INC_TARGET := regxstring.h
INSTALL_OUT_DIR := /usr/local/bin
INSTALL_LIB_DIR := /usr/lib
INSTALL_INC_DIR := /usr/include
DEBUG := -g -O0 -DTEST
#RELEASE := -O2 -DNDEBUG
CXXFLAGS := -Wall -fPIC $(DEBUG) $(RELEASE)
ARFLAGS := cr
LIB := /usr/lib/libpcre.a
CP := cp -f
SRC := $(wildcard *.cpp)
OBJ := $(SRC:.cpp=.o)
DEP := $(OBJ:.o=.d)
HEADER := $(wildcard *.h)
CXXFLAGS+=-MD
all : out lib so
@$(CP) $(INC_TARGET) $(BIN_DIR)
install :
$(CP) $(OUT_TARGET) $(INSTALL_OUT_DIR)
$(CP) $(LIB_TARGET) $(SO_TARGET) $(INSTALL_LIB_DIR)
$(CP) $(INC_TARGET) $(INSTALL_INC_DIR)
uninstall :
$(RM) $(INSTALL_OUT_DIR)/$(notdir $(OUT_TARGET))
$(RM) $(INSTALL_LIB_DIR)/$(notdir $(LIB_TARGET))
$(RM) $(INSTALL_LIB_DIR)/$(notdir $(SO_TARGET))
$(RM) $(INSTALL_INC_DIR)/$(INC_TARGET)
out : $(OUT_TARGET)
lib : $(LIB_TARGET)
so : $(SO_TARGET)
$(OUT_TARGET) : $(OBJ)
$(CXX) -o $@ $^ $(LIB)
$(LIB_TARGET) : $(OBJ)
$(AR) $(ARFLAGS) $@ $^
$(SO_TARGET) : $(OBJ)
$(CXX) -shared -fPIC -o $@ $^
cleandist :
$(RM) *.o
clean : cleandist
$(RM) *.d $(BIN_DIR)/*
love : clean all
lines :
@echo $(HEADER) $(SRC) | xargs wc -l
.PHONY : all install uninstall out lib so cleandist clean love lines
ifneq (${MAKECMDGOALS},install)
ifneq (${MAKECMDGOALS},uninstall)
ifneq (${MAKECMDGOALS},clean)
ifneq (${MAKECMDGOALS},cleandist)
ifneq (${MAKECMDGOALS},love)
ifneq (${MAKECMDGOALS},lines)
sinclude $(DEP)
endif
endif
endif
endif
endif
endif