forked from DfX-NYUAD/Corblivar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
185 lines (164 loc) · 6.94 KB
/
Copy pathMakefile
File metadata and controls
185 lines (164 loc) · 6.94 KB
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#=============================================================================#
# Application Name:
#=============================================================================#
APP := Corblivar
#AUX := 3DFP_Parser 3DSTAF_Parser
AUX := Correlation_TSC Variation_TSC Postprocessing_TSC
ALL := $(APP) $(AUX)
#=============================================================================#
# Define Compiler Executable:
#=============================================================================#
COMPILER = clang++
#COMPILER = /opt/clang+llvm-3.2-x86-linux-ubuntu-12.04/bin/clang++
#COMPILER = g++
# Intel compiler; required for proper analysis w/ Intel VTune Amplifier XE
#COMPILER = /opt/intel/bin/icpc
#=============================================================================#
# Compiler Options:
#=============================================================================#
# warnings
OPT := $(OPT) -Wall -Wextra #-Wconversion
# C++11
OPT := $(OPT) -std=c++11
# explicit library location
#OPT := $(OPT) -I/usr/include/i386-linux-gnu/c++/4.8
# threading support, requires clang > 3.0
#OPT := $(OPT) -pthread
# OpenMP, requires gcc
#OPT := $(OPT) -fopenmp
# gprof profiler code
#OPT := $(OPT) -pg
# 32bit binary
#OPT := $(OPT) -m32
# debug symbols
OPT := $(OPT) -g
# Runtime Optimization
OPT := $(OPT) -O3
# native tuning, since gcc 4.2
OPT := $(OPT) -march=native
#=============================================================================#
# Variables:
#=============================================================================#
BUILD_DIR := build
SRC_DIR := src
LIBS_DIR := libs
SRC_AUX := src_aux
DOC_DIR := doc
DOXYGEN_DIR := $(DOC_DIR)/Doxygen
DOXYFILE := $(DOC_DIR)/Doxyfile
# derive related variables
SRC := $(wildcard $(SRC_DIR)/*.cpp)
OBJ := $(SRC:%.cpp=%.o)
OBJ := $(notdir $(OBJ))
OBJ := $(addprefix $(BUILD_DIR)/,$(OBJ))
DEP := $(OBJ:%.o=%.d)
# assume all objects to be required for aux binaries, expect main object
OBJ_AUX := $(filter-out $(BUILD_DIR)/$(APP).o, $(OBJ))
# variable to monitor changes in aux src
SRC_AUX_ALL := $(wildcard $(SRC_AUX)/*.cpp)
#=============================================================================#
# Library Options:
#=============================================================================#
#OPT := $(OPT) -I$(LIBS_DIR)/include
#=============================================================================#
# Linker Options:
#=============================================================================#
#LIBS := -fopenmp
#=============================================================================#
# Link Main Executable
#=============================================================================#
all: libs $(ALL)
$(APP): $(BUILD_DIR) $(OBJ)
@echo
@echo linking main binary
$(COMPILER) $(OBJ) $(LIBS) -o $@
$(BUILD_DIR):
@echo
@echo create build dir
mkdir -p $(BUILD_DIR)
#=============================================================================#
# Target for auxiliary binaries: each target represents one binary
#=============================================================================#
$(AUX): $(BUILD_DIR) $(SRC_AUX_ALL) $(OBJ_AUX)
@echo
@echo compile and link aux binary $@
$(COMPILER) $(OPT) $(SRC_AUX)/$@.cpp $(OBJ_AUX) -o $@
#=============================================================================#
# Compile Source Code to Object Files
#=============================================================================#
# pull in dependency for compiled objects
# -include performs include w/o warning, aborts for non-existent files
-include $(DEP)
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.cpp
@echo
@echo compile and determine dependencies for $<
$(COMPILER) -c $(OPT) $< -o $@
$(COMPILER) -MM $(OPT) $< | sed 's/$(basename $(notdir $@))\.o/$(BUILD_DIR)\/$(notdir $@)/g' > $(@:%.o=%.d)
#=============================================================================#
# Librarys build
#=============================================================================#
libs:
#$(LIB_GC_SO):
# @echo
# @echo Building GC lib
# cd ./$(LIB_GC_DIR) && ./configure --prefix=$(LIBS_DIR) --disable-threads && make && make check && make install
#=============================================================================#
# Librarys cleanup
#=============================================================================#
cleanlibs:
# @echo
# @echo Cleanup GC lib
# cd ./$(LIB_GC_DIR) && make clean && make uninstall
##=============================================================================#
## Doxygen documentation:
##=============================================================================#
doc: $(SRC) $(SRC_AUX) $(DOXYFILE)
doxygen $(DOXYFILE)
##=============================================================================#
## Doxygen documentation:
##=============================================================================#
#doclatex: doc
# cd ./doc/latex && $(MAKE)
#
##=============================================================================#
## Remove documentation files
##=============================================================================#
docclean:
@echo "Deleting Doxygen documentation"
rm -rf $(DOXYGEN_DIR)
#=============================================================================#
# Cleanup build
#=============================================================================#
clean:
@echo "removing: $(BUILD_DIR)/* $(APP) $(AUX)"
rm -f $(BUILD_DIR)/* $(APP) $(AUX)
#=============================================================================#
# Purge build
#=============================================================================#
purge: clean cleanlibs docclean
#=============================================================================#
# Pack source
#=============================================================================#
#release: all
# @echo "packing source archive"
# @echo "save as $(APP).tar.gz"
# tar -czf $(APP).tar.gz . --exclude=libs/lib --exclude=libs/share --exclude=libs/packages --exclude=libs/bin --exclude=build/* --exclude=$(APP)* --exclude=*.out --exclude=*.swp
#=============================================================================#
# Some debugging output
#=============================================================================#
debug:
@echo -----------------------------------------------------------------------
@echo - COMPILER: $(COMPILER)
@echo -----------------------------------------------------------------------
@echo - APP : $(APP)
@echo -----------------------------------------------------------------------
@echo - SRC : $(SRC)
@echo -----------------------------------------------------------------------
@echo - OBJ : $(OBJ)
@echo -----------------------------------------------------------------------
@echo - DEP : $(DEP)
@echo -----------------------------------------------------------------------
@echo - SRC_AUX : $(SRC_AUX_ALL)
@echo -----------------------------------------------------------------------
@echo - OBJ_AUX : $(OBJ_AUX)
@echo -----------------------------------------------------------------------