This repository has been archived by the owner on Dec 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile.template
57 lines (46 loc) · 1.96 KB
/
Makefile.template
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
# Build files only if they exist.
$(UPPERC_DIR)_SRCS := $(wildcard $($(UPPERC_DIR)_SRCS))
$(UPPERC_DIR)_EXECUTABLES := $(wildcard $($(UPPERC_DIR)_EXECUTABLES))
$(UPPERC_DIR)_OBJS := $(patsubst %.cc, $(OBJDIR)/%.o, $($(UPPERC_DIR)_SRCS))
ifneq ($($(UPPERC_DIR)_EXECUTABLES),)
$(UPPERC_DIR)_DEPLOY := $(foreach EXEC, $($(UPPERC_DIR)_EXECUTABLES), $(BINDIR)/$(EXEC))
$(UPPERC_DIR)_DEPLOY := $(patsubst $(BINDIR)/$(LOWERC_DIR)/%.cpp, $(BINDIR)/%, $($(UPPERC_DIR)_DEPLOY))
else
$(UPPERC_DIR)_DEPLOY :=
endif
# Protobuf specific instructions
ifeq ($(LOWERC_DIR),proto)
$(UPPERC_DIR)_OBJS := $(patsubst %.proto, $(OBJDIR)/%.pb.o, $($(UPPERC_DIR)_OBJS))
endif
$(UPPERC_DIR)_TEST_SRCS := $(wildcard $(patsubst %.cc, %_test.cc, $($(UPPERC_DIR)_SRCS)))
$(UPPERC_DIR)_TEST_SRCS += $(filter %_test.cc, $($(UPPERC_DIR)_SRCS))
$(UPPERC_DIR)_TEST_OBJS := $(patsubst %.cc, $(OBJDIR)/%.o, $($(UPPERC_DIR)_TEST_SRCS))
$(UPPERC_DIR)_TESTS := $(patsubst %.cc, $(BINDIR)/%, $($(UPPERC_DIR)_TEST_SRCS))
TESTS += test-$(LOWERC_DIR)
all: $(LOWERC_DIR)-all
$(LOWERC_DIR)-all: $(LOWERC_DIR) $(LOWERC_DIR)-tests
$(LOWERC_DIR): $(patsubst %, $(BINDIR)/%, $($(UPPERC_DIR)_PROG))\
$($(UPPERC_DIR)_OBJS)
$(LOWERC_DIR)-tests: $($(UPPERC_DIR)_TESTS)
ifeq ($(LOWERC_DIR),proto)
SRC_CC_FILES :=
else
SRC_CC_FILES := $(LOWERC_DIR)/%.cc
endif
$(OBJDIR)/$(LOWERC_DIR)/%.o: $(SRC_CC_FILES) $(SRC_LINKED_OBJECTS)
@echo + cxx $<
@mkdir -p $(@D)
$(V)$(CXX) $(CXXFLAGS) -o $@ -c $<
$(BINDIR)/$(LOWERC_DIR)/%_test: $(OBJDIR)/$(LOWERC_DIR)/%_test.o \
$(filter-out %_test.o, $($(UPPERC_DIR)_OBJS)) \
$(TEST_LINKED_OBJECTS)
@echo + ld $@
@mkdir -p $(@D)
$(V)$(CXX) -o $@ $^ $(LDFLAGS)
ifneq ($($(UPPERC_DIR)_EXECUTABLES),)
$(BINDIR)/%: $(LOWERC_DIR)/%.cc $(EXECUTABLE_OBJS) $($(UPPERC_DIR)_OBJS)
@echo + ld $@
@mkdir -p $(@D)
$(V)$(CXX) -o $@ $^ $(CXXFLAGS) $(LDFLAGS)
endif
.PHONY: $(LOWERC_DIR)-all $(LOWERC_DIR) $(LOWERC_DIR)-tests test-$(LOWERC_DIR)