-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
308 lines (235 loc) · 8.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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
# Makefile for WordClus
# Last change: 01aug2019
PACKAGE = wordclus
#########################################################################
# define the locations of all the files
# the top of the source tree
TOP = .
# where to find FramepaC-ng include files
FP = ./framepac/framepac
FPT = ./framepac/template
# where to put the compiled library and required header files
INSTDIR = $(TOP)/include
LIBINSTDIR = $(TOP)/lib
# where to put the compiled main program
BINDIR = $(TOP)/bin
# where to look for header files from other modules when compiling
INCLUDEDIRS = -I./framepac -I$(TOP)/include
# the header files needed by applications using this library
HEADERS = wordclus.h
# the object modules to be included in the library file
OBJS = build/wctrmvec$(OBJ) \
build/wcclust$(OBJ) \
build/wcbatch$(OBJ) \
build/wcdelim$(OBJ) \
build/wcoutput$(OBJ) \
build/wcmain$(OBJ) \
build/gencorpus$(OBJ) \
build/wcidhash$(OBJ) \
build/wcglobal$(OBJ) \
build/wcpairmap$(OBJ) \
build/wcparam$(OBJ)
# the library archive file for this module
LIBRARY = $(PACKAGE)$(LIB)
# the executables to generate
EXES = bin/wordclus
# files to be included in the source distribution archive
DISTFILES = COPYING LICENSE README makefile makefile.?nx *.h *$(C)
#########################################################################
# compilation options
## uncommment the following line to enable corpora up to 1 trillion tokens instead of 4 billion
#CFLAGS += -DHUGE_CORPUS
# select the default debugging level. This can be overridden by commandline
# 0=fully optimized for distribution, 1=include debug info, 2=disable optimizations
BUILD_DBG?=0
# select default bitness (32/64). This can be overridden by commandline
#BITS?=32
BITS?=64
# include multi-threading support? This is the default, can be overridden by commandline
THREADS?=1
#THREADS?=0
# enable execution profiling?
#PROFILE?=-pg
# enable a release build with all debugging support turned off?
#NODEBUG?= -DNDEBUG
ifndef GDB
#GDB = -ggdb3
endif
# enable one of the various sanitizers? This is the default, and can be overridden by commandline
# options: 0=disabled, 1=threads, 2=address, 3=leak, 4=memory, 5=undefined-behavior
SANE?=0
#########################################################################
# define the compiler and its options
CC = g++ --std=c++11
CCLINK=$(CC)
LINKBITS=-m$(BITS)
CPUDEF=-march=native
# compiler warnings to enable
WARN=-Wall -Wextra
WARN+= -Wno-deprecated -Wshadow -Wcast-align -Wmissing-noreturn -Wmissing-format-attribute
WARN+= -Wunused-result -Wno-multichar -Wpacked
#WARN+=-Wdisabled-optimization -Wpadded
#WARN+=-pedantic
ifeq ($(THREADS),1)
PTHREAD=-pthread
else
PTHREAD=-DFrSINGLE_THREADED
endif
ifeq ($(SANE),1)
SANITIZE=-fsanitize=thread -fPIC
LINKSAN=-fPIC -pie
else ifeq ($(SANE),2)
SANITIZE=-fsanitize=address -fno-omit-frame-pointer
else ifeq ($(SANE),3)
SANITIZE=-fsanitize=leak -fno-omit-frame-pointer
else ifeq ($(SANE),4)
SANITIZE=-fsanitize=memory -fno-omit-frame-pointer
else ifeq ($(SANE),5)
SANITIZE=-fsanitize=undefined -DSANITIZING
endif
# now build the complete set of compiler flags
CFLAGS= $(WARN) $(CPUDEF) $(PTHREAD) $(INCLUDEDIRS)
CFLAGS +=$(PROFILE)
CFLAGS +=$(NODEBUG)
CFLAGS +=$(LINKBITS)
CFLAGS +=$(EXTRAINC)
CFLAGS +=$(SANITIZE)
CFLAGS +=$(SHAREDLIB)
CFLAGS +=$(COMPILE_OPTS)
CFLAGEXE = -L./framepac $(PROFILE)
ifeq ($(BUILD_DBG),2)
CFLAGS += -ggdb3 -O0 -fno-inline -g3
else
ifeq ($(BUILD_DBG),1)
CFLAGS += -ggdb3 -Og -g3
else
CFLAGS += -O3 -fexpensive-optimizations -g$(DBGLVL) $(GDB)
endif
endif
# and finally, build the complete set of linker flags
LINKFLAGS = $(LINKBITS) $(PTHREAD)
LINKFLAGS+= $(LINKTYPE)
LINKFLAGS+= $(SANITIZE)
LINKFLAGS+= $(LINKSAN)
#########################################################################
# define the various extensions in use
OBJ = .o
EXE =
LIB = .a
C = .C
#########################################################################
# define the object module librarian and its options
LIBRARIAN = ar
LIBFLAGS = rucl
LIBOBJS = $(OBJS)
#########################################################################
# define the library indexer and its options
LIBINDEXER = ranlib
LIBIDXFLAGS = $(LIBRARY)
#########################################################################
# define file copy/deletion/etc. programs
RM = rm -f
CP = cp -p
ZIP = zip
ZIPFLAGS = -qo9
BITBUCKET = >&/dev/null
TOUCH = touch
#########################################################################
## standard targets
all: framepac $(EXES)
help:
@echo "The makefile for $(PACKAGE) understands the following targets:"
@echo " all perform a complete build of library and test program"
@echo " lib build the library only"
@echo " install build and install the library"
@echo " clean erase intermediate files from the build"
@echo " veryclean erase all intermediate and backup files"
@echo " bootstrap install files needed by packages on which we depend"
@echo " tags rebuild TAGS database"
@echo " tar pack up all distribution files in a tar archive"
@echo " compress pack up all distribution files in a compressed tar file"
@echo " zip pack up all distribution files in a PKzip archive"
@echo " purify build a Purified executable (requires Purify)"
@echo " help you're looking at it..."
lib: $(LIBRARY)
clean:
-$(RM) build/*$(OBJ) $(EXES) $(LIBRARY) ; true
veryclean: clean
-$(RM) *.BAK *.CKP *~ "#*#"
(cd framepac ; $(MAKE) clean)
install: $(LIBINSTDIR)/$(LIBRARY)
bootstrap:
@mkdir -p build
tags:
etags --c++ *.h *$(C) \
$(FP)/*.h $(TOP)/FramepaC-ng/src/*$(C) $(TOP)/FramepaC-ng/template/*.cc
tar:
$(RM) $(PACKAGE).tar
tar chf $(PACKAGE).tar $(DISTFILES)
compress: tar
compress $(PACKAGE).tar
xz: tar
xz -8 $(PACKAGE).tar
zip:
$(RM) $(PACKAGE).zip
$(ZIP) $(ZIPFLAGS) $(PACKAGE) $(DISTFILES)
#########################################################################
## executables
bin/wordclus$(EXE): build/wordclus$(OBJ) $(LIBRARY) framepac/framepacng.a
mkdir -p bin
$(CCLINK) $(LINKFLAGS) $(CFLAGEXE) -o $@ $^
$(LIBINSTDIR)/$(LIBRARY): $(LIBRARY)
$(CP) $(HEADERS) $(INSTDIR)
$(CP) $< $@
#########################################################################
# the dependencies for each module of the full package
build/gencorpus$(OBJ): gencorpus$(C) wordclus.h wcbatch.h wcparam.h $(FP)/threadpool.h \
$(FP)/progress.h $(FP)/string.h $(FP)/symboltable.h $(FP)/texttransforms.h $(FP)/words.h
build/wcbatch$(OBJ): wcbatch$(C) wordclus.h wcbatch.h wcparam.h \
$(FP)/texttransforms.h $(FP)/threadpool.h
build/wcclust$(OBJ): wcclust$(C) wordclus.h wctrmvec.h wcparam.h \
$(FP)/message.h $(FP)/symboltable.h
build/wcdelim$(OBJ): wcdelim$(C) wordclus.h
build/wcglobal$(OBJ): wcglobal$(C) wordclus.h
build/wcidhash$(OBJ): wcidhash$(C) wordclus.h $(FPT)/hashtable.cc
build/wcmain$(OBJ): wcmain$(C) wordclus.h wcbatch.h wcpair.h wctrmvec.h wcparam.h
build/wcoutput$(OBJ): wcoutput$(C) wordclus.h wctrmvec.h
build/wcpairmap$(OBJ): wcpairmap$(C) wcpair.h
build/wcparam$(OBJ): wcparam$(C) wcparam.h wordclus.h $(FP)/cluster.h $(FP)/stringbuilder.h \
$(FP)/texttransforms.h
build/wctrmvec$(OBJ): wctrmvec$(C) wordclus.h wctrmvec.h $(FP)/memory.h $(FP)/symboltable.h
build/wordclus$(OBJ): wordclus$(C) wordclus.h wcparam.h \
$(FP)/argparser.h $(FP)/symboltable.h $(FP)/memory.h $(FP)/timer.h \
$(FP)/stringbuilder.h
wcbatch.h: $(FP)/file.h
$(TOUCH) $@
wcparam.h: $(FP)/contextcoll.h $(FP)/cstring.h $(FP)/hashtable.h
$(TOUCH) $@
wctrmvec.h: $(FP)/list.h $(FP)/vecsim.h wcparam.h
$(TOUCH) $@
wordclus.h: $(FP)/cluster.h $(FP)/file.h $(FP)/hashtable.h $(FP)/list.h \
$(FP)/threshold.h $(FP)/wordcorpus.h
$(TOUCH) $@
#########################################################################
## library
$(LIBRARY): $(OBJS)
-$(RM) $(LIBRARY)
$(LIBRARIAN) $(LIBFLAGS) $(LIBRARY) $(LIBOBJS)
$(LIBINDEXER) $(LIBIDXFLAGS)
framepac/framepacng.a:
(cd framepac ; make lib)
#########################################################################
## submodule initialization
framepac:
@[[ -e ../framepac-ng/framepac ]] && echo "Linking to local install of FramepaC-ng" && ln -s ../framepac-ng framepac ; true
@[[ -e ../framepac/framepac ]] && echo "Linking to local install of FramepaC-ng" && ln -s ../framepac framepac ; true
@[[ ! -e framepac ]] && [[ -e .git ]] && echo "Fetching FramepaC-ng" && git submodule add ../framepac-ng.git framepac && git submodule update --init
@[[ -e framepac ]] || (echo "Please install FramepaC-ng in subdir 'framepac'" ;exit 1)
#########################################################################
## default compilation rule
.C.o: ; $(CC) $(CFLAGS) $(CPUTYPE) -c $<
build/%$(OBJ) : %$(C)
@mkdir -p build
$(CC) $(CFLAGS) $(CPUTYPE) -c -o $@ $<
.SUFFIXES: $(OBJ) .C $(C) .cpp
# End of Makefile