# --------------------------------------------------------------------------- # \author mdejong # # This file implements the part of the general make procedure which # provides for the global definitions and auxiliary methods. # # In this file, the used suffixes are defined. # To avoid application of implicit rules, all other suffixes are removed. # # The default values for the various file lists are defined here # which will subsequently be used in JMakedependencies according # the rules defined in JMakerules. # # In general, the prefixes NATIVE and PUBLIC refer to # local files (i.e. files which reside in the current working directory) and # public files (i.e. files which reside in the common output directory), respectively. # # The symbol NATIVE_SRCS refers to a list of C++ source files # which should locally be compiled and linked. # For the compilation and linking of these files, # the symbols NATIVE_OBJS and NATIVE_BINS are reserved. # # The symbols NATIVE_BINS and NATIVE_LIBS refer to the list of # locally created executable and library files, respectively. # # The symbols PUBLIC_BINS and PUBLIC_LIBS refer to the list of # executable files and library files which should be installed # in the directories $JPP_BIN and $JPP_LIB, respectively. # By default, all files contained in the lists NATIVE_BINS and # NATIVE_LIBS are installed. # # The symbols NATIVE_SCRIPTS and PUBLIC_SCRIPTS refer to the list # of local and public scripts, respectively. # By default, all files contained in the lists NATIVE_SCRIPTS are # installed in directory $JPP_BIN. # # The symbol NATIVE_DOCS refers to the list of document files # which should locally be typeset. # # The symbol PUBLIC_DOCS refers to the list of document files # which should be installed in the directory $JPP_DOC. # By default, all files contained in the list NATIVE_DOCS # are installed. # # The names of files produced conform portable data format have # extension PDF rather than pdf to mark the difference # files that are part of the repository. # # Note that a designated namespace is defined for each project, namely: # KM3NET, KM3NET_HIGHQE and ANTARES for KM3NeT, KM3NeT with high QE PMT # and Antares, respectively. # In order to make an experiment specific installation, a corresponding # target is defined here. # # An project specific installation can then be made by: # # make Antares # make KM3NeT # make KM3NeT_highQE # # --------------------------------------------------------------------------- ifndef __JMAKEDEFINES__ __JMAKEDEFINES__=$(lastword $(MAKEFILE_LIST)) #.DEFAULT_GOAL := default default: # Auxiliary functions # Convert the given set of white space separated words into a unique set of words. # # param set of paths # return set of paths # unique =$(if $(1),\ $(firstword $(1)) \ $(call unique,$(filter-out $(firstword $(1)), $(wordlist 2, $(words $(1)), $(1))))) # Insert path at begin of given set of paths if not yet present. # # param path # param set of paths # return set of paths # insert =$(if $(findstring $(subst //,/,$(1)),$(subst //,/,$(2))),$(2),$(1):$(2)) # Get complete path of given shell command. # # param command # return path (empty if command not found) # which =$(shell which $(1) 2> /dev/null) # File name extensions for typesetting of documents. TEX := $(if $(call which, pdflatex),.PDF,.TEX) PPTX := $(if $(call which, libreoffice),.PDF,.PPTX) DOCX := $(if $(call which, libreoffice),.PDF,.DOCX) # Typeset documents. # The file name extensitions are replaced according availability of drivers. # # param set of file names # return set of file names # typeset =$(subst .docx,$(DOCX), $(subst .pptx,$(PPTX), $(subst .tex,$(TEX), $(1)))) # Extract to-be binary files, i.e. source files with a main routine. # # param set of source file names # return set of binary file names # binary =$(if $(1),$(patsubst %.cc,%,$(shell egrep -l "int +main" $(1))),) # Extract files for rootcint, i.e. include files with some ClassDef. # # param set of include file names # return set of include file names # linkdef =$(if $(1),$(shell egrep -l "ClassDef" $(1)),) # Get ROOT pcm files # # param dictionary name # return pcm file name (or empty if ROOT version is 5) # rootpcm =$(if $(subst 5,,$(ROOT_VERSION)),$(1)_rdict.pcm,) # System SYSTEM := $(shell uname -s) MACHINE := $(shell uname -m) PROCESSOR := $(shell uname -p) GIT_EXITCODE := $(shell git status > /dev/null 2>&1; echo $$?) ifeq ($(GIT_EXITCODE),0) GIT_VERSION := $(shell cd $(JPP_DIR); git --no-pager describe --tags --always | sed -r 's/^v([0-9].*)/\1/g') GIT_COMMIT := $(shell cd $(JPP_DIR); git rev-parse --verify HEAD) GIT_DATE := $(firstword $(shell cd $(JPP_DIR); git --no-pager show \ --date=iso \ --format="%ad" \ --name-only \ | sed "s/./T/11" | sed "s/.//20")) # If working tree is dirty, append dirty flag ifneq ($(strip $(shell cd $(JPP_DIR); git status --porcelain 2>/dev/null)),) GIT_VERSION := $(GIT_VERSION)-D endif else GIT_VERSION := "?" GIT_COMMIT := "?" GIT_DATE := "?" endif BUILD_DATE := $(shell date "+%Y-%m-%dT%H:%M:%S%z") MKDIR := mkdir -p INSTALL := install INSTALL_MODE := -m 644 -p INSTALL_XMODE := -m 755 RM := rm -f CP := cp -f DOXYGEN := doxygen # Jpp/ JPP_OUT = $(JPP_DIR)/out/ JPP_BIN = $(JPP_OUT)/$(SYSTEM)/bin/ JPP_LIB = $(JPP_OUT)/$(SYSTEM)/lib/ JPP_DOC = $(JPP_DIR)/doc/ JPP_INCLUDE = $(JPP_DIR)/software/ JPP_EXTERNALS = $(JPP_DIR)/externals/ JPP_DATA = $(JPP_DIR)/data/ INFO := $(JPP_DIR)/README/INFO JPP_LIBS := -llang -luuid JDAQ_CHSM := -lDAQ_CHSM JTRIGGER_LIBS := -ltriggerROOT $(JPP_LIBS) JEVT_LIBS := -levtROOT $(JPP_LIBS) JAANET_LIBS := -ljaanetROOT $(JPP_LIBS) JCOMPAREHISTOGRAMS_LIBS := -ljcomparehistogramsROOT $(JPP_LIBS) JACOUSTICS_LIBS := -lacousticsROOT $(JPP_LIBS) JCOMPASS_LIBS := -lcompassROOT $(JPP_LIBS) JMARKOV_LIBS := -lmarkovROOT # KM3NeT DAQ KM3NET_LIB = $(JPP_EXTERNALS)/km3net-dataformat/lib KM3NET_LIBS := -lKM3NeTROOT -lEG # Antares ANTARES_LIB = $(JPP_EXTERNALS)/antares-dataformat ANTARES_LIBS := -lAntaresDAQROOT # Flux FLUX_LIB = $(JPP_EXTERNALS)/flux FLUX_INCLUDE = $(JPP_EXTERNALS)/flux FLUX_LIBS := -lKM3NeTflux # Database JDB_LIB = $(JPP_EXTERNALS)/dbclient/lib JDB_INCLUDE = $(JPP_EXTERNALS)/dbclient/include JDB_LIBS := -ljdbROOT -lKM3NeTDBClient # ROOT ROOTLIBS = $(shell root-config --libs) ROOTGLIBS = $(shell root-config --glibs) ROOTINCL = $(shell root-config --cflags) ROOT_VERSION = $(shell root-config --version | sed 's/\..*//') ROOTCINTFLAGS = -I$(JPP_INCLUDE) -I$(JPP_EXTERNALS) -DNAMESPACE=$(NAMESPACE) -inlineInputHeader # CHSM #CHSM_DIR = $(CHSM_DIR) CHSM2CXX = $(CHSM_DIR)/bin/chsm2c++ CHSM_LIBS = $(CHSM_DIR)/lib/libchsm.a -lpthread CHSM_INCLUDE = $(CHSM_DIR)/include CHSM_CXXFLAGS = -DCHSM_MULTITHREADED -D_REENTRANT # DAQ MAKEFILE_DAQ := Makefile.DAQ # PATH ifeq ($(origin PATH), undefined) PATH := . endif PATH:=$(call insert,$(ROOTSYS)/bin,$(PATH)) # LD_LIBRARY_PATH ifeq ($(origin LD_LIBRARY_PATH), undefined) LD_LIBRARY_PATH := . endif LD_LIBRARY_PATH:=$(call insert,$(ROOTSYS)/lib,$(LD_LIBRARY_PATH)) LD_LIBRARY_PATH:=$(call insert,$(JPP_LIB),$(LD_LIBRARY_PATH)) # C++ compiler CXX := g++ CXXFLAGS += -Wall -ansi -fPIC -std=c++11 ifdef JPP_COVERAGE CXXFLAGS += -fprofile-arcs -ftest-coverage --coverage -fno-inline -fno-inline-small-functions -fno-default-inline else CXXFLAGS += -O3 # -Os endif ifdef VALGRIND_COVERAGE CXXFLAGS += -g endif ifdef GPROF_COVERAGE CXXFLAGS += -pg endif CXXFLAGS += -I$(JPP_INCLUDE) CXXFLAGS += -I$(JPP_EXTERNALS) CXXFLAGS += $(ROOTINCL) CXXFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\"\ -DGIT_COMMIT=\"$(GIT_COMMIT)\"\ -DGIT_DATE=\"$(GIT_DATE)\"\ -DBUILD_DATE=\"$(BUILD_DATE)\" CXXFLAGS += -DNAMESPACE=$(NAMESPACE) SOFLAGS = -O -shared LDFLAGS += -Wl,--as-needed -L$(JPP_LIB) -L$(KM3NET_LIB) -L$(ANTARES_LIB) -L$(FLUX_LIB) LOADLIBES += $(JPP_LIBS) $(ROOTLIBS) LOADLIBES += -lz # Coverage ifdef JPP_COVERAGE LDFLAGS += -lgcov --coverage -fprofile-arcs SOFLAGS += -lgcov --coverage -fprofile-arcs endif ifdef VALGRIND_COVERAGE LDFLAGS += -g SOFLAGS += -g endif ifdef GPROF_COVERAGE LDFLAGS += -pg SOFLAGS += -pg endif # microsoft LIBREOFFICE = libreoffice -env:UserInstallation=file:///tmp/ --headless --invisible --convert-to PDF:writer_pdf_Export # latex PDFLATEX = pdflatex BIBTEX = bibtex # Boost ifneq ("$(BOOST_ROOT)", "") CXXFLAGS += -I$(BOOST_ROOT)/include LDFLAGS += -L$(BOOST_ROOT)/lib endif # Suffixes .SUFFIXES: .SUFFIXES: .so .o .d .cc .hh .h .PDF .tex .PPTX .pptx .DOCX .docx # Default values for lists of native files NATIVE_SRCS = $(wildcard *.cc) NATIVE_OBJS = $(NATIVE_SRCS:.cc=.o) NATIVE_BINS = $(call binary,$(NATIVE_SRCS)) NATIVE_SCRIPTS = $(wildcard *.sh) $(wildcard *.csh) NATIVE_DOCS = $(call typeset, $(wildcard *.tex *.pptx *.docx)) NATIVE_DOCS += $(subst .pptx,.PPTX, $(wildcard *.pptx)) # Generation of public executable and library files only when originals reside in sub-directory software/ JPP_SOFTWARE = $(abspath $(JPP_DIR)/software) ifeq ($(findstring $(JPP_SOFTWARE), $(shell cd ..; pwd -L)), $(JPP_SOFTWARE)) PUBLIC_BINS += $(addprefix $(JPP_BIN), $(NATIVE_BINS)) PUBLIC_SCRIPTS += $(addprefix $(JPP_BIN), $(NATIVE_SCRIPTS)) PUBLIC_LIBS += $(addprefix $(JPP_LIB), $(NATIVE_LIBS)) endif # Generation of public documentation files only when originals reside in sub-directory documentation/ JPP_DOCUMENTATION = $(abspath $(JPP_DIR)/documentation) ifeq ($(findstring $(JPP_DOCUMENTATION), $(shell cd ..; pwd -L)), $(JPP_DOCUMENTATION)) PUBLIC_DOCS += $(addprefix $(JPP_DOC), $(NATIVE_DOCS)) endif # Experiment specific namespace definition KM3NeT: NAMESPACE := KM3NET KM3NeT_highQE: NAMESPACE := KM3NET_HIGHQE Antares: NAMESPACE := ANTARES ifndef NAMESPACE NAMESPACE := KM3NET endif export NAMESPACE KM3NeT: default KM3NeT_highQE: default Antares: default endif