2012-09-05 13:37:39 +04:00
# Module.mk for cling module
# Copyright (c) 2011 Rene Brun and Fons Rademakers
#
# Author: Axel Naumann, 2011-10-18
MODNAME := cling
MODDIR := $( ROOT_SRCDIR) /interpreter/$( MODNAME)
CLINGDIR := $( MODDIR)
##### libCling #####
CLINGS := $( wildcard $( MODDIR) /lib/Interpreter/*.cpp) \
$( wildcard $( MODDIR) /lib/MetaProcessor/*.cpp) \
2014-06-04 11:13:35 +04:00
$( wildcard $( MODDIR) /lib/TagsExtension/*.cpp) \
2012-09-05 13:37:39 +04:00
$( wildcard $( MODDIR) /lib/Utils/*.cpp)
CLINGO := $( call stripsrc,$( CLINGS:.cpp= .o) )
2016-04-11 18:40:07 +03:00
CLINGEXCEPO := $( call stripsrc,$( MODDIR) /lib/Interpreter/ExceptionRTTI.o)
2014-01-13 20:43:45 +04:00
CLINGCOMPDH := $( call stripsrc,$( MODDIR) /lib/Interpreter/cling-compiledata.h)
2012-09-05 13:37:39 +04:00
CLINGDEP := $( CLINGO:.o= .d)
2013-03-05 02:23:43 +04:00
CLINGETC_CLING := DynamicExprInfo.h DynamicLookupRuntimeUniverse.h \
DynamicLookupLifetimeHandler.h Interpreter.h InvocationOptions.h \
2015-11-27 15:54:20 +03:00
Exception.h RuntimePrintValue.h RuntimeUniverse.h Value.h
2013-03-05 02:23:43 +04:00
CLINGETC_LLVM := llvm/ADT/IntrusiveRefCntPtr.h \
llvm/ADT/StringRef.h \
2014-06-27 18:21:13 +04:00
llvm/ADT/SmallVector.h \
2015-08-14 23:49:01 +03:00
llvm/ADT/iterator_range.h \
2013-04-24 23:12:50 +04:00
llvm/Config/llvm-config.h \
2014-02-18 14:22:42 +04:00
llvm/Support/AlignOf.h \
2014-02-18 13:55:37 +04:00
llvm/Support/Allocator.h \
2013-03-05 02:23:43 +04:00
llvm/Support/Casting.h \
llvm/Support/Compiler.h \
llvm/Support/DataTypes.h \
2014-02-18 14:22:42 +04:00
llvm/Support/MathExtras.h \
2014-06-27 18:21:13 +04:00
llvm/Support/Memory.h \
2014-02-18 14:22:42 +04:00
llvm/Support/SwapByteOrder.h \
2013-03-05 02:23:43 +04:00
llvm/Support/type_traits.h
2014-04-09 13:04:19 +04:00
CLINGETCPCH := $( addprefix etc/cling/Interpreter/,$( CLINGETC_CLING) ) \
2013-03-05 02:23:43 +04:00
$( addprefix etc/cling/,$( CLINGETC_LLVM) )
2014-04-09 13:04:19 +04:00
CLINGETC := $( CLINGETCPCH) $( addprefix etc/cling/cint/,multimap multiset)
2013-03-05 02:23:43 +04:00
CLINGETC_ORIGINALS := $( addprefix $( call stripsrc,$( LLVMDIRI) ) /include/,$( CLINGETC_LLVM) ) \
$( addprefix $( CLINGDIR) /include/cling/,$( CLINGETC_CLING) )
2012-09-05 13:37:39 +04:00
2012-10-16 04:51:45 +04:00
i f n e q ( $( LLVMDEV ) , )
CLINGEXES := $( wildcard $( MODDIR) /tools/driver/*.cpp) \
$( wildcard $( MODDIR) /lib/UserInterface/*.cpp)
CLINGEXEO := $( call stripsrc,$( CLINGEXES:.cpp= .o) )
CLINGEXE := $( LLVMDIRO) /Debug+Asserts/bin/cling
ALLEXECS += $( CLINGEXE)
e n d i f
2012-09-05 13:37:39 +04:00
# include all dependency files
INCLUDEFILES += $( CLINGDEP)
# include dir for picking up RuntimeUniverse.h etc - need to
# 1) copy relevant headers to include/
# 2) rely on TCling to addIncludePath instead of using CLING_..._INCL below
2016-06-17 12:22:55 +03:00
# -fvisibility=hidden renders libCore unusable.
# Filter out warning flags.
2016-06-17 16:46:25 +03:00
CLINGLLVMCXXFLAGS = $( filter-out -fvisibility-inlines-hidden,$( filter-out -fvisibility= hidden,\
$( filter-out -W%,\
$( patsubst -O%,,$( shell $( LLVMCONFIG) --cxxflags) ) ) ) )
2014-03-20 01:42:59 +04:00
# -ffunction-sections breaks the debugger on some platforms ... and does not help libCling at all.
CLINGCXXFLAGS += -I$( CLINGDIR) /include $( filter-out -ffunction-sections,$( CLINGLLVMCXXFLAGS) ) -fno-strict-aliasing
2012-09-19 18:12:07 +04:00
i f e q ( $( CTORSINITARRAY ) , y e s )
CLINGLDFLAGSEXTRA := -Wl,--no-ctors-in-init-array
e n d i f
2013-02-07 17:11:08 +04:00
2013-06-21 17:37:27 +04:00
# Define NDEBUG for consistency with llvm and clang.
2013-06-26 16:56:11 +04:00
CLINGCXXNDEBUG := -DNDEBUG
2013-06-21 17:37:27 +04:00
i f e q ( $( ROOTBUILD ) , d e b u g )
2013-06-26 16:58:58 +04:00
ifneq ( $( LLVMDEV) ,)
CLINGCXXNDEBUG :=
endif
2013-06-26 16:56:11 +04:00
e n d i f
CLINGCXXFLAGS += $( CLINGCXXNDEBUG)
2014-02-14 21:01:07 +04:00
CLINGCXXFLAGSNOI = $( patsubst -I%,,$( CLINGCXXFLAGS) )
2013-06-21 17:37:27 +04:00
2013-12-17 23:09:49 +04:00
i f n e q ( , $( filter $ ( ARCH ) ,win 32gcc win 64gcc ) )
2013-02-07 17:11:08 +04:00
# Hide llvm / clang symbols:
CLINGLDFLAGSEXTRA += -Wl,--exclude-libs,ALL
e n d i f
2012-09-19 18:12:07 +04:00
CLINGLIBEXTRA = $( CLINGLDFLAGSEXTRA) -L$( shell $( LLVMCONFIG) --libdir) \
2012-09-05 13:37:39 +04:00
$( addprefix -lclang,\
2014-08-14 14:17:14 +04:00
Frontend Serialization Driver CodeGen Parse Sema Analysis AST Edit Lex Basic) \
2016-06-17 12:21:45 +03:00
$( shell $( LLVMCONFIG) --libs bitwriter coverage orcjit mcjit native option ipo instrumentation objcarcopts profiledata) \
2014-02-18 11:22:16 +04:00
$( shell $( LLVMCONFIG) --ldflags) $( shell $( LLVMCONFIG) --system-libs)
2012-09-05 13:37:39 +04:00
2013-12-17 23:09:49 +04:00
i f n e q ( , $( filter $ ( ARCH ) ,win 32gcc win 64gcc ) )
2013-08-02 14:04:44 +04:00
# for EnumProcessModules() in TCling.cxx
CLINGLIBEXTRA += -lpsapi
e n d i f
2012-09-05 13:37:39 +04:00
##### local rules #####
2014-01-13 20:43:45 +04:00
.PHONY : all -$( MODNAME ) clean -$( MODNAME ) distclean -$( MODNAME ) FORCE
2012-09-05 13:37:39 +04:00
all-$(MODNAME) :
clean-$(MODNAME) :
@rm -f $( CLINGO)
clean :: clean -$( MODNAME )
distclean-$(MODNAME) : clean -$( MODNAME )
@rm -f $( CLINGDEP) $( CLINGETC)
distclean :: distclean -$( MODNAME )
2012-09-10 17:46:36 +04:00
$(CLINGDIRS)/Module.mk : $( LLVMCONFIG )
2013-03-05 02:23:43 +04:00
$(CLINGETC_ORIGINALS) : %: $( LLVMLIB )
2013-02-19 18:14:07 +04:00
etc/cling/llvm/% : $( call stripsrc ,$ ( LLVMDIRI ) ) /include /llvm /%
2012-09-05 13:37:39 +04:00
+@[ -d $( dir $@ ) ] || mkdir -p $( dir $@ )
2013-03-01 18:13:04 +04:00
cp $< $@
2012-09-05 13:37:39 +04:00
2013-02-19 18:14:07 +04:00
etc/cling/cint/% : $( CLINGDIR ) /include /cling /cint /%
2012-09-05 13:37:39 +04:00
+@[ -d $( dir $@ ) ] || mkdir -p $( dir $@ )
2013-03-01 18:13:04 +04:00
cp $< $@
2012-09-05 13:37:39 +04:00
2013-02-21 21:28:27 +04:00
etc/cling/%.h : $( CLINGDIR ) /include /cling /%.h
+@[ -d $( dir $@ ) ] || mkdir -p $( dir $@ )
2013-03-01 18:13:04 +04:00
cp $< $@
2013-02-21 21:28:27 +04:00
2012-09-05 13:37:39 +04:00
$(CLINGDIR)/%.o : $( CLINGDIR ) /%.cpp $( LLVMDEP )
2016-04-12 12:51:39 +03:00
$( MAKEDEP) -R -f$( @:.o= .d) -Y -w 1000 -- $( CXXFLAGS) $( CLINGCXXFLAGS) $( CLINGRTTI) -D__cplusplus -- $<
$( CXX) $( OPT) $( CXXMKDEPFLAGS) $( CLINGCXXFLAGS) $( CXXOUT) $@ -c $<
2012-09-05 13:37:39 +04:00
$(call stripsrc,$(CLINGDIR)/%.o) : $( CLINGDIR ) /%.cpp $( LLVMDEP )
$( MAKEDIR)
2016-04-12 12:51:39 +03:00
$( MAKEDEP) -R -f$( @:.o= .d) -Y -w 1000 -- $( CXXFLAGS) $( CLINGCXXFLAGS) $( CLINGRTTI) -D__cplusplus -- $<
$( CXX) $( OPT) $( CXXMKDEPFLAGS) $( CLINGCXXFLAGS) $( CXXOUT) $@ -c $<
2012-09-05 13:37:39 +04:00
2014-01-20 18:07:59 +04:00
$(CLINGCOMPDH) : FORCE $( LLVMDEP )
2014-01-22 18:54:01 +04:00
@mkdir -p $( dir $@ )
2016-08-11 13:12:20 +03:00
@echo '#define CLING_CXX_PATH "$(CXX) $(OPT) $(CLINGCXXFLAGSNOI)"' > $@ _tmp
2014-01-13 20:43:45 +04:00
@diff -q $@ _tmp $@ > /dev/null 2>& 1 || mv $@ _tmp $@
@rm -f $@ _tmp
2012-10-16 04:51:45 +04:00
i f n e q ( $( LLVMDEV ) , )
2012-11-10 18:14:27 +04:00
i f n e q ( $( PLATFORM ) , m a c o s x )
# -Wl,-E exports all symbols, such that the JIT can find them.
# Doesn't exist on MacOS where this behavior is default.
CLINGLDEXPSYM := -Wl,-E
e n d i f
2012-10-16 04:51:45 +04:00
$(CLINGEXE) : $( CLINGO ) $( CLINGEXEO ) $( LTEXTINPUTO )
$( RSYNC) --exclude '.svn' $( CLINGDIR) $( LLVMDIRO) /tools
2016-07-13 15:53:42 +03:00
#@cd $(LLVMDIRS)/tools && ln -sf ../../../cling # yikes
2012-10-16 04:51:45 +04:00
@mkdir -p $( dir $@ )
2012-11-10 18:14:27 +04:00
$( LD) $( CLINGLDEXPSYM) -o $@ $( CLINGO) $( CLINGEXEO) $( LTEXTINPUTO) $( CLINGLIBEXTRA)
2012-10-16 04:51:45 +04:00
e n d i f
2012-09-05 13:37:39 +04:00
##### extra rules ######
2012-10-16 04:51:45 +04:00
i f n e q ( $( LLVMDEV ) , )
2013-09-30 20:03:35 +04:00
$(CLINGO) : CLINGCXXFLAGS += '-DCLING_INCLUDE_PATHS ="$( CLINGDIR ) /include :$( shell pwd ) /$( LLVMDIRO ) /include :$( shell pwd ) /$( LLVMDIRO ) /tools /clang /include :$( LLVMDIRS ) /include :$( LLVMDIRS ) /tools /clang /include "'
2016-07-13 00:08:21 +03:00
$(CLINGEXEO) : CLINGCXXFLAGS += -fexceptions -I $( TEXTINPUTDIRS ) -I $( LLVMDIRO ) /include
2013-08-28 11:34:28 +04:00
e l s e
2012-10-16 04:51:45 +04:00
e n d i f
2013-02-25 20:25:39 +04:00
2014-09-19 15:59:31 +04:00
CLING_VERSION = ROOT_$( shell cat " $( CLINGDIR) /VERSION " )
2014-05-09 17:16:50 +04:00
2016-04-12 12:51:39 +03:00
$(CLINGEXCEPO) : CLINGCXXFLAGS += -frtti -fexceptions
2013-03-01 18:13:04 +04:00
$(CLINGETC) : $( LLVMLIB )
$(CLINGO) : $( CLINGETC )
2014-01-13 20:43:45 +04:00
$(call stripsrc,$(MODDIR)/lib/Interpreter/CIFactory.o) : $( CLINGCOMPDH )
2015-06-05 09:38:02 +03:00
$(call stripsrc,$(MODDIR)/lib/Interpreter/CIFactory.o) : CLINGCXXFLAGS += -I $( dir $ ( CLINGCOMPDH ) ) -pthread
2016-09-01 00:05:05 +03:00
i f e q ( $( PLATFORM ) , m a c o s x )
$(call stripsrc,$(MODDIR)/lib/Interpreter/CIFactory.o) : CLINGCXXFLAGS += -Wno -deprecated -declarations
e n d i f
2014-03-08 22:10:03 +04:00
$(call stripsrc,$(MODDIR)/lib/Interpreter/Interpreter.o) : $( CLINGCOMPDH )
$(call stripsrc,$(MODDIR)/lib/Interpreter/Interpreter.o) : CLINGCXXFLAGS += -I $( dir $ ( CLINGCOMPDH ) )
2015-03-06 00:47:17 +03:00
$(call stripsrc,$(MODDIR)/lib/Interpreter/Interpreter.o) : CLINGCXXFLAGS += -DCLING_VERSION =$( CLING_VERSION )
2014-03-08 22:10:03 +04:00