-
Notifications
You must be signed in to change notification settings - Fork 14
/
Makefile
124 lines (97 loc) · 3.58 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
121
122
123
124
# Copyright 2016 Eddie Antonio Santos <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Install prefix, if installing globally.
# See also: `exports` target
PREFIX = /usr/local
BINDIR = $(PREFIX)/bin
MANDIR = $(PREFIX)/share/man/man1
# List of all the tools (executables + manual pages)
TOOLS = accci accdist accsum accuracy editop editopcost editopsum \
groupacc ngram nonstopacc synctext vote wordacc wordaccci \
wordaccdist wordaccsum wordfreq
# Name: libocreval, or -locreval
NAME = ocreval
MAJOR_VERSION = 7
MINOR_VERSION = 0
# All the executables go in bin/
EXECUTABLES = $(addprefix bin/,$(TOOLS))
# All manual pages go in share/man/man1
MANPAGES = $(foreach TOOL,$(TOOLS),share/man/man1/$(TOOL).1)
include use-libocreval-internal.mk
LIBRARY.a = lib/lib$(NAME).a
ifeq ($(shell uname -s),Darwin)
LIBRARY.so = $(LIBRARY.a:.a=.dylib)
else
LIBRARY.so = $(LIBRARY.a:.a=.so.$(MAJOR_VERSION).$(MINOR_VERSION))
endif
################################################################################
# Allows for proper compilation and linking settings for libocreval
all: $(EXECUTABLES)
install: install-bin install-man
install-bin: $(EXECUTABLES)
mkdir -p $(BINDIR)
cp $(EXECUTABLES) $(BINDIR)/
install-man: $(MANPAGES)
mkdir -p $(MANDIR)
cp $(MANPAGES) $(MANDIR)/
# Prints a bunch of exports you can source in your shell's startup file.
exports:
@echo '#' ocreval
@echo export PATH='$(TOP)bin:$$PATH'
@echo export MANPATH='$(TOP)share/man:$$MANPATH'
ifeq ($(shell uname -s),Darwin)
@echo export DYLD_LIBRARY_PATH='$(TOP)lib:$$DYLD_LIBRARY_PATH'
else
@echo export LD_LIBRARY_PATH='$(TOP)lib:$$LD_LIBRARY_PATH'
endif
clean: clean-objs clean-execs clean-libs clean-deps clean-test
clean-libs:
$(RM) $(LIBRARY.a) $(LIBRARY.so)
clean-objs:
$(RM) $(MODULES:.c=.o)
clean-deps:
$(RM) $(DEPENDENCIES)
clean-execs:
$(RM) $(EXECUTABLES)
clean-test:
$(MAKE) -C test clean
TEST_ARGS =
test: $(EXECUTABLES) $(LIBRARY.a)
$(MAKE) -C test
# Uses https://github.com/alexch/rerun
# $ gem install rerun
watch:
rerun --clear --exit --pattern '**/*.{c,h}' -- make test
.PHONY: all
.PHONY: install install-bin install-man
.PHONY: clean clean-deps clean-execs clean-lib clean-objs clean-test
.PHONY: test watch
################################################################################
# Executable sources are C files that provide a main() for executables.
EXECUTABLE_SOURCES := $(foreach TOOL,$(TOOLS),src/$(TOOL).c)
# Modules are all object files exclusively for inclusion in libocreval
MODULE_SOURCES := $(filter-out $(EXECUTABLE_SOURCES),$(wildcard src/*.c))
MODULES := $(MODULE_SOURCES:.c=.o)
# Dependencies are .d files included by Make
DEPENDENCIES := $(EXECUTABLES:=.d) $(MODULES:.o=.d)
-include $(DEPENDENCIES)
# Rules for building executables; they are statically linked with the library.
bin/%: src/%.c $(LIBRARY.a)
$(LINK.c) -o $@ $< $(LDLIBS)
$(LIBRARY.a): $(MODULES)
$(AR) $(ARFLAGS) -s $@ $^
# Special case: Generate this include file, required by libocreval.a
$(TOP)src/word_break_property.h src/word_break_property.h: \
libexec/generate_word_break.py libexec/WordBreakProperty.txt.gz
./$< > $@