File: Makefile

package info (click to toggle)
neartree 5.1.1+dfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 1,380 kB
  • sloc: cpp: 12,313; ansic: 5,956; makefile: 495
file content (411 lines) | stat: -rw-r--r-- 14,427 bytes parent folder | download
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
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
#
#  Makefile
#  NearTree
#
#  Part if the NearTree API
#  Copyright 2008, 2009 Larry Andrews.  All rights reserved
#
#  Makefile created by Herbert J. Bernstein on 1/08/09
#  with permission from Larry Andrews.
#  Copyright 2008 Larry Andrews and Herbert J. Bernstein. 
#  All rights reserved.
#
#  Revised 30 May 2009, release with full containerization of C++
#                       version and KNear/Far in C++ and C, LCA + HJB
#
#  Revised 31 October 2009, adding triple.h
#
#  Revised 8 Octber 2012, remove duplicate library load
#


#**********************************************************************
#*                                                                    *
#* YOU MAY REDISTRIBUTE THE NearTree API UNDER THE TERMS OF THE LGPL  *
#*                                                                    *
#**********************************************************************/

#************************* LGPL NOTICES *******************************
#*                                                                    *
#* This library is free software; you can redistribute it and/or      *
#* modify it under the terms of the GNU Lesser General Public         *
#* License as published by the Free Software Foundation; either       *
#* version 2.1 of the License, or (at your option) any later version. *
#*                                                                    *
#* This library is distributed in the hope that it will be useful,    *
#* but WITHOUT ANY WARRANTY; without even the implied warranty of     *
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU  *
#* Lesser General Public License for more details.                    *
#*                                                                    *
#* You should have received a copy of the GNU Lesser General Public   *
#* License along with this library; if not, write to the Free         *
#* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,    *
#* MA  02110-1301  USA                                                *
#*                                                                    *
#**********************************************************************/

# Version string
VERSION = 7:0:0
RELEASE = 4.0


#
# Compiler and compilation flags
#
CC	= gcc
CXX     = g++
ifneq ($(MSYSTEM),MINGW32)
CFLAGS  += -g -O3  -Wall  -ansi -pedantic -DCNEARTREE_SAFE_TRIANG=1
TIME = time
else
CFLAGS  += -g -O2 -Wall  -DCNEARTREE_SAFE_TRIANG=1
TIME = 
endif

#
# libtool path if system default is not suitable
#
#LIBTOOL = $(HOME)/bin/libtool
ifndef LIBTOOL
  LIBTOOL = libtool
endif

#
# If local headers must be quoted uncomment the next line
#
#USE_LOCAL_HEADERS = 1

#
# Uncomment the next two lines if CVector is installed locally in $(HOME)/include
# and $(HOME)/lib
#
#CVECTOR_INCLUDE = -I$(HOME)/include 
#CVECTOR_LIBLOC = -L$(HOME)/lib

#
# Directories
#
ROOT     = .
LIB      = $(ROOT)/lib
BIN      = $(ROOT)/bin
SRC      = $(ROOT)
INC      = $(ROOT)
EXAMPLES = $(ROOT)
TESTDATA = $(ROOT)
ifndef INSTALL_PREFIX
INSTALL_PREFIX = $(DESTDIR)/usr
#INSTALL_PREFIX  = $(HOME)
endif
INSTALL_LIB ?= lib

#
# Include directories
#
ifdef USE_LOCAL_HEADERS
INCLUDES = -DUSE_LOCAL_HEADERS
else
INCLUDES = -I$(INC) $(CVECTOR_INCLUDE)
endif

#
# C++ Libraries
#
CPPLIBRARIES = -lm


#
# C Libraries
#
CLIBRARIES = $(CVECTOR_LIBLOC) -lCVector -lm

COMPILE_COMMAND        =  $(LIBTOOL) --mode=compile $(CC) $(CPPFLAGS) $(CFLAGS) $(INCLUDES) $(WARNINGS) -c
CPPCOMPILE_COMMAND     =  $(LIBTOOL) --mode=compile $(CXX) $(CPPFLAGS) $(CFLAGS) $(CXXFLAGS) $(INCLUDES) $(WARNINGS) -c
LIBRARY_LINK_COMMAND   =  $(LIBTOOL) --mode=link $(CC) -version-info $(VERSION) -no-undefined -rpath /usr/$(INSTALL_LIB) $(LDFLAGS)
BUILD_COMMAND_LOCAL    =  $(LIBTOOL) --mode=link $(CC) $(CPPFLAGS) $(CFLAGS) $(INCLUDES) $(LDFLAGS)
CPPBUILD_COMMAND_LOCAL =  $(LIBTOOL) --mode=link $(CXX) $(CPPFLAGS) -no-undefined $(CFLAGS) $(CXXFLAGS) $(INCLUDES) $(LDFLAGS)
BUILD_COMMAND_DYNAMIC  =  $(LIBTOOL) --mode=link $(CC) $(CPPFLAGS) -no-undefined $(CFLAGS) -shared -I$(INSTALL_PREFIX)/include $(LDFLAGS)
BUILD_COMMAND_STATIC   =  $(LIBTOOL) --mode=link $(CC) $(CPPFLAGS) $(CFLAGS) -static-libtool-libs -I$(INSTALL_PREFIX)/include $(LDFLAGS)
INSTALL_COMMAND        =  $(LIBTOOL) --mode=install cp
INSTALL_FINISH_COMMAND =  $(LIBTOOL) --mode=finish

OBJ_EXT                =  lo
LIB_EXT                =  la

######################################################################
#  You should not need to make modifications below this line         #
######################################################################

#
# Suffixes of files to be used or built
#
.SUFFIXES:	.c .$(OBJ_EXT) .$(LIB_EXT)

#
# Common dependencies
#
COMMONDEP = Makefile

#
# Source files
#
CPPSOURCE =	$(SRC)/main.cpp $(SRC)/CNearTreeTest.cpp $(SRC)/v.cpp
CSOURCE   =	$(SRC)/CNearTree.c $(SRC)/main.c $(SRC)/CNearTreeTest.c
SOURCE   =  $(CPPSOURCE) $(CSOURCE)

#
# Header files
#
HEADERS   =  $(INC)/TNear.h $(INC)/CNearTree.h $(INC)/v.h $(INC)/rhrand.h $(INC)/triple.h

# Default: instructions
#
default:
	@echo ' '
	@echo '***************************************************************'
	@echo ' '
	@echo ' PLEASE READ README_NearTree.txt and lgpl.txt'
	@echo ' '
	@echo ' Before making the NearTree libraries and example programs, check'
	@echo ' that the chosen settings are correct'
	@echo ' '
	@echo ' The current C++ and C compile commands are:'
	@echo ' '
	@echo '   $(CPPCOMPILE_COMMAND)'
	@echo '   $(COMPILE_COMMAND)'
	@echo ' '
	@echo ' The C API, CNearTree.c, depends on the sourceforge project CVector '
ifdef CVECTOR_INCLUDE
	@echo ' The variable CVECTOR_INCLUDE is defined as '
	@echo '   $(CVECTOR_INCLUDE)'
else
	@echo ' You are currently setup to use the system defaults for CVector'
	@echo ' If that is not correct, define the variable CVECTOR_INCLUDE '
endif
	@echo ' '
	@echo ' The current library link command is:'
	@echo ' '
	@echo '   $(LIBRARY_LINK_COMMAND)'
	@echo ' '
	@echo ' The current C++ and C library local, and C dynamic and static build commands are:'
	@echo ' '
	@echo '   $(CPPBUILD_COMMAND_LOCAL)'
	@echo '   $(BUILD_COMMAND_LOCAL)'
	@echo '   $(BUILD_COMMAND_DYNAMIC)'
	@echo '   $(BUILD_COMMAND_STATIC)'
	@echo ' '
	@echo ' Before installing the NearTree library and example programs, check'
	@echo ' that the install directory and install commands are correct:'
	@echo ' '
	@echo ' The current values are :'
	@echo ' '
	@echo '   $(INSTALL_PREFIX) '	
	@echo '   $(INSTALL_COMMAND) '	
	@echo '   $(INSTALL_FINISH) '	
	@echo ' '
	@echo ' To compile the NearTree library and example programs type:'
	@echo ' '
	@echo '   make clean'
	@echo '   make all'
	@echo ' '
	@echo ' To run a set of tests type:'
	@echo ' '
	@echo '   make tests'
	@echo ' '
	@echo ' To clean up the directories type:'
	@echo ' '
	@echo '   make clean'
	@echo ' '
	@echo ' To install the library and headers type:'
	@echo ' '
	@echo '   make install'
	@echo ' '
	@echo '***************************************************************'
	@echo ' '

#
# Compile the library and examples
#
all:	$(LIB) $(BIN) $(SOURCE) $(HEADERS) \
		$(LIB)/libCNearTree.$(LIB_EXT) \
		$(BIN)/CPPMain $(BIN)/CMain $(BIN)/CPPNearTreeTest $(BIN)/CNearTreeTest $(BIN)/CNearTreeTestInst 
		
install:  all $(INSTALL_PREFIX) $(INSTALL_PREFIX)/$(INSTALL_LIB) $(INSTALL_PREFIX)/include \
		  $(INC) $(LIB)/libCNearTree.$(LIB_EXT)  $(INC)/TNear.h $(INC)/CNearTree.h \
		  $(INC)/rhrand.h $(INC)/triple.h
		  $(INSTALL_COMMAND) $(LIB)/libCNearTree.$(LIB_EXT) $(INSTALL_PREFIX)/$(INSTALL_LIB)/libCNearTree.$(LIB_EXT)
		  $(INSTALL_FINISH_COMMAND) $(INSTALL_PREFIX)/$(INSTALL_LIB)/libCNearTree.$(LIB_EXT)
		  -cp $(INSTALL_PREFIX)/include/TNear.h $(INSTALL_PREFIX)/include/TNear_old.h
		  -cp $(INSTALL_PREFIX)/include/CNearTree.h $(INSTALL_PREFIX)/include/CNearTree_old.h
		  cp $(INC)/TNear.h $(INSTALL_PREFIX)/include/TNear.h
		  cp $(INC)/rhrand.h $(INSTALL_PREFIX)/include/rhrand.h
		  cp $(INC)/triple.h $(INSTALL_PREFIX)/include/triple.h
		  cp $(INC)/CNearTree.h $(INSTALL_PREFIX)/include/CNearTree.h
		  chmod 644 $(INSTALL_PREFIX)/include/TNear.h
		  chmod 644 $(INSTALL_PREFIX)/include/CNearTree.h
		  chmod 644 $(INSTALL_PREFIX)/include/rhrand.h
		  chmod 644 $(INSTALL_PREFIX)/include/triple.h
		  echo "Testing final install static"
		  $(BUILD_COMMAND_STATIC) $(INCLUDES) $(EXAMPLES)/CNearTreeTest.c \
		  -L$(INSTALL_PREFIX)/$(INSTALL_LIB) -lCNearTree $(CLIBRARIES) -o $(BIN)/CNearTreeTest_static
		  $(BIN)/CNearTreeTest_static 
		  echo "Testing final install dynamic"
		  $(BUILD_COMMAND_DYNAMIC) $(INCLUDES) $(EXAMPLES)/CNearTreeTest.c \
		  -L$(INSTALL_PREFIX)/$(INSTALL_LIB) -lCNearTree $(CLIBRARIES) -o $(BIN)/CNearTreeTest_dynamic
		  $(BIN)/CNearTreeTest_dynamic 
		
		  
		  
#
# Directories
#
$(INSTALL_PREFIX):
	mkdir -p $(INSTALL_PREFIX)

$(INSTALL_PREFIX)/$(INSTALL_LIB):  $(INSTALL_PREFIX)
	mkdir -p $(INSTALL_PREFIX)/$(INSTALL_LIB)

$(INSTALL_PREFIX)/bin:  $(INSTALL_PREFIX)
	mkdir -p $(INSTALL_PREFIX)/bin

$(INSTALL_PREFIX)/include:  $(INSTALL_PREFIX)
	mkdir -p $(INSTALL_PREFIX)/include
	

$(LIB):
	mkdir $(LIB)

$(BIN):
	mkdir $(BIN)

#
# CNearTree library
#
$(LIB)/libCNearTree.$(LIB_EXT): $(SRC)/CNearTree.c $(INC)/CNearTree.h $(LIB) $(COMMONDEP)
	$(COMPILE_COMMAND) -c $(SRC)/CNearTree.c
	$(LIBRARY_LINK_COMMAND) -o $(LIB)/libCNearTree.$(LIB_EXT) CNearTree.$(OBJ_EXT)  $(INCLUDES) \
	$(CLIBRARIES)

#
#  example programs
#
$(BIN)/CPPMain: $(INC)/TNear.h $(EXAMPLES)/main.cpp $(EXAMPLES)/v.cpp $(BIN)
	$(CPPBUILD_COMMAND_LOCAL) $(EXAMPLES)/main.cpp $(EXAMPLES)/v.cpp $(CPPLIBRARIES) \
		  -o $@

$(BIN)/CPPMain_Flip: $(INC)/TNear.h $(EXAMPLES)/main_flip.cpp $(EXAMPLES)/v.cpp $(BIN)
	$(CPPBUILD_COMMAND_LOCAL) $(EXAMPLES)/main_flip.cpp $(EXAMPLES)/v.cpp $(CPPLIBRARIES) \
		  -o $@
		  
$(BIN)/CPPNearTreeTest: $(INC)/TNear.h $(EXAMPLES)/CNearTreeTest.cpp $(EXAMPLES)/v.cpp $(BIN)
	$(CPPBUILD_COMMAND_LOCAL) $(EXAMPLES)/CNearTreeTest.cpp $(EXAMPLES)/v.cpp $(CPPLIBRARIES) \
		  -o $@

$(BIN)/CPPNearTreeTest_2SAMP: $(INC)/TNear.h $(EXAMPLES)/CNearTreeTest.cpp $(EXAMPLES)/v.cpp $(BIN)
		$(CPPBUILD_COMMAND_LOCAL) -DCNEARTREE_DIMSAMPLES=2 $(EXAMPLES)/CNearTreeTest.cpp $(EXAMPLES)/v.cpp $(CPPLIBRARIES) \
		  -o $@

$(BIN)/CPPNearTreeTest_6SAMP: $(INC)/TNear.h $(EXAMPLES)/CNearTreeTest.cpp $(EXAMPLES)/v.cpp $(BIN)
	$(CPPBUILD_COMMAND_LOCAL) -DCNEARTREE_DIMSAMPLES=6 $(EXAMPLES)/CNearTreeTest.cpp $(EXAMPLES)/v.cpp $(CPPLIBRARIES) \
		  -o $@


$(BIN)/CPPNearTreeTest_8SAMP: $(INC)/TNear.h $(EXAMPLES)/CNearTreeTest.cpp $(EXAMPLES)/v.cpp $(BIN)
		$(CPPBUILD_COMMAND_LOCAL) -DCNEARTREE_DIMSAMPLES=8 $(EXAMPLES)/CNearTreeTest.cpp $(EXAMPLES)/v.cpp $(CPPLIBRARIES) \
		  -o $@


$(BIN)/CPPNearTreeTestInst: $(INC)/TNear.h $(EXAMPLES)/CNearTreeTest.cpp $(EXAMPLES)/v.cpp $(BIN)
	$(CPPBUILD_COMMAND_LOCAL) -DCNEARTREE_INSTRUMENTED $(EXAMPLES)/CNearTreeTest.cpp $(EXAMPLES)/v.cpp $(CPPLIBRARIES) \
		  -o $@

$(BIN)/CPPNearTreeTestInstFlip: $(INC)/TNear.h $(EXAMPLES)/CNearTreeTest.cpp $(EXAMPLES)/v.cpp $(BIN)
	$(CPPBUILD_COMMAND_LOCAL) -DCNEARTREE_INSTRUMENTED -DCNEARTREE_FORCEFLIP $(EXAMPLES)/CNearTreeTest.cpp $(EXAMPLES)/v.cpp $(CPPLIBRARIES) \
		  -o $@
		  
$(BIN)/CPPNearTreeTestInstNoDefer: $(INC)/TNear.h $(EXAMPLES)/CNearTreeTest.cpp $(EXAMPLES)/v.cpp $(BIN)
	$(CPPBUILD_COMMAND_LOCAL) -DCNEARTREE_INSTRUMENTED -DCNEARTREE_NODEFER $(EXAMPLES)/CNearTreeTest.cpp $(EXAMPLES)/v.cpp $(CPPLIBRARIES) \
		  -o $@

$(BIN)/CPPNearTreeTestInstNoFlip: $(INC)/TNear.h $(EXAMPLES)/CNearTreeTest.cpp $(EXAMPLES)/v.cpp $(BIN)
	$(CPPBUILD_COMMAND_LOCAL) -DCNEARTREE_INSTRUMENTED -DCNEARTREE_NOFLIP $(EXAMPLES)/CNearTreeTest.cpp $(EXAMPLES)/v.cpp $(CPPLIBRARIES) \
		      -o $@

$(BIN)/CPPNearTreeTestInstNoFlipNoDefer: $(INC)/TNear.h $(EXAMPLES)/CNearTreeTest.cpp $(EXAMPLES)/v.cpp $(BIN)
	$(CPPBUILD_COMMAND_LOCAL) -DCNEARTREE_INSTRUMENTED -DCNEARTREE_NOFLIP -DCNEARTREE_NODEFER $(EXAMPLES)/CNearTreeTest.cpp $(EXAMPLES)/v.cpp $(CPPLIBRARIES) \
		  -o $@
		  
$(BIN)/CMain: $(INC)/CNearTree.h $(EXAMPLES)/main.c $(SRC)/CNearTree.c $(BIN) $(LIB)/libCNearTree.$(LIB_EXT)
	$(BUILD_COMMAND_LOCAL) $(EXAMPLES)/main.c  $(LIB)/libCNearTree.$(LIB_EXT) $(CLIBRARIES) \
		  -o $@

$(BIN)/CNearTreeTest: $(INC)/CNearTree.h $(EXAMPLES)/CNearTreeTest.c $(SRC)/CNearTree.c $(BIN) $(LIB)/libCNearTree.$(LIB_EXT)
	$(BUILD_COMMAND_LOCAL) $(EXAMPLES)/CNearTreeTest.c $(LIB)/libCNearTree.$(LIB_EXT) $(CLIBRARIES) \
		  -o $@

$(BIN)/CNearTreeTestInst: $(INC)/CNearTree.h $(EXAMPLES)/CNearTreeTest.c $(SRC)/CNearTree.c $(BIN) $(LIB)/libCNearTree.$(LIB_EXT)
	$(BUILD_COMMAND_LOCAL) -DCNEARTREE_INSTRUMENTED $(EXAMPLES)/CNearTreeTest.c $(LIB)/libCNearTree.$(LIB_EXT) $(CLIBRARIES) \
		  -o $@


#
# Tests
#
tests:		$(LIB) $(BIN) $(BIN)/CPPMain $(BIN)/CPPMain_Flip $(BIN)/CPPNearTreeTest \
		$(BIN)/CPPNearTreeTest_2SAMP \
		$(BIN)/CPPNearTreeTest_6SAMP \
		$(BIN)/CPPNearTreeTest_8SAMP \
		$(BIN)/CPPNearTreeTestInst $(BIN)/CMain $(BIN)/CNearTreeTest \
		$(BIN)/CPPNearTreeTestInstFlip $(BIN)/CPPNearTreeTestInstNoDefer \
		$(BIN)/CPPNearTreeTestInstNoFlip $(BIN)/CPPNearTreeTestInstNoFlipNoDefer \
		$(BIN)/CNearTreeTestInst
		$(TIME) $(BIN)/CPPMain 3458923 > $(TESTDATA)/CPPMain.lst
		$(TIME) $(BIN)/CPPMain_Flip 3458923 > $(TESTDATA)/CPPMain_Flip.lst
		$(TIME) $(BIN)/CMain 3458923 > $(TESTDATA)/CMain.lst
		$(TIME) $(BIN)/CPPNearTreeTest_2SAMP
		$(TIME) $(BIN)/CPPNearTreeTest
		$(TIME) $(BIN)/CPPNearTreeTest_6SAMP
		$(TIME) $(BIN)/CPPNearTreeTest_8SAMP
		$(TIME) $(BIN)/CPPNearTreeTestInst
		$(TIME) $(BIN)/CPPNearTreeTestInstFlip
		$(TIME) $(BIN)/CPPNearTreeTestInstNoDefer
		$(TIME) $(BIN)/CPPNearTreeTestInstNoFlip
		$(TIME) $(BIN)/CNearTreeTest --debug
		$(TIME) $(BIN)/CNearTreeTestInst --debug
ifneq ($(MSYSTEM),MINGW32)
		diff -b -c $(TESTDATA)/CPPMain_orig.lst $(TESTDATA)/CPPMain.lst
		diff -b -c $(TESTDATA)/CPPMain_orig.lst $(TESTDATA)/CPPMain_Flip.lst
		diff -b -c $(TESTDATA)/CMain_orig.lst $(TESTDATA)/CMain.lst
else
		diff -b -c $(TESTDATA)/CPPMain_MINGW_orig.lst $(TESTDATA)/CPPMain.lst
		diff -b -c $(TESTDATA)/CPPMain_MINGW_orig.lst $(TESTDATA)/CPPMain_Flip.lst
		diff -b -c $(TESTDATA)/CMain_MINGW_orig.lst $(TESTDATA)/CMain.lst
endif
		
#
# Remove all non-source files
#
empty:
		  @-rm -rf $(LIB)
		  @-rm -rf $(BIN)
		  
#
# Remove temporary files
#
clean:
	@-rm -f core 
	@-rm -f *.o
	@-rm -f *.$(OBJ_EXT)
	@-rm -f *.c.*
	@-rm -rf .libs
	@-rm CMain.lst
	@-rm CPPMain.lst

#
# Restore to distribution state
#
distclean:	clean empty