-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile_unix
34 lines (27 loc) · 887 Bytes
/
Makefile_unix
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
SHELL = bash
CXX = g++
CPPFLAGS = -DUNIX_SYSTEM
CFLAGS = -std=c++11 -Wall -g1 -O2
LFLAGS = -lxerces-c -lc -lpthread
bin_path = bin
dep_path = dep
VPATH = $(dep_path) $(bin_path)
executable = yafs
-include sources
objects = $(sources:%.cpp=%.o)
objects_with_path = $(sources:%.cpp=$(bin_path)/%.o)
dependences = $(sources:%.cpp=%.d)
dependences_with_path = $(sources:%.cpp=$(dep_path)/%.d)
$(executable) : $(dependences) $(objects)
$(CXX) $(CFLAGS) $(CPPFLAGS) $(objects_with_path) $(LFLAGS) -o $(bin_path)/$(executable)
.PHONY : clean
clean :
rm -f $(dependences_with_path) $(objects_with_path) $(bin_path)/$(executable)
-include $(dependences_with_path)
%.o : %.cpp
$(CXX) -c $(CFLAGS) $(CPPFLAGS) $< -o $(bin_path)/$@
$(dep_path)/%.d : %.cpp
@rm -f $@.tmp
@$(CXX) -MM $(CPPFLAGS) $< > $@.tmp
@sed 's,\($*\)\.o[ :]*,\1.o $@ : Makefile_unix ,g' < $@.tmp > $@
@rm -f $@.tmp