Skip to content

Commit 418e220

Browse files
hahnjojblomer
andcommitted
Improve Makefile setup
More use of variables that users can also override, and removal of unnecessary dependencies. Co-authored-by: Jakob Blomer <jblomer@cern.ch>
1 parent ac3ae05 commit 418e220

File tree

7 files changed

+91
-55
lines changed

7 files changed

+91
-55
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ROOT_EXE := $(shell which root.exe)
1+
ROOT_EXE ?= $(shell which root.exe)
22
ifeq ($(ROOT_EXE),)
33
$(error Could not find root.exe)
44
endif

types/multiset/nested/Makefile

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
1-
CXX=g++
2-
CXXFLAGS_ROOT=$(shell root-config --cflags)
3-
ifeq ($(CXXFLAGS_ROOT),)
4-
$(error cannot find root-config: make sure to source thisroot.sh)
1+
ROOT_CONFIG ?= $(shell which root-config)
2+
ifeq ($(ROOT_CONFIG),)
3+
$(error Could not find root-config)
54
endif
6-
CXXFLAGS=-Wall $(CXXFLAGS_ROOT)
7-
LDFLAGS=$(shell root-config --libs)
5+
ROOTCLING ?= $(shell which rootcling)
6+
ifeq ($(ROOTCLING),)
7+
$(error Could not find rootcling)
8+
endif
9+
10+
CXX := $(shell $(ROOT_CONFIG) --cxx)
11+
CXXFLAGS_ROOT := $(shell $(ROOT_CONFIG) --cflags)
12+
CXXFLAGS := -Wall $(CXXFLAGS_ROOT)
13+
LDFLAGS := $(shell $(ROOT_CONFIG) --libs)
814

915
.PHONY: all clean
1016

11-
all: NestedMultiset.cxx libNestedMultiset.so
17+
all: libNestedMultiset.so
1218

1319
NestedMultiset.cxx: NestedMultiset.hxx LinkDef.h
14-
rootcling -f $@ $^
20+
$(ROOTCLING) -f $@ $^
1521

1622
libNestedMultiset.so: NestedMultiset.cxx
1723
$(CXX) -shared -fPIC -o $@ $^ $(CXXFLAGS) $(LDFLAGS)
1824

1925
clean:
20-
rm -f NestedMultiset.cxx NestedMultiset_rdict.pcm libNestedMultiset.so
26+
$(RM) NestedMultiset.cxx NestedMultiset_rdict.pcm libNestedMultiset.so

types/set/nested/Makefile

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
1-
CXX=g++
2-
CXXFLAGS_ROOT=$(shell root-config --cflags)
3-
ifeq ($(CXXFLAGS_ROOT),)
4-
$(error cannot find root-config: make sure to source thisroot.sh)
1+
ROOT_CONFIG ?= $(shell which root-config)
2+
ifeq ($(ROOT_CONFIG),)
3+
$(error Could not find root-config)
54
endif
6-
CXXFLAGS=-Wall $(CXXFLAGS_ROOT)
7-
LDFLAGS=$(shell root-config --libs)
5+
ROOTCLING ?= $(shell which rootcling)
6+
ifeq ($(ROOTCLING),)
7+
$(error Could not find rootcling)
8+
endif
9+
10+
CXX := $(shell $(ROOT_CONFIG) --cxx)
11+
CXXFLAGS_ROOT := $(shell $(ROOT_CONFIG) --cflags)
12+
CXXFLAGS := -Wall $(CXXFLAGS_ROOT)
13+
LDFLAGS := $(shell $(ROOT_CONFIG) --libs)
814

915
.PHONY: all clean
1016

11-
all: NestedSet.cxx libNestedSet.so
17+
all: libNestedSet.so
1218

1319
NestedSet.cxx: NestedSet.hxx LinkDef.h
14-
rootcling -f $@ $^
20+
$(ROOTCLING) -f $@ $^
1521

1622
libNestedSet.so: NestedSet.cxx
1723
$(CXX) -shared -fPIC -o $@ $^ $(CXXFLAGS) $(LDFLAGS)
1824

1925
clean:
20-
rm -f NestedSet.cxx NestedSet_rdict.pcm libNestedSet.so
26+
$(RM) NestedSet.cxx NestedSet_rdict.pcm libNestedSet.so
Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
1-
CXX=g++
2-
CXXFLAGS_ROOT=$(shell root-config --cflags)
3-
ifeq ($(CXXFLAGS_ROOT),)
4-
$(error cannot find root-config: make sure to source thisroot.sh)
1+
ROOT_CONFIG ?= $(shell which root-config)
2+
ifeq ($(ROOT_CONFIG),)
3+
$(error Could not find root-config)
54
endif
6-
CXXFLAGS=-Wall $(CXXFLAGS_ROOT)
7-
LDFLAGS=$(shell root-config --libs)
5+
ROOTCLING ?= $(shell which rootcling)
6+
ifeq ($(ROOTCLING),)
7+
$(error Could not find rootcling)
8+
endif
9+
10+
CXX := $(shell $(ROOT_CONFIG) --cxx)
11+
CXXFLAGS_ROOT := $(shell $(ROOT_CONFIG) --cflags)
12+
CXXFLAGS := -Wall $(CXXFLAGS_ROOT)
13+
LDFLAGS := $(shell $(ROOT_CONFIG) --libs)
814

915
.PHONY: all clean
1016

11-
all: NestedUnorderedMultiset.cxx libNestedUnorderedMultiset.so
17+
all: libNestedUnorderedMultiset.so
1218

1319
NestedUnorderedMultiset.cxx: NestedUnorderedMultiset.hxx LinkDef.h
14-
rootcling -f $@ $^
20+
$(ROOTCLING) -f $@ $^
1521

1622
libNestedUnorderedMultiset.so: NestedUnorderedMultiset.cxx
1723
$(CXX) -shared -fPIC -o $@ $^ $(CXXFLAGS) $(LDFLAGS)
1824

1925
clean:
20-
rm -f NestedUnorderedMultiset.cxx NestedUnorderedMultiset_rdict.pcm libNestedUnorderedMultiset.so
26+
$(RM) NestedUnorderedMultiset.cxx NestedUnorderedMultiset_rdict.pcm libNestedUnorderedMultiset.so
Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
1-
CXX=g++
2-
CXXFLAGS_ROOT=$(shell root-config --cflags)
3-
ifeq ($(CXXFLAGS_ROOT),)
4-
$(error cannot find root-config: make sure to source thisroot.sh)
1+
ROOT_CONFIG ?= $(shell which root-config)
2+
ifeq ($(ROOT_CONFIG),)
3+
$(error Could not find root-config)
54
endif
6-
CXXFLAGS=-Wall $(CXXFLAGS_ROOT)
7-
LDFLAGS=$(shell root-config --libs)
5+
ROOTCLING ?= $(shell which rootcling)
6+
ifeq ($(ROOTCLING),)
7+
$(error Could not find rootcling)
8+
endif
9+
10+
CXX := $(shell $(ROOT_CONFIG) --cxx)
11+
CXXFLAGS_ROOT := $(shell $(ROOT_CONFIG) --cflags)
12+
CXXFLAGS := -Wall $(CXXFLAGS_ROOT)
13+
LDFLAGS := $(shell $(ROOT_CONFIG) --libs)
814

915
.PHONY: all clean
1016

11-
all: NestedUnorderedSet.cxx libNestedUnorderedSet.so
17+
all: libNestedUnorderedSet.so
1218

1319
NestedUnorderedSet.cxx: NestedUnorderedSet.hxx LinkDef.h
14-
rootcling -f $@ $^
20+
$(ROOTCLING) -f $@ $^
1521

1622
libNestedUnorderedSet.so: NestedUnorderedSet.cxx
1723
$(CXX) -shared -fPIC -o $@ $^ $(CXXFLAGS) $(LDFLAGS)
1824

1925
clean:
20-
rm -f NestedUnorderedSet.cxx NestedUnorderedSet_rdict.pcm libNestedUnorderedSet.so
26+
$(RM) NestedUnorderedSet.cxx NestedUnorderedSet_rdict.pcm libNestedUnorderedSet.so

types/user/class/Makefile

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
1-
CXX=g++
2-
CXXFLAGS_ROOT=$(shell root-config --cflags)
3-
ifeq ($(CXXFLAGS_ROOT),)
4-
$(error cannot find root-config: make sure to source thisroot.sh)
1+
ROOT_CONFIG ?= $(shell which root-config)
2+
ifeq ($(ROOT_CONFIG),)
3+
$(error Could not find root-config)
54
endif
6-
CXXFLAGS=-Wall $(CXXFLAGS_ROOT)
7-
LDFLAGS=$(shell root-config --libs)
5+
ROOTCLING ?= $(shell which rootcling)
6+
ifeq ($(ROOTCLING),)
7+
$(error Could not find rootcling)
8+
endif
9+
10+
CXX := $(shell $(ROOT_CONFIG) --cxx)
11+
CXXFLAGS_ROOT := $(shell $(ROOT_CONFIG) --cflags)
12+
CXXFLAGS := -Wall $(CXXFLAGS_ROOT)
13+
LDFLAGS := $(shell $(ROOT_CONFIG) --libs)
814

915
.PHONY: all clean
1016

11-
all: UserClass.cxx libUserClass.so
17+
all: libUserClass.so
1218

1319
UserClass.cxx: UserClass.hxx LinkDef.h
14-
rootcling -f $@ $^
20+
$(ROOTCLING) -f $@ $^
1521

1622
libUserClass.so: UserClass.cxx
1723
$(CXX) -shared -fPIC -o $@ $^ $(CXXFLAGS) $(LDFLAGS)
1824

1925
clean:
20-
rm -f UserClass.cxx UserClass_rdict.pcm libUserClass.so
26+
$(RM) UserClass.cxx UserClass_rdict.pcm libUserClass.so

types/user/enum/Makefile

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
1-
CXX=g++
2-
CXXFLAGS_ROOT=$(shell root-config --cflags)
3-
ifeq ($(CXXFLAGS_ROOT),)
4-
$(error cannot find root-config: make sure to source thisroot.sh)
1+
ROOT_CONFIG ?= $(shell which root-config)
2+
ifeq ($(ROOT_CONFIG),)
3+
$(error Could not find root-config)
54
endif
6-
CXXFLAGS=-Wall $(CXXFLAGS_ROOT)
7-
LDFLAGS=$(shell root-config --libs)
5+
ROOTCLING ?= $(shell which rootcling)
6+
ifeq ($(ROOTCLING),)
7+
$(error Could not find rootcling)
8+
endif
9+
10+
CXX := $(shell $(ROOT_CONFIG) --cxx)
11+
CXXFLAGS_ROOT := $(shell $(ROOT_CONFIG) --cflags)
12+
CXXFLAGS := -Wall $(CXXFLAGS_ROOT)
13+
LDFLAGS := $(shell $(ROOT_CONFIG) --libs)
814

915
.PHONY: all clean
1016

11-
all: UserEnum.cxx libUserEnum.so
17+
all: libUserEnum.so
1218

1319
UserEnum.cxx: UserEnum.hxx LinkDef.h
14-
rootcling -f $@ $^
20+
$(ROOTCLING) -f $@ $^
1521

1622
libUserEnum.so: UserEnum.cxx
1723
$(CXX) -shared -fPIC -o $@ $^ $(CXXFLAGS) $(LDFLAGS)
1824

1925
clean:
20-
rm -f UserEnum.cxx UserEnum_rdict.pcm libUserEnum.so
26+
$(RM) UserEnum.cxx UserEnum_rdict.pcm libUserEnum.so

0 commit comments

Comments
 (0)