1# NOTE: this makefile contains two parts:
2#  1. for compilation on VxWorks in the RAID's environment.
3#  2. for compilation on Linux.
4#
5# to compile on VxWorks - define an environemnt variable named 'VXWORKS', set
6#   to a non-empty string.
7
8ifneq ($(VXWORKS),)
9
10##########################################################33
11##### Makefile rules for working on VxWorks
12
13COMPONENT = fastdb
14#MAKE_DL_FILE = yes
15MAKE_DL_FILE = no
16FLASH_MODULE_NAME = FASTDB
17IS_MODULE = yes
18IS_MODULE_TEST = yes
19
20CPPSRC = src/class.cpp src/compiler.cpp src/database.cpp src/xml.cpp src/hashtab.cpp src/file.cpp src/symtab.cpp src/\
21         src/ttree.cpp src/rtree.cpp src/container.cpp src/cursor.cpp src/query.cpp src/wwwapi.cpp  \
22         src/unisock.cpp src/sync.cpp src/localcli.cpp src/stdtp.cpp src/fastdbShim.cpp
23
24FASTDBCPPOBJ=$(addsuffix .o, $(basename $(CPPSRC)))
25
26CLEANUP += $(FASTDBCPPOBJ)
27
28DEFS += LSI_CONTROLLER_FIRMWARE
29
30# Include make configuration and rules from base directory
31-include .config
32
33FAULT_TOLERANT=0
34
35# from here on are parts of the original makefile to be sorted
36
37VERSION=2
38
39else
40
41##########################################################33
42##### Makefile rules for working on Linux
43
44# -*- makefile -*-
45# Makefile for Generic Unix with GCC compiler
46
47FAULT_TOLERANT=0
48
49# Default install directory
50PREFIX ?= /usr/local
51
52# Place where to copy GastDB header files
53INCSPATH=$(PREFIX)/include/fastdb
54
55#Place where to copy Fastdb library
56LIBSPATH=$(PREFIX)/lib
57
58#Place where to copy Fastdb subsql utility
59BINSPATH=$(PREFIX)/bin
60
61ifdef NO_PTHREADS
62OBJS = class.o compiler.o database.o xml.o hashtab.o file.o symtab.o ttree.o rtree.o container.o \
63	cursor.o query.o wwwapi.o unisock.o sync.o localcli.o stdtp.o
64else
65OBJS = class.o compiler.o database.o xml.o hashtab.o file.o symtab.o ttree.o rtree.o container.o \
66	cursor.o query.o wwwapi.o unisock.o sync.o localcli.o stdtp.o server.o
67endif
68
69CLI_OBJS = cli.o unisock.o repsock.o stdtp.o
70
71INCS = inc/fastdb.h inc/stdtp.h inc/config.h inc/class.h inc/database.h inc/cursor.h inc/reference.h inc/wwwapi.h \
72	inc/cli.h inc/array.h inc/file.h inc/hashtab.h inc/ttree.h inc/rtree.h inc/container.h inc/sync.h inc/sync_unix.h \
73	inc/query.h inc/datetime.h inc/harray.h inc/rectangle.h inc/timeseries.h inc/exception.h
74
75#
76# threads settings - please comment this lines for single-threaded libs
77#
78ifdef NO_PTHREADS
79TFLAGS=-DNO_PTHREADS
80THRLIBS=
81SUFF=
82else
83TFLAGS=-pthread
84THRLIBS=-lpthread
85SUFF=_r
86endif
87
88STDLIBS =  -lm  $(THRLIBS)
89SOCKLIBS =
90
91VERSION=2
92FASTDB_LIB = libfastdb$(SUFF).a
93FASTDB_SHARED = libfastdb$(SUFF).so.${VERSION}
94CLI_LIB = libcli$(SUFF).a
95JNI_LIB = libjnicli$(SUFF).so.${VERSION}
96CLI_SHARED = libcli$(SUFF).so.${VERSION}
97
98EXES = subsql forcerecovery cleanupsem
99#FASTDB_LIBS=-L. -lfastdb$(SUFF)
100#CLI_LIBS=-L. -lcli$(SUFF)
101
102ifndef ARCH
103ARCH=$(shell uname | tr 'A-Z' 'a-z')
104endif # ndef ARCH
105
106FASTDB_LIBS=-L. -lfastdb$(SUFF) -L$(PROJ_HOME)/bin_$(ARCH) -lsvmlib -L${PROJ_HOME}/../ACE_wrappers/ace -lACE -lz
107CLI_LIBS=-L. -lcli$(SUFF)
108
109EXAMPLES = guess testdb testleak testfrag testjoin testperf testpar testindex testfuzzy testsync testconc testiref testtrav testidx clitest clitest2 testrect testalter testraw localclitest testharr testspat testtl
110# testddl
111
112WEB_EXAMPLES = cgistub bugdb clidb
113
114CC = g++
115
116# DEFS macro is deprecatred, edit config.h file instead
117DEFS =
118
119#CFLAGS = $(TFLAGS) -Iinc -c -Wall -O5 -g  -fPIC $(DEFS)
120CFLAGS = -c -Iinc -I../H -I../SvmLib -Wall -O0 -g -fPIC $(DEFS) $(TFLAGS) -DUNIX -DZIP_STD -D_XOPEN_SOURCE=600 -D_DEBUG -I${PROJ_HOME}/../ACE_wrappers -I${PROJ_HOME}/../ACE_wrappers/objdir -DNO_MMAP=1
121#CFLAGS = -c -Iinc -Wall -O0 -fPIC -DFASTDB_DEBUG=DEBUG_TRACE -g $(DEFS) $(TFLAGS)
122
123#SHFLAGS=-shared -Wl,-soname,$@
124SHFLAGS=-shared
125
126
127LD = $(CC)
128LDFLAGS = -g $(TFLAGS)
129
130AR = ar
131ARFLAGS = -cru
132RANLIB = true
133
134ifneq (0,$(FAULT_TOLERANT))
135STDLIBS +=  $(SOCKLIBS)
136DEFS += -DREPLICATION_SUPPORT
137endif
138
139
140all: static shared bins
141
142static: $(FASTDB_LIB) $(CLI_LIB)
143
144shared: $(FASTDB_SHARED) $(CLI_SHARED)
145
146bins: $(EXES) $(EXAMPLES)
147
148www: $(FASTDB_SHARED) $(WEB_EXAMPLES)
149
150
151class.o: src/class.cpp inc/compiler.h inc/compiler.d inc/symtab.h $(INCS)
152	$(CC) $(CFLAGS) src/class.cpp
153
154compiler.o: src/compiler.cpp inc/compiler.h inc/compiler.d inc/symtab.h $(INCS)
155	$(CC) $(CFLAGS) src/compiler.cpp
156
157query.o: src/query.cpp inc/compiler.h inc/compiler.d inc/symtab.h $(INCS)
158	$(CC) $(CFLAGS) src/query.cpp
159
160database.o: src/database.cpp inc/compiler.h inc/compiler.d inc/symtab.h $(INCS)
161	$(CC) $(CFLAGS) src/database.cpp
162
163xml.o: src/xml.cpp inc/compiler.h inc/compiler.d inc/symtab.h $(INCS)
164	$(CC) $(CFLAGS) src/xml.cpp
165
166localcli.o: src/localcli.cpp inc/compiler.h inc/compiler.d inc/symtab.h inc/localcli.h $(INCS)
167	$(CC) $(CFLAGS) src/localcli.cpp
168
169cursor.o: src/cursor.cpp inc/compiler.h inc/compiler.d $(INCS)
170	$(CC) $(CFLAGS) src/cursor.cpp
171
172hashtab.o: src/hashtab.cpp $(INCS)
173	$(CC) $(CFLAGS) src/hashtab.cpp
174
175file.o: src/file.cpp $(INCS)
176	$(CC) $(CFLAGS) src/file.cpp
177
178stdtp.o: src/stdtp.cpp $(INCS)
179	$(CC) $(CFLAGS) src/stdtp.cpp
180
181sync.o: src/sync.cpp $(INCS)
182	$(CC) $(CFLAGS) src/sync.cpp
183
184symtab.o: src/symtab.cpp inc/symtab.h $(INCS)
185	$(CC) $(CFLAGS) src/symtab.cpp
186
187ttree.o: src/ttree.cpp $(INCS)
188	$(CC) $(CFLAGS) src/ttree.cpp
189
190rtree.o: src/rtree.cpp $(INCS)
191	$(CC) $(CFLAGS) src/rtree.cpp
192
193container.o: src/container.cpp $(INCS)
194	$(CC) $(CFLAGS) src/container.cpp
195
196wwwapi.o: src/wwwapi.cpp inc/wwwapi.h inc/sockio.h inc/stdtp.h inc/sync.h inc/config.h inc/sync_unix.h
197	$(CC) $(CFLAGS) src/wwwapi.cpp
198
199unisock.o: src/unisock.cpp inc/unisock.h inc/sockio.h inc/stdtp.h
200	$(CC) $(CFLAGS) src/unisock.cpp
201
202repsock.o: src/repsock.cpp inc/unisock.h inc/sockio.h inc/stdtp.h inc/sync.h inc/sync_unix.h inc/config.h
203	$(CC) $(CFLAGS) src/repsock.cpp
204
205cli.o: src/cli.cpp inc/cli.h inc/cliproto.h
206	$(CC) $(CFLAGS) src/cli.cpp
207
208$(FASTDB_LIB): $(OBJS)
209	rm -f $(FASTDB_LIB)
210	$(AR) $(ARFLAGS) $(FASTDB_LIB) $(OBJS)
211	$(RANLIB) $(FASTDB_LIB)
212
213$(FASTDB_SHARED): $(OBJS)
214	rm -f $(FASTDB_SHARED)
215	$(CC) $(SHFLAGS) -o $(FASTDB_SHARED) $(OBJS) $(THRLIBS)
216	ln -f -s $(FASTDB_SHARED) libfastdb$(SUFF).so
217
218$(CLI_LIB): $(CLI_OBJS)
219	rm -f $(CLI_LIB)
220	$(AR) $(ARFLAGS) $(CLI_LIB) $(CLI_OBJS)
221	$(RANLIB) $(CLI_LIB)
222
223$(CLI_SHARED): $(CLI_OBJS)
224	rm -f $(CLI_SHARED)
225	$(CC) $(SHFLAGS) -o  $(CLI_SHARED) $(CLI_OBJS) $(THRLIBS)
226	ln -f -s $(CLI_SHARED) libcli$(SUFF).so
227
228
229clitest.o: examples/clitest.c inc/cli.h
230	$(CC) $(CFLAGS) examples/clitest.c
231
232clitest: clitest.o $(CLI_LIB)
233	$(LD) $(LDFLAGS) -o clitest clitest.o $(CLI_LIBS) $(STDLIBS) $(SOCKLIBS)
234
235clitest2.o: examples/clitest2.c inc/cli.h
236	$(CC) $(CFLAGS) examples/clitest2.c
237
238clitest2: clitest2.o $(FASTDB_LIB)
239	$(LD) $(LDFLAGS) -o clitest2 clitest2.o $(FASTDB_LIBS) $(STDLIBS)
240
241testalter.o: examples/testalter.c inc/cli.h
242	$(CC) $(CFLAGS) examples/testalter.c
243
244testalter: testalter.o $(FASTDB_LIB)
245	$(LD) $(LDFLAGS) -o testalter testalter.o $(FASTDB_LIBS) $(STDLIBS)
246
247localclitest: clitest.o $(FASTDB_LIB)
248	$(LD) $(LDFLAGS) -o localclitest clitest.o $(FASTDB_LIBS) $(STDLIBS)
249
250testrect.o: examples/testrect.c inc/cli.h
251	$(CC) $(CFLAGS) examples/testrect.c
252
253testrect: testrect.o $(FASTDB_LIB)
254	$(LD) $(LDFLAGS) -o testrect testrect.o $(FASTDB_LIBS) $(STDLIBS)
255
256subsql.o: src/subsql.cpp inc/subsql.h inc/compiler.h inc/compiler.d inc/symtab.h $(INCS)
257	$(CC) $(CFLAGS) src/subsql.cpp
258
259server.o: src/server.cpp inc/server.h inc/cli.h inc/cliproto.h inc/subsql.h inc/compiler.h inc/compiler.d inc/symtab.h $(INCS)
260	$(CC) $(CFLAGS) src/server.cpp
261
262subsql: subsql.o $(FASTDB_LIB)
263	$(LD) $(LDFLAGS) -o subsql subsql.o $(FASTDB_LIBS) $(STDLIBS) $(SOCKLIBS)
264
265bugdb.o: examples/bugdb.cpp examples/bugdb.h $(INCS)
266	$(CC) $(CFLAGS) examples/bugdb.cpp
267
268bugdb: bugdb.o  $(FASTDB_LIB)
269	$(LD) $(LDFLAGS) -o bugdb bugdb.o $(FASTDB_LIBS) $(STDLIBS) $(SOCKLIBS)
270
271clidb.o: examples/clidb.cpp examples/clidb.h $(INCS)
272	$(CC) $(CFLAGS) examples/clidb.cpp
273
274clidb: clidb.o  $(FASTDB_LIB)
275	$(LD) $(LDFLAGS) -o clidb clidb.o $(FASTDB_LIBS) $(STDLIBS) $(SOCKLIBS)
276
277cgistub.o: src/cgistub.cpp inc/stdtp.h inc/sockio.h
278	$(CC) $(CFLAGS) src/cgistub.cpp
279
280cgistub: cgistub.o
281	$(LD) $(LDFLAGS) -o cgistub cgistub.o $(FASTDB_LIBS) $(STDLIBS) $(SOCKLIBS)
282
283
284forcerecovery.o: src/forcerecovery.cpp inc/database.h
285	$(CC) $(CFLAGS) src/forcerecovery.cpp
286
287forcerecovery: forcerecovery.o
288	$(LD) $(LDFLAGS)  -o forcerecovery forcerecovery.o
289
290cleanupsem.o: src/cleanupsem.cpp inc/database.h
291	$(CC) $(CFLAGS) src/cleanupsem.cpp
292
293cleanupsem: cleanupsem.o
294	$(LD) $(LDFLAGS)  -o cleanupsem cleanupsem.o
295
296
297guess.o: examples/guess.cpp $(INCS)
298	$(CC) $(CFLAGS) examples/guess.cpp
299
300guess: guess.o $(FASTDB_LIB)
301	$(LD) $(LDFLAGS) -o guess guess.o $(FASTDB_LIBS) $(STDLIBS)
302
303testharr.o: examples/testharr.cpp $(INCS)
304	$(CC) $(CFLAGS) examples/testharr.cpp
305
306testharr: testharr.o $(FASTDB_LIB)
307	$(LD) $(LDFLAGS) -o testharr testharr.o $(FASTDB_LIBS) $(STDLIBS)
308
309testdb.o: examples/testdb.cpp $(INCS)
310	$(CC) $(CFLAGS) examples/testdb.cpp
311
312testdb: testdb.o $(FASTDB_LIB)
313	$(LD) $(LDFLAGS) -o testdb testdb.o $(FASTDB_LIBS) $(STDLIBS)
314
315testraw.o: examples/testraw.cpp $(INCS)
316	$(CC) $(CFLAGS) examples/testraw.cpp
317
318testraw: testraw.o $(FASTDB_LIB)
319	$(LD) $(LDFLAGS) -o testraw testraw.o $(FASTDB_LIBS) $(STDLIBS)
320
321testleak.o: examples/testleak.cpp $(INCS)
322	$(CC) $(CFLAGS) examples/testleak.cpp
323
324testleak: testleak.o $(FASTDB_LIB)
325	$(LD) $(LDFLAGS) -o testleak testleak.o $(FASTDB_LIBS) $(STDLIBS)
326
327testfrag.o: examples/testfrag.cpp $(INCS)
328	$(CC) $(CFLAGS) examples/testfrag.cpp
329
330testfrag: testfrag.o $(FASTDB_LIB)
331	$(LD) $(LDFLAGS) -o testfrag testfrag.o $(FASTDB_LIBS) $(STDLIBS)
332
333testjoin.o: examples/testjoin.cpp $(INCS)
334	$(CC) $(CFLAGS) examples/testjoin.cpp
335
336testjoin: testjoin.o $(FASTDB_LIB)
337	$(LD) $(LDFLAGS) -o testjoin testjoin.o $(FASTDB_LIBS) $(STDLIBS)
338
339testddl.o: examples/testddl.cpp $(INCS)
340	$(CC) $(CFLAGS) examples/testddl.cpp
341
342testddl: testddl.o $(FASTDB_LIB)
343	$(LD) $(LDFLAGS) -o testddl testddl.o $(FASTDB_LIBS) $(STDLIBS)
344
345testperf.o: examples/testperf.cpp $(INCS)
346	$(CC) $(CFLAGS) examples/testperf.cpp
347
348testperf: testperf.o $(FASTDB_LIB)
349	$(LD) $(LDFLAGS) -o testperf testperf.o $(FASTDB_LIBS) $(STDLIBS)
350
351testpar.o: examples/testpar.cpp $(INCS)
352	$(CC) $(CFLAGS) examples/testpar.cpp
353
354testpar: testpar.o $(FASTDB_LIB)
355	$(LD) $(LDFLAGS) -o testpar testpar.o $(FASTDB_LIBS) $(STDLIBS)
356
357testindex.o: examples/testindex.cpp $(INCS)
358	$(CC) $(CFLAGS) examples/testindex.cpp
359
360testindex: testindex.o $(FASTDB_LIB)
361	$(LD) $(LDFLAGS) -o testindex testindex.o $(FASTDB_LIBS) $(STDLIBS)
362
363testspat.o: examples/testspat.cpp $(INCS)
364	$(CC) $(CFLAGS) examples/testspat.cpp
365
366testspat: testspat.o $(FASTDB_LIB)
367	$(LD) $(LDFLAGS) -o testspat testspat.o $(FASTDB_LIBS) $(STDLIBS)
368
369testfuzzy.o: examples/testfuzzy.cpp $(INCS)
370	$(CC) $(CFLAGS) examples/testfuzzy.cpp
371
372testfuzzy: testfuzzy.o $(FASTDB_LIB)
373	$(LD) $(LDFLAGS) -o testfuzzy testfuzzy.o $(FASTDB_LIBS) $(STDLIBS)
374
375testidx.o: examples/testidx.cpp $(INCS)
376	$(CC) $(CFLAGS) examples/testidx.cpp
377
378testidx: testidx.o $(FASTDB_LIB)
379	$(LD) $(LDFLAGS) -o testidx testidx.o $(FASTDB_LIBS) $(STDLIBS)
380
381testtl.o: examples/testtl.cpp $(INCS)
382	$(CC) $(CFLAGS) examples/testtl.cpp
383
384testtl: testtl.o $(FASTDB_LIB)
385	$(LD) $(LDFLAGS) -o testtl testtl.o $(FASTDB_LIBS) $(STDLIBS)
386
387testsync.o: examples/testsync.cpp $(INCS)
388	$(CC) $(CFLAGS) examples/testsync.cpp
389
390testsync: testsync.o $(FASTDB_LIB)
391	$(LD) $(LDFLAGS) -o testsync testsync.o $(FASTDB_LIBS) $(STDLIBS)
392
393testconc.o: examples/testconc.cpp $(INCS)
394	$(CC) $(CFLAGS) examples/testconc.cpp
395
396testconc: testconc.o $(FASTDB_LIB)
397	$(LD) $(LDFLAGS) -o testconc testconc.o $(FASTDB_LIBS) $(STDLIBS)
398
399testreplic.o: examples/testreplic.cpp $(INCS)
400	$(CC) $(CFLAGS) examples/testreplic.cpp
401
402testreplic: testreplic.o $(FASTDB_LIB)
403	$(LD) $(LDFLAGS) -o testreplic testreplic.o $(FASTDB_LIBS) $(STDLIBS)
404
405testiref.o: examples/testiref.cpp $(INCS)
406	$(CC) $(CFLAGS) examples/testiref.cpp
407
408testiref: testiref.o $(FASTDB_LIB)
409	$(LD) $(LDFLAGS) -o testiref testiref.o $(FASTDB_LIBS) $(STDLIBS)
410
411testtrav.o: examples/testtrav.cpp $(INCS)
412	$(CC) $(CFLAGS) examples/testtrav.cpp
413
414testtrav: testtrav.o $(FASTDB_LIB)
415	$(LD) $(LDFLAGS) -o testtrav testtrav.o $(FASTDB_LIBS) $(STDLIBS)
416
417
418java: jnicli.jar $(JNI_LIB) examples/JniTestIndex.class
419
420jnicli.o: jnicli/jnicli.cpp
421	$(CC) $(CFLAGS) -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux -I. jnicli/jnicli.cpp
422
423$(JNI_LIB): jnicli.o $(GB_LIB)
424	$(CC) $(SHFLAGS) -o $(JNI_LIB) jnicli.o $(FASTDB_LIB)
425	ln -f -s $(JNI_LIB) libjnicli.so
426
427jnicli.jar: jnicli/*.java
428	javac -g jnicli/*.java
429	jar cvf jnicli.jar jnicli/*.class
430	javadoc -d jnicli/docs -public jnicli/*.java
431
432examples/JniTestIndex.class: examples/JniTestIndex.java jnicli.jar
433	javac -classpath jnicli.jar examples/JniTestIndex.java
434
435install: subsql cleanupsem installlib
436	mkdir -p $(BINSPATH)
437	cp subsql $(BINSPATH)
438	strip $(BINSPATH)/subsql
439	cp cleanupsem $(BINSPATH)
440	strip $(BINSPATH)/cleanupsem
441
442installlib: $(FASTDB_LIB) $(CLI_LIB) $(FASTDB_SHARED) $(CLI_SHARED)
443	mkdir -p $(INCSPATH)
444	cp $(INCS) $(INCSPATH)
445	mkdir -p $(LIBSPATH)
446	cp $(FASTDB_LIB) $(CLI_LIB) $(FASTDB_SHARED) $(CLI_SHARED) $(LIBSPATH)
447	(cd $(LIBSPATH) && ln -f -s $(FASTDB_SHARED) libfastdb$(SUFF).so \
448	 && ln -f -s $(CLI_SHARED) libcli$(SUFF).so)
449	if [ -f $(JNI_LIB) ]; then cp $(JNI_LIB) $(LIBSPATH); \
450	  cd $(LIBSPATH) && ln -f -s $(JNI_LIB) libjnicli.so; fi
451
452uninstall:
453	rm -fr $(INCSPATH)
454	cd $(LIBSPATH); rm -f $(FASTDB_LIB) $(CLI_LIB) $(FASTDB_SHARED) $(CLI_SHARED) $(JNI_LIB) libfastdb$(SUFF).so libjnicli.so libcli$(SUFF).so
455	rm $(BINSPATH)/subsql
456
457cleanobj:
458	rm -fr *.o *.tgz jnicli/*.class core *~ cxx_repository
459
460cleandbs:
461	rm -f *.fdb
462
463
464clean: cleanobj cleandbs
465	rm -f *.a *.so *.so.* $(EXAMPLES) $(WEB_EXAMPLES) $(EXES)
466
467tgz:	clean
468	cd ..; tar cvzf fastdb.tgz fastdb
469
470copytgz: tgz
471	mcopy -o ../fastdb.tgz a:
472endif
473### endif of which environment we compile for.
474