-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
74 lines (60 loc) · 2.02 KB
/
Makefile
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
#----------------------------------------------------------------------------
# Macros
#----------------------------------------------------------------------------
CXX = g++
SED = sed
RM = rm -rf
MKDIR = mkdir -p
TESTDIRSTART = test -d
NUL = /dev/null
TESTDIREND = ||
#GENFLAGS = -g
GENFLAGS =
LD = $(CXX) $(CCFLAGS) $(CPPFLAGS)
#CPPFLAGS = $(GENFLAGS) -D_REENTRANT -fPIC
CPPFLAGS = $(GENFLAGS) -D_REENTRANT -fPIC -O2
WORKDIR = $(shell pwd)
LDLIBS = -ldl
LDFLAGS = -L"./obj"
COMPILE.cc = $(CXX) $(CCFLAGS) $(CPPFLAGS) -c
LINK.cc = $(LD)
OUTPUT_OPTION = -o "$@"
DEPENDENCIES = .depend
SRCDIR = source
OBJDIR = obj
SRCS = $(wildcard $(SRCDIR)/*.cxx)
OBJS = $(patsubst $(SRCDIR)/%.cxx,$(OBJDIR)/%.o,$(SRCS))
MAINSRCDIR = main
MAINOBJDIR = obj
MAINSRCS = $(wildcard $(MAINSRCDIR)/*.cxx)
MAINOBJS = $(patsubst $(MAINSRCDIR)/%.cxx,$(MAINOBJDIR)/%.o,$(MAINSRCS))
BINDIR = .
BIN = $(patsubst $(MAINSRCDIR)/%.cxx,$(BINDIR)/%,$(MAINSRCS))
#----------------------------------------------------------------------------
# Local targets
#----------------------------------------------------------------------------
.PHONY : clean all gendir depend contrib
all: gendir contrib $(BIN) $(DEPENDENCIES)
$(MAKE) -C processor
contrib:
$(MAKE) -C crfpp
$(BINDIR)/%: $(MAINOBJDIR)/%.o $(OBJS)
$(LINK.cc) $^ $(OUTPUT_OPTION) $(LDFLAGS) $(LDLIBS)
gendir:
-$(TESTDIRSTART) "$(OBJDIR)" $(TESTDIREND) $(MKDIR) "$(OBJDIR)"
depend: $(DEPENDENCIES)
$(DEPENDENCIES):
$(CC) -MM $(SRCS) > $(DEPENDENCIES)
$(SED) -i 's/^\([^ ]\)/$(OBJDIR)\/\1/g' $(DEPENDENCIES)
$(OBJDIR)/%.o: $(SRCDIR)/%.cxx
$(COMPILE.cc) $(EXPORTFLAGS) $(OUTPUT_OPTION) $<
$(MAINOBJDIR)/%.o: $(MAINSRCDIR)/%.cxx
$(COMPILE.cc) $(EXPORTFLAGS) $(OUTPUT_OPTION) $<
clean:
-$(RM) $(OBJS)
-$(RM) $(MAINOBJS)
-$(RM) $(BIN)
-$(RM) $(DEPENDENCIES)
$(MAKE) -C processor clean
$(MAKE) -C crfpp clean
-include $(DEPENDENCIES)