# # # $Header$ # # # This is a generic makefile used to build all the source in the # current directory (anything with a .c, .cc, .cxx, .cpp or .F # suffix) into a library. This file is actually included by another # file which implements the actual rule. The idea is that a given # directory will contain source that represents a library, # in which case Makefile.lib is included, or an executable, # in which case Makefile.bin is included. # .PHONY: mkdirs clean env all first # The first target is made by default when make is invoked with no # arguments. We want to include other targets here (namely, depends # files) so we need to make a dummy target appear first that calls # the real default target which resides in either Makefile.bin or # Makefile.lib first: all ifndef OSNAME OSNAME = $(shell uname) endif ifndef FC FC = g77 endif ifndef CC CC = gcc endif ifndef CXX CXX = g++ endif # Only the GNU compiler seems to support the -MM option right now. # hence, we define separate compilers for creating the gmake rules ifndef DFC DFC = g77 endif ifndef DCC DCC = gcc endif ifndef DCXX DCXX = g++ endif LIB_DIR = $(HALLD_HOME)/lib/$(OSNAME) BIN_DIR = $(HALLD_HOME)/bin/$(OSNAME) DEP_DIR = .depends/$(OSNAME) # Sometimes, one wants to build executables by linking to the common # area libraries, but putting the executables in a local or private # directory. This is handled by defining the HALLD_MY environment # variable to point to the top level directory where the output should # go. If HALLD_MY is not set, then everything defaults to HALLD_HOME. ifdef HALLD_MY BIN_DIR = $(HALLD_MY)/bin/$(OSNAME) LIB_DIR = $(HALLD_MY)/lib/$(OSNAME) FFLAGS += -I. -I$(HALLD_MY)/src/include -I$(HALLD_MY)/src/libraries/include CFLAGS += -I. -I$(HALLD_MY)/src/include -I$(HALLD_MY)/src/libraries/include CXXFLAGS += -I. -I$(HALLD_MY)/src/include -I$(HALLD_MY)/src/libraries/include endif FFLAGS += -I. -I$(HALLD_HOME)/src/include -I$(HALLD_HOME)/src/libraries/include -I$(HALLD_HOME)/src/libraries CFLAGS += -I. -I$(HALLD_HOME)/src/include -I$(HALLD_HOME)/src/libraries/include -I$(HALLD_HOME)/src/libraries CXXFLAGS += -I. -I$(HALLD_HOME)/src/include -I$(HALLD_HOME)/src/libraries/include -I$(HALLD_HOME)/src/libraries # Include user specified package makefiles BMS_PATH = $(HALLD_HOME)/src/BMS PACKAGE_MAKEFILES = $(foreach name,$(subst :, ,$(PACKAGES)),$(BMS_PATH)/Makefile.$(name)) ifdef PACKAGES include $(PACKAGE_MAKEFILES) endif FSRC += $(wildcard *.F) CSRC += $(wildcard *.c) CXXSRC += $(wildcard *.cc *.cpp *.cxx) # Create ROOT dictionaries from C++ files containing ClassDef HSRC = $(wildcard *.h) ifneq ($(strip $(HSRC)),) DICT_IN = $(shell grep -l "ClassDef" $(HSRC)) ifneq ($(strip $(DICT_IN)),) DICT_SRC = $(addsuffix _Dict.cc,$(basename $(DICT_IN))) DICT_FILES = $(DICT_SRC) $(DICT_SRC:.cc=.h) endif endif NON_DICT_OBJS = $(addsuffix .o,$(basename $(FSRC) $(CSRC) $(CXXSRC))) DEPS = $(NON_DICT_OBJS:.o=.d) # Note: we use sort here just to remove duplicates OBJS = $(sort $(NON_DICT_OBJS) $(addsuffix .o,$(basename $(DICT_SRC)))) ifdef ONLINE CFLAGS += -DONLINE CXXFLAGS += -DONLINE LIBS += -let -lposix4 -lpthread endif ifdef DEBUG DEBUG_SUFFIX = _d FFLAGS += -g -pg CFLAGS += -g -pg CXXFLAGS += -g -pg else # Do NOT turn on optimization in FFLAGS. Compilation will fail on hddsGeant3.F CFLAGS += -O2 CXXFLAGS += -O2 endif ifdef JILIO CXXFLAGS += -DJILIO endif ifndef MODULE_NAME MODULE_NAME = $(shell basename $(shell pwd)) endif LIBNAME = $(LIB_DIR)/lib$(MODULE_NAME)$(DEBUG_SUFFIX).a # Include platform specific definitions # (the "-" at the front means don't error if the file doesn't exist) -include $(HALLD_HOME)/src/BMS/Makefile.$(OSNAME) # For GNU compilers, add verbose warnings ifeq ($(FC),g77) FFLAGS += -Wall endif ifeq ($(CC),gcc) CFLAGS += -Wall endif ifeq ($(CXX),g++) CXXFLAGS += -Wall endif # Include all dependancy files ifneq ($(strip $(DEPS)),) -include $(foreach s,$(DEPS),$(DEP_DIR)/$s) endif