Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
146 | f9daq | 1 | # Makefile tutorial: https://www.gnu.org/software/make/manual/html_node/index.html#SEC_Contents |
2 | |||
3 | # Make variables ---------------------------------------------------- |
||
4 | |||
5 | # ROOT include and libraries |
||
6 | ROOTINC=$(shell root-config --incdir) |
||
7 | ROOTLIB=$(shell root-config --libs) |
||
8 | GRROOTLIB=$(shell root-config --cflags --glibs) |
||
9 | |||
10 | # Source and debug directories |
||
11 | SRC=./src |
||
12 | DBG=./dbg |
||
13 | IDIR=./include |
||
14 | BIN=./bin |
||
15 | DICT=./dict |
||
16 | LDIR=./lib |
||
17 | |||
18 | # Includes and libraries, 32 vs. 64 bit type, libraries |
||
19 | INC=-I. -I$(ROOTINC) |
||
20 | OSTYPE=none |
||
21 | LIBS=$(ROOTLIB) -L. -lm |
||
22 | |||
23 | # Compiler options |
||
24 | COMPOPT=-fPIC -g -Wno-unused-value |
||
25 | #COMPOPT=-fPIC -g -Wall |
||
26 | |||
27 | # CAMAC DAQ library variables |
||
28 | OBJ_FILES = $(SRC)/wusbxx_dll.o $(SRC)/libxxusb.o |
||
29 | LIBFILE = $(LDIR)/libdaqusb.a |
||
30 | |||
31 | # Specific variables for the main program |
||
32 | TARGET=sipmscan |
||
33 | #FILES=$(SRC)/sipmscan.cpp $(SRC)/substructure.cpp $(SRC)/connections.cpp $(SRC)/window_layout.cpp $(SRC)/separate_functions.cpp $(SRC)/tooltips.cpp |
||
34 | DAQFILE = $(SRC)/daqusb.C |
||
35 | #FILES=$(wildcard $(SRC)/*.cpp) $(SRC)/daqusb.C $(SRC)/daqscope.C |
||
36 | FILES=$(shell find $(SRC)/ ! -name "libxxusb.cpp" -name "*.cpp") $(SRC)/daqusb.C $(SRC)/daqscope.C |
||
37 | HEADER=$(IDIR)/daq.h $(IDIR)/workstation.h $(IDIR)/sipmscan.h $(IDIR)/root_include.h |
||
38 | CAMLIB = $(LIBFILE) |
||
39 | SHLIB = $(LIBFILE) $(LDIR)/libvxi11.a |
||
40 | |||
41 | # VXI scope connection variables, Scope DAQ library variables |
||
42 | VXIDIR = $(IDIR)/vxi11_$(OSTYPE) |
||
43 | #VXI_FILES = $(VXIDIR)/vxi11_user.o $(VXIDIR)/vxi11.h $(VXIDIR)/vxi11_clnt.c $(VXIDIR)/vxi11_xdr.c |
||
44 | VXI_OBJECT = $(VXIDIR)/vxi11_user.o $(VXIDIR)/vxi11_clnt.o $(VXIDIR)/vxi11_xdr.o |
||
45 | |||
46 | # ------------------------------------------------------------------- |
||
47 | |||
48 | # Base rules -------------------------------------------------------- |
||
49 | |||
50 | # Make the main program and libraries |
||
51 | all: libsubstr.so $(LDIR)/libdaqusb.so $(LDIR)/libvxi11.so $(TARGET) |
||
52 | |||
53 | # Rules for making the main program |
||
54 | $(TARGET): $(FILES) library |
||
55 | @echo "\n# Generating dictionary GuiDict.C ---------------------------" |
||
56 | rootcint -f $(DICT)/GuiDict.C -c -p $(INC) $(CPPFLAGS) $(IDIR)/sipmscan.h $(DICT)/GuiLinkDef.h |
||
57 | @echo "\n# Checking to see if bin directory already exists -----------" |
||
58 | if [ ! -d "$(BIN)" ];then mkdir $(BIN); fi |
||
59 | @echo "\n# Compiling main program ------------------------------------" |
||
60 | $(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 |
||
61 | @echo "\n# Compilation successful ------------------------------------" |
||
62 | @echo "# Use ./start.sh to run the program -------------------------" |
||
63 | |||
64 | # ------------------------------------------------------------------- |
||
65 | |||
66 | # CAMAC DAQ library rules ----------------------------------------------------- |
||
67 | |||
68 | # Rules for making CAMAC DAQ library source files (wusbxx_dll and libxxusb) |
||
69 | library: $(OBJ_FILES) |
||
70 | |||
71 | $(OBJ_FILES): $(SRC)/wusbxx_dll.c $(IDIR)/wusbxx_dll.h $(SRC)/libxxusb.cpp $(IDIR)/libxxusb.h |
||
72 | @echo "\n# Compiling CAMAC USB source files --------------------------" |
||
73 | $(CXX) $(CPPFLAGS) $(INC) -c $(SRC)/wusbxx_dll.c -o $(SRC)/wusbxx_dll.o |
||
74 | $(CXX) $(CPPFLAGS) $(INC) -c $(SRC)/libxxusb.cpp -o $(SRC)/libxxusb.o |
||
75 | |||
76 | .cc.o: |
||
77 | @echo "\n# Creating a static CAMAC USB library (libdaqusb.a) ---------" |
||
78 | $(CXX) -fPIC -c $< |
||
79 | ar r $(LIBFILE) $@ |
||
80 | |||
81 | .cpp.o: |
||
82 | @echo "\n# Creating a static CAMAC USB library (libdaqusb.a) ---------" |
||
83 | $(CXX) -fPIC -c $< |
||
84 | ar r $(LIBFILE) $@ |
||
85 | |||
86 | .c.o: |
||
87 | @echo "\n# Creating a static CAMAC USB library (libdaqusb.a) ---------" |
||
88 | $(CXX) -fPIC -c $< |
||
89 | ar r $(LIBFILE) $@ |
||
90 | |||
91 | # Rule for making the CAMAC DAQ library (libdaqusb.so) |
||
92 | $(LDIR)/libdaqusb.so: $(LIBFILE) $(DAQFILE) |
||
93 | @echo "\n# Generating dictionary Dict.C ------------------------------" |
||
94 | rootcint -f $(DICT)/Dict.C -c $(INC) $(CPPFLAGS) $(HEADER) $(DICT)/LibLinkDef.h |
||
95 | @echo "\n# Checking to see if lib directory already exists -----------" |
||
96 | if [ ! -d "$(LDIR)" ];then mkdir $(LDIR); fi |
||
97 | @echo "\n# Compiling CAMAC DAQ library (libdaqusb.so) ----------------" |
||
98 | $(CXX) $(CPPFLAGS) $(INC) -fPIC -g -Wall $(DAQFILE) $(DICT)/Dict.C $(CAMLIB) -shared -o $@ |
||
99 | |||
100 | # Rule for making the CAMAC DAQ library (libdaqusb.a) |
||
101 | $(LIBFILE): $(OBJ_FILES) |
||
102 | @echo "\n# Creating a static CAMAC USB library (libdaqusb.a) ---------" |
||
103 | ar r $@ $^ |
||
104 | # ----------------------------------------------------------------------------- |
||
105 | |||
106 | # Scope DAQ library rules ----------------------------------------------------- |
||
107 | |||
108 | $(LDIR)/libvxi11.so: $(LDIR)/libvxi11.a |
||
109 | @echo "\n# Generating dictionary VxiDict.C ---------------------------" |
||
110 | rootcint -f $(DICT)/VxiDict.C -c $(INC) $(CPPFLAGS) $(IDIR)/daqscope.h $(DICT)/LibLinkDef.h |
||
111 | @echo "\n# Checking to see if lib directory already exists -----------" |
||
112 | if [ ! -d "$(LDIR)" ];then mkdir $(LDIR); fi |
||
113 | @echo "\n# Compiling scope VXI library (libvxi11.so) -----------------" |
||
114 | $(CXX) $(CPPFLAGS) $(INC) -fPIC -g -Wall $(SRC)/daqscope.C $(DICT)/VxiDict.C -L. $(LDIR)/libvxi11.a -shared -o $@ |
||
115 | |||
116 | $(LDIR)/libvxi11.a: $(VXI_OBJECT) |
||
117 | ar r $@ $^ |
||
118 | # ----------------------------------------------------------------------------- |
||
119 | |||
120 | # Substructue library rules --------------------------------------------------- |
||
121 | |||
122 | # Rules for making user defined libraries |
||
123 | libsubstr.so: libsubstr.a |
||
124 | @echo "\n# Creating a shared testing library -------------------------" |
||
125 | rootcint -f $(DICT)/TestDict.C -c $(INC) $(CPPFLAGS) $(IDIR)/substructure.h $(DICT)/TestLinkDef.h |
||
126 | $(CXX) $(CPPFLAGS) $(INC) $(COMPOPT) $(SRC)/substructure.cpp $(DICT)/TestDict.C libsubstr.a -shared -o $@ |
||
127 | @echo "\n# Checking to see if lib directory already exists -----------" |
||
128 | if [ ! -d "$(LDIR)" ];then mkdir $(LDIR); fi |
||
129 | mv $@ $^ $(LDIR)/ |
||
130 | |||
131 | libsubstr.a: $(SRC)/substructure.o |
||
132 | @echo "\n# Creating a static testing library -------------------------" |
||
133 | ar r $@ $^ |
||
134 | |||
135 | $(SRC)/substructure.o: $(SRC)/substructure.cpp $(IDIR)/substructure.h |
||
136 | @echo "\n# Compiling separate source files ---------------------------" |
||
137 | $(CXX) $(CPPFLAGS) $(INC) -c $(SRC)/substructure.cpp -o $(SRC)/substructure.o |
||
138 | |||
139 | # ------------------------------------------------------------------- |
||
140 | |||
141 | # Cleaning rules ---------------------------------------------------- |
||
142 | |||
143 | # Rules for cleaning the installation |
||
144 | clean: |
||
145 | @echo "# Cleaning the installation directory -------------------------" |
||
146 | rm -fr $(DICT)/*Dict.C $(DICT)/*Dict.h $(BIN) $(LDIR) start.sh *.o $(SRC)/*.o |
||
147 | rm -fr $(IDIR)/workstation.h $(SRC)/daqscope.C $(SRC)/daqusb.C $(IDIR)/usb.h $(IDIR)/libxxusb.h $(DBG)/finish_sig.txt |
||
148 | |||
149 | # ------------------------------------------------------------------- |