forked from cmsromadaq/DQM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
95 lines (71 loc) · 2.52 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
# $Id: Makefile,v 1.8 2010/08/25 08:36:35 rahatlou Exp $
ROOTLIBS = $(shell $(ROOTSYS)/bin/root-config --libs)
ROOTGLIBS = $(shell $(ROOTSYS)/bin/root-config --glibs)
BINFILES = readBinary.cpp
PROGRAMS = $(patsubst %.cpp,%,$(BINFILES))
# --- External configuration ---------------------------------
THREADTST = -D_THREADLIB_
CC = g++
CCFLAGS = $(shell $(ROOTSYS)/bin/root-config --cflags)
MFLAGS = -MM
INCLUDES =
WORKDIR = bin/
LIBDIR = lib/
PACKAGE = DQM
CINTFILE = $(PACKAGE)Cint.cc
CINTOBJ = $(PACKAGE)Cint.o
LIBFILE = $(LIBDIR)/lib$(PACKAGE).a
SHLIBFILE = $(LIBDIR)/lib$(PACKAGE).so
OBJDIR=$(LIBDIR)/objects/
INCLUDES += -I. -I$(ROOTSYS)/include
ROOTSYS ?= ERROR_RootSysIsNotDefined
EXTRALIBS :=
# -L$(LIBDIR) -l$(PACKAGE)
HHLIST=$(filter-out $(PACKAGE)_LinkDef.h,$(wildcard *.h))
# CC files excluding the binaries
CCFILES=$(filter-out $(BINFILES),$(wildcard *.cc))
# List of all object files to build
OLIST=$(patsubst %.cc,$(OBJDIR)/%.o,$(CCFILES))
# Implicit rule to compile all classes
$(OBJDIR)/%.o : %.cc
@echo "Compiling $<"
@mkdir -p $(OBJDIR)
$(CC) $(CCFLAGS) -c $< -o $@ $(INCLUDES)
$(OBJDIR)/$(CINTOBJ): $(HHLLIST)
@mkdir -p $(OBJDIR)
# @cp *.hh $(INCDIR)
# @echo "Running rootcint"
# $(ROOTSYS)/bin/rootcint -f $(CINTFILE) -c $(INCLUDES) $(HHLIST) $(PACKAGE)_LinkDef.h
# @echo "Compiling $(CINTFILE)"
# @$(CC) $(INCLUDES) $(CCFLAGS) -c $(CINTFILE) -o $(OBJDIR)/$(CINTOBJ)
#
$(PROGRAMS) :
mkdir -p $(WORKDIR)
#$(OLIST)
@echo "Linking $@"
# $(CC) $(CCFLAGS) $(INCLUDES) $(ROOTLIBS) $(EXTRALIBS) -o $(WORKDIR)/$@ $(patsubst %,%.cpp,$@)
$(CC) $(CCFLAGS) $(INCLUDES) -o $(WORKDIR)/$@ $(patsubst %,%.cpp,$@) $(ROOTLIBS) $(EXTRALIBS)
default : $(PROGRAMS)
@echo "Programs are $(PROGRAMS)"
all : $(PROGRAMS)
# Rule to combine objects into a library
$(LIBFILE): $(OLIST) $(patsubst %.cc,%.o,$(OBJDIR)/$(CINTFILE))
@echo "Making $(LIBFILE)"
@rm -f $(LIBFILE)
@ar q $(LIBFILE) $(OLIST) $(addprefix $(OBJDIR)/,$(OLIST) $(patsubst %.cc,%.o,$(CINTFILE)))
@ranlib $(LIBFILE)
# Rule to combine objects into a shared library
$(SHLIBFILE): $(OLIST) $(patsubst %.cc,%.o,$(OBJDIR)/$(CINTFILE))
@echo "Making $(SHLIBFILE)"
@rm -f $(SHLIBFILE)
$(CC) $(CCFLAGS) $(OLIST) $(addprefix $(OBJDIR)/,$(patsubst %.cc,%.o,$(CINTFILE))) -shared -o $(SHLIBFILE)
# Useful build targets
lib: $(LIBFILE)
shlib: $(SHLIBFILE)
clean:
@rm -Rf $(WORKDIR)/* $(LIBDIR)/* $(CINTFILE) $(patsubst %.cc,%.h,$(CINTFILE))
@rm -f $(LIBFILE)
@rm -Rf *.o
veryclean:
rm -Rf $(WORKDIR)
#.PHONY : shlib lib default clean