Makefile 3.52 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
# -*- Mode: Makefile -*-

.DEFAULT_GOAL=build
TOKUROOT=../
INCLUDEDIRS=-I$(TOKUROOT)newbrt -I./lock_tree -I./range_tree
DEPEND_COMPILE += \
	ydb-internal.h \
	$(TOKUROOT)include/db.h \
	$(TOKUROOT)newbrt/cachetable.h \
	$(TOKUROOT)newbrt/brt.h \
	$(TOKUROOT)newbrt/log.c \
#End of line
ydbtrace.o tdbtrace.o: tdbtrace.h
14 15
include $(TOKUROOT)toku_include/Makefile.include
CPPFLAGS+=-D_GNU_SOURCE -D_THREAD_SAFE
16 17

YDB=ydb.$(AEXT)
Yoni Fogel's avatar
Yoni Fogel committed
18
YDB_BUNDLE=ydb.bundle
19
TYDB=tydb.$(AEXT)
Yoni Fogel's avatar
Yoni Fogel committed
20
TYDB_BUNDLE=tydb.bundle
21

22
LIBNAME=libtokudb
23
TLIBNAME=libtokudbtrace
Bradley C. Kuszmaul's avatar
up  
Bradley C. Kuszmaul committed
24

25 26 27 28 29 30 31 32
LIBRARY=$(LIBNAME).$(SOEXT)
TLIBRARY=$(TLIBNAME).$(SOEXT)
LIBRARY_S=$(LIBNAME).$(AEXT)
TLIBRARY_S=$(TLIBNAME).$(AEXT)
OBJS_RAW = \
	ydb_lib \
	ydb \
	errors \
Yoni Fogel's avatar
Yoni Fogel committed
33
	dlmalloc \
34 35 36
	elocks \
#\end
#OBJS automatically defined.
Rich Prohaska's avatar
Rich Prohaska committed
37

38 39 40 41 42 43
LIBRARIES= \
	$(LIBRARY) \
	$(TLIBRARY) \
	$(LIBRARY_S) \
	$(TLIBRARY_S) \
#Purposely here for \ at end of prev
44

45 46 47 48 49 50 51 52 53 54
INSTALL_LIBRARIES= $(patsubst %,%.install,$(LIBRARIES))

.PHONY:install_libs install.% build install local build_tests

#Half Build Half Install???
build: local build_tests ;

local: buildlocktrees libs install_libs ;

build_tests: | local
55
	cd tests && $(MAKE) build
56

57

58
TOBJS= tdbtrace.$(OEXT) $(patsubst ydb.$(OEXT),ydbtrace.$(OEXT),$(OBJS))
59

60

61 62
install_libs: $(INSTALL_LIBRARIES)
%.install: %
63
	if ! diff $* ../lib/$* > /dev/null 2>&1; then cp $* ../lib/; fi
64

65
.PHONY: install
66
install: libs install_libs ;
Rich Prohaska's avatar
Rich Prohaska committed
67

68 69
.PHONY: local libs buildlocktrees
libs: $(LIBRARIES) ;
Yoni Fogel's avatar
Yoni Fogel committed
70 71 72 73 74
$(LIBRARIES): export.def
export.def: export.map
	echo "EXPORTS" > $@
	cat export.map |sed -n "s/\([a-zA-Z_0-9][a-zA-Z_0-9]*\);/\t\1 @/g;/@/ P" |sed -n 'P;=' | sed '{;N;s/\n//;}' >> $@
	echo "" >> $@
75

76
buildlocktrees: $(LOCKTREE) $(RANGETREE) ;
77

78
$(OBJS) $(TOBJS): CPPFLAGS+=-I$(TOKUROOT)include
79 80
$(YDB):  $(OBJS) 
$(TYDB): $(TOBJS)
81

Bradley C. Kuszmaul's avatar
up  
Bradley C. Kuszmaul committed
82

83 84
$(LIBRARY):  $(YDB)  $(LOCKTREE) $(RANGETREE) $(NEWBRT) $(DEPEND_COMPILE) $(DEPEND_LINK) 
$(TLIBRARY): $(TYDB) $(LOCKTREE) $(RANGETREE) $(NEWBRT) $(DEPEND_COMPILE) $(DEPEND_LINK)
Yoni Fogel's avatar
Yoni Fogel committed
85

86 87
$(LIBRARY):  LINK_FILES=ydb_lib.$(OEXT) $(YDB)  $(LOCKTREE) $(RANGETREE) $(NEWBRT)
$(TLIBRARY): LINK_FILES=$(TYDB) $(LOCKTREE) $(RANGETREE) $(NEWBRT)
Bradley C. Kuszmaul's avatar
up  
Bradley C. Kuszmaul committed
88

89 90
#Skip all BDB tests for CYGWIN+ICC
ifeq ($(CYGWIN),)
Bradley C. Kuszmaul's avatar
Bradley C. Kuszmaul committed
91 92
$(LIBRARY_S):  $(patsubst %.$(AEXT),%.bundle, $(YDB) $(LOCKTREE) $(RANGETREE) $(NEWBRT) $(LIBPORTABILITY))
$(TLIBRARY_S): $(TYDB) $(LOCKTREE) $(RANGETREE) $(NEWBRT_BUNDLE) $(LIBPORTABILITY)
93 94 95 96 97 98 99 100 101
else ifneq ($(CC),icc)
$(LIBRARY_S):  $(YDB)  $(LOCKTREE) $(RANGETREE) $(NEWBRT) $(LIBPORTABILITY)
$(TLIBRARY_S): $(TYDB) $(LOCKTREE) $(RANGETREE) $(NEWBRT) $(LIBPORTABILITY)
else
$(LIBRARY_S):  $(LIBRARY)  ;
$(TLIBRARY_S): $(TLIBRARY) ;
#$(LIBRARY_S):  $(YDB)  $(LOCKTREE) $(RANGETREE) $(NEWBRT) $(LIBPORTABILITY)
#$(TLIBRARY_S): $(TYDB) $(LOCKTREE) $(RANGETREE) $(NEWBRT) $(LIBPORTABILITY)
endif
102

103
static_libtokudb.lib: $(YDB) $(LOCKTREE) $(RANGETREE) $(NEWBRT) $(LIBPORTABILITY)
104 105
	xilib /out:$@ $^

Yoni Fogel's avatar
Yoni Fogel committed
106 107
ipo_libtokudb.obj: $(YDB_BUNDLE) $(LOCKTREE_BUNDLE) $(RANGETREE_BUNDLE) $(NEWBRT_BUNDLE) $(LIBPORTABILITY_BUNDLE)
	$(CC) $(CFLAGS) $(CPPFLAGS) -Qipo-c $(filter %.$(OEXT),$^) $(patsubst %.bundle, %.bundle/*.$(OEXT), $(filter-out %.$(OEXT),$^))
108 109 110 111
	mv ipo_out.obj $@

ipo_libtokudb.lib: ipo_libtokudb.obj
	xilib /out:$@ $^
Bradley C. Kuszmaul's avatar
up  
Bradley C. Kuszmaul committed
112

Yoni Fogel's avatar
Yoni Fogel committed
113

Bradley C. Kuszmaul's avatar
Bradley C. Kuszmaul committed
114
check_globals: $(LIBNAME).$(SOEXT)
115
	python tokuglobals.py $<
Bradley C. Kuszmaul's avatar
up  
Bradley C. Kuszmaul committed
116

117 118
.PHONY: check_tests
check_tests: build_tests
119
	cd tests && $(MAKE) check
120

121 122 123 124 125
.PHONY: check
check: local check_globals check_tests

.PHONY: strip
strip: $(LIBRARY)
126
	strip $<
127 128

clean:
129 130 131
	cd tests && $(MAKE) clean
	cd lock_tree && $(MAKE) clean
	cd range_tree && $(MAKE) clean
132

133
ydbtrace.$(OEXT): CPPFLAGS+=-DTOKUTRACE
134
ydbtrace.$(OEXT): ydb.c $(DEPEND_COMPILE)
135
	$(CC) -c $< $(CPPFLAGS) $(CFLAGS) $(OOUTPUT)$@
136