forked from AlloSphere-Research-Group/AlloSystem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.rules
111 lines (84 loc) · 2.92 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#=========================================================================
# Common rules for all Makefiles
#=========================================================================
# Append linker flags set elsewhere
CPPFLAGS += $(LINK_CPPFLAGS)
LDFLAGS += $(LINK_LDFLAGS)
CFLAGS := $(CPPFLAGS) $(CFLAGS)
CXXFLAGS := $(CFLAGS) $(CXXFLAGS)
DEPFLAGS =
ifneq ($(DEP_TRACK), 0)
DEPFLAGS = -MMD -MF $(basename $@).dep
endif
ALL_BUILD_DIRS = $(BIN_DIR)/ $(OBJ_DIR)/ $(BUILD_DIR)include/ $(BUILD_DIR)lib/
#--------------------------------------------------------------------------
# Rules
#--------------------------------------------------------------------------
all: $(LIB_PATH)
# Build object file from C++ source
$(OBJ_DIR)%.o:: %.cpp
@echo CXX $< $@
$(CXX) -c $(CXXFLAGS) $< -o $@ $(DEPFLAGS)
$(OBJ_DIR)%.o:: %.cc
@echo CXX $< $@
$(CXX) -c $(CXXFLAGS) $< -o $@ $(DEPFLAGS)
# Build object file from C source
$(OBJ_DIR)%.o:: %.c
@echo CC $< $@
$(CC) -c $(CFLAGS) $< -o $@ $(DEPFLAGS)
# Build object file from Obj-C++ source
$(OBJ_DIR)%.o:: %.mm
@echo CC $< $@
$(CXX) -c $(CFLAGS) $< -o $@ $(DEPFLAGS)
# Build pre-compiled headers
$(OBJ_DIR)%.hpp.gch:: %.hpp
@echo CXX $< $@
$(CXX) -x c++ -c $(CXXFLAGS) -Winvalid-pch $< -o $@ $(DEPFLAGS)
# Include GCC generated dependency files
-include $(wildcard $(OBJ_DIR)*.dep)
# Prevent Make from automatically searching its predefined implicit rules
%.dep: ;
Makefile.%: ;
%.inl: ;
%.h: ;
%.hpp: ;
# Build static library
$(SLIB_PATH): $(addprefix $(OBJ_DIR), $(OBJS) $(PCHS))
ifneq ($(OBJS),)
@echo AR $@
@$(RM) $@
$(AR) $@ $(filter %.o, $^) $(SLIB_FLAGS)
# @$(RANLIB) $@
# libtool --mode=link --tag=CXX $(filter %.o, $^) $(SLIB_FLAGS) -o $@
# @libtool -static $@ $(patsubst %, $(DEV_DIR)lib/lib%.a, $(STATIC_LIBS)) -o $@
endif
# Build dynamic library
$(DLIB_PATH): $(addprefix $(OBJ_DIR), $(OBJS))
ifneq ($(OBJS),)
@echo DY $@
$(CXX) $(DLIB_FLAGS) $(CXXFLAGS) -o $@ $(filter %.o, $^) $(LDFLAGS)
endif
# Dummy target to force rebuilds
FORCE: ;
# This creates a particular build folder
$(ALL_BUILD_DIRS):
@mkdir -p $@
# This rule creates all the build directories ONCE when the first object is built
$(addprefix $(OBJ_DIR), $(OBJS)): | $(ALL_BUILD_DIRS)
# Create file with settings for linking to external libraries
linkfile:
@printf "%b\n" "CPPFLAGS +=$(LINK_CPPFLAGS)\r\nLDFLAGS +=-l$(LIB_NAME) $(LINK_LDFLAGS)"> Makefile.link
# @printf "%b(LDFLAGS)\n" "CPPFLAGS +=$(LINK_CPPFLAGS)\r\nLDFLAGS :=-l$(LIB_NAME) $(LINK_LDFLAGS) $$"> Makefile.link
# Archive repository
archive:
@echo Creating archive $(LIB_NAME).zip...
@git archive --format zip --output ./$(LIB_NAME).zip master
## svn version
# $(eval $@_TMP := $(shell mktemp -d tmp.XXXXXXXXXX))
# @echo Creating archive, this may take some time...
# @echo Creating temporary export...
# @svn export --force . $($@_TMP)
# @echo Compressing...
# @cd $($@_TMP) && tar -czf ../$(LIB_NAME).tar.gz .
# @echo Compression complete.
# @$(RM) -R $($@_TMP)