-
Stephen A. Wood authored
Make setup scripts work from anywhere (so can be added to login script) Makefile builds the Hall A analyzer.
Stephen A. Wood authoredMake setup scripts work from anywhere (so can be added to login script) Makefile builds the Hall A analyzer.
Makefile 5.03 KiB
#------------------------------------------------------------------------------
# Names of source files and target libraries
# You do want to modify this section
# List all your source files here. They will be put into a shared library
# that can be loaded from a script.
# List only the implementation files (*.cxx). For every implementation file
# there must be a corresponding header file (*.h).
SRC = src/THcInterface.cxx src/THcParmList.cxx
# Name of your package.
# The shared library that will be built will get the name lib$(PACKAGE).so
PACKAGE = HallC
# Name of the LinkDef file
LINKDEF = src/$(PACKAGE)_LinkDef.h
#------------------------------------------------------------------------------
# This part defines overall options and directory locations.
# Change as necessary,
# Compile debug version
export DEBUG = 1
# Architecture to compile for
ARCH = linux
#ARCH = solarisCC5
#------------------------------------------------------------------------------
# Directory locations. All we need to know is INCDIRS.
# INCDIRS lists the location(s) of the C++ Analyzer header (.h) files
# The following should work with both local installations and the
# Hall A counting house installation. For local installations, verify
# the setting of ANALYZER, or specify INCDIRS explicitly.
# To use this makefile without modif, you need to have the ANALYZER environment
# variable defined, pointing to the directory where the Hall A analyzer (Podd)
# that you use is located
ifndef ANALYZER
$(error $$ANALYZER environment variable not defined)
endif
INCDIRS = $(wildcard $(addprefix $(ANALYZER)/, include src hana_decode hana_scaler)), $(shell pwd)/src
#------------------------------------------------------------------------------
# Do not change anything below here unless you know what you are doing
ifeq ($(strip $(INCDIRS)),)
$(error No Analyzer header files found. Check $$ANALYZER)
endif
ROOTCFLAGS := $(shell root-config --cflags)
ROOTLIBS := $(shell root-config --libs)
ROOTGLIBS := $(shell root-config --glibs)
INCLUDES = $(ROOTCFLAGS) $(addprefix -I, $(INCDIRS) )
#INCLUDES = $(ROOTCFLAGS) $(addprefix -I, $(INCDIRS) ) -I$(shell pwd)
USERLIB = lib$(PACKAGE).so
USERDICT = $(PACKAGE)Dict
LIBS =
GLIBS =
ifeq ($(ARCH),solarisCC5)
# Solaris CC 5.0
CXX = CC
ifdef DEBUG
CXXFLAGS = -g
LDFLAGS = -g
else
CXXFLAGS = -O
LDFLAGS = -O
endif
CXXFLAGS += -KPIC
LD = CC
SOFLAGS = -G
endif
ifeq ($(ARCH),linux)
# Linux with egcs (>= RedHat 5.2)
CXX = g++
ifdef DEBUG
CXXFLAGS = -g -O0
LDFLAGS = -g -O0
else
CXXFLAGS = -O
LDFLAGS = -O
endif
CXXFLAGS += -Wall -Woverloaded-virtual -fPIC
LD = g++
SOFLAGS = -shared
endif
ifeq ($(CXX),)
$(error $(ARCH) invalid architecture)
endif
CXXFLAGS += $(INCLUDES)
LIBS += $(ROOTLIBS) $(SYSLIBS)
GLIBS += $(ROOTGLIBS) $(SYSLIBS)
MAKEDEPEND = gcc
ifdef WITH_DEBUG
CXXFLAGS += -DWITH_DEBUG
endif
ifdef PROFILE
CXXFLAGS += -pg
LDFLAGS += -pg
endif
ifndef PKG
PKG = lib$(PACKAGE)
LOGMSG = "$(PKG) source files"
else
LOGMSG = "$(PKG) Software Development Kit"
endif
DISTFILE = $(PKG).tar.gz
#------------------------------------------------------------------------------
OBJ = $(SRC:.cxx=.o)
RCHDR = $(SRC:.cxx=.h) src/THcGlobals.h
HDR = $(SRC:.cxx=.h)
DEP = $(SRC:.cxx=.d) src/main.d
OBJS = $(OBJ) $(USERDICT).o
HDR_COMPILEDATA = $(ANALYZER)/src/ha_compiledata.h
all: $(USERLIB) hcana
LIBDIR:=$(ANALYZER)
LIBHALLA := $(LIBDIR)/libHallA.so
LIBDC := $(LIBDIR)/libdc.so
LIBSCALER := $(LIBDIR)/libscaler.so
HALLALIBS := -L$(LIBDIR) -lHallA -ldc -lscaler
src/THcInterface.d: $(HDR_COMPILEDATA)
hcana: src/main.o $(LIBDC) $(LIBSCALER) $(LIBHALLA) $(USERLIB)
$(LD) $(LDFLAGS) $< $(HALLALIBS) -L. -lHallC $(GLIBS) -o $@
$(USERLIB): $(HDR) $(OBJS)
$(LD) $(LDFLAGS) $(SOFLAGS) -o $@ $(OBJS)
@echo "$@ done"
$(HDR_COMPILEDATA): $(ANALYZER)/Makefile
@echo "Building Podd"
@cd $(ANALYZER) ; make
$(LIBHALLA): $(ANALYZER)/Makefile
@echo "Building Podd"
@cd $(ANALYZER) ; make
$(USERDICT).cxx: $(RCHDR) $(HDR) $(LINKDEF)
@echo "Generating dictionary $(USERDICT)..."
$(ROOTSYS)/bin/rootcint -f $@ -c $(INCLUDES) $^
install: all
cp -p $(USERLIB) $(HOME)/cue/SRC/ana
clean:
rm -f *.o *~ $(USERLIB) $(USERDICT).*
realclean: clean
rm -f *.d
srcdist:
rm -f $(DISTFILE)
rm -rf $(PKG)
mkdir $(PKG)
cp -p $(SRC) $(HDR) $(LINKDEF) db*.dat README Makefile $(PKG)
gtar czvf $(DISTFILE) --ignore-failed-read \
-V $(LOGMSG)" `date -I`" $(PKG)
rm -rf $(PKG)
.PHONY: all clean realclean srcdist
.SUFFIXES:
.SUFFIXES: .c .cc .cpp .cxx .C .o .d
%.o: %.cxx
$(CXX) $(CXXFLAGS) -o $@ -c $<
# FIXME: this only works with gcc
%.d: %.cxx
@echo Creating dependencies for $<
@$(SHELL) -ec '$(MAKEDEPEND) -MM $(INCLUDES) -c $< \
| sed '\''s%^.*\.o%$*\.o%g'\'' \
| sed '\''s%\($*\)\.o[ :]*%\1.o $@ : %g'\'' > $@; \
[ -s $@ ] || rm -f $@'
###
-include $(DEP)