-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathMakefile
108 lines (87 loc) · 3.04 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#********************************************************************
#
# name: Makefile
# date: 26 Jan 15
# auth: Zach Hartwig
# mail: [email protected]
#
# desc: GNU makefile for building the ADAQAcquisition binary
#
# dpnd: The build system requires the following dependencies:
# -- ROOT
# -- ADAQ libraries (ADAQControl, ADAQReadout)
# -- Boost libraries (boost-thread)
#
# To build the binary
# $ make
#
# To clean the bin/ and build/ directories
# $ make clean
#
#********************************************************************
#**** MACRO DEFINITIONS ****#
# Include the Makefile for ROOT-based projects
RC:=root-config
ROOTSYS:=$(shell $(RC) --etcdir)
ROOTMAKE:=$(ROOTSYS)/Makefile.arch
include $(ROOTMAKE)
# Specify the the binary, build, and source directories
BUILDDIR = build
BINDIR = bin
SRCDIR = src
# Specify header files directory. Note that this must be an absolute
# path to ensure the ROOT dictionary files can find the headers
INCLDIR = $(PWD)/include
# Specify all header files
INCLS = $(INCLDIR)/*.hh
# Specify all object files (to be built in the build/ directory)
SRCS = $(wildcard $(SRCDIR)/*.cc)
TMP = $(patsubst %.cc,%.o,$(SRCS))
OBJS = $(subst src/,build/,$(TMP))
# Add the mandatory ROOT dictionary object file
OBJS += $(BUILDDIR)/ADAQAcquisitionDict.o
# Add various compiler flags
CXXFLAGS += -w -I$(INCLDIR) -I$(ADAQHOME)/include
# Add linker flags for the ADAQ libraries
LDFLAGS+=-L$(ADAQHOME)/lib/$(HOSTTYPE) -lADAQControl -lADAQReadout
# Add linker flags for CAEN libraries (architecture dependent). Note
# that these libraries are PROVIDED by the ADAQ code
LDFLAGS+=-L$(ADAQHOME)/lib/$(HOSTTYPE) -lCAENVME -lCAENComm -lCAENDigitizer -lncurses -lc -lm -lrt
# Define the target binary
TARGET = $(BINDIR)/ADAQAcquisition
#***************#
#**** RULES ****#
#***************#
#*************************#
# Rules to build the binary
$(TARGET) : $(OBJS)
@echo -e "\nBuilding $@ ..."
$(CXX) -g -o $@ $^ $(LDFLAGS) $(ROOTGLIBS)
@echo -e "\n$@ build is complete!\n"
$(BUILDDIR)/%.o : $(SRCDIR)/%.cc $(INCLS)
@echo -e "\nBuilding object file '$@' ..."
$(CXX) $(CXXFLAGS) -c -o $@ $<
#***********************************************#
# Rules to generate the necessary ROOT dictionary
$(BUILDDIR)/ADAQAcquisitionDict.o : $(BUILDDIR)/ADAQAcquisitionDict.cc
@echo -e "\nBuilding '$@' ..."
$(CXX) -g $(CXXFLAGS) -c -o $@ $<
# Generate the necessary ROOT dictionaries
$(BUILDDIR)/ADAQAcquisitionDict.cc : $(INCLS) $(INCLDIR)/RootLinkDef.h
@echo -e "\nGenerating ROOT dictionary '$@' ..."
rootcling -f $@ -c -I$(ADAQHOME)/include $^
@cp $(BUILDDIR)/*.pcm $(BINDIR)
# Clean the directory of all build files and binaries
.PHONY:
clean:
@echo -e "\nCleaning up the build and binary ..."
rm -f $(BUILDDIR)/*.o *.d $(BUILDDIR)/*Dict.* $(TARGET)
@echo -e ""
# Useful notes for the uninitiated:
#
# <target> : <dependency list>
# --TAB-- <rule>
#
# "$@" == subst. the word to the left of the ":"
# "$^" == subst. the words to the right of ":"
# "$<" == subst. first item in dependency list