forked from Miniball/MiniballSort
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
151 lines (126 loc) · 4.46 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
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
147
148
149
150
151
# Makefile for MiniballSort
.PHONY: clean all
PWD := $(shell pwd)
BIN_DIR := ./bin
SRC_DIR := ./src
LIB_DIR := ./lib
INC_DIR := ./include
UTIL_DIR := ./utils
AME_FILE := \"$(PWD)/data/mass_1.mas20\"
SRIM_DIR := \"$(PWD)/srim/\"
CUR_DIR := \"$(PWD)/\"
ROOTVER := $(shell root-config --version | head -c1)
ROOTSUBVER := $(shell root-config --version | cut -d '.' -f 2 | cut -d '/' -f 1)
ifeq ($(ROOTVER),5)
ROOTDICT := rootcint
DICTEXT := .h
else
ROOTDICT := rootcling
DICTEXT := _rdict.pcm
endif
PLATFORM:=$(shell uname)
ifeq ($(PLATFORM),Darwin)
SHAREDSWITCH = -Qunused-arguments -shared -undefined dynamic_lookup -dynamiclib -Wl,-install_name,'@executable_path/../lib/'# NO ENDING SPACE
OSDEF = -DMACOSX
else
SHAREDSWITCH = -shared -Wl,-soname,# NO ENDING SPACE
OSDEF = -DLINUX
LIBEXTRA = -lrt
endif
ROOTCFLAGS := $(shell root-config --cflags)
ROOTLDFLAGS := $(shell root-config --ldflags)
ROOTLIBS := $(shell root-config --glibs) -lRHTTP -lThread
LIBS := $(ROOTLIBS) $(LIBEXTRA)
# Compiler.
CC = $(shell root-config --cxx)
# Flags for compiler.
CFLAGS = -c -Wall -Wextra $(ROOTCFLAGS) -g -fPIC -O3
CFLAGS += -DUNIX -DPOSIX $(OSDEF)
INCLUDES += -I$(INC_DIR) -I.
# Pass in the data file locations
CFLAGS += -DAME_FILE=$(AME_FILE)
CFLAGS += -DSRIM_DIR=$(SRIM_DIR)
CFLAGS += -DCUR_DIR=$(CUR_DIR)
# Pass in the ROOT version
CFLAGS += -DROOTVER=$(ROOTVER) -DROOTSUBVER=$(ROOTSUBVER)
# Linker.
LD = $(shell root-config --ld)
# Flags for linker.
LDFLAGS += $(ROOTLDFLAGS)
# The object files.
OBJECTS = $(SRC_DIR)/Calibration.o \
$(SRC_DIR)/CommandLineInterface.o \
$(SRC_DIR)/Converter.o \
$(SRC_DIR)/DataPackets.o \
$(SRC_DIR)/DataSpy.o \
$(SRC_DIR)/Settings.o \
$(SRC_DIR)/EventBuilder.o \
$(SRC_DIR)/MedConverter.o \
$(SRC_DIR)/MbsConverter.o \
$(SRC_DIR)/MbsFormat.o \
$(SRC_DIR)/MidasConverter.o \
$(SRC_DIR)/MiniballAngleFitter.o \
$(SRC_DIR)/MiniballEvts.o \
$(SRC_DIR)/MiniballGeometry.o \
$(SRC_DIR)/Reaction.o \
$(SRC_DIR)/Histogrammer.o \
$(SRC_DIR)/MiniballGUI.o
# The header files.
DEPENDENCIES = $(INC_DIR)/Calibration.hh \
$(INC_DIR)/CommandLineInterface.hh \
$(INC_DIR)/Converter.hh \
$(INC_DIR)/DataPackets.hh \
$(INC_DIR)/DataSpy.hh \
$(INC_DIR)/Settings.hh \
$(INC_DIR)/EventBuilder.hh \
$(INC_DIR)/MedConverter.hh \
$(INC_DIR)/MbsConverter.hh \
$(INC_DIR)/MbsDefines.hh \
$(INC_DIR)/MbsFormat.hh \
$(INC_DIR)/MidasConverter.hh \
$(INC_DIR)/MiniballAngleFitter.hh \
$(INC_DIR)/MiniballEvts.hh \
$(INC_DIR)/MiniballGeometry.hh \
$(INC_DIR)/Reaction.hh \
$(INC_DIR)/Histogrammer.hh \
$(INC_DIR)/MiniballGUI.hh
.PHONY : all
#all: $(BIN_DIR)/mb_sort $(LIB_DIR)/libmb_sort.so $(UTIL_DIR)/mb_angle_fit
all: $(BIN_DIR)/mb_sort $(LIB_DIR)/libmb_sort.so
$(LIB_DIR)/libmb_sort.so: mb_sort.o $(OBJECTS) mb_sortDict.o
mkdir -p $(LIB_DIR)
$(LD) mb_sort.o $(OBJECTS) mb_sortDict.o $(SHAREDSWITCH)$@ $(LIBS) -o $@
$(BIN_DIR)/mb_sort: mb_sort.o $(OBJECTS) mb_sortDict.o
mkdir -p $(BIN_DIR)
$(LD) -o $@ $^ $(LDFLAGS) $(LIBS)
mb_sort.o: mb_sort.cc mb_sort.hh
$(CC) $(CFLAGS) $(INCLUDES) $^
$(UTIL_DIR)/%: $(UTIL_DIR)/%.o $(OBJECTS) $(UTIL_DIR)/%Dict.o
mkdir -p $(BIN_DIR)
$(LD) -o $@ $^ $(LDFLAGS) $(LIBS)
$(UTIL_DIR)/%.o: $(UTIL_DIR)/%.cc
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
$(SRC_DIR)/%.o: $(SRC_DIR)/%.cc $(INC_DIR)/%.hh
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
mb_sortDict.o: mb_sortDict.cc mb_sortDict$(DICTEXT) $(INC_DIR)/RootLinkDef.h
$(CC) -fPIC $(CFLAGS) $(INCLUDES) -c $<
mkdir -p $(BIN_DIR)
mkdir -p $(LIB_DIR)
cp $(basename $@)$(DICTEXT) $(LIB_DIR)/
cp $(basename $@)$(DICTEXT) $(BIN_DIR)/
mb_sortDict.cc: $(DEPENDENCIES) $(INC_DIR)/RootLinkDef.h
$(ROOTDICT) -f $@ -c $(INCLUDES) $(DEPENDENCIES) $(INC_DIR)/RootLinkDef.h
# Generated by the rule above.
mb_sortDict$(DICTEXT): mb_sortDict.cc
$(UTIL_DIR)/%Dict.o: $(UTIL_DIR)/%Dict.cc $(UTIL_DIR)/%Dict$(DICTEXT) $(INC_DIR)/RootLinkDef.h
$(CC) -fPIC $(CFLAGS) $(INCLUDES) -c $<
mkdir -p $(BIN_DIR)
mkdir -p $(LIB_DIR)
cp $(basename $@)$(DICTEXT) $(LIB_DIR)/
cp $(basename $@)$(DICTEXT) $(BIN_DIR)/
$(UTIL_DIR)/%Dict.cc: $(DEPENDENCIES) $(INC_DIR)/RootLinkDef.h
$(ROOTDICT) -f $@ -c $(INCLUDES) $(DEPENDENCIES) $(INC_DIR)/RootLinkDef.h
clean:
rm -vf $(BIN_DIR)/mb_sort $(SRC_DIR)/*.o $(UTIL_DIR)/*.o $(SRC_DIR)/*~ \
$(UTIL_DIR)/*~ $(INC_DIR)/*.gch *.o $(BIN_DIR)/*.pcm $(UTIL_DIR)/*.pcm \
*.pcm $(BIN_DIR)/*Dict* $(UTIL_DIR)/*Dict* *Dict* $(LIB_DIR)/*