-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile_archive
163 lines (123 loc) · 4.45 KB
/
makefile_archive
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
SRCDIR=src
ODIR=build
ODIRCUDA=build_cuda
IDIR=include/gwat/
LDIR_LOCAL=lib
PYDIR=gwatpy
PYSRC=mcmc_routines_ext.pyx waveform_generator_ext.pyx
PROJ_PYSRC=$(addprefix $(PYDIR)/src/,$(PYSRC))
PYLIB=mcmc_routines_ext.cpp waveform_generator_ext.cpp
PROJ_PYLIB=$(addprefix $(PYDIR)/,$(PYLIB))
LOCAL_LIB=libgwat.a
LOCAL_SHARED_LIB=libgwat.so
PROJ_LIB=$(addprefix $(LDIR_LOCAL)/,$(LOCAL_LIB))
PROJ_SHARED_LIB=$(addprefix $(LDIR_LOCAL)/,$(LOCAL_SHARED_LIB))
EXEDIR:=bin
MCMC_TOOL:=$(EXEDIR)/mcmc_gw_tool
WAVEFORM_TOOL:=$(EXEDIR)/waveform_tool
TEST_CODE_DIR:=tests
TESTSRC=testing/test.cpp
TESTOBJ=testing/test.o
TESTDIR=bin
TEST=$(addprefix $(TESTDIR)/,exe.a)
TESTFISHERSRC=testing/fisher_comparison.cpp
TESTFISHEROBJ=testing/fisher_comparison.o
TESTFISHER=$(addprefix $(TESTDIR)/,exefisher.a)
CONFIGFILE:=include/gwat/GWATConfig.h
#CFLAGS=-I$(IDIR) -I/opt/lalsuite/lalsimulation/src -I/opt/lalsuite/include -Wall -fPIC -g -O3 -std=c++11
CFLAGS=-I$(IDIR) -fopenmp -fPIC -O2 -std=c++11 -g
#LFLAGS= -L/usr/local/cuda/lib64 -fopenmp
LFLAGS= -fopenmp
CFLAGSCUDA=-I$(IDIR) -shared -Xcompiler -fpic -O2 -std=c++11
SRCEXT := cpp
SOURCES := $(shell find $(SRCDIR) -type f -name *.$(SRCEXT))
OBJECTS := $(patsubst $(SRCDIR)/%,$(ODIR)/%,$(SOURCES:.$(SRCEXT)=.o))
OBJECTS_NONEXE:= $(OBJECTS)
OBJECTS_NONEXE:=$(filter-out $(ODIR)/mcmc_gw_tool.o, $(OBJECTS_NONEXE))
OBJECTS_NONEXE:=$(filter-out $(ODIR)/waveform_tool.o, $(OBJECTS_NONEXE))
SRCEXTCUDA := cu
SOURCESCUDA := $(shell find $(SRCDIR) -type f -name *.$(SRCEXTCUDA))
############################################################################
#CUDA OPTIONS
#LIBS=-ladolc -lgsl -lgslcblas -lfftw3 -lcudart
#OBJECTSCUDA := $(patsubst $(SRCDIR)/%,$(ODIRCUDA)/%,$(SOURCESCUDA:.$(SRCEXTCUDA)=.o))
LIBS=-ladolc -lgsl -lgslcblas -lfftw3
OBJECTSCUDA :=
########################################################################
IEXT := h
DEPS:= $(shell find $(IDIR) -type f -name *.$(IEXT))
#CUDA specific header files -- not meant for external use
IEXTCUDA := hu
DEPSCUDA:= $(shell find $(IDIR) -type f -name *.$(IEXTCUDA))
CC=$(CXX)
#CC=g++
CCCUDA=nvcc
#CC=nvcc
.PHONY: all
all: $(PROJ_LIB) $(PROJ_PYLIB) $(PROJ_SHARED_LIB) $(MCMC_TOOL) $(WAVEFORM_TOOL)
$(ODIR)/%.o : $(SRCDIR)/%.$(SRCEXT) $(DEPS) $(CONFIGFILE)
$(CC) $(CFLAGS) -c -o $@ $<
#Write pertinent information to config file -- ie filepaths
$(CONFIGFILE):
@cp data/Config_template.txt $(CONFIGFILE)
@pwd | awk '{print "#define GWAT_ROOT_DIRECTORY \""$$1"/\""}' >> $(CONFIGFILE)
@echo "">>$(CONFIGFILE)
@echo "#endif">>$(CONFIGFILE)
$(ODIRCUDA)/%.o : $(SRCDIR)/%.$(SRCEXTCUDA) $(DEPS) $(DEPSCUDA)
$(CCCUDA) $(CFLAGSCUDA) -c -o $@ $<
$(OBJECTS): | $(ODIR)
$(OBJECTSCUDA): | $(ODIRCUDA)
$(ODIR):
mkdir -p $(ODIR)
$(ODIRCUDA):
mkdir -p $(ODIRCUDA)
$(TESTOBJ): $(TESTSRC)
$(CC) $(CFLAGS) -c -o $@ $<
$(TESTFISHEROBJ): $(TESTFISHERSRC)
$(CC) $(CFLAGS) -c -o $@ $<
$(PROJ_LIB) : $(OBJECTS_NONEXE) $(OBJECTSCUDA) | $(LDIR_LOCAL)
ar rcs $(LDIR_LOCAL)/$(LOCAL_LIB) $^ $(OBJECTSCUDA)
$(PROJ_SHARED_LIB) : $(OBJECTS_NONEXE) $(OBJECTSCUDA) | $(LDIR_LOCAL)
$(CC) -shared -fopenmp $^ -o $(LDIR_LOCAL)/$(LOCAL_SHARED_LIB) $(LIBS)
$(LDIR_LOCAL):
mkdir -p $(LDIR_LOCAL)
$(PROJ_PYLIB): $(PROJ_LIB) $(PROJ_SHARED_LIB) $(PROJ_PYSRC)
make -C $(PYDIR)
$(TESTFISHER) : $(OBJECTS) $(TESTFISHEROBJ) | $(TESTDIR)
$(CC) $(LFLAGS) -o $@ $^ $(LIBS)
$(TEST) : $(OBJECTS_NONEXE) $(OBJECTSCUDA) $(TESTOBJ) | $(TESTDIR)
@echo $(OBJECTS_TEST)
$(CC) $(LFLAGS) -o $@ $^ $(LIBS)
$(TESTDIR):
mkdir -p $(TESTDIR)
Doxyfile: $(OBJECTS) $(OBJECTSCUDA) $(PROJ_PYLIB)
doxygen Doxyfile
#make -C docs/latex
#cp docs/latex/refman.pdf ./
#make -C docs/latex clean
.PHONY: c
c: $(PROJ_LIB) $(PROJ_SHARED_LIB) $(MCMC_TOOL) $(WAVEFORM_TOOL)
.PHONY: test
test:$(TEST) $(PROJ_LIB) $(PROJ_SHARED_LIB) $(PROJ_PYLIB) $(MCMC_TOOL)
.PHONY: testfisher
testfisher: $(TESTFISHER) $(PROJ_LIB) $(PROJ_SHARED_LIB)
.PHONY: testc
testc: $(TEST) $(PROJ_LIB) $(PROJ_SHARED_LIB) $(MCMC_TOOL) $(WAVEFORM_TOOL)
.PHONY: tests
tests: $(PROJ_LIB) $(PROJ_SHARED_LIB) $(MCMC_TOOL) $(WAVEFORM_TOOL)
make -C $(TEST_CODE_DIR)
.PHONY: clean
clean:
-rm build/*.o
-rm build_cuda/*.o
-make -C $(TEST_CODE_DIR) clean
.PHONY: remove
remove:
-rm build/*.o build_cuda/* bin/* lib/*.a lib/*.so
-rm include/gwat/GWATConfig.h
-make -C $(PYDIR) remove
-make -C $(TEST_CODE_DIR) remove
$(MCMC_TOOL): $(OBJECTS_NONEXE) $(ODIR)/mcmc_gw_tool.o
$(CC) $(LFLAGS) -o $@ $^ $(LIBS)
$(WAVEFORM_TOOL): $(OBJECTS_NONEXE) $(ODIR)/waveform_tool.o
$(CC) $(LFLAGS) -o $@ $^ $(LIBS)