# # # $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 OS OS = $(shell uname) endif ifndef ARCH ARCH = $(shell uname -p) endif ifndef OSNAME OSNAME = $(OS)-$(ARCH) 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 = .lib/$(OSNAME) BIN_DIR = .bin/$(OSNAME) DEP_DIR = .depends/$(OSNAME) INSTALL_DIR = $(HALLD_HOME)# (gets overwritten with HALLD_MY below) # include working directory and parent directory first FFLAGS += -I. -I.. -I../include CFLAGS += -I. -I.. -I../include CXXFLAGS += -I. -I.. -I../include # include HALLD_MY include directory (if HALLD_MY) is defined ifdef HALLD_MY FFLAGS += -I$(HALLD_MY)/include CFLAGS += -I$(HALLD_MY)/include CXXFLAGS += -I$(HALLD_MY)/include INSTALL_DIR = $(HALLD_MY) endif # include HALLD_HOME include directory FFLAGS += -I$(HALLD_HOME)/include CFLAGS += -I$(HALLD_HOME)/include CXXFLAGS += -I$(HALLD_HOME)/include # Include user specified package makefiles PACKAGE_MAKEFILES = $(foreach name,$(subst :, ,$(PACKAGES)),$(HALLD_HOME)/src/BMS/Makefile.$(name)) ifdef PACKAGES include $(PACKAGE_MAKEFILES) endif FSRC += $(wildcard *.F) CSRC += $(wildcard *.c) CXXSRC += $(wildcard *.cc *.cpp *.cxx) # Note: we use sort here just to remove duplicates OBJS += $(NO_DEP_OBJS) OBJS += $(sort $(addsuffix .o,$(basename $(FSRC) $(CSRC) $(CXXSRC)))) ODEPS = $(filter-out $(NO_DEP_OBJS),$(OBJS)) DEPS += $(ODEPS:.o=.d) 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 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.$(OS) -include $(HALLD_HOME)/src/BMS/Makefile.$(ARCH) -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