Subversion Repositories f9daq

Rev

Blame | Last modification | View Log | RSS feed

# Makefile tutorial: https://www.gnu.org/software/make/manual/html_node/index.html#SEC_Contents
 
# Make variables ----------------------------------------------------

# ROOT include and libraries
ROOTINC=$(shell root-config --incdir)
ROOTLIB=$(shell root-config --libs)
GRROOTLIB=$(shell root-config --cflags --glibs)

# Source and debug directories
SRC=./src
DBG=./dbg
IDIR=./include
BIN=./bin
DICT=./dict
LDIR=./lib

# Includes and libraries, 32 vs. 64 bit type, libraries
INC=-I. -I$(ROOTINC)
OSTYPE=none
LIBS=$(ROOTLIB) -L. -lm

# Compiler options
COMPOPT=-fPIC -g -Wno-unused-value
#COMPOPT=-fPIC -g -Wall

# CAMAC DAQ library variables
OBJ_FILES =  $(SRC)/wusbxx_dll.o $(SRC)/libxxusb.o 
LIBFILE = $(LDIR)/libdaqusb.a

# Specific variables for the main program
TARGET=sipmscan
#FILES=$(SRC)/sipmscan.cpp $(SRC)/substructure.cpp $(SRC)/connections.cpp $(SRC)/window_layout.cpp $(SRC)/separate_functions.cpp $(SRC)/tooltips.cpp
DAQFILE  = $(SRC)/daqusb.C
#FILES=$(wildcard $(SRC)/*.cpp) $(SRC)/daqusb.C $(SRC)/daqscope.C
FILES=$(shell find $(SRC)/ ! -name "libxxusb.cpp" -name "*.cpp") $(SRC)/daqusb.C $(SRC)/daqscope.C
HEADER=$(IDIR)/daq.h $(IDIR)/workstation.h $(IDIR)/sipmscan.h $(IDIR)/root_include.h
CAMLIB = $(LIBFILE)
SHLIB = $(LIBFILE) $(LDIR)/libvxi11.a

# VXI scope connection variables, Scope DAQ library variables
VXIDIR = $(IDIR)/vxi11_$(OSTYPE)
#VXI_FILES = $(VXIDIR)/vxi11_user.o $(VXIDIR)/vxi11.h $(VXIDIR)/vxi11_clnt.c $(VXIDIR)/vxi11_xdr.c
VXI_OBJECT = $(VXIDIR)/vxi11_user.o $(VXIDIR)/vxi11_clnt.o $(VXIDIR)/vxi11_xdr.o

# -------------------------------------------------------------------

# Base rules --------------------------------------------------------

# Make the main program and libraries
all: libsubstr.so $(LDIR)/libdaqusb.so $(LDIR)/libvxi11.so $(TARGET) 

# Rules for making the main program
$(TARGET): $(FILES) library
        @echo "\n# Generating dictionary GuiDict.C ---------------------------"
        rootcint -f $(DICT)/GuiDict.C -c -p $(INC) $(CPPFLAGS) $(IDIR)/sipmscan.h $(DICT)/GuiLinkDef.h
        @echo "\n# Checking to see if bin directory already exists -----------"
        if [ ! -d "$(BIN)" ];then  mkdir $(BIN);  fi
        @echo "\n# Compiling main program ------------------------------------"
        $(CXX) $(INC) $(COMPOPT) $(FILES) $(DICT)/GuiDict.C $(CPPFLAGS) $(VXI_OBJECT) -o $(BIN)/$(TARGET) $(SHLIB) $(GRROOTLIB) -lstdc++ -lSpectrum -L$(LDIR)/libsubstr.so -L$(LDIR)/libdaqusb.so -L$(LDIR)/libvxi11.so
        @echo "\n# Compilation successful ------------------------------------"
        @echo "# Use ./start.sh to run the program -------------------------"

# -------------------------------------------------------------------

# CAMAC DAQ library rules -----------------------------------------------------

# Rules for making CAMAC DAQ library source files (wusbxx_dll and libxxusb)
library: $(OBJ_FILES)

$(OBJ_FILES): $(SRC)/wusbxx_dll.c $(IDIR)/wusbxx_dll.h $(SRC)/libxxusb.cpp $(IDIR)/libxxusb.h
        @echo "\n# Compiling CAMAC USB source files --------------------------"
        $(CXX) $(CPPFLAGS) $(INC) -c $(SRC)/wusbxx_dll.c -o $(SRC)/wusbxx_dll.o
        $(CXX) $(CPPFLAGS) $(INC) -c $(SRC)/libxxusb.cpp -o $(SRC)/libxxusb.o

.cc.o:
        @echo "\n# Creating a static CAMAC USB library (libdaqusb.a) ---------"
        $(CXX) -fPIC -c $<
        ar r $(LIBFILE) $@

.cpp.o:
        @echo "\n# Creating a static CAMAC USB library (libdaqusb.a) ---------"
        $(CXX) -fPIC -c $<
        ar r $(LIBFILE) $@

.c.o:
        @echo "\n# Creating a static CAMAC USB library (libdaqusb.a) ---------"
        $(CXX) -fPIC -c  $<
        ar r $(LIBFILE) $@

# Rule for making the CAMAC DAQ library (libdaqusb.so)
$(LDIR)/libdaqusb.so: $(LIBFILE) $(DAQFILE)
        @echo "\n# Generating dictionary Dict.C ------------------------------"
        rootcint -f $(DICT)/Dict.C -c $(INC)  $(CPPFLAGS) $(HEADER) $(DICT)/LibLinkDef.h
        @echo "\n# Checking to see if lib directory already exists -----------"
        if [ ! -d "$(LDIR)" ];then  mkdir $(LDIR);  fi
        @echo "\n# Compiling CAMAC DAQ library (libdaqusb.so) ----------------"
        $(CXX) $(CPPFLAGS) $(INC) -fPIC -g -Wall $(DAQFILE) $(DICT)/Dict.C $(CAMLIB) -shared -o $@

# Rule for making the CAMAC DAQ library (libdaqusb.a)
$(LIBFILE): $(OBJ_FILES)
        @echo "\n# Creating a static CAMAC USB library (libdaqusb.a) ---------"
        ar r $@ $^
# -----------------------------------------------------------------------------

# Scope DAQ library rules -----------------------------------------------------

$(LDIR)/libvxi11.so: $(LDIR)/libvxi11.a
        @echo "\n# Generating dictionary VxiDict.C ---------------------------"
        rootcint -f $(DICT)/VxiDict.C -c $(INC) $(CPPFLAGS) $(IDIR)/daqscope.h $(DICT)/LibLinkDef.h
        @echo "\n# Checking to see if lib directory already exists -----------"
        if [ ! -d "$(LDIR)" ];then  mkdir $(LDIR);  fi
        @echo "\n# Compiling scope VXI library (libvxi11.so) -----------------"
        $(CXX) $(CPPFLAGS) $(INC) -fPIC -g -Wall $(SRC)/daqscope.C $(DICT)/VxiDict.C -L. $(LDIR)/libvxi11.a -shared -o $@

$(LDIR)/libvxi11.a: $(VXI_OBJECT)
        ar r $@ $^
# -----------------------------------------------------------------------------

# Substructue library rules ---------------------------------------------------

# Rules for making user defined libraries
libsubstr.so: libsubstr.a
        @echo "\n# Creating a shared testing library -------------------------"
        rootcint -f $(DICT)/TestDict.C -c $(INC) $(CPPFLAGS) $(IDIR)/substructure.h $(DICT)/TestLinkDef.h
        $(CXX) $(CPPFLAGS) $(INC) $(COMPOPT) $(SRC)/substructure.cpp $(DICT)/TestDict.C libsubstr.a -shared -o $@
        @echo "\n# Checking to see if lib directory already exists -----------"
        if [ ! -d "$(LDIR)" ];then  mkdir $(LDIR);  fi
        mv $@ $^ $(LDIR)/

libsubstr.a: $(SRC)/substructure.o
        @echo "\n# Creating a static testing library -------------------------"
        ar r $@ $^

$(SRC)/substructure.o: $(SRC)/substructure.cpp $(IDIR)/substructure.h
        @echo "\n# Compiling separate source files ---------------------------"
        $(CXX) $(CPPFLAGS) $(INC) -c $(SRC)/substructure.cpp -o $(SRC)/substructure.o

# -------------------------------------------------------------------

# Cleaning rules ----------------------------------------------------

# Rules for cleaning the installation
clean:
        @echo "# Cleaning the installation directory -------------------------"
        rm -fr $(DICT)/*Dict.C $(DICT)/*Dict.h $(BIN) $(LDIR) start.sh *.o $(SRC)/*.o
        rm -fr $(IDIR)/workstation.h $(SRC)/daqscope.C $(SRC)/daqusb.C $(IDIR)/usb.h $(IDIR)/libxxusb.h $(DBG)/finish_sig.txt

# -------------------------------------------------------------------