-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.cc
53 lines (36 loc) · 1.16 KB
/
Makefile.cc
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
# makefile template for creating C programs
#################################################################
# sources & dependencies
SRCS := $(wildcard *.cpp)
HDRS := $(wildcard *.h)
DEP_IN = ${SRCS} ${HDRS}
OBJS := $(patsubst %.cpp,%.o,$(SRCS))
#################################################################
default: ${NAME}
${NAME}: ${OBJS}
${CXX} ${CXXFLAGS} ${LDFLAGS} ${INCLUDES} -o $@ ${OBJS} ${LIBS}
#################################################################
# common rules
%.o: %.cpp
${CXX} ${CXXFLAGS} ${INCLUDES} -c $<
.PHONY: install install-static install-shared install-headers install-dirs clean proper
proper: clean
-@rm -f ID tags
clean:
-@rm -f ${NAME} *.o *.d core core.* *~ Makefile.deps
ifneq ($(MAKECMDGOALS),proper)
ifneq ($(MAKECMDGOALS),clean)
-include $(SRCS:.cpp=.d)
endif
endif
%.d: %.cpp
@$(CXX) -M $(CXXFLAGS) $(INCLUDES) $< > $@.$$$$; \
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
rm -f $@.$$$$
#################################################################
# instalation
install: ${NAME} install-dirs
$(install-bin) $(NAME) $(bin-dir)
install-dirs: $(bin-dir)
$(bin-dir):
mkdir -p $(bin-dir)