2013-04-16 23:57:27 -04:00
# -*- Mode: Makefile -*-
# TODO: Find a way to point out directories (i.e. current dir, or root dir)
# TODO: Find the names of the icc windows library includes.. i.e. dlls/etc.
# TODO: Find icc equivalents for W64 (warn about 32 vs 64 bit incompatibility
# TODO: Add (linux) icc warning about windows porting issues.
# TODO: There is an icc option for short 1-liner diagnostics.. see if there is
# an opposite! (i.e. long diagnostics which maybe will give us a stack trace
# for warnings)
# TODO: Learn how the hell to use idb.
#
# Default include makefile.
# Before (or after?) including this makefile, define the following variables
# INCLUDES = -I $(TOKUROOT)/.. -I . -I $(TOKUROOT)/... #Whatever include directories
# List of directories to include for search paths.
# TOKUROOT = absolute path of the root of this branch.
# TODO: find alternative way to do this.
# BINS = base names for bins
# SUBDIRS = Subdirs to make/clean
#
# On cygwin do:
# make CYGWIN=cygwin check
#
# For default=debug (no optimization) do
# make DEBUG=1
# For verbose output do
# make VERBOSE=1
# For very verbose output do
# make VERBOSE=2
# For CIL do
# make CIL=1
# For coverage do
# make GCOV=1
# For profiling do
# make PROF=1
# To make warnings be warnngs instead of errors do
# make WERROR=
2013-04-16 23:57:30 -04:00
ifeq ($(DEBUG),)
DEBUG = 0
endif
2013-04-16 23:57:30 -04:00
2013-04-16 23:57:42 -04:00
ifeq ($(VTUNE),1)
LINK_MUST_BE_LAST = /link /fixed:no
else
LINK_MUST_BE_LAST =
endif
2013-04-16 23:57:27 -04:00
.DELETE_ON_ERROR:
ifneq ($(GCOV),)
2013-04-16 23:57:48 -04:00
GCOV_FLAGS = -fprofile-arcs -ftest-coverage -DGCOV
2013-04-16 23:57:27 -04:00
endif
ifneq ($(PROF),)
PROF_FLAGS = -pg
endif
OPT_OPTFLAGS = -O3 -finline-functions
DBG_OPTFLAGS = -O0
2013-04-16 23:57:54 -04:00
SYSTEM = $(shell uname -s | tr [:upper:] [:lower:])
2013-04-16 23:58:04 -04:00
ARCH = $(shell uname -m | tr [:upper:] [:lower:])
2013-04-16 23:57:53 -04:00
2013-04-16 23:57:27 -04:00
ifeq ($(VERBOSE),2)
VERBVERBOSE=-v
MAYBEATSIGN=
else ifeq ($(VERBOSE),1)
2013-04-16 23:57:46 -04:00
VERBVERBOSE=
2013-04-16 23:57:27 -04:00
MAYBEATSIGN=
else
VERBVERBOSE=-q
MAYBEATSIGN=@
endif
2013-04-16 23:57:37 -04:00
CPPFLAGS = $(INCLUDEDIRS) -I$(PORTABILITY_HEADERS) -I$(TOKUROOT)toku_include
2013-04-16 23:57:53 -04:00
ifeq ($(SYSTEM),freebsd)
CPPFLAGS += -DTOKU_ALLOW_DEPRECATED
endif
2013-04-16 23:57:54 -04:00
ifeq ($(SYSTEM),sunos)
CPPFLAGS += -DTOKU_ALLOW_DEPRECATED
endif
2013-04-16 23:57:53 -04:00
2013-04-16 23:59:36 -04:00
ifeq ($(TOKUDB_REVISION),)
TOKUDB_REVISION = 0
endif
CPPFLAGS += -DTOKUDB_REVISION=$(TOKUDB_REVISION)
2013-04-16 23:57:27 -04:00
#CFLAG default options
# Add -Wconversion #DISABLED for now.
2013-04-16 23:57:53 -04:00
ifeq ($(SYSTEM),freebsd)
WERROR =
else
2013-04-16 23:57:27 -04:00
WERROR = -Werror
2013-04-16 23:57:53 -04:00
endif
2013-04-16 23:58:59 -04:00
2013-04-16 23:59:40 -04:00
ifeq ($(GCCVERSION),)
GCCVERSION = $(shell $(CC) --version | head -1 | cut -f3 -d " ")
endif
2013-04-16 23:59:36 -04:00
# -Wno-deprecated is needed on gcc 4.4.{0,1,2,4} to make the #ident complaints go away.
# -Wno-strict-aliasing is needed on gcc 4.4.{1,2,4} to make certain gratuitous warnings go away.
2013-04-16 23:59:21 -04:00
# -Wno-unused-result is needed on gcc 4.4.1 to make warnings about ignoring the results of certain system calls go away.
2013-04-16 23:59:34 -04:00
# Gcc 4.4.1-4ubuntu9 cannot handle --combine, but 4.4.4 can. But 4.5 cannot.
2013-04-16 23:59:36 -04:00
ifeq ($(GCCVERSION),4.4.4)
GCC_VERSION_SPECIFIC = -Wno-deprecated
else ifeq ($(GCCVERSION),4.4.2)
2013-04-16 23:58:57 -04:00
GCC_VERSION_SPECIFIC = -Wno-deprecated
2013-04-16 23:59:07 -04:00
else ifeq ($(GCCVERSION),4.4.1)
2013-04-16 23:59:21 -04:00
GCC_VERSION_SPECIFIC = -Wno-deprecated -Wno-unused-result
2013-04-16 23:59:34 -04:00
COMBINE := 0
2013-04-16 23:59:36 -04:00
else ifeq ($(GCCVERSION),4.4.0)
GCC_VERSION_SPECIFIC = -Wno-deprecated
2013-04-16 23:59:07 -04:00
endif
2013-04-16 23:59:07 -04:00
2013-04-16 23:58:57 -04:00
WALL = $(GCC_VERSION_SPECIFIC) -Wall -Wextra -Wcast-align -Wbad-function-cast -Wno-missing-noreturn -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations
2013-04-16 23:57:27 -04:00
2013-04-16 23:57:59 -04:00
FORMAT = -Wmissing-format-attribute #-Wformat=2 #Stronger printf warnings once logger.c cleaned up
2013-04-16 23:57:54 -04:00
ifeq ($(SYSTEM),sunos)
VISIBILITY=
else
2013-04-16 23:57:27 -04:00
VISIBILITY= -fvisibility=hidden
2013-04-16 23:57:54 -04:00
endif
2013-04-16 23:57:27 -04:00
FPICFLAGS = -fPIC
SHADOW = -Wshadow
SYMBOLS = -g3 -ggdb3
PORTABILITY=
SKIP_WARNING=
COMBINE_C = -combine -c
2013-04-16 23:59:36 -04:00
ifeq ($(GCCVERSION),4.4.4)
CFLAGS += -Wno-strict-aliasing
else ifeq ($(GCCVERSION),4.4.2)
2013-04-16 23:58:59 -04:00
CFLAGS += -Wno-strict-aliasing
2013-04-16 23:59:07 -04:00
else ifeq ($(GCCVERSION),4.4.1)
CFLAGS += -Wno-strict-aliasing
2013-04-16 23:59:36 -04:00
else ifeq ($(GCCVERSION),4.4.0)
CFLAGS += -Wno-strict-aliasing
2013-04-16 23:58:57 -04:00
endif
2013-04-16 23:57:37 -04:00
LIBPORTABILITY = $(TOKUROOT)lib/libtokuportability.$(AEXT)
LIBPORTABILITY_BUNDLE = $(TOKUROOT)lib/libtokuportability.bundle
2013-04-16 23:57:27 -04:00
2013-04-16 23:57:53 -04:00
PORTABILITY_HEADERS= $(TOKUROOT)$(SYSTEM)
2013-04-16 23:57:33 -04:00
ALWAYS_LINK= $(LIBPORTABILITY) -lz -lpthread
2013-04-16 23:57:44 -04:00
ifeq ($(CC),icc)
ifeq ($(CYGWIN),)
ALWAYS_LINK += -static-intel
endif
endif
2013-04-16 23:57:27 -04:00
C99 = -std=c99
W64 = #-Wshorten-64-to-32
BINOUTPUT = -o
OOUTPUT = -o
AROUTPUT =#empty
BINSUF=#none
WRONGBINSUF=.exe
OEXT=o
WRONGOEXT=obj
AEXT=a
WRONGAEXT=lib
SOEXT=so
WRONGSOEXT=dll
AR=ar
2013-04-16 23:57:34 -04:00
DBG_ARFLAGS=cr
OPT_ARFLAGS=cr
2013-04-16 23:57:27 -04:00
LINK=-l
DEPEND_COMPILE += \
$(TOKUROOT)include/db.h \
2013-04-16 23:57:37 -04:00
$(TOKUROOT)toku_include/toku_os.h \
$(TOKUROOT)toku_include/toku_portability.h \
$(TOKUROOT)toku_include/rdtsc.h \
2013-04-16 23:57:27 -04:00
# keep this line so I can have a \ on the previous line
CCQUIET=
comma:=,
empty:=#
space:=$(empty) $(empty)
LINK_LPATH=$(patsubst %,-Wl$(comma)-rpath$(comma)%,$(RPATH_DIRS))
LINK_RPATH=$(patsubst %,-L%$(space),$(RPATH_DIRS))
DLINK_FILES_PREPROCESS_1=$(patsubst %.$(SOEXT),%,$(DLINK_FILES))
DLINK_FILES_PREPROCESS_2=$(patsubst lib%,%,$(notdir $(DLINK_FILES_PREPROCESS_1)))
LINK_DLINK_FILES=$(patsubst %,$(LINK)%,$(notdir $(DLINK_FILES_PREPROCESS_2)))
CRUNTIME=
DEPEND_LINK += \
2013-04-16 23:57:33 -04:00
$(LIBPORTABILITY) \
2013-04-16 23:57:27 -04:00
$(LINK_FILES) \
# keep this line so I can have a \ on the previous line
ifeq ($(CYGWIN),)
2013-04-16 23:57:53 -04:00
OS_CHOICE=$(SYSTEM)
2013-04-16 23:57:34 -04:00
OS_NOTCHOICE=windows
2013-04-16 23:57:27 -04:00
else ifneq ($(CC),icc)
2013-04-16 23:57:53 -04:00
OS_CHOICE=$(SYSTEM)
2013-04-16 23:57:34 -04:00
OS_NOTCHOICE=windows
2013-04-16 23:57:27 -04:00
else
OS_CHOICE=windows
2013-04-16 23:57:53 -04:00
OS_NOTCHOICE=$(SYSTEM)
2013-04-16 23:57:27 -04:00
endif
DEPEND_COMPILE += $(wildcard $(TOKUROOT)$(OS_CHOICE)/*.h)
2013-04-16 23:57:30 -04:00
SUPPRESSIONS=no
2013-04-16 23:57:27 -04:00
#Tools
2013-04-16 23:59:18 -04:00
ifeq ($(VALGRIND),)
VALGRIND=valgrind
endif
2013-04-16 23:59:05 -04:00
VGRIND_BASE=$(VALGRIND) --quiet --error-exitcode=1 \
2013-04-16 23:57:27 -04:00
--suppressions=$(TOKUROOT)newbrt/valgrind.suppressions \
2013-04-16 23:57:30 -04:00
--suppressions=$(TOKUROOT)src/tests/bdb.suppressions \
2013-04-16 23:59:01 -04:00
--gen-suppressions=$(SUPPRESSIONS) --num-callers=20
2013-04-16 23:57:44 -04:00
ifeq ($(DB_ATTACH),1)
2013-04-16 23:59:05 -04:00
VGRIND_BASE+=--db-attach=yes
2013-04-16 23:57:44 -04:00
endif
Addresses #1125 Merged nested transactions from temporary merge branch into main.
Current tests fail (not regressions, they fail as of 13461)
* {{{x1.tdbrun}}}
* {{{test_log(2,3,4,5,6,7,8,9,10).recover}}}
* {{{test-recover(1,2,3).tdbrun}}}
* {{{test1324.tdbrun}}}
ULE_DEBUG disabled (defined to 0) Can be re-enabled for test purposes (set to 1).
refs [t:1125]
Merging into the temp branch (tokudb.main_13461+1125)
{{{svn merge --accept=postpone -r 12527:13461 ../tokudb.1125 ./}}}
Merging into main
{{{svn merge --accept=postpone -r13462:13463 ../tokudb.main_13461+1125/ ./}}}
git-svn-id: file:///svn/toku/tokudb@13464 c7de825b-a66e-492c-adef-691d508d4ae1
2013-04-16 23:57:56 -04:00
ifeq ($(TRACK_ORIGINS),1)
2013-04-16 23:59:05 -04:00
VGRIND_BASE+=--track-origins=yes
endif
VGRIND=$(VGRIND_BASE) --leak-check=full --show-reachable=yes
ifeq ($(VGRIND),)
VGRIND_NOMEM=
else
VGRIND_NOMEM=$(VGRIND_BASE)
Addresses #1125 Merged nested transactions from temporary merge branch into main.
Current tests fail (not regressions, they fail as of 13461)
* {{{x1.tdbrun}}}
* {{{test_log(2,3,4,5,6,7,8,9,10).recover}}}
* {{{test-recover(1,2,3).tdbrun}}}
* {{{test1324.tdbrun}}}
ULE_DEBUG disabled (defined to 0) Can be re-enabled for test purposes (set to 1).
refs [t:1125]
Merging into the temp branch (tokudb.main_13461+1125)
{{{svn merge --accept=postpone -r 12527:13461 ../tokudb.1125 ./}}}
Merging into main
{{{svn merge --accept=postpone -r13462:13463 ../tokudb.main_13461+1125/ ./}}}
git-svn-id: file:///svn/toku/tokudb@13464 c7de825b-a66e-492c-adef-691d508d4ae1
2013-04-16 23:57:56 -04:00
endif
2013-04-16 23:57:30 -04:00
HGRIND=valgrind --quiet --tool=helgrind --error-exitcode=1
2013-04-16 23:57:27 -04:00
# When debugging, try: valgrind --show-reachable=yes --leak-check=full ./brt-test
# When debugging, try: valgrind --show-reachable=yes --leak-check=full ./brt-test
2013-04-16 23:57:42 -04:00
ifeq ($(WINDBG),)
WINDBG=0
endif
2013-04-16 23:57:27 -04:00
ifeq ($(CC),icc)
#icc only:
OPT_OPTFLAGS = -O3 -ip -ipo1
DBG_OPTFLAGS = -O0
COMBINE_C = -ipo-c
FORMAT= #No argument for extra format warnings.
WALL = -Wall -Wcheck # '-Wextra' becomes '-Wcheck' in icc
2013-04-16 23:59:39 -04:00
SYMBOLS= -g -debug all # deprecated -inline-debug-info
2013-04-16 23:57:27 -04:00
PORTABILITY=-diag-enable port-win
AR=xiar
2013-04-16 23:58:59 -04:00
DISABLE_WARNING=
2013-04-16 23:57:27 -04:00
ifneq ($(CYGWIN),)
#Cygwin
ICC_NOWARN=-Qdiag-disable:
2013-04-16 23:58:59 -04:00
DISABLE_WARNING +=869# Don't complain about unused variables (since we defined __attribute__ to be nothing.)
DISABLE_WARNING +=593# Don't complain about unused variables (since we defined __attribute__ to be nothing.)
DISABLE_WARNING +=11000# Disable message about multi-file optimization
DISABLE_WARNING +=11000# Disable message about single-file optimization
DISABLE_WARNING +=11005# Disable message about creating object file
DISABLE_WARNING +=188# Disable message about 0 used for enum
DISABLE_WARNING +=1011# Disable message about missing return with an abort
2013-04-16 23:57:27 -04:00
else
#Linux
ICC_NOWARN=-diag-disable #Need the space
endif
2013-04-16 23:59:13 -04:00
DISABLE_WARNING +=111# Unreachable code (i.e. assert(0) )
2013-04-16 23:59:10 -04:00
DISABLE_WARNING +=271# Remove warnings about trailing comma being nonstandard
DISABLE_WARNING +=424# Remove warnings about extra ';' being ignored
2013-04-16 23:58:59 -04:00
DISABLE_WARNING +=810# Remove warnings about losing precision
DISABLE_WARNING +=94# Allow arrays of length 0
DISABLE_WARNING +=118# Allow void functions to return void functions
DISABLE_WARNING +=177# Don't complain about static variables that are not used.
#DISABLE_WARNING +=188# Don't complain about enumerated type mixed with another type.
DISABLE_WARNING +=589# Don't complain about goto into a block that skips initializing variables. GCC catches the actual uninitialized variables.
DISABLE_WARNING +=981# Don't complain about "operands are evaluated in unspecified order". This seems to be generated whenever more than one argument to a function or operand is computed by function call.
DISABLE_WARNING +=1324# Don't complain about rdtsc clobbering its registers more than once.
DISABLE_WARNING +=1786# Don't complain about 'read/write/other standards' being deprecated
SKIP_WARNING = $(ICC_NOWARN)$(shell sed 's/ /,/g' <<< "$(DISABLE_WARNING)" | sed 's/,//')
2013-04-16 23:57:27 -04:00
endif
2013-04-16 23:58:04 -04:00
ifneq ($(CC),icc)
ifeq ($(ARCH),i686)
ARCHFLAGS = -march=$(ARCH)
endif
endif
2013-04-16 23:57:27 -04:00
ifneq ($(CYGWIN),)
#Cygwin (Windows) Must override some settings
BINSUF=.exe
WRONGBINSUF=#empty
2013-04-16 23:57:33 -04:00
ALWAYS_LINK=$(LIBPORTABILITY) /usr/lib/libz.a
2013-04-16 23:57:34 -04:00
SRCPATH_DIRS = `find $(TOKUROOT) -type d | grep -v '/\.[^.]' | grep -F -v "$(TOKUROOT)$(OS_NOTCHOICE)" | tr '\n' ';'`
2013-04-16 23:57:42 -04:00
ifeq ($(WINDBG),1)
2013-04-16 23:57:43 -04:00
VGRIND = windbg -hd -y "$(SRCPATH_DIRS)" -srcpath "$(SRCPATH_DIRS)" #No Valgrind in cygwin #-G is quit at exit, but does not return ERROR on error!!! and quits on error to quickly
2013-04-16 23:57:42 -04:00
else
2013-04-16 23:57:48 -04:00
VGRIND =
2013-04-16 23:57:42 -04:00
endif
2013-04-16 23:57:27 -04:00
HGRIND =#No Hgrind in cygwin
FPICFLAGS=#FPIC is default and not allowed as an option.
VISIBILITY=#Not supported
SHADOW=#Not supported
ifeq ($(CC),icc)
#Cygwin icc only
ifeq ($(CRUNTIME),)
2013-04-16 23:57:30 -04:00
ifeq ($(DEBUG),0)
2013-04-16 23:57:40 -04:00
CRUNTIME=MT
2013-04-16 23:57:30 -04:00
else
2013-04-16 23:57:40 -04:00
CRUNTIME=MTd
2013-04-16 23:57:27 -04:00
endif
endif
2013-04-16 23:58:56 -04:00
ALWAYS_LINK=$(LIBPORTABILITY) $(TOKUROOT)windows/lib/$(CRUNTIME)/zlib.lib Ws2_32.lib psapi.lib PowrProf.lib
2013-04-16 23:57:27 -04:00
LINK=#Empty
BINOUTPUT=-Fe
OOUTPUT=-Fo
AROUTPUT=/out:
OEXT=obj
WRONGOEXT=o
AEXT=lib
WRONGAEXT=a
SOEXT=dll
WRONGSOEXT=so
2013-04-16 23:57:53 -04:00
C99 = -Qstd=c99 -Qvc9
2013-04-16 23:57:27 -04:00
OPT_OPTFLAGS = -Ox -Qip -Qipo1
DBG_OPTFLAGS = -Od
COMBINE_C = -Qipo-c
2013-04-16 23:57:45 -04:00
WERROR = -WX # Windows icc version of -Werror
2013-04-16 23:59:01 -04:00
WERROR += -Qdiag-error:167,266,810,592,147 # Workarounds for -WX not being complete on windows icc
2013-04-16 23:57:27 -04:00
SYMBOLS= -Zi -debug:all -Qinline-debug-info
PORTABILITY=
PORTABILITY_HEADERS = $(TOKUROOT)windows
AR=xilib
DBG_AROPT=-qnoipo
OPT_AROPT=-qipo
DBG_ARFLAGS=$(DBG_AROPT) -lib /VERBOSE /WX /NOLOGO
OPT_ARFLAGS=$(OPT_AROPT) -lib /VERBOSE /WX /NOLOGO
CCQUIET=-nologo
LINK_DLINK_FILES=$(patsubst %.$(SOEXT),%.$(AEXT),$(DLINK_FILES))
LINK_RPATH=
LINK_LPATH=
DEPEND_LINK += $(LINK_DLINK_FILES)
W64 = -Wport #-Wp64
else
#Cygwin gcc only
FORMAT = -Wno-format
endif
endif
2013-04-16 23:57:30 -04:00
ifeq ($(DEBUG),0)
2013-04-16 23:57:27 -04:00
OPTFLAGS = $(OPT_OPTFLAGS)
ARFLAGS = $(OPT_ARFLAGS)
2013-04-16 23:57:30 -04:00
else
OPTFLAGS = $(DBG_OPTFLAGS)
ARFLAGS = $(DBG_ARFLAGS)
2013-04-16 23:57:27 -04:00
endif
2013-04-16 23:58:59 -04:00
CFLAGS += $(WALL) $(W64) $(WERROR) $(FORMAT) $(VISIBILITY) $(FPICFLAGS) $(SHADOW) $(ARCHFLAGS)
2013-04-16 23:57:27 -04:00
CFLAGS += $(OPTFLAGS) $(GCOV_FLAGS) $(PROF_FLAGS)
CFLAGS += $(SYMBOLS) $(SKIP_WARNING) $(C99) $(CCQUIET)
LDFLAGS_NOLIB = $(OPTFLAGS) $(SYMBOLS) $(GCOV_FLAGS) $(PROF_FLAGS)
2013-04-16 23:59:09 -04:00
LDFLAGS = $(LDFLAGS_NOLIB) $(LINK_LPATH) $(LINK_FILES) $(ALWAYS_LINK) $(LINK_DLINK_FILES) $(LINK_RPATH)
2013-04-16 23:57:54 -04:00
2013-04-16 23:57:27 -04:00
ifneq ($(CRUNTIME),)
LDFLAGS += -$(CRUNTIME)
CFLAGS += -$(CRUNTIME)
endif
2013-04-16 23:57:54 -04:00
2013-04-16 23:57:27 -04:00
# Need XOPEN_SOURCE=600 to get strtoll()
2013-04-16 23:57:53 -04:00
ifeq ($(SYSTEM),linux)
2013-04-16 23:57:37 -04:00
CPPFLAGS+=-D_SVID_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_XOPEN_SOURCE=600
2013-04-16 23:57:53 -04:00
endif
2013-04-16 23:57:54 -04:00
ifeq ($(SYSTEM),sunos)
2013-04-16 23:57:54 -04:00
CPPFLAGS+=-D_SVID_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_XOPEN_SOURCE=600
2013-04-16 23:57:54 -04:00
endif
2013-04-16 23:57:27 -04:00
#TODO: Fix this up if we want to keep using CIL.
#ifeq ($(CIL),1)
# CC=../../cil/cil-1.3.6/bin/cilly --merge --keepmerged
#endif
# When debugging, try: valgrind --show-reachable=yes --leak-check=full ./brt-test
ifneq ($(CYGWIN),)
CSCOPE=mlcscope
else
CSCOPE=cscope
endif
.PHONY: tags
2013-04-16 23:59:06 -04:00
tags: $(TOKUROOT)cscope.out $(TOKUROOT)TAGS
2013-04-16 23:57:27 -04:00
2013-04-16 23:59:06 -04:00
ifneq ($(TOKUROOT),./)
2013-04-16 23:57:27 -04:00
TAGS: $(TOKUROOT)*/*.[ch] $(TOKUROOT)*/*/*.[ch] $(TOKUROOT)*/*/*/*.[ch]
2013-04-16 23:57:34 -04:00
etags $(TOKUROOT)*/*.[ch] $(TOKUROOT)*/*/*.[ch] $(TOKUROOT)*/*/*/*.[ch]
2013-04-16 23:59:06 -04:00
endif
$(TOKUROOT)TAGS: $(TOKUROOT)*/*.[ch] $(TOKUROOT)*/*/*.[ch] $(TOKUROOT)*/*/*/*.[ch]
cd $(TOKUROOT) && etags */*.[ch] */*/*.[ch] */*/*/*.[ch]
$(TOKUROOT)cscope.files: $(TOKUROOT)*/*.[ch] $(TOKUROOT)*/*/*.[ch] $(TOKUROOT)*/*/*/*.[ch]
cd $(TOKUROOT) && (echo */*.[ch] */*/*.[ch] */*/*/*.[ch] | tr " " "\n") > $(notdir $@)
2013-04-16 23:57:27 -04:00
2013-04-16 23:59:06 -04:00
$(TOKUROOT)cscope.in.out $(TOKUROOT)cscope.po.out: $(TOKUROOT)cscope.out;
2013-04-16 23:57:27 -04:00
2013-04-16 23:59:06 -04:00
$(TOKUROOT)cscope.out: $(TOKUROOT)cscope.files $(TOKUROOT)*/*.[ch] $(TOKUROOT)*/*/*.[ch] $(TOKUROOT)*/*/*/*.[ch]
cd $(TOKUROOT) && $(CSCOPE) -qb
2013-04-16 23:57:27 -04:00
2013-04-16 23:57:34 -04:00
.PHONY: clean clean-default %.dir.clean
2013-04-16 23:57:27 -04:00
clean: clean-default
2013-04-16 23:57:34 -04:00
%.dir.clean:
2013-04-16 23:57:34 -04:00
cd $* && $(MAKE) clean
2013-04-16 23:57:34 -04:00
2013-04-16 23:57:27 -04:00
clean-default:
2013-04-16 23:57:34 -04:00
rm -f $(BINS) *.$(AEXT) *.$(SOEXT) *.$(OEXT)
rm -f *.bb *.bbg *.da *.gcov *.gcno *.gcda
rm -f *.exe *.obj *.pdb *.ilk
rm -f *.exe.manifest *.dll.manifest
2013-04-16 23:57:42 -04:00
rm -rf *.bundle
2013-04-16 23:57:53 -04:00
2013-04-16 23:57:27 -04:00
#Prevent using the wrong extensions/target types (Otherwise prereqs get confused).
%$(WRONGBINSUF): %.c
2013-04-16 23:57:34 -04:00
echo "Wrong target type: $@ should be $*$(BINSUF)" && false
2013-04-16 23:57:27 -04:00
%$(WRONGBINSUF): %.$(WRONGOEXT)
2013-04-16 23:57:34 -04:00
echo "Wrong target type: $@ should be $*$(BINSUF)" && false
2013-04-16 23:57:27 -04:00
%.$(WRONGOEXT): %.c
2013-04-16 23:57:34 -04:00
echo "Wrong target type: $@ should be $*.$(OEXT)" && false
2013-04-16 23:57:27 -04:00
%.$(WRONGAEXT):
2013-04-16 23:57:34 -04:00
echo "Wrong target type: $@ should be $*.$(AEXT)" && false
2013-04-16 23:57:27 -04:00
%.$(WRONGSOEXT):
2013-04-16 23:57:34 -04:00
echo "Wrong target type: $@ should be $*.$(SOEXT)" && false
2013-04-16 23:57:27 -04:00
ifeq ($(SKIP_LIBPORTABILITYRULE),)
ifeq ($(CYGWIN),)
2013-04-16 23:57:53 -04:00
$(LIBPORTABILITY): $(TOKUROOT)$(SYSTEM)/*.[ch]
pwd && cd $(TOKUROOT)$(SYSTEM) && $(MAKE) install
2013-04-16 23:57:27 -04:00
else ifneq ($(CC),icc)
2013-04-16 23:57:53 -04:00
$(LIBPORTABILITY): $(TOKUROOT)$(SYSTEM)/*.[ch]
cd $(TOKUROOT)$(SYSTEM) && $(MAKE) install
2013-04-16 23:57:27 -04:00
else
$(LIBPORTABILITY): $(TOKUROOT)windows/*.[ch]
2013-04-16 23:57:34 -04:00
cd $(TOKUROOT)windows && $(MAKE) install
2013-04-16 23:57:27 -04:00
endif
endif
ifeq ($(SKIP_LOCKTREERULE),)
LOCKTREE = $(TOKUROOT)src/lock_tree/locktree.$(AEXT)
2013-04-16 23:57:37 -04:00
LOCKTREE_BUNDLE = $(TOKUROOT)src/lock_tree/locktree.bundle
2013-04-16 23:57:27 -04:00
LOCKTREE_LINEAR = $(TOKUROOT)src/lock_tree/locktree_linear.$(AEXT)
LOCKTREE_TLOG = $(TOKUROOT)src/lock_tree/locktree_tlog.$(AEXT)
LOCKTREE_LOG = $(TOKUROOT)src/lock_tree/locktree_log.$(AEXT)
2013-04-16 23:57:40 -04:00
$(LOCKTREE) $(LOCKTREE_LINEAR) $(LOCKTREE_TLOG) $(LOCKTREE_LOG) $(LOCKTREE_BUNDLE): $(@D)*.[ch]
2013-04-16 23:57:34 -04:00
cd $(@D) && $(MAKE) $(@F)
2013-04-16 23:57:53 -04:00
$(LOCKTREE) $(LOCKTREE_LINEAR) $(LOCKTREE_TLOG) $(LOCKTREE_LOG) $(LOCKTREE_BUNDLE): $(NEWBRT_BUNDLE) $(LIBPORTABILITY_BUNDLE) $(LIBPORTABILITY)
2013-04-16 23:57:27 -04:00
endif
ifeq ($(SKIP_RANGETREERULE),)
RANGETREE = $(TOKUROOT)src/range_tree/rangetree.$(AEXT)
2013-04-16 23:57:37 -04:00
RANGETREE_BUNDLE = $(TOKUROOT)src/range_tree/rangetree.bundle
2013-04-16 23:57:27 -04:00
RANGETREE_LINEAR = $(TOKUROOT)src/range_tree/rangetree_linear.$(AEXT)
RANGETREE_TLOG = $(TOKUROOT)src/range_tree/rangetree_tlog.$(AEXT)
RANGETREE_LOG = $(TOKUROOT)src/range_tree/rangetree_log.$(AEXT)
2013-04-16 23:57:40 -04:00
$(RANGETREE) $(RANGETREE_LINEAR) $(RANGETREE_TLOG) $(RANGETREE_LOG) $(RANGETREE_BUNDLE): $(@D)*.[ch]
2013-04-16 23:57:34 -04:00
cd $(@D) && $(MAKE) $(@F)
2013-04-16 23:57:53 -04:00
$(RANGETREE) $(RANGETREE_LINEAR) $(RANGETREE_TLOG) $(RANGETREE_LOG) $(RANGETREE_BUNDLE): $(NEWBRT_BUNDLE) $(LIBPORTABILITY_BUNDLE) $(LIBPORTABILITY)
2013-04-16 23:57:27 -04:00
endif
ifeq ($(SKIP_NEWBRTRULE),)
2013-04-16 23:57:40 -04:00
IPO_NEWBRT = $(TOKUROOT)newbrt/ipo_newbrt.$(AEXT)
2013-04-16 23:57:27 -04:00
NEWBRT = $(TOKUROOT)newbrt/newbrt.$(AEXT)
2013-04-16 23:57:31 -04:00
NEWBRT_BUNDLE = $(TOKUROOT)newbrt/newbrt.bundle
2013-04-16 23:57:40 -04:00
$(NEWBRT) $(NEWBRT_BUNDLE) $(IPO_NEWBRT): $(@D)*.[ch]
2013-04-16 23:57:53 -04:00
pwd && cd $(@D) && $(MAKE) $(@F)
$(NEWBRT): $(NEWBRT_BUNDLE)
2013-04-16 23:59:01 -04:00
LOG_HEADER = $(TOKUROOT)newbrt/log_header.h
$(LOG_HEADER): $(TOKUROOT)newbrt/logformat.c
cd $(@D) && $(MAKE) $(@F)
2013-04-16 23:57:40 -04:00
endif
ifeq ($(SKIP_YDBRULE),)
IPO_YDB = $(TOKUROOT)src/ipo_libtokudb.$(AEXT)
NOIPO_YDB = $(TOKUROOT)src/static_libtokudb.$(AEXT)
$(NOIPO_YDB) $(IPO_YDB): $(@D)*.[ch]
2013-04-16 23:57:34 -04:00
cd $(@D) && $(MAKE) $(@F)
2013-04-16 23:59:06 -04:00
ifeq ($(DEBUG),0)
WIN_YDB = $(IPO_YDB)
else
WIN_YDB = $(NOIPO_YDB)
endif
2013-04-16 23:57:27 -04:00
endif
2013-04-16 23:57:53 -04:00
ifeq ($(OS_CHOICE),windows)
2013-04-16 23:57:53 -04:00
PTHREAD_LIB=$(TOKUROOT)lib/pthreadVC2.dll
2013-04-16 23:57:53 -04:00
PTHREAD_LOCAL=$(notdir $(PTHREAD_LIB))
$(PTHREAD_LOCAL): $(PTHREAD_LIB)
2013-04-16 23:57:53 -04:00
cp -u $< $@
2013-04-16 23:57:53 -04:00
else
PTHREAD_LOCAL=
endif
2013-04-16 23:57:38 -04:00
BIN_FROM_C_FLAGS =$(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(BINOUTPUT)$@
BIN_FROM_C_FLAGS_NOLIB=$(CFLAGS) $(CPPFLAGS) $(LDFLAGS_NOLIB) $(BINOUTPUT)$@
2013-04-16 23:57:27 -04:00
%$(BINSUF):%.c $(DEPEND_COMPILE) $(DEPEND_LINK)
2013-04-16 23:57:42 -04:00
$(CC) $< $(BIN_FROM_C_FLAGS) $(LINK_MUST_BE_LAST)
2013-04-16 23:57:27 -04:00
2013-04-16 23:57:38 -04:00
BIN_FROM_O_FLAGS =$(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(BINOUTPUT)$@
BIN_FROM_O_FLAGS_NOLIB=$(CFLAGS) $(CPPFLAGS) $(LDFLAGS_NOLIB) $(BINOUTPUT)$@
2013-04-16 23:57:27 -04:00
%$(BINSUF):%.$(OEXT) $(DEPEND_COMPILE) $(DEPEND_LINK)
2013-04-16 23:57:42 -04:00
$(CC) $< $(BIN_FROM_O_FLAGS) $(LINK_MUST_BE_LAST)
2013-04-16 23:57:27 -04:00
%.$(OEXT):%.c $(DEPEND_COMPILE)
2013-04-16 23:57:37 -04:00
$(CC) $< -c $(CPPFLAGS) $(CFLAGS) $(OOUTPUT)$@
2013-04-16 23:57:27 -04:00
2013-04-16 23:59:09 -04:00
CILKROOT=/usr/local/cilk/
CILKPP=$(CILKROOT)bin/cilk++
2013-04-16 23:58:59 -04:00
CILKFLAGS=$(filter-out -Wbad-function-cast -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -std=c99,$(CFLAGS)) $(CPPFLAGS)
%$(BINSUF):%.cilk $(DEPEND_COMPILE)
$(CILKPP) $(CILKFLAGS) $< $(LOADLIBES) -o $@
%.serial$(BINSUF): %.cilk
$(CILKPP) -fcilk-stub $(CILKFLAGS) $^ $(LOADLIBES) -o $@
2013-04-16 23:59:09 -04:00
CXXFLAGS=$(filter-out -Wbad-function-cast -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -std=c99,$(CFLAGS)) $(CPPFLAGS)
2013-04-16 23:58:59 -04:00
2013-04-16 23:57:27 -04:00
%.$(AEXT):
2013-04-16 23:57:34 -04:00
$(AR) $(ARFLAGS) $(AROUTPUT)$@ $(filter %.$(OEXT),$^) $(patsubst %.bundle, %.bundle/*.$(OEXT), $(filter-out %.$(OEXT),$^))
2013-04-16 23:57:31 -04:00
ifeq ($(AEXT),a)
2013-04-16 23:57:31 -04:00
%.bundle: %.$(AEXT)
2013-04-16 23:59:21 -04:00
rm -f $@/*.$(OEXT) && mkdir -p $@ && cd $@ && $(AR) x ../$(<F)
2013-04-16 23:57:34 -04:00
touch $@
2013-04-16 23:57:31 -04:00
else
#Windows lib cannot extract everything.
#Do a for loop and extract one at a time.
%.bundle: %.$(AEXT)
2013-04-16 23:57:34 -04:00
mkdir -p $@ && cd $@ && for ofile in `lib /list ../$(<F) |dos2unix |grep -F obj`; do lib /extract:$$ofile ../$(<F); done
touch $@
2013-04-16 23:57:31 -04:00
endif
2013-04-16 23:57:27 -04:00
ifeq ($(SOEXT),so)
EXPORTMAPFILE=export.map
EXPORTMAP = -Wl,--version-script=$(EXPORTMAPFILE)
SHARED=-shared
endif
ifeq ($(SOEXT),dll)
2013-04-16 23:57:30 -04:00
ifeq ($(DEBUG),0)
2013-04-16 23:57:27 -04:00
SHARED=/LD
else
SHARED=/LDd
endif
EXPORTMAPFILE=export.def
EXPORTMAP=/link /def:$(EXPORTMAPFILE)
endif
SO_FLAGS=$(SHARED) $(BIN_FROM_O_FLAGS) $(EXPORTMAP)
2013-04-16 23:59:17 -04:00
2013-04-16 23:59:09 -04:00
ifeq ($(BRTLOADER),cilk)
2013-04-16 23:59:23 -04:00
CILK_LINKER_FLAGS = -Wl,-Bsymbolic-functions -Wl,-z,now
2013-04-16 23:59:17 -04:00
ifeq ($(ARCH),x86_64)
2013-04-16 23:59:23 -04:00
CILKRTS_LIB = -L$(CILKROOT)/lib64 -lcilkrts_pic
2013-04-16 23:59:17 -04:00
else
2013-04-16 23:59:23 -04:00
CILKRTS_LIB = -L$(CILKROOT)/lib32 -lcilkrta_pic
2013-04-16 23:59:17 -04:00
endif
2013-04-16 23:59:23 -04:00
SO_FLAGS += $(CILK_LINKER_FLAGS) $(CILKRTS_LIB)
2013-04-16 23:59:17 -04:00
TOKULINKER = $(CXX)
2013-04-16 23:59:09 -04:00
else
2013-04-16 23:59:17 -04:00
TOKULINKER = $(CC)
2013-04-16 23:59:09 -04:00
endif
2013-04-16 23:57:27 -04:00
2013-04-16 23:59:17 -04:00
%.$(SOEXT): $(EXPORTMAPFILE)
$(TOKULINKER) $(SO_FLAGS)
2013-04-16 23:57:27 -04:00
#Testing tools
ifeq ($(SUMMARIZE),1)
SUMMARIZE_CMD = ;if test $$? = 0; then printf "%-60sPASS\n" $(HERE)/$@; else printf "%-60sFAIL\n" $(HERE)/$@ ; test 0 = 1; fi
SUMMARIZE_SHOULD_FAIL= ;if test $$? = 0; then printf "%-60sXFAIL\n" $(HERE)/$@; else printf "%-60sXPASS\n" $(HERE)/$@ ; test 0 = 1; fi
INVERTER=;test $$? -ne 0
else
SUMMARIZE_CMD =
endif
2013-04-16 23:59:37 -04:00
#target for flymake-mode
.PHONY: check-syntax
check-syntax: $(DEPEND_COMPILE)
$(CC) $(CPPFLAGS) $(CFLAGS) -fno-ident -fsyntax-only $(CHK_SOURCES)
2013-04-16 23:57:27 -04:00
#Auto change variables from raw to include .exe if necessary.
BINS = $(patsubst %,%$(BINSUF),$(BINS_RAW))
OBJS = $(patsubst %,%.$(OEXT),$(OBJS_RAW))
REGRESSION_TESTS = $(patsubst %,%$(BINSUF),$(REGRESSION_TESTS_RAW))
2013-04-16 23:57:34 -04:00
APPVERIFIER_TESTS=exceptions handles heaps locks memory threadpool tls dangerousapis dirtystacks filepaths inputoutput
APPVERIFIER_TESTS_NONDEFAULT=heaps.backward:TRUE heaps.protect:TRUE
ENABLE_APPVERIFIER_FOR=appverif -enable $(APPVERIFIER_TESTS) -with $(APPVERIFIER_TESTS_NONDEFAULT) -for
DISABLE_APPVERIFIER_FOR=appverif -disable \* -for
%.appverifyenable:
2013-04-16 23:57:34 -04:00
$(ENABLE_APPVERIFIER_FOR) $*.exe
2013-04-16 23:57:34 -04:00
%.appverifydisable:
2013-04-16 23:57:34 -04:00
$(DISABLE_APPVERIFIER_FOR) $*.exe
2013-04-16 23:57:34 -04:00
.PHONY:%.appverifyenable %.appverifydisable %.appverifymaybeenable %.appverifymaybedisable
EXE_FILES = $(wildcard *.exe)
appverifyenable: $(patsubst %.exe,%.appverifyenable,$(EXE_FILES));
appverifydisable: $(patsubst %.exe,%.appverifydisable,$(EXE_FILES));