-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1-23.mak
46 lines (39 loc) · 991 Bytes
/
1-23.mak
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
# Specify the source files, target files, the build directories,
# and the install directory
SOURCES = hellobeatles.cpp
OUTPUTFILE = hellobeatles
LIBJOHNPAUL = libjohnpaul.a
LIBGEORGERINGO = libgeorgeringo.so
JOHNPAULDIR = ../johnpaul
GEORGERINGODIR = ../georgeringo
INSTALLDIR = ../binaries
#
# Add the parent directory as an include path
#
CPPFLAGS += -I..
#
# Default target
#
.PHONY: all
all: $(HELLOBEATLES)
#
# Target to build the executable.
#
$(OUTPUTFILE): $(subst .cpp,.o,$(SOURCES)) \
$(JOHNPAULDIR)/$(LIBJOHNPAUL) \
$(GEORGERINGODIR)/$(LIBGEORGERINGO)
$(CXX) $(LDFLAGS) -o $@ $^
.PHONY: install
install:
mkdir -p $(INSTALLDIR)
cp -p $(OUTPUTFILE) $(INSTALLDIR)
.PHONY: clean
clean:
rm -f *.o
rm -f $(OUTPUTFILE)
# Generate dependencies of .ccp files on .hpp files
include $(subst .cpp,.d,$(SOURCES))
%.d: %.cpp
$(CC) -M $(CPPFLAGS) $< > $@.$$$$; \
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
rm -f $@.$$$$