forked from jalmond/LQanalyzer
/
Makefile.common
executable file
·147 lines (124 loc) · 6.63 KB
/
Makefile.common
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# Dear emacs, this is a -*- makefile -*-
# $Id: Makefile.common almond $
###########################################################################
MAKEFLAGS = --no-print-directory -r -s -j4
#
# Include the architecture definitions from the ROOT sources
#
# Makefile.arch can be in two different locations depending on the system
# you're compiling on. The Fink installed version of ROOT has this file
# in a different location than the "normally installed" ROOT versions...
#
ARCH_LOC_1 := $(wildcard $(shell root-config --prefix)/test/Makefile.arch)
ARCH_LOC_2 := $(wildcard $(shell root-config --prefix)/share/root/test/Makefile.arch)
ARCH_LOC_3 := $(wildcard $(shell root-config --prefix)/share/doc/root/test/Makefile.arch)
ARCH_LOC_4 := $(wildcard $(shell root-config --prefix)/etc/Makefile.arch)
ARCH_LOC_5 := $(wildcard $(shell root-config --prefix)/etc/root/Makefile.arch)
ARCH_LOC_5 := $(wildcard $(shell root-config --prefix)/etc/root/Makefile.arch)
ARCH_LOC_6 := $(wildcard $(shell root-config --etcdir)/Makefile.arch)
ifneq ($(strip $(ARCH_LOC_1)),)
$(info Using $(ARCH_LOC_1))
include $(ARCH_LOC_1)
else
ifneq ($(strip $(ARCH_LOC_2)),)
$(info Using $(ARCH_LOC_2))
include $(ARCH_LOC_2)
else
ifneq ($(strip $(ARCH_LOC_3)),)
$(info Using $(ARCH_LOC_3))
include $(ARCH_LOC_3)
else
ifneq ($(strip $(ARCH_LOC_4)),)
$(info Using $(ARCH_LOC_4))
include $(ARCH_LOC_4)
else
ifneq ($(strip $(ARCH_LOC_5)),)
$(info Using $(ARCH_LOC_5))
include $(ARCH_LOC_5)
else
ifneq ($(strip $(ARCH_LOC_6)),)
$(info Using $(ARCH_LOC_6))
include $(ARCH_LOC_6)
else
$(error Could not find Makefile.arch!)
endif
endif
endif
endif
endif
endif
# Some compilation options
VPATH += $(OBJDIR) $(SRCDIR)
INCLUDES += -Iinclude -I./
CXXFLAGS += -Wall -Wextra -Wno-overloaded-virtual # -Wparentheses-equality #-Wno-unused
# Set the locations of some files
DICTHEAD = $(SRCDIR)/$(LIBRARY)_Dict.h
DICTFILE = $(SRCDIR)/$(LIBRARY)_Dict.cxx
DICTOBJ = $(OBJDIR)/$(LIBRARY)_Dict.o
DICTLDEF = $(INCDIR)/$(LIBRARY)_LinkDef.h
SKIPCPPLIST = $(DICTFILE)
SKIPHLIST = $(DICTHEAD) $(DICTLDEF)
LIBFILE = $(LQANALYZER_LIB_PATH)/lib$(LIBRARY).a
SHLIBFILE = $(LQANALYZER_LIB_PATH)/lib$(LIBRARY).$(DllSuf)
UNAME = $(shell uname)
# Set up the default targets
default: shlib
# List of all header and source files to build
HLIST = $(filter-out $(SKIPHLIST),$(wildcard $(INCDIR)/*.h))
CPPLIST = $(filter-out $(SKIPCPPLIST),$(wildcard $(SRCDIR)/*.cc))
# List of all object files to build
OLIST = $(patsubst %.cc,%.o,$(notdir $(CPPLIST)))
# Implicit rule to compile all sources
%.o : %.cc
@echo "Compiling $<"
@mkdir -p $(OBJDIR)
@$(CXX) $(CXXFLAGS) -c $< -o $(OBJDIR)/$(notdir $@) $(INCLUDES)
# Rule to create the dictionary
$(DICTFILE): $(HLIST) $(DICTLDEF)
@echo "Generating dictionary $@"
@$(shell root-config --exec-prefix)/bin/rootcint -f $(DICTFILE) -c -p $(INCLUDES) $^
# Rule to comile the dictionary
$(DICTOBJ): $(DICTFILE)
@echo "Compiling $<"
@mkdir -p $(OBJDIR)
@$(CXX) $(CXXFLAGS) -c $(INCLUDES) -o $@ $<
##############################
# The dependencies section
# - the purpose of the .d files is to keep track of the
# header file dependence
# - this can be achieved using the makedepend command
##############################
# Useful build targets
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),distclean)
-include $(foreach var,$(notdir $(CPPLIST:.cc=.d)),$(DEPDIR)/$(var))
endif
endif
$(DEPDIR)/%.d: %.cc
@mkdir -p $(DEPDIR)
if test -f $< ; then \
echo "Making $(@F)"; \
$(SHELL) -ec '$(CPP) -MM $(CXXFLAGS) $(INCLUDES) $< | sed '\''/Cstd\/rw/d'\'' > $@'; \
fi
# Rule to combine objects into a unix shared library
$(SHLIBFILE): $(OLIST) $(DICTOBJ)
@echo "Making shared library: $(SHLIBFILE)"
@rm -f $(SHLIBFILE)
ifneq (,$(findstring macosx,$(ARCH)))
@$(LD) $(LDFLAGS) -dynamiclib -single_module -undefined dynamic_lookup $(addprefix $(OBJDIR)/,$(OLIST)) $(DICTOBJ) -o $(SHLIBFILE)
else
@$(LD) $(LDFLAGS) $(SOFLAGS) $(addprefix $(OBJDIR)/,$(OLIST)) $(DICTOBJ) -o $(SHLIBFILE)
endif
shlib: $(SHLIBFILE)
clean:
@rm -f $(DICTFILE) $(DICTHEAD)
@rm -f $(OBJDIR)/*.o
@rm -f $(SHLIBFILE)
@rm -f $(SFRAME_LIB_PATH)/lib$(LIBRARY).so
distclean:
@rm -rf $(OBJDIR)
@rm -rf $(DEPDIR)
@rm -f $(DICTFILE) $(DICTHEAD)
@rm -f $(SHLIBFILE)
@rm -f lib/lib$(LIBRARY).so
.PHONY : shlib default clean