-macro(add_parfile PARMODULE PARSOURCES PARHEADERS PARLINKDEF)
+macro(add_parfile PARMODULE PARSOURCES PARHEADERS PARLINKDEF PARLIBDEPS)
message(STATUS "PARfile generation: ${PARMODULE}")
- message(STATUS "--> Module: ${PARMODULE}")
- message(STATUS "--> Sources: ${PARSOURCES}")
+
+ # Libraries
+ foreach(THISLIB ${PARLIBDEPS})
+ set(_PARLIBDEPS "${_PARLIBDEPS} lib${THISLIB}")
+ endforeach()
+ string(STRIP "${_PARLIBDEPS}" PARLIBDEPS)
# Export variable
set(PARMODULE "${PARMODULE}")
+ message(STATUS "--> Module: ${PARMODULE}")
+ message(STATUS "--> Sources: ${PARSOURCES}")
+ message(STATUS "--> Deps: ${PARLIBDEPS}")
+
foreach(LOOPVAR ${PARSOURCES})
message(STATUS "----> ${LOOPVAR}")
endforeach()
# Name of this module
PAR_MODULE := @PARMODULE@
+# This module depends on the following libraries
+PAR_LIBDEPS := @PARLIBDEPS@
+
# Include paths
PAR_INCLUDES = -I. -I$(ALICE_ROOT)/include -I$(ALICE_PHYSICS)/include -I$(ROOTSYS)/include
COLZ := \033[m
# Default rule (it's the first one, "all" is just a convention)
-all: lib$(PAR_MODULE).so
+all: lib$(PAR_MODULE).rootmap lib$(PAR_MODULE).so
@echo -e "[$(COLM)$(PAR_MODULE)$(COLZ)] $(COLG)PARfile built successfully$(COLZ)"
# Abstract rule to compile classes to objects
@echo -e "[$(COLM)$(PAR_MODULE)$(COLZ)]" generating dictionary
@rootcint -f $@ -c -p $(PAR_INCLUDES) $^
+# Generate rootmap (for automatic loading of libraries)
+lib$(PAR_MODULE).rootmap: lib$(PAR_MODULE).so
+ @echo -e "[$(COLM)$(PAR_MODULE)$(COLZ)]" generating rootmap
+ @rlibmap -o $@ -l lib$(PAR_MODULE) -d $(PAR_LIBDEPS) -c $(DHDR)
+
# Delete all
clean:
- rm -f $(OBJS) *.so G__$(PAR_MODULE).*
+ rm -f $(OBJS) *.so G__$(PAR_MODULE).* *.rootmap
const char *wd = gSystem->WorkingDirectory();
// Set include path for CINT (PARfile is unpacked as a subfolder of current workdir)
+ // TODO: prepend path instead of appending (not currently supported by ROOT!)
buf.Form(".include %s", wd);
gROOT->ProcessLine(buf.Data());
- // Prepend include path for other stuff
+ // Prepend include path for compiled code
buf.Form("-I%s %s", wd, gSystem->GetIncludePath());
gSystem->SetIncludePath(buf.Data());
buf.Form("%s:%s", wd, gSystem->GetDynamicPath());
gSystem->SetDynamicPath(buf.Data());
- // Load library
- if ( gSystem->Load("lib@PARMODULE@") < 0 ) {
- // Error loading
- return -1;
- }
+ // Add our rootmap
+ // TODO: disabled because it triggers actual library loading wherever it finds nested classes!
+ // buf.Form("%s/lib@PARMODULE@.rootmap", wd);
+ // gInterpreter->UnloadLibraryMap("lib@PARMODULE@");
+ // gInterpreter->LoadLibraryMap(buf.Data());
- // Set our location, so that other packages can find us
- //gSystem->Setenv("@PARMODULE@_INCLUDE", "@PARMODULE@");
-
- // Set our lib coordinates, so that other packages can link to us
- //buf.Form("-L%s -l@PARMODULE@", wd);
- //gSystem->Setenv("@PARMODULE@_LIBS", buf.Data());
+ // Note: there is no need to actually load the library thanks to the rootmap
return 0;
}