-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile.rules
79 lines (58 loc) · 1.46 KB
/
Makefile.rules
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
CXX = g++
NAME = cpppoa
SRC_DIR = ../src
OBJ_DIR = obj
INC_DIR = ../include/$(NAME)
LIB_DIR = ../lib
API = $(SRC_DIR)/poa.hpp
CXX_FLAGS += -std=c++11
CXX_FLAGS += -I../lib
CXX_FLAGS += -W -Wall -Wno-long-long -pedantic -Wno-variadic-macros
LD_FLAGS =
CPP_FILES := $(wildcard $(SRC_DIR)/*.cpp)
OBJ_FILES := $(addprefix $(OBJ_DIR)/,$(notdir $(CPP_FILES:.cpp=.o)))
DEP_FILES = $(OBJ_FILES:.o=.d)
LIB_FILE = $(LIB_DIR)/lib$(NAME).a
INC_FILES = $(subst $(SRC_DIR), $(INC_DIR), $(API))
UNAME_S := $(shell uname -s)
versions := 0
ifeq ($(UNAME_S),Linux)
# add rt library linking on Linux OS
LD_FLAGS+=-lrt
endif
ifeq ($(UNAME_S),Darwin)
# attempts to select the highest g++ version available
compiler := $(shell g++-4.8 --version 2>/dev/null)
ifdef compiler
CXX = g++-4.8
endif
compiler := $(shell g++-4.9 --version 2>/dev/null)
ifdef compiler
CXX = g++-4.9
endif
compiler := $(shell g++-5 --version 2>/dev/null)
ifdef compiler
CXX = g++-5
endif
endif
default: all
all: include lib
include: $(INC_FILES)
lib: $(LIB_FILE)
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
@echo [CC] $<
@mkdir -p $(dir $@)
@$(CXX) $(CXX_FLAGS) -c -MMD -o $@ $<
$(LIB_FILE): $(OBJ_FILES)
@echo [AR] $@
@mkdir -p $(dir $@)
@ar rcs $(LIB_FILE) $(OBJ_FILES) 2> /dev/null
$(INC_DIR)/%.hpp: $(SRC_DIR)/%.hpp
@echo [CP] $@
@mkdir -p $(dir $@)
@cp $< $@
clean:
@echo [RM] cleaning $(MODULE)
@rm -rf $(OBJ_DIR) $(INC_DIR) $(LIB_DIR)
.PHONY: default all lib include clean
-include $(DEP_FILES)