2012-09-05 09:37:39 +00: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 09:13:35 +02:00
$( wildcard $( MODDIR) /lib/TagsExtension/*.cpp) \
2012-09-05 09:37:39 +00:00
$( wildcard $( MODDIR) /lib/Utils/*.cpp)
CLINGO := $( call stripsrc,$( CLINGS:.cpp= .o) )
2016-04-11 17:40:07 +02:00
CLINGEXCEPO := $( call stripsrc,$( MODDIR) /lib/Interpreter/ExceptionRTTI.o)
2014-01-13 17:43:45 +01:00
CLINGCOMPDH := $( call stripsrc,$( MODDIR) /lib/Interpreter/cling-compiledata.h)
2012-09-05 09:37:39 +00:00
CLINGDEP := $( CLINGO:.o= .d)
2013-03-04 22:23:43 +00:00
CLINGETC_CLING := DynamicExprInfo.h DynamicLookupRuntimeUniverse.h \
DynamicLookupLifetimeHandler.h Interpreter.h InvocationOptions.h \
2015-11-27 13:54:20 +01:00
Exception.h RuntimePrintValue.h RuntimeUniverse.h Value.h
2013-03-04 22:23:43 +00:00
CLINGETC_LLVM := llvm/ADT/IntrusiveRefCntPtr.h \
llvm/ADT/StringRef.h \
2014-06-27 16:21:13 +02:00
llvm/ADT/SmallVector.h \
2015-08-14 22:49:01 +02:00
llvm/ADT/iterator_range.h \
2013-04-24 19:12:50 +00:00
llvm/Config/llvm-config.h \
2014-02-18 11:22:42 +01:00
llvm/Support/AlignOf.h \
2014-02-18 10:55:37 +01:00
llvm/Support/Allocator.h \
2013-03-04 22:23:43 +00:00
llvm/Support/Casting.h \
llvm/Support/Compiler.h \
llvm/Support/DataTypes.h \
2014-02-18 11:22:42 +01:00
llvm/Support/MathExtras.h \
2014-06-27 16:21:13 +02:00
llvm/Support/Memory.h \
2014-02-18 11:22:42 +01:00
llvm/Support/SwapByteOrder.h \
2013-03-04 22:23:43 +00:00
llvm/Support/type_traits.h
2014-04-09 11:04:19 +02:00
CLINGETCPCH := $( addprefix etc/cling/Interpreter/,$( CLINGETC_CLING) ) \
2013-03-04 22:23:43 +00:00
$( addprefix etc/cling/,$( CLINGETC_LLVM) )
2014-04-09 11:04:19 +02:00
CLINGETC := $( CLINGETCPCH) $( addprefix etc/cling/cint/,multimap multiset)
2013-03-04 22:23:43 +00:00
CLINGETC_ORIGINALS := $( addprefix $( call stripsrc,$( LLVMDIRI) ) /include/,$( CLINGETC_LLVM) ) \
$( addprefix $( CLINGDIR) /include/cling/,$( CLINGETC_CLING) )
2012-09-05 09:37:39 +00:00
2012-10-16 00:51:45 +00: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 09:37:39 +00: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 11:22:55 +02:00
# -fvisibility=hidden renders libCore unusable.
# Filter out warning flags.
2016-06-17 15:46:25 +02:00
CLINGLLVMCXXFLAGS = $( filter-out -fvisibility-inlines-hidden,$( filter-out -fvisibility= hidden,\
$( filter-out -W%,\
$( patsubst -O%,,$( shell $( LLVMCONFIG) --cxxflags) ) ) ) )
2014-03-19 16:42:59 -05: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 14:12:07 +00:00
i f e q ( $( CTORSINITARRAY ) , y e s )
CLINGLDFLAGSEXTRA := -Wl,--no-ctors-in-init-array
e n d i f
2013-02-07 13:11:08 +00:00
2013-06-21 15:37:27 +02:00
# Define NDEBUG for consistency with llvm and clang.
2013-06-26 14:56:11 +02:00
CLINGCXXNDEBUG := -DNDEBUG
2013-06-21 15:37:27 +02:00
i f e q ( $( ROOTBUILD ) , d e b u g )
2013-06-26 14:58:58 +02:00
ifneq ( $( LLVMDEV) ,)
CLINGCXXNDEBUG :=
endif
2013-06-26 14:56:11 +02:00
e n d i f
CLINGCXXFLAGS += $( CLINGCXXNDEBUG)
2014-02-14 18:01:07 +01:00
CLINGCXXFLAGSNOI = $( patsubst -I%,,$( CLINGCXXFLAGS) )
2013-06-21 15:37:27 +02:00
2013-12-17 20:09:49 +01:00
i f n e q ( , $( filter $ ( ARCH ) ,win 32gcc win 64gcc ) )
2013-02-07 13:11:08 +00:00
# Hide llvm / clang symbols:
CLINGLDFLAGSEXTRA += -Wl,--exclude-libs,ALL
e n d i f
2012-09-19 14:12:07 +00:00
CLINGLIBEXTRA = $( CLINGLDFLAGSEXTRA) -L$( shell $( LLVMCONFIG) --libdir) \
2012-09-05 09:37:39 +00:00
$( addprefix -lclang,\
2014-08-14 12:17:14 +02:00
Frontend Serialization Driver CodeGen Parse Sema Analysis AST Edit Lex Basic) \
2016-06-17 11:21:45 +02:00
$( shell $( LLVMCONFIG) --libs bitwriter coverage orcjit mcjit native option ipo instrumentation objcarcopts profiledata) \
2014-02-18 08:22:16 +01:00
$( shell $( LLVMCONFIG) --ldflags) $( shell $( LLVMCONFIG) --system-libs)
2012-09-05 09:37:39 +00:00
2013-12-17 20:09:49 +01:00
i f n e q ( , $( filter $ ( ARCH ) ,win 32gcc win 64gcc ) )
2013-08-02 12:04:44 +02:00
# for EnumProcessModules() in TCling.cxx
CLINGLIBEXTRA += -lpsapi
e n d i f
2012-09-05 09:37:39 +00:00
##### local rules #####
2014-01-13 17:43:45 +01:00
.PHONY : all -$( MODNAME ) clean -$( MODNAME ) distclean -$( MODNAME ) FORCE
2012-09-05 09:37:39 +00: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 13:46:36 +00:00
$(CLINGDIRS)/Module.mk : $( LLVMCONFIG )
2013-03-04 22:23:43 +00:00
$(CLINGETC_ORIGINALS) : %: $( LLVMLIB )
2013-02-19 14:14:07 +00:00
etc/cling/llvm/% : $( call stripsrc ,$ ( LLVMDIRI ) ) /include /llvm /%
2012-09-05 09:37:39 +00:00
+@[ -d $( dir $@ ) ] || mkdir -p $( dir $@ )
2013-03-01 14:13:04 +00:00
cp $< $@
2012-09-05 09:37:39 +00:00
2013-02-19 14:14:07 +00:00
etc/cling/cint/% : $( CLINGDIR ) /include /cling /cint /%
2012-09-05 09:37:39 +00:00
+@[ -d $( dir $@ ) ] || mkdir -p $( dir $@ )
2013-03-01 14:13:04 +00:00
cp $< $@
2012-09-05 09:37:39 +00:00
2013-02-21 17:28:27 +00:00
etc/cling/%.h : $( CLINGDIR ) /include /cling /%.h
+@[ -d $( dir $@ ) ] || mkdir -p $( dir $@ )
2013-03-01 14:13:04 +00:00
cp $< $@
2013-02-21 17:28:27 +00:00
2012-09-05 09:37:39 +00:00
$(CLINGDIR)/%.o : $( CLINGDIR ) /%.cpp $( LLVMDEP )
2016-04-12 11:51:39 +02:00
$( MAKEDEP) -R -f$( @:.o= .d) -Y -w 1000 -- $( CXXFLAGS) $( CLINGCXXFLAGS) $( CLINGRTTI) -D__cplusplus -- $<
$( CXX) $( OPT) $( CXXMKDEPFLAGS) $( CLINGCXXFLAGS) $( CXXOUT) $@ -c $<
2012-09-05 09:37:39 +00:00
$(call stripsrc,$(CLINGDIR)/%.o) : $( CLINGDIR ) /%.cpp $( LLVMDEP )
$( MAKEDIR)
2016-04-12 11:51:39 +02:00
$( MAKEDEP) -R -f$( @:.o= .d) -Y -w 1000 -- $( CXXFLAGS) $( CLINGCXXFLAGS) $( CLINGRTTI) -D__cplusplus -- $<
$( CXX) $( OPT) $( CXXMKDEPFLAGS) $( CLINGCXXFLAGS) $( CXXOUT) $@ -c $<
2012-09-05 09:37:39 +00:00
2014-01-20 15:07:59 +01:00
$(CLINGCOMPDH) : FORCE $( LLVMDEP )
2014-01-22 15:54:01 +01:00
@mkdir -p $( dir $@ )
2016-08-11 06:12:20 -04:00
@echo '#define CLING_CXX_PATH "$(CXX) $(OPT) $(CLINGCXXFLAGSNOI)"' > $@ _tmp
2014-01-13 17:43:45 +01:00
@diff -q $@ _tmp $@ > /dev/null 2>& 1 || mv $@ _tmp $@
@rm -f $@ _tmp
2012-10-16 00:51:45 +00:00
i f n e q ( $( LLVMDEV ) , )
2012-11-10 14:14:27 +00: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 00:51:45 +00:00
$(CLINGEXE) : $( CLINGO ) $( CLINGEXEO ) $( LTEXTINPUTO )
$( RSYNC) --exclude '.svn' $( CLINGDIR) $( LLVMDIRO) /tools
2016-07-13 14:53:42 +02:00
#@cd $(LLVMDIRS)/tools && ln -sf ../../../cling # yikes
2012-10-16 00:51:45 +00:00
@mkdir -p $( dir $@ )
2012-11-10 14:14:27 +00:00
$( LD) $( CLINGLDEXPSYM) -o $@ $( CLINGO) $( CLINGEXEO) $( LTEXTINPUTO) $( CLINGLIBEXTRA)
2012-10-16 00:51:45 +00:00
e n d i f
2012-09-05 09:37:39 +00:00
##### extra rules ######
2012-10-16 00:51:45 +00:00
i f n e q ( $( LLVMDEV ) , )
2013-09-30 18:03:35 +02: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-12 16:08:21 -05:00
$(CLINGEXEO) : CLINGCXXFLAGS += -fexceptions -I $( TEXTINPUTDIRS ) -I $( LLVMDIRO ) /include
2013-08-28 09:34:28 +02:00
e l s e
2012-10-16 00:51:45 +00:00
e n d i f
2013-02-25 16:25:39 +00:00
2014-09-19 13:59:31 +02:00
CLING_VERSION = ROOT_$( shell cat " $( CLINGDIR) /VERSION " )
2014-05-09 15:16:50 +02:00
2016-04-12 11:51:39 +02:00
$(CLINGEXCEPO) : CLINGCXXFLAGS += -frtti -fexceptions
2013-03-01 14:13:04 +00:00
$(CLINGETC) : $( LLVMLIB )
$(CLINGO) : $( CLINGETC )
2014-01-13 17:43:45 +01:00
$(call stripsrc,$(MODDIR)/lib/Interpreter/CIFactory.o) : $( CLINGCOMPDH )
2015-06-05 08:38:02 +02:00
$(call stripsrc,$(MODDIR)/lib/Interpreter/CIFactory.o) : CLINGCXXFLAGS += -I $( dir $ ( CLINGCOMPDH ) ) -pthread
2014-03-08 19:10:03 +01:00
$(call stripsrc,$(MODDIR)/lib/Interpreter/Interpreter.o) : $( CLINGCOMPDH )
$(call stripsrc,$(MODDIR)/lib/Interpreter/Interpreter.o) : CLINGCXXFLAGS += -I $( dir $ ( CLINGCOMPDH ) )
2015-03-05 22:47:17 +01:00
$(call stripsrc,$(MODDIR)/lib/Interpreter/Interpreter.o) : CLINGCXXFLAGS += -DCLING_VERSION =$( CLING_VERSION )
2014-03-08 19:10:03 +01:00