-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
120 lines (95 loc) · 4.66 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#
# Unix/Linux makefile
# Abulhair Saparov
#
#
# List of source files
#
EXECUTIVE_TEST_CPP_SRCS=executive_test.cpp
EXECUTIVE_TEST_DBG_OBJS=$(EXECUTIVE_TEST_CPP_SRCS:.cpp=.debug.o)
EXECUTIVE_TEST_OBJS=$(EXECUTIVE_TEST_CPP_SRCS:.cpp=.release.o)
PWL_REASONER_CPP_SRCS=pwl_reasoner.cpp
PWL_REASONER_DBG_OBJS=$(PWL_REASONER_CPP_SRCS:.cpp=.debug.o)
PWL_REASONER_OBJS=$(PWL_REASONER_CPP_SRCS:.cpp=.release.o)
EXTRACT_WIKT_MORPHOLOGY_EN_CPP_SRCS=extract_wikt_morphology_en.cpp
EXTRACT_WIKT_MORPHOLOGY_EN_DBG_OBJS=$(EXTRACT_WIKT_MORPHOLOGY_EN_CPP_SRCS:.cpp=.debug.o)
EXTRACT_WIKT_MORPHOLOGY_EN_OBJS=$(EXTRACT_WIKT_MORPHOLOGY_EN_CPP_SRCS:.cpp=.release.o)
SET_REASONING_TEST_CPP_SRCS=set_reasoning_test.cpp
SET_REASONING_TEST_DBG_OBJS=$(SET_REASONING_TEST_CPP_SRCS:.cpp=.debug.o)
SET_REASONING_TEST_OBJS=$(SET_REASONING_TEST_CPP_SRCS:.cpp=.release.o)
#
# Compile and link options
#
CPP=g++
cc-option = $(shell $(CPP) -Werror $(1) -c -x c /dev/null -o /dev/null 2>/dev/null; echo $$?)
LIBRARY_PKG_LIBS=
PKG_LIBS=
NO_AS_NEEDED=-Wl,--no-as-needed
ifeq ($(call cc-option, $(NO_AS_NEEDED)),0)
PKG_LIBS += $(NO_AS_NEEDED)
endif
GLIBC := $(word 2,$(shell getconf GNU_LIBC_VERSION 2>/dev/null))
ifeq "$(.SHELLSTATUS)" "0"
GLIBC_HAS_RT := $(shell expr $(GLIBC) \>= 2.17)
ifeq "$(GLIBC_HAS_RT)" "0"
LIBRARY_PKG_LIBS += -lrt
PKG_LIBS += -lrt
endif
endif
WARNING_FLAGS=-Wall -Wpedantic
override CPPFLAGS_DBG += $(WARNING_FLAGS) -I. -g -march=native -mtune=native -std=c++17 -DDISABLE_SSL
override CPPFLAGS += $(WARNING_FLAGS) -I. -Ofast -fno-finite-math-only -DNDEBUG -march=native -mtune=native -std=c++17 -fno-stack-protector -DDISABLE_SSL
override LDFLAGS_DBG += -g $(LIB_PATHS) $(PKG_LIBS)
override LDFLAGS += $(LIB_PATHS) -fwhole-program $(PKG_LIBS)
#
# GNU Make: targets that don't build files
#
.PHONY: all debug clean distclean
#
# Make targets
#
all: executive_test extract_wikt_morphology_en set_reasoning_test
debug: executive_test_dbg extract_wikt_morphology_en_dbg set_reasoning_test_dbg
-include $(EXECUTIVE_TEST_OBJS:.release.o=.release.d)
-include $(EXECUTIVE_TEST_DBG_OBJS:.debug.o=.debug.d)
-include $(PWL_REASONER_OBJS:.release.o=.release.d)
-include $(PWL_REASONER_DBG_OBJS:.debug.o=.debug.d)
-include $(EXTRACT_WIKT_MORPHOLOGY_EN_OBJS:.release.o=.release.d)
-include $(EXTRACT_WIKT_MORPHOLOGY_EN_DBG_OBJS:.debug.o=.debug.d)
-include $(SET_REASONING_TEST_OBJS:.release.o=.release.d)
-include $(SET_REASONING_TEST_DBG_OBJS:.debug.o=.debug.d)
define make_dependencies
$(1) $(2) -c $(3).$(4) -o $(3).$(5).o
$(1) -MM $(2) $(3).$(4) > $(3).$(5).d
@mv -f $(3).$(5).d $(3).$(5).d.tmp
@sed -e 's|.*:|$(3).$(5).o:|' < $(3).$(5).d.tmp > $(3).$(5).d
@sed -e 's/.*://' -e 's/\\$$//' < $(3).$(5).d.tmp | fmt -1 | \
sed -e 's/^ *//' -e 's/$$/:/' >> $(3).$(5).d
@rm -f $(3).$(5).d.tmp
endef
%.release.o: %.cpp
$(call make_dependencies,$(CPP),$(CPPFLAGS),$*,cpp,release)
%.release.pic.o: %.cpp
$(call make_dependencies,$(CPP),$(CPPFLAGS),$*,cpp,release.pic)
%.debug.o: %.cpp
$(call make_dependencies,$(CPP),$(CPPFLAGS_DBG),$*,cpp,debug)
%.debug.pic.o: %.cpp
$(call make_dependencies,$(CPP),$(CPPFLAGS_DBG),$*,cpp,debug.pic)
executive_test: $(LIBS) $(EXECUTIVE_TEST_OBJS)
$(CPP) -o executive_test $(CPPFLAGS) $(EXECUTIVE_TEST_OBJS) $(LDFLAGS) -lssl -lcrypto
executive_test_dbg: $(LIBS) $(EXECUTIVE_TEST_DBG_OBJS)
$(CPP) -o executive_test_dbg $(CPPFLAGS_DBG) $(EXECUTIVE_TEST_DBG_OBJS) $(LDFLAGS_DBG) -lssl -lcrypto
pwl_reasoner: $(LIBS) $(PWL_REASONER_OBJS)
$(CPP) -o pwl_reasoner $(CPPFLAGS) $(PWL_REASONER_OBJS) $(LDFLAGS)
pwl_reasoner_dbg: $(LIBS) $(PWL_REASONER_DBG_OBJS)
$(CPP) -o pwl_reasoner_dbg $(CPPFLAGS_DBG) $(PWL_REASONER_DBG_OBJS) $(LDFLAGS_DBG)
extract_wikt_morphology_en: $(LIBS) $(EXTRACT_WIKT_MORPHOLOGY_EN_OBJS)
$(CPP) -o extract_wikt_morphology_en $(CPPFLAGS) $(EXTRACT_WIKT_MORPHOLOGY_EN_OBJS) $(LDFLAGS)
extract_wikt_morphology_en_dbg: $(LIBS) $(EXTRACT_WIKT_MORPHOLOGY_EN_DBG_OBJS)
$(CPP) -o extract_wikt_morphology_en_dbg $(CPPFLAGS_DBG) $(EXTRACT_WIKT_MORPHOLOGY_EN_DBG_OBJS) $(LDFLAGS_DBG)
set_reasoning_test: $(LIBS) $(SET_REASONING_TEST_OBJS)
$(CPP) -o set_reasoning_test $(CPPFLAGS) $(SET_REASONING_TEST_OBJS) $(LDFLAGS)
set_reasoning_test_dbg: $(LIBS) $(SET_REASONING_TEST_DBG_OBJS)
$(CPP) -o set_reasoning_test_dbg $(CPPFLAGS_DBG) $(SET_REASONING_TEST_DBG_OBJS) $(LDFLAGS_DBG)
clean:
${RM} -f *.o */*.o */*/*.o *.d */*.d */*/*.d executive_test executive_test.exe executive_test_dbg executive_test_dbg.exe pwl_reasoner pwl_reasoner.exe pwl_reasoner_dbg pwl_reasoner_dbg.exe extract_wikt_morphology_en extract_wikt_morphology_en_dbg extract_wikt_morphology_en.exe extract_wikt_morphology_en_dbg.exe set_reasoning_test set_reasoning_test_dbg set_reasoning_test.exe set_reasoning_test_dbg.exe $(LIBS)